From ce632ff9d534f1279144135c0c343a1410a98047 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 4 Mar 2019 18:03:16 +0100 Subject: [PATCH] reg3:: in reg hyperbolic honeycombs, celldistance now works correctly for small distances (required for trans walls) --- reg3.cpp | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/reg3.cpp b/reg3.cpp index ae915645..c1ca5db5 100644 --- a/reg3.cpp +++ b/reg3.cpp @@ -18,6 +18,16 @@ namespace binary { namespace reg3 { + map close_distances; + + int bucketer(ld x) { + return int(x * 10 + 100000.5) - 100000; + } + + int bucketer(hyperpoint h) { + return bucketer(h[0]) + 1000 * bucketer(h[1]) + 1000000 * bucketer(h[2]); + } + int loop, face; vector cellshape; @@ -192,6 +202,12 @@ namespace reg3 { reg_gmatrix[origin] = make_pair(alt, T); altmap[alt].emplace_back(origin, T); + + celllister cl(origin->c7, 4, 100000, NULL); + for(cell *c: cl.lst) { + hyperpoint h = tC0(relative_matrix(c->master, origin)); + close_distances[bucketer(h)] = cl.getdist(c); + } } ld worst_error1, worst_error2; @@ -315,9 +331,15 @@ void draw() { int celldistance(cell *c1, cell *c2) { if(c1 == c2) return 0; + auto r = regmap(); + + hyperpoint h = tC0(relative_matrix(c1->master, c2->master)); + int b = bucketer(h); + if(close_distances.count(b)) return close_distances[b]; + dynamicval g(geometry, gBinary3); - return 1 + binary::celldistance3(r->reg_gmatrix[c1->master].first, r->reg_gmatrix[c2->master].first); + return 20 + binary::celldistance3(r->reg_gmatrix[c1->master].first, r->reg_gmatrix[c2->master].first); } bool pseudohept(cell *c) { @@ -360,16 +382,6 @@ ld adistance(cell *c) { return regmap()->reg_gmatrix[c->master].first->distance * log(2) - h[0]; } -int bucketer(ld x) { - return int(x * 10 + 100000.5) - 100000; - } - -int bucketer(hyperpoint h) { - return bucketer(h[0]) + 1000 * bucketer(h[1]) + 1000000 * bucketer(h[2]); - } - -map close_distances; - unordered_map, int> memo; bool cdd;