From 377fd3f8bd7c647131949a70947312a20459cbe5 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 2 Nov 2019 22:17:57 +0100 Subject: [PATCH] torus3 improvements --- cell.cpp | 2 +- euclid.cpp | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cell.cpp b/cell.cpp index 520d030d..ee4197c0 100644 --- a/cell.cpp +++ b/cell.cpp @@ -435,7 +435,7 @@ EX int celldist(cell *c) { if(fulltorus && WDIM == 2) return get_torus_dist(decodeId(c->master)); if(nil) return DISTANCE_UNKNOWN; - if(euwrap) + if(euwrap && WDIM == 2) return torusconfig::cyldist(decodeId(c->master), 0); if(masterless) return eudist(decodeId(c->master)); diff --git a/euclid.cpp b/euclid.cpp index 73a7da80..f0a1ff0e 100644 --- a/euclid.cpp +++ b/euclid.cpp @@ -846,7 +846,7 @@ EX namespace euclid3 { EX int celldistance(cell *c1, cell *c2) { auto cm = cubemap(); - return celldistance(cm->ispacemap[c1->master] - cm->ispacemap[c2->master]); + return celldistance(canonicalize(cm->ispacemap[c1->master] - cm->ispacemap[c2->master])); } EX void set_land(cell *c) { @@ -913,15 +913,16 @@ EX namespace euclid3 { int coords; int twisted0, twisted_edit; - EX void clear_torus3() { - for(int i=0; i<3; i++) user_axes[i] = 0; - } - EX void set_torus3(int x, int y, int z) { for(int i=0; i<3; i++) for(int j=0; j<3; j++) T0[i][j] = 0; tie(T0[0][0], T0[1][1], T0[2][2]) = make_tuple(x, y, z); + twisted = 0; build_torus3(); } + + EX void clear_torus3() { + set_torus3(0, 0, 0); + } unordered_map canonical_hash; vector canonical_seq;