From d10181e363744f40dd5e1db41f325c22ee560408 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 29 Jul 2021 12:06:52 +0200 Subject: [PATCH] gp:: replaced draw_li with current_li which is computed when needed --- floorshapes.cpp | 8 ++++++-- goldberg.cpp | 14 +++++--------- hypgraph.cpp | 26 ++++++++++++++++---------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/floorshapes.cpp b/floorshapes.cpp index 782b9aae..5b4be578 100644 --- a/floorshapes.cpp +++ b/floorshapes.cpp @@ -859,6 +859,10 @@ EX namespace gp { } EX int get_plainshape_id(cell *c) { + if(li_for != c) { + li_for = c; + current_li = get_local_info(c); + } int siid, sidir; cell *c1 = c; auto f = [&] { @@ -892,11 +896,11 @@ EX namespace gp { sidir = 0; } else f(); - auto& id = cgi.gpdata->pshid[siid][sidir][draw_li.relative.first&GOLDBERG_MASK][draw_li.relative.second&GOLDBERG_MASK][gmod(draw_li.total_dir, S6)]; + auto& id = cgi.gpdata->pshid[siid][sidir][current_li.relative.first&GOLDBERG_MASK][current_li.relative.second&GOLDBERG_MASK][gmod(current_li.total_dir, S6)]; if(id == -1 && sphere && isize(cgi.shFloor.b) > 0) { forCellEx(c1, c) if(!gmatrix0.count(c1)) return 0; } - if(id == -1) build_plainshape(id, draw_li, c, siid, sidir); + if(id == -1) build_plainshape(id, current_li, c, siid, sidir); return id; } EX } diff --git a/goldberg.cpp b/goldberg.cpp index 0868f25d..6a54478d 100644 --- a/goldberg.cpp +++ b/goldberg.cpp @@ -63,7 +63,8 @@ EX namespace gp { }; #endif - EX local_info draw_li; + EX local_info current_li; + EX cell *li_for; EX loc eudir(int d) { if(S3 == 3) { @@ -1270,11 +1271,11 @@ EX namespace gp { in_underlying([&] { if(GOLDBERG) { - gp::draw_li = gp::get_local_info(c1); + gp::current_li = gp::get_local_info(c1); } else { - gp::draw_li.relative.first = shvid(c1); - gp::draw_li.relative.second = shift[c]; + gp::current_li.relative.first = shvid(c1); + gp::current_li.relative.second = shift[c]; } }); @@ -1297,11 +1298,6 @@ EX namespace gp { return gp::get_plainshape_id(c); } - int full_shvid(cell *c) override { - gp::draw_li = gp::get_local_info(c); - return shvid(c); - } - hyperpoint get_corner(cell *c, int cid, ld cf) override { if(UNTRUNCATED) { cell *c1 = gp::get_mapped(c); diff --git a/hypgraph.cpp b/hypgraph.cpp index 3161fcc5..6c179606 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1586,16 +1586,18 @@ void drawrec(cell *c, const transmatrix& V) { } } */ - bool drawrec(cell *c, const shiftmatrix& V, gp::loc at, int dir, int maindir) { + bool drawrec(cell *c, const shiftmatrix& V, gp::loc at, int dir, int maindir, local_info li) { bool res = false; - shiftmatrix V1 = V * cgi.gpdata->Tf[draw_li.last_dir][at.first&GOLDBERG_MASK][at.second&GOLDBERG_MASK][fixg6(dir)]; + shiftmatrix V1 = V * cgi.gpdata->Tf[li.last_dir][at.first&GOLDBERG_MASK][at.second&GOLDBERG_MASK][fixg6(dir)]; if(do_draw(c, V1)) { /* auto li = get_local_info(c); if((dir - li.total_dir) % S6) printf("totaldir %d/%d\n", dir, li.total_dir); if(at != li.relative) printf("at %s/%s\n", disp(at), disp(li.relative)); if(maindir != li.last_dir) printf("ld %d/%d\n", maindir, li.last_dir); */ - draw_li.relative = at; - draw_li.total_dir = fixg6(dir); + li.relative = at; + li.total_dir = fixg6(dir); + current_li = li; + li_for = c; drawcell(c, V1); res = true; } @@ -1604,15 +1606,19 @@ void drawrec(cell *c, const transmatrix& V) { if(!c2) continue; if(c2->move(0) != c) continue; if(c2 == c2->master->c7) continue; - res |= drawrec(c2, V, at + eudir(dir+i), dir + i + SG3, maindir); + res |= drawrec(c2, V, at + eudir(dir+i), dir + i + SG3, maindir, li); } return res; } bool drawrec(cell *c, const shiftmatrix& V) { - draw_li.relative = loc(0,0); - draw_li.total_dir = 0; - draw_li.last_dir = -1; + local_info li; + li.relative = loc(0,0); + li.total_dir = 0; + li.last_dir = -1; + li.first_dir = -1; + li_for = c; + current_li = li; bool res = false; if(do_draw(c, V)) drawcell(c, V), res = true; @@ -1621,8 +1627,8 @@ void drawrec(cell *c, const transmatrix& V) { if(!c2) continue; if(c2->move(0) != c) continue; if(c2 == c2->master->c7) continue; - draw_li.last_dir = i; - res |= drawrec(c2, V, gp::loc(1,0), SG3, i); + li.last_dir = i; + res |= drawrec(c2, V, gp::loc(1,0), SG3, i, li); } return res; }