From 4320119d021711eb9643dcc49d35ea051213c341 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 16 Jul 2018 20:02:33 +0200 Subject: [PATCH] calc_relative_matrix now accepts hyperpoint as the direction hint --- conformal.cpp | 10 +++++----- hyper.h | 9 +++++++++ rogueviz.cpp | 4 ++-- shmup.cpp | 15 +++++++++------ 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/conformal.cpp b/conformal.cpp index b56fa122..6ca340f7 100644 --- a/conformal.cpp +++ b/conformal.cpp @@ -337,10 +337,10 @@ namespace conformal { // virtualRebase(v[j], false); - hyperpoint prev = shmup::calc_relative_matrix(v[j-1]->base, v[j]->base, NOHINT) * + hyperpoint prev = shmup::calc_relative_matrix(v[j-1]->base, v[j]->base, C0) * v[j-1]->at * C0; - hyperpoint next = shmup::calc_relative_matrix(v[j+1]->base, v[j]->base, NOHINT) * + hyperpoint next = shmup::calc_relative_matrix(v[j+1]->base, v[j]->base, C0) * v[j+1]->at * C0; hyperpoint hmid = mid(prev, next); @@ -352,7 +352,7 @@ namespace conformal { } } - hyperpoint next0 = shmup::calc_relative_matrix(v[1]->base, v[0]->base, NOHINT) * v[1]->at * C0; + hyperpoint next0 = shmup::calc_relative_matrix(v[1]->base, v[0]->base, C0) * v[1]->at * C0; v[0]->at = v[0]->at * rspintox(inverse(v[0]->at) * next0); llv = ticks; @@ -380,7 +380,7 @@ namespace conformal { hyperpoint now = v[ph]->at * C0; - hyperpoint next = shmup::calc_relative_matrix(v[ph+1]->base, v[ph]->base, NOHINT) * + hyperpoint next = shmup::calc_relative_matrix(v[ph+1]->base, v[ph]->base, C0) * v[ph+1]->at * C0; View = spin(M_PI/180 * rotation) * xpush(-(phase-ph) * hdist(now, next)) * View; @@ -411,7 +411,7 @@ namespace conformal { for(int j=0; jat) * - shmup::calc_relative_matrix(v[j+1]->base, v[j]->base, NOHINT) * + shmup::calc_relative_matrix(v[j+1]->base, v[j]->base, C0) * v[j+1]->at * C0; hyperpoint nextscr; diff --git a/hyper.h b/hyper.h index b54126ff..020015ef 100644 --- a/hyper.h +++ b/hyper.h @@ -706,6 +706,7 @@ namespace shmup { void virtualRebase(cell*& base, transmatrix& at, bool tohex); void virtualRebase(shmup::monster *m, bool tohex); + transmatrix calc_relative_matrix(cell *c, cell *c1, const hyperpoint& point_hint); transmatrix calc_relative_matrix(cell *c, cell *c1, int direction_hint); void fixStorage(); void addShmupHelp(string& out); @@ -3661,4 +3662,12 @@ heptspin& operator += (heptspin& h, wstep_t); bool anglestraight(cell *c, int d1, int d2); +hyperpoint randomPointIn(int t); + +void buildpolys(); + +bool compute_relamatrix(cell *src, cell *tgt, int direction_hint, transmatrix& T); + +extern bool need_reset_geometry; +extern ld hexshift; } diff --git a/rogueviz.cpp b/rogueviz.cpp index 4f8f1528..4a130cdf 100644 --- a/rogueviz.cpp +++ b/rogueviz.cpp @@ -163,7 +163,7 @@ hyperpoint where(int i, cell *base) { auto m = vdata[i].m; if(m->base == base) return tC0(m->at); else if(quotient || elliptic || torus) { - return shmup::calc_relative_matrix(m->base, base, NOHINT) * tC0(m->at); + return shmup::calc_relative_matrix(m->base, base, C0) * tC0(m->at); } else { // notimpl(); // actually probably that's a buug @@ -1078,7 +1078,7 @@ map, transmatrix> relmatrices; transmatrix& memo_relative_matrix(cell *c1, cell *c2) { auto& p = relmatrices[make_pair(c1, c2)]; if(p[2][2] == 0) - p = shmup::calc_relative_matrix(c1, c2, NOHINT); + p = shmup::calc_relative_matrix(c1, c2, C0); return p; } diff --git a/shmup.cpp b/shmup.cpp index 737caa46..ad4b3abf 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -3333,8 +3333,12 @@ transmatrix master_relative(cell *c, bool get_inverse) { return pispin * Id; } -// target, source, direction from source to target transmatrix calc_relative_matrix(cell *c2, cell *c1, int direction_hint) { + return calc_relative_matrix(c2, c1, ddspin(c1, direction_hint) * xpush(1e-2) * C0); + } + +// target, source, direction from source to target +transmatrix calc_relative_matrix(cell *c2, cell *c1, const hyperpoint& point_hint) { if(sphere) { if(!gmatrix0.count(c2) || !gmatrix0.count(c1)) { @@ -3399,20 +3403,19 @@ transmatrix calc_relative_matrix(cell *c2, cell *c1, int direction_hint) { while(h1 != h2) { if(quotient & qSMALL) { transmatrix T; - hyperpoint hint = ddspin(c1, direction_hint) * xpush(1e-2) * C0; ld bestdist = 1e9; for(int d=0; dmove[d]) { int sp = h2->spin(d); transmatrix S = heptmove[sp] * spin(2*M_PI*d/S7); if(h2->move[d] == h1) { transmatrix T1 = gm * S * where; - auto curdist = hdist(tC0(T1), hint); + auto curdist = hdist(tC0(T1), point_hint); if(curdist < bestdist) T = T1, bestdist = curdist; } for(int e=0; emove[d]->move[e] == h1) { int sp2 = h2->move[d]->spin(e); transmatrix T1 = gm * heptmove[sp2] * spin(2*M_PI*e/S7) * S * where; - auto curdist = hdist(tC0(T1), hint); + auto curdist = hdist(tC0(T1), point_hint); if(curdist < bestdist) T = T1, bestdist = curdist; } } @@ -3460,13 +3463,13 @@ transmatrix &ggmatrix(cell *c) { transmatrix& t = gmatrix[c]; if(t[2][2] == 0) { if(torus && centerover.c) - t = calc_relative_matrix(c, centerover.c, NOHINT); + t = calc_relative_matrix(c, centerover.c, C0); else if(euclid) { if(!centerover.c) centerover = cwt; t = View * eumove(cell_to_vec(c) - cellwalker_to_vec(centerover)); } else - t = actualV(viewctr, cview()) * calc_relative_matrix(c, viewctr.h->c7, NOHINT); + t = actualV(viewctr, cview()) * calc_relative_matrix(c, viewctr.h->c7, C0); } return t; }