mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-27 14:37:16 +00:00
calc_relative_matrix now accepts hyperpoint as the direction hint
This commit is contained in:
parent
b0278e02c8
commit
4320119d02
@ -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; j<siz-1; j++) {
|
||||
hyperpoint next =
|
||||
inverse(v[j]->at) *
|
||||
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;
|
||||
|
9
hyper.h
9
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;
|
||||
}
|
||||
|
@ -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<pair<cell*, cell*>, 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;
|
||||
}
|
||||
|
||||
|
15
shmup.cpp
15
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; d<S7; d++) if(h2->move[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; e<S7; e++) if(h2->move[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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user