From ac9d18adfb87e877f4002dc2149e66a604cfbcee Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 6 Dec 2019 11:47:26 +0100 Subject: [PATCH] simplified the drawing algo for product --- celldrawer.cpp | 2 - graph.cpp | 1 - hypgraph.cpp | 1 - nonisotropic.cpp | 120 ++++++++++++++--------------------------------- 4 files changed, 35 insertions(+), 89 deletions(-) diff --git a/celldrawer.cpp b/celldrawer.cpp index 37b862e3..79948a9f 100644 --- a/celldrawer.cpp +++ b/celldrawer.cpp @@ -2351,8 +2351,6 @@ void celldrawer::draw_gravity_particles() { void celldrawer::draw() { - if(hybrid::pmap) { product::drawcell_stack(c, V); return; } - cells_drawn++; #if CAP_TEXTURE diff --git a/graph.cpp b/graph.cpp index 7c0adf83..1edffd94 100644 --- a/graph.cpp +++ b/graph.cpp @@ -3606,7 +3606,6 @@ EX void gridline(const transmatrix& V, const hyperpoint h1, const hyperpoint h2, } EX int wall_offset(cell *c) { - if(prod) return product::cwall_offset; if(hybri) return hybrid::wall_offset(c); if(penrose && kite::getshape(c->master) == kite::pKite) return 10; return 0; diff --git a/hypgraph.cpp b/hypgraph.cpp index 1f67dcad..fcb7a990 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1927,7 +1927,6 @@ bool limited_generation(cell *c) { EX bool do_draw(cell *c, const transmatrix& T) { - if(hybrid::pmap) return hybrid::do_draw(c, T); if(WDIM == 3) { // do not care about cells outside of the track if(GDIM == 3 && racing::on && c->land == laMemory && cells_drawn >= S7+1) return false; diff --git a/nonisotropic.cpp b/nonisotropic.cpp index a56387fb..cf7ff5d0 100644 --- a/nonisotropic.cpp +++ b/nonisotropic.cpp @@ -1088,6 +1088,40 @@ EX namespace hybrid { virtual transmatrix spin_to(cell *c, int d, ld bonus) override { if(d >= c->type-2) return Id; c = get_where(c).first; return in_underlying([&] { return currentmap->spin_to(c, d, bonus); }); } virtual transmatrix spin_from(cell *c, int d, ld bonus) override { if(d >= c->type-2) return Id; c = get_where(c).first; return in_underlying([&] { return currentmap->spin_from(c, d, bonus); }); } + void draw() override { + set visited; + + cell* start = centerover; + vector> dq; + + visited.insert(start); + dq.emplace_back(start, cview()); + product::cwall_mask = -1; + + for(int i=0; i 1000) continue; + + for(int i=0; itype; i++) { + cell *c1 = c->cmove(i); + if(visited.count(c1)) continue; + visited.insert(c1); + dq.emplace_back(c1, V * adj(c, i)); + } + } + } }; hrmap_hybrid* hmap() { return (hrmap_hybrid*) currentmap; } @@ -1208,10 +1242,6 @@ EX namespace hybrid { return wo; } - EX bool do_draw(cell *c, const transmatrix& T) { - return in_actual([&] { return hr::do_draw(hybrid::get_at(c, get_where(centerover).second), T); }); - } - vector to_link; EX void will_link(cell *c) { if(pmap && ((hrmap_hybrid*) pmap)->twisted) to_link.push_back(c); } @@ -1297,14 +1327,6 @@ EX namespace product { return PIU(currentmap->adj(c, i)); } - void draw() override { - auto w = hybrid::get_where(centerover); - z0 = w.second; - actual_view_level = z0 - floor(zlevel(tC0(cview())) / cgi.plevel + .5); - dynamicval co(centerover, hybrid::get_where(centerover).first); - in_underlying([=] { currentmap->draw(); }); - } - hrmap_product() { current_spin_invalid = false; if((cspin || cmirror) && csteps) { @@ -1331,50 +1353,9 @@ EX namespace product { EX bool current_spin_invalid; - EX int cwall_offset, cwall_mask, actual_view_level, csteps, cspin; + EX int csteps, cspin; EX bool cmirror; - EX void drawcell_stack(cellwalker cw, transmatrix V) { - cell *c = cw.at; - if(sphere) gmatrix[c] = V; /* some computations need gmatrix0 for underlying geometry */ - bool s = sphere || pmodel != mdPerspective; - bool euc = euclid; - hybrid::in_actual([&] { - cell *c0 = hybrid::get_at(c, z0); - cwall_offset = hybrid::wall_offset(c0); - if(s) cwall_mask = (1<type) - 1; - else { - cwall_mask = 0; - ld d = euc ? sqhypot_d(2, tC0(V)) : V[2][2]; - for(int i=0; itype; i++) { - hyperpoint h = (V * cgi.walltester[cwall_offset + i]); - ld d1 = euc ? sqhypot_d(2, h) : h[2]; - if(d1 < d - 1e-6) cwall_mask |= (1<type); - int flat_distance = hdist0(product_decompose(tC0(V)).second); - int max_z = flat_distance > sightranges[gProduct] ? 0 : sqrt(sightranges[gProduct] * sightranges[gProduct] - flat_distance * flat_distance) + 1; - for(int si: {0, 1}) { - cell *c1 = hybrid::get_at(c, z0); - int dir = c1->type-1-si; - int z1 = z0; - auto V0 = V; - for(int z=0; z<=max_z; z++) { - if(((hybrid::hrmap_hybrid*)currentmap)->twisted) cwall_mask = -1; - cwall_mask &= ~(3<type); - if(z1 > actual_view_level) cwall_mask |= (1<type); - if(z1 < actual_view_level) cwall_mask |= (2<type); - setdist(c1, 7, NULL); - if(z || !si) drawcell(c1, V0); - V0 = V0 * currentmap->adj(c1, dir); - c1 = c1->cmove(dir); - z1 += (si ? -1 : 1); - } - } - }); - } - EX hyperpoint inverse_exp(hyperpoint h) { hyperpoint res; res[2] = zlevel(h); @@ -1821,37 +1802,6 @@ EX namespace rots { return Id; // not implemented yet } - void draw() override { - set visited; - - cell* start = centerover; - vector> dq; - - visited.insert(start); - dq.emplace_back(start, cview()); - - for(int i=0; i 1000) continue; - - for(int i=0; itype; i++) { - cell *c1 = c->cmove(i); - if(visited.count(c1)) continue; - visited.insert(c1); - dq.emplace_back(c1, V * adj(c, i)); - } - } - } }; /** reinterpret the given point of rotspace as a rotation matrix in the underlying geometry */