From aa174d92c841088b1603bdc258969a84d17aa336 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 18 Aug 2024 21:21:18 +0200 Subject: [PATCH] nilrider:: triangles should work with multiple sublevels --- rogueviz/nilrider/level.cpp | 7 ++++++- rogueviz/nilrider/nilrider.h | 1 + rogueviz/nilrider/timestamp.cpp | 11 ++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/rogueviz/nilrider/level.cpp b/rogueviz/nilrider/level.cpp index 41ad605d..2a71024c 100644 --- a/rogueviz/nilrider/level.cpp +++ b/rogueviz/nilrider/level.cpp @@ -374,6 +374,7 @@ void level::init() { d.where = h; d.x = x; d.y = y; + d.which = this; for(int i=0; i<7; i++) d.colors[i] = gradient(0xFFD500FF, 0xFF, 0, i, 8); d.colors[6] = d.colors[0]; @@ -420,7 +421,11 @@ void level::init() { init_plan(); - for(auto s: sublevels) s->init(); + for(auto s: sublevels) { + s->init(); + for(auto& t: s->triangles) triangles.push_back(t); + s->triangles.clear(); + } } xy_float level::get_xy_f(hyperpoint h) { diff --git a/rogueviz/nilrider/nilrider.h b/rogueviz/nilrider/nilrider.h index 028bfe62..e2ac87a9 100644 --- a/rogueviz/nilrider/nilrider.h +++ b/rogueviz/nilrider/nilrider.h @@ -68,6 +68,7 @@ struct statue { struct triangledata { int x, y; hyperpoint where; + level *which; array colors; }; diff --git a/rogueviz/nilrider/timestamp.cpp b/rogueviz/nilrider/timestamp.cpp index eab5dcdc..87e57547 100644 --- a/rogueviz/nilrider/timestamp.cpp +++ b/rogueviz/nilrider/timestamp.cpp @@ -89,12 +89,13 @@ bool timestamp::out_of_surface(level *lev) { } bool timestamp::collect(level *lev) { - auto xy = lev->get_xy_i(where); - char ch = lev->mapchar(xy); + auto xy = on_surface->get_xy_i(where); + char ch = on_surface->mapchar(xy); if(ch == 'r') return false; if(ch == '*') { for(int i=0; itriangles); i++) { auto& t = lev->triangles[i]; + if(t.which != on_surface) continue; if(t.x == xy.first && t.y == xy.second) collected_triangles |= (1<surface(wnext); + wnext[2] = on_surface->surface(wnext); wnext = gpushxto0(where) * wnext; slope = atan(wnext[2] / eps); @@ -187,7 +188,7 @@ bool timestamp::tick(level *lev, ld time_left) { auto mvel = (vel + ovel) / 2; where[0] += cos(heading_angle) * mvel * cos(slope) * time_left; where[1] += sin(heading_angle) * mvel * cos(slope) * time_left; - where[2] = lev->surface(where); + where[2] = on_surface->surface(where); circvel = mvel / whrad; } @@ -336,7 +337,7 @@ void timestamp::centerview(level *lev) { for(int i=0; i<8; i++) { shift_view(ztangent(whdist * lev->scale / 8.)); hyperpoint p = inverse(View) * C0; - ld room = p[2] - lev->surface(p); + ld room = p[2] - on_surface->surface(p); if(room < .1 * lev->scale) return true; for(hyperpoint h: {point3(0,0,0), point3(.001,0,0), point3(-.001,0,0), point3(0,-0.001,0), point3(0,0.001,0)}) if(lev->mapchar(p+h) == 'r') return true;