1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-25 17:40:36 +00:00

solv:: fixup to ilocal_perspective removal, to work in mdPerspective too

This commit is contained in:
Zeno Rogue 2019-07-31 12:18:53 +02:00
parent 49c3a643ae
commit 8ba99c42a0
3 changed files with 22 additions and 13 deletions

View File

@ -5009,6 +5009,8 @@ void drawcell_in_radar(cell *c, transmatrix V) {
} }
#endif #endif
transmatrix ilocal_perspective;
void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
PROD( if(product::pmap) { product::drawcell_stack(c, V, spinv, mirrored); return; } ) PROD( if(product::pmap) { product::drawcell_stack(c, V, spinv, mirrored); return; } )
@ -5966,23 +5968,25 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
int d = (wcol & 0xF0F0F0) >> 4; int d = (wcol & 0xF0F0F0) >> 4;
hyperpoint h; if(sol) { if(pmodel == mdSolPerspective) h = tC0(V); else h = ilocal_perspective * tC0(V); }
for(int a=0; a<c->type; a++) for(int a=0; a<c->type; a++)
if(c->move(a) && !isWall3(c->move(a), dummy)) { if(c->move(a) && !isWall3(c->move(a), dummy)) {
if(pmodel == mdPerspective && !sphere && !quotient && !sol && !penrose) { if(pmodel == mdPerspective && !sphere && !quotient && !penrose && !sol) {
if(a < 4 && among(geometry, gHoroTris, gBinary3) && celldistAlt(c) >= celldistAlt(viewctr.at->c7)) continue; if(a < 4 && among(geometry, gHoroTris, gBinary3) && celldistAlt(c) >= celldistAlt(viewctr.at->c7)) continue;
else if(a < 2 && among(geometry, gHoroRec) && celldistAlt(c) >= celldistAlt(viewctr.at->c7)) continue; else if(a < 2 && among(geometry, gHoroRec) && celldistAlt(c) >= celldistAlt(viewctr.at->c7)) continue;
else if(c->move(a)->master->distance > c->master->distance && c->master->distance > viewctr.at->distance && !quotient) continue; else if(c->move(a)->master->distance > c->master->distance && c->master->distance > viewctr.at->distance && !quotient) continue;
} }
if(sol && in_perspective()) { else if(sol && in_perspective()) {
ld b = vid.binary_width * log(2) / 2; ld b = vid.binary_width * log(2) / 2;
const ld l = log(2) / 2; const ld l = log(2) / 2;
switch(a) { switch(a) {
case 0: if(V[0][3] >= b) continue; break; case 0: if(h[0] >= b) continue; break;
case 1: if(V[1][3] >= b) continue; break; case 1: if(h[1] >= b) continue; break;
case 2: case 3: if (pmodel == mdPerspective && V[2][3] >= l) continue; break; case 2: case 3: if (pmodel == mdPerspective && h[2] >= l) continue; break;
case 4: if(V[0][3] <= -b) continue; break; case 4: if(h[0] <= -b) continue; break;
case 5: if(V[1][3] <= -b) continue; break; case 5: if(h[1] <= -b) continue; break;
case 6: case 7: if (pmodel == mdPerspective && V[2][3] <= -l) continue; break; case 6: case 7: if (pmodel == mdPerspective && h[2] <= -l) continue; break;
} }
} }
if(qfi.fshape && wmescher) { if(qfi.fshape && wmescher) {
@ -7113,6 +7117,15 @@ void make_actual_view() {
actual_view_transform = sphereflip; actual_view_transform = sphereflip;
if(vid.yshift && WDIM == 2) actual_view_transform = ypush(vid.yshift) * actual_view_transform; if(vid.yshift && WDIM == 2) actual_view_transform = ypush(vid.yshift) * actual_view_transform;
#if MAXMDIM >= 4 #if MAXMDIM >= 4
if(sol) {
transmatrix T = eupush( tC0(inverse(View)) );
solv::local_perspective = View * T;
if(pmodel == mdSolPerspective) {
actual_view_transform = inverse(solv::local_perspective) * actual_view_transform;
return;
}
else ilocal_perspective = inverse(solv::local_perspective);
}
if(GDIM == 3) { if(GDIM == 3) {
ld max = WDIM == 2 ? vid.camera : vid.yshift; ld max = WDIM == 2 ? vid.camera : vid.yshift;
if(max) if(max)

View File

@ -1261,7 +1261,6 @@ void centerpc(ld aspd) {
transmatrix T = cwtV; transmatrix T = cwtV;
#if MAXMDIM >= 4 #if MAXMDIM >= 4
if(pmodel == mdSolPerspective) T = solv::local_perspective * T;
if(GDIM == 3 && WDIM == 2) { if(GDIM == 3 && WDIM == 2) {
geom3::do_auto_eye(); geom3::do_auto_eye();
int sl = snakelevel(cwt.at); int sl = snakelevel(cwt.at);

View File

@ -272,10 +272,7 @@ namespace solv {
void draw() override { void draw() override {
dq::visited.clear(); dq::visited.clear();
transmatrix T = eupush( tC0(inverse(View)) ); dq::enqueue(viewctr.at, cview());
local_perspective = View * T;
dq::enqueue(viewctr.at, inverse(local_perspective) * cview());
while(!dq::drawqueue.empty()) { while(!dq::drawqueue.empty()) {
auto& p = dq::drawqueue.front(); auto& p = dq::drawqueue.front();