1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-01-23 07:27:07 +00:00

fixed relative gmatrix computation in gp and line animation

This commit is contained in:
Zeno Rogue 2018-04-21 14:01:54 +02:00
parent e101b092a4
commit edf4dd42cc
5 changed files with 70 additions and 52 deletions

View File

@ -320,41 +320,38 @@ namespace conformal {
reverse(v.begin(), v.end());
int Q = size(v)-1;
// virtualRebase(v[0], false);
// virtualRebase(v[Q], false);
for(int i=0; i<1000; i++) {
progress(XLAT("Preparing the line (%1/1000)...", its(i+1)));
/*for(int j=1; j<Q; j++) {
hyperpoint cur = v[j]->at * C0;
printf("%4d/%3d. %p [%3d] %Lf %Lf %Lf\n", i, j, v[j]->base, celldist(v[j]->base), cur[0], cur[1], cur[2]);
} */
for(int j=1; j<Q; j++) if((j^i)&1) {
virtualRebase(v[j], false);
// virtualRebase(v[j], false);
hyperpoint prev = shmup::calc_relative_matrix(v[j-1]->base, v[j]->base->master) *
hyperpoint prev = shmup::calc_relative_matrix(v[j-1]->base, v[j]->base) *
v[j-1]->at * C0;
hyperpoint next = shmup::calc_relative_matrix(v[j+1]->base, v[j]->base->master) *
hyperpoint next = shmup::calc_relative_matrix(v[j+1]->base, v[j]->base) *
v[j+1]->at * C0;
hyperpoint hmid = mid(prev, next);
v[j]->at = rgpushxto0(hmid);
transmatrix at = rgpushxto0(hmid);
v[j]->at = v[j]->at * rspintox(inverse(v[j]->at) * next);
v[j]->at = at * rspintox(inverse(at) * next);
fixmatrix(v[j]->at);
}
}
hyperpoint next0 = shmup::calc_relative_matrix(v[1]->base, v[0]->base->master) *
v[1]->at * C0;
hyperpoint next0 = shmup::calc_relative_matrix(v[1]->base, v[0]->base) * v[1]->at * C0;
v[0]->at = v[0]->at * rspintox(inverse(v[0]->at) * next0);
llv = ticks;
phase = 0;
if(0)
for(int j=0; j<=Q; j++) {
hyperpoint cur = v[j]->at * C0;
printf("%4d/%3d. %p [%3d] %s\n", j, Q, v[j]->base, celldist(v[j]->base), display(cur));
@ -371,15 +368,13 @@ namespace conformal {
viewctr.h = v[ph]->base->master;
viewctr.spin = 0;
View = inverse(v[ph]->at);
int j = ph;
hyperpoint now = v[j]->at * C0;
View = inverse(shmup::master_relative(v[ph]->base) * v[ph]->at);
hyperpoint now = v[ph]->at * C0;
hyperpoint next = shmup::calc_relative_matrix(v[j+1]->base, v[j]->base->master) *
v[j+1]->at * C0;
hyperpoint next = shmup::calc_relative_matrix(v[ph+1]->base, v[ph]->base) *
v[ph+1]->at * C0;
View = spin(M_PI/180 * rotation) * xpush(-(phase-ph) * hdist(now, next)) * View;
playermoved = false;
@ -409,7 +404,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->master) *
shmup::calc_relative_matrix(v[j+1]->base, v[j]->base) *
v[j+1]->at * C0;
hyperpoint nextscr;

View File

@ -5500,6 +5500,16 @@ void drawfullmap() {
queuechr(xpush(-vid.twopoint_param) * C0, vid.xres / 100, 'X', 0xFF0000);
}
/*
if(conformal::on) {
char ch = 'A';
for(auto& v: conformal::v) {
queuepoly(shmup::ggmatrix(v->base) * v->at, shTriangle, 0x306090C0);
queuechr(shmup::ggmatrix(v->base) * v->at * C0, 10, ch++, 0xFF0000);
}
}
*/
if(!twopoint_do_flips && !stereo::active() && sphere && pmodel == mdTwoPoint) {
queuereset(vid.usingGL ? mdDisk : mdUnchanged, PPR_CIRCLE);

View File

@ -589,11 +589,12 @@ namespace shmup {
void virtualRebase(cell*& base, transmatrix& at, bool tohex);
void virtualRebase(shmup::monster *m, bool tohex);
transmatrix calc_relative_matrix(cell *c, heptagon *h1);
transmatrix calc_relative_matrix(cell *c, cell *c1);
void fixStorage();
void addShmupHelp(string& out);
void activateArrow(cell *c);
transmatrix& ggmatrix(cell *c);
transmatrix master_relative(cell *c, bool get_inverse = false);
void pushmonsters();
void popmonsters();

View File

@ -486,7 +486,7 @@ transmatrix actualV(const heptspin& hs, const transmatrix& V) {
}
transmatrix applyspin(const heptspin& hs, const transmatrix& V) {
return (hs.spin || nonbitrunc) ? V * spin(hs.spin*2*M_PI/S7) : V;
return hs.spin ? V * spin(hs.spin*2*M_PI/S7) : V;
}
// in hyperbolic quotient geometries, relying on pathdist is not sufficient

View File

@ -3319,28 +3319,43 @@ void destroyBoats(cell *c) {
m->inBoat = false;
}
transmatrix calc_relative_matrix(cell *c, heptagon *h1) {
transmatrix master_relative(cell *c, bool get_inverse) {
if(gp::on) {
if(c == c->master->c7) {
return spin((get_inverse?-1:1) * master_to_c7_angle());
}
else {
auto li = gp::get_local_info(c);
transmatrix T = spin(master_to_c7_angle()) * gp::Tf[li.last_dir][li.relative.first&31][li.relative.second&31][fix6(li.total_dir)];
if(get_inverse) T = inverse(T);
return T;
}
}
else if(!nonbitrunc) {
for(int d=0; d<S7; d++) if(c->master->c7->mov[d] == c)
return (get_inverse?invhexmove:hexmove)[d];
return Id;
}
else
return pispin * Id;
}
transmatrix calc_relative_matrix(cell *c2, cell *c1) {
if(sphere) {
if(gmatrix0.count(c) && gmatrix0.count(h1->c7))
return inverse(gmatrix0[h1->c7]) * gmatrix0[c];
if(gmatrix0.count(c2) && gmatrix0.count(c1))
return inverse(gmatrix0[c1]) * gmatrix0[c2];
else {
printf("error: gmatrix0 not known\n");
exit(1);
}
}
heptagon *h1 = c1->master;
transmatrix gm = master_relative(c1, true);
heptagon *h2 = c2->master;
transmatrix where = master_relative(c2);
transmatrix gm = Id;
heptagon *h2 = c->master;
transmatrix where = Id;
if(gp::on && c != c->master->c7) {
auto li = gp::get_local_info(c);
where = gp::Tf[li.last_dir][li.relative.first&31][li.relative.second&31][fix6(li.total_dir)];
}
else if(!nonbitrunc)
for(int d=0; d<S7; d++) if(h2->c7->mov[d] == c)
where = hexmove[d];
// always add to last!
//bool hsol = false;
//transmatrix sol;
@ -3385,7 +3400,7 @@ transmatrix &ggmatrix(cell *c) {
t = gmatrix[centerover.c] * eumove(cell_to_vec(c) - cellwalker_to_vec(centerover));
}
else
t = applyspin(viewctr, cview()) * calc_relative_matrix(c, viewctr.h);
t = applyspin(viewctr, cview()) * calc_relative_matrix(c, viewctr.h->c7);
}
return t;
}
@ -3445,15 +3460,11 @@ void virtualRebase(cell*& base, transmatrix& at, bool tohex) {
return;
}
at = master_relative(base) * at;
base = base->master->c7;
while(true) {
if(!ctof(base)) {
cell *c7 = base->master->c7;
for(int d=0; d<S7; d++) if(c7->mov[d] == base)
at = hexmove[d] * at;
base = c7;
}
double currz = (at * C0)[2];
heptagon *h = base->master;
@ -3467,8 +3478,7 @@ void virtualRebase(cell*& base, transmatrix& at, bool tohex) {
hs.h = h;
hs.spin = d;
heptspin hs2 = hs + wstep;
transmatrix V2 = spin((nonbitrunc?M_PI:0)-hs2.spin*2*M_PI/S7) * invheptmove[d];
if(nonbitrunc) V2 = V2 * spin(M_PI);
transmatrix& V2 = invheptmove[d];
double newz = (V2 * at * C0) [2];
if(newz < currz) {
currz = newz;
@ -3477,7 +3487,11 @@ void virtualRebase(cell*& base, transmatrix& at, bool tohex) {
}
}
if(!newbase) {
if(newbase) {
base = newbase;
at = bestV * at;
}
else {
if(tohex && !nonbitrunc) for(int d=0; d<S7; d++) {
cell *c = createMov(base, d);
transmatrix V2 = spin(-base->spn(d)*2*M_PI/S6) * invhexmove[d];
@ -3492,13 +3506,11 @@ void virtualRebase(cell*& base, transmatrix& at, bool tohex) {
base = newbase;
at = bestV * at;
}
else at = master_relative(base, true) * at;
break;
}
base = newbase;
at = bestV * at;
}
}
void virtualRebase(shmup::monster *m, bool tohex) {