diff --git a/rogueviz/nilrider/level.cpp b/rogueviz/nilrider/level.cpp index 14359f72..ff3a5348 100644 --- a/rogueviz/nilrider/level.cpp +++ b/rogueviz/nilrider/level.cpp @@ -74,50 +74,18 @@ void level::init_textures() { } } -void level::init() { - if(initialized) return; - initialized = true; +void level::init_shapes() { check_cgi(); - - real_minx = HUGE_VAL; - real_miny = HUGE_VAL; - real_maxx = -HUGE_VAL; - real_maxy = -HUGE_VAL; + string s = "nillevel-" + name; + if(cgi.ext.count(s)) return; + cgi.ext[s] = nullptr; - if(flags & nrlPolar) - scale = 1; - else - scale = abs(maxx - minx) / isize(map_tiles[0]); - println(hlog, "SCALE IS ", this->scale); - - init_textures(); - int tY = isize(map_tiles); int tX = isize(map_tiles[0]); - start.where = mappt(startx+.5, starty+.5, 1); - start.t = 0; - start.timer = 0; - current = start; - println(hlog, "start.where = ", start.where); - println(hlog, "current.where = ", current.where, " : ", format("%p", ¤t)); - - int qgoals = isize(goals); - records[0].resize(qgoals, 0); - records[1].resize(qgoals, 0); - current_score.resize(qgoals, 0); - - /* start facing slightly to the right from the slope */ - for(auto b: {true, false}) while(true) { - auto c = start; - /* no treasures are known, which confuses goals */ - dynamicval lop1(loaded_or_planned, true); - dynamicval lop2(planning_mode, false); - if(c.tick(this) == b) break; - start.heading_angle -= 1 * degree; - } - - for(int s=0; s<3; s++) { + for(int s=0; s<3; s++) { + if(euclid && s != 1) continue; + if(nil && s == 1) continue; cgi.bshape(s == 0 ? shFloor : s == 1 ? shPlanFloor : shStepFloor, PPR::WALL); shFloor.flags |= POLY_TRIANGLES; shPlanFloor.flags |= POLY_TRIANGLES; @@ -127,8 +95,10 @@ void level::init() { if(s == 2) prec *= 4; int cdiv = prec / steps_per_block; + bool need_uniltinf = uniltinf.tvertices.empty(); + auto pt = [&] (int x, int y, int qx, int qy) { - if(s == 0) uniltinf.tvertices.push_back(glhr::makevertex(x * 1. / tX / prec, y * 1. / tY / prec, 0)); + if(need_uniltinf) uniltinf.tvertices.push_back(glhr::makevertex(x * 1. / tX / prec, y * 1. / tY / prec, 0)); if(s == 2) { ld ax = x, ay = y; if(qx) { @@ -334,7 +304,37 @@ void level::init() { ptc(.4, asdw, -oasdw2, x2, y2); } } - } + } + } + cgi.finishshape(); + } + + cgi.extra_vertices(); + } + +void level::init() { + if(initialized) return; + initialized = true; + check_cgi(); + + real_minx = HUGE_VAL; + real_miny = HUGE_VAL; + real_maxx = -HUGE_VAL; + real_maxy = -HUGE_VAL; + + if(flags & nrlPolar) + scale = 1; + else + scale = abs(maxx - minx) / isize(map_tiles[0]); + println(hlog, "SCALE IS ", this->scale); + + if(1) { + int tY = isize(map_tiles); + int tX = isize(map_tiles[0]); + + for(int y=0; y lop1(loaded_or_planned, true); + dynamicval lop2(planning_mode, false); + if(c.tick(this) == b) break; + start.heading_angle -= 1 * degree; + } + if(flags & nrlOrder) { sort(triangles.begin(), triangles.end(), [this] (triangledata a, triangledata b) { return atan2(spin(120*degree)*(a.where - start.where)) < atan2(spin(120*degree)*(b.where - start.where)); }); for(auto t: triangles) println(hlog, t.where); } - - cgi.extra_vertices(); + init_plan(); } @@ -433,6 +457,9 @@ bool stepped_display; void level::draw_level(const shiftmatrix& V) { int id = 0; + init_statues(); + curlev->init_shapes(); + for(auto& t: triangles) { bool gotit = current.collected_triangles & Flag(id); id++; diff --git a/rogueviz/nilrider/nilrider.h b/rogueviz/nilrider/nilrider.h index dd68da4b..102f9444 100644 --- a/rogueviz/nilrider/nilrider.h +++ b/rogueviz/nilrider/nilrider.h @@ -134,6 +134,9 @@ struct level { /** initialize textures */ void init_textures(); + /** initialize shapes */ + void init_shapes(); + /** initialize all */ void init(); diff --git a/rogueviz/nilrider/planning.cpp b/rogueviz/nilrider/planning.cpp index 9bd2ebc0..a40677cb 100644 --- a/rogueviz/nilrider/planning.cpp +++ b/rogueviz/nilrider/planning.cpp @@ -100,6 +100,9 @@ void level::draw_planning_screen() { dynamicval pm(pmodel, mdDisk); dynamicval ga(vid.always3, false); dynamicval gi(ginf[gEuclid].g, giEuclid2); + check_cgi(); + cgi.require_shapes(); + curlev->init_shapes(); initquickqueue(); if(recompute_plan_transform) { diff --git a/rogueviz/nilrider/statues.cpp b/rogueviz/nilrider/statues.cpp index a0cf46d8..f91c454c 100644 --- a/rogueviz/nilrider/statues.cpp +++ b/rogueviz/nilrider/statues.cpp @@ -114,6 +114,9 @@ template void add_statue(const T1& grid, const T2& f) { hpcshape shGeostatue; void init_statues() { + check_cgi(); + if(cgi.ext.count("nil-statues")) return; + cgi.ext["nil-statues"] = nullptr; create_minitriangle(); create_castle();