gp:: replaced draw_li with current_li which is computed when needed

This commit is contained in:
Zeno Rogue 2021-07-29 12:06:52 +02:00
parent f996104074
commit d10181e363
3 changed files with 27 additions and 21 deletions

View File

@ -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 }

View File

@ -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);

View File

@ -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;
}