From aa1b102b781e22d843e73a82c3b19627cd097b3e Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 4 Dec 2018 18:10:36 +0100 Subject: [PATCH] crystal::rug:: correct centering --- crystal.cpp | 19 +++++++++++++++++++ hyper.h | 1 + hypgraph.cpp | 4 ++++ 3 files changed, 24 insertions(+) diff --git a/crystal.cpp b/crystal.cpp index fed8adbb..8bc2717b 100644 --- a/crystal.cpp +++ b/crystal.cpp @@ -755,6 +755,8 @@ ld crug_rotation[MAXDIM][MAXDIM]; int ho = 1; +ldcoord rug_center; + void init_rotation() { for(int i=0; i= 4.99) aspd = 1000; + + auto m = crystal_map(); + ldcoord at = m->get_coord(cwt.at) - rug_center; + + ld R = sqrt(at|at); + + if(R < 1e-9) rug_center = m->get_coord(cwt.at); + else { + aspd *= (2+3*R*R); + if(aspd > R) aspd = R; + rug_center = rug_center + at * aspd / R; + } + } + void build_rugdata() { using namespace rug; rug::clear_model(); diff --git a/hyper.h b/hyper.h index 2d74be3a..f67ad236 100644 --- a/hyper.h +++ b/hyper.h @@ -4164,6 +4164,7 @@ namespace crystal { ld compass_angle(); string compass_help(); void may_place_compass(cell *c); + void centerrug(ld aspd); } hyperpoint get_warp_corner(cell *c, int cid); diff --git a/hypgraph.cpp b/hypgraph.cpp index 3f05b5cc..c00a26b0 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -956,6 +956,10 @@ void spinEdge(ld aspd) { } void centerpc(ld aspd) { + + if(geometry == gCrystal) + crystal::centerrug(aspd); + if(ors::mode == 2 && vid.sspeed < 5) return; if(vid.sspeed >= 4.99) aspd = 1000; DEBB(DF_GRAPH, (debugfile,"center pc\n"));