1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 09:00:34 +00:00

rug:: extra variables to report the rug shape

This commit is contained in:
Zeno Rogue 2021-03-06 11:46:57 +01:00
parent 40d450676e
commit ff4d86ee65

21
rug.cpp
View File

@ -165,6 +165,8 @@ bool rug_hyperbolic() { USING_NATIVE_GEOMETRY; return hyperbolic; }
bool rug_sphere() { USING_NATIVE_GEOMETRY; return sphere; } bool rug_sphere() { USING_NATIVE_GEOMETRY; return sphere; }
bool rug_elliptic() { USING_NATIVE_GEOMETRY; return elliptic; } bool rug_elliptic() { USING_NATIVE_GEOMETRY; return elliptic; }
EX map<cell*, rugpoint*> rug_map;
EX rugpoint *addRugpoint(shiftpoint h, double dist) { EX rugpoint *addRugpoint(shiftpoint h, double dist) {
rugpoint *m = new rugpoint; rugpoint *m = new rugpoint;
m->h = h; m->h = h;
@ -560,12 +562,10 @@ EX void buildRug() {
celllister cl(centerover ? centerover : cwt.at, get_sightrange(), vertex_limit, NULL); celllister cl(centerover ? centerover : cwt.at, get_sightrange(), vertex_limit, NULL);
map<cell*, rugpoint *> vptr;
for(int i=0; i<isize(cl.lst); i++) for(int i=0; i<isize(cl.lst); i++)
vptr[cl.lst[i]] = addRugpoint(ggmatrix(cl.lst[i])*C0, cl.dists[i]); rug_map[cl.lst[i]] = addRugpoint(ggmatrix(cl.lst[i])*C0, cl.dists[i]);
for(auto& p: vptr) { for(auto& p: rug_map) {
cell *c = p.first; cell *c = p.first;
rugpoint *v = p.second; rugpoint *v = p.second;
@ -584,11 +584,11 @@ EX void buildRug() {
else for(int j=0; j<c->type; j++) try { else for(int j=0; j<c->type; j++) try {
cell *c2 = c->move(j); cell *c2 = c->move(j);
rugpoint *w = vptr.at(c2); rugpoint *w = rug_map.at(c2);
// if(v<w) addEdge(v, w); // if(v<w) addEdge(v, w);
cell *c3 = c->modmove(j+1); cell *c3 = c->modmove(j+1);
rugpoint *w2 = vptr.at(c3); rugpoint *w2 = rug_map.at(c3);
cell *c4 = (cellwalker(c,j) + wstep - 1).cpeek(); cell *c4 = (cellwalker(c,j) + wstep - 1).cpeek();
@ -776,7 +776,8 @@ EX void optimize(rugpoint *m, bool do_preset) {
force(*m, *m->edges[j].target, m->edges[j].len, false, 1, 0); force(*m, *m->edges[j].target, m->edges[j].len, false, 1, 0);
} }
int divides = 0; EX int divides;
EX int precision_increases;
bool stop = false; bool stop = false;
EX bool subdivide_further() { EX bool subdivide_further() {
@ -794,6 +795,7 @@ EX void subdivide() {
stop = true; stop = true;
} }
else { else {
precision_increases++;
err_zero_current /= 2; err_zero_current /= 2;
println(hlog, "increasing precision to ", err_zero_current); println(hlog, "increasing precision to ", err_zero_current);
for(auto p: points) enqueue(p); for(auto p: points) enqueue(p);
@ -1182,6 +1184,8 @@ EX void init_model() {
qvalid = 0; dt = 0; queueiter = 0; qvalid = 0; dt = 0; queueiter = 0;
err_zero_current = err_zero; err_zero_current = err_zero;
divides = 0;
precision_increases = 0;
#if CAP_CRYSTAL #if CAP_CRYSTAL
if(cryst && surface::sh == surface::dsNone) { if(cryst && surface::sh == surface::dsNone) {
@ -1238,6 +1242,7 @@ EX void init() {
EX void clear_model() { EX void clear_model() {
triangles.clear(); triangles.clear();
for(int i=0; i<isize(points); i++) delete points[i]; for(int i=0; i<isize(points); i++) delete points[i];
rug_map.clear();
points.clear(); points.clear();
pqueue = queue<rugpoint*> (); pqueue = queue<rugpoint*> ();
} }
@ -1910,6 +1915,8 @@ auto rug_hook =
addHook(hooks_args, 100, rugArgs); addHook(hooks_args, 100, rugArgs);
#endif #endif
auto clear_rug_map = addHook(hooks_clearmemory, 40, [] () { rug_map.clear(); });
EX } EX }
#endif #endif