From 982f01e6e59d7ec39e44333a2035ac8429649005 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 23 Nov 2019 19:05:24 +0100 Subject: [PATCH] tracking the specific copy of the player in confusing geometries --- basegraph.cpp | 2 ++ celldrawer.cpp | 2 ++ game.cpp | 2 ++ graph.cpp | 2 ++ hypgraph.cpp | 33 +++++++++++++++++++++++++++------ orbs.cpp | 2 ++ shmup.cpp | 7 +++++++ 7 files changed, 44 insertions(+), 6 deletions(-) diff --git a/basegraph.cpp b/basegraph.cpp index 9f20a7d8..c45e4471 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -47,6 +47,8 @@ struct display_data { void set_mask(int ed); void set_all(int ed); + /** Which copy of the player cell? */ + transmatrix which_copy; }; #define View (::hr::current_display->view_matrix) diff --git a/celldrawer.cpp b/celldrawer.cpp index ef48a0a3..f36cd235 100644 --- a/celldrawer.cpp +++ b/celldrawer.cpp @@ -1713,6 +1713,8 @@ void celldrawer::bookkeeping() { else { playerV = V * ddspin(c, cwt.spin, 0); if(cwt.mirrored) playerV = playerV * Mirror; + if(!confusingGeometry() || eqmatrix(V, current_display->which_copy, 1e-2)) + current_display->which_copy = V; if(orig) cwtV = playerV; } } diff --git a/game.cpp b/game.cpp index ff691ccc..99ce0ee7 100644 --- a/game.cpp +++ b/game.cpp @@ -6660,6 +6660,7 @@ EX bool activateRecall() { // local_perspective = recallDisplay.local_perspective; gmatrix = recallDisplay.cellmatrices; gmatrix0 = recallDisplay.old_cellmatrices; + current_display->which_copy = recallDisplay.which_copy; makeEmpty(cwt.at); forCellEx(c2, cwt.at) @@ -8628,6 +8629,7 @@ EX bool movepcto(int d, int subdir IS(1), bool checkonly IS(false)) { } else animateMovement(mi, LAYER_SMALL); + current_display->which_copy = current_display->which_copy * adj(mi); mirror::act(origd, mirror::SPINMULTI | mirror::ATTACK | mirror::GO); diff --git a/graph.cpp b/graph.cpp index a28d5b1a..b58a1f13 100644 --- a/graph.cpp +++ b/graph.cpp @@ -3919,6 +3919,8 @@ EX void drawMarkers() { if(!(cmode & sm::NORMAL)) return; + queuepolyat(current_display->which_copy, cgi.shAsymmetric, 0xC0C0C0FF, PPR::SUPERLINE); + callhooks(hooks_markers); #if CAP_SHAPES viewmat(); diff --git a/hypgraph.cpp b/hypgraph.cpp index f99cd357..7e9a8acd 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1378,11 +1378,22 @@ EX void centerpc(ld aspd) { if(ors::mode == 2 && vid.sspeed < 5) return; if(vid.sspeed >= 4.99) aspd = 1000; DEBBI(DF_GRAPH, ("center pc")); + + auto& W = current_display->which_copy; + ors::unrotate(W); ors::unrotate(View); ors::unrotate(cwtV); + + /* what should we center? */ + transmatrix T; + if(multi::players > 1) + T = cwtV; /* do not even try */ + else { + T = W; + if(shmup::on) + T = T * shmup::pc[0]->at; + } - ors::unrotate(cwtV); ors::unrotate(View); - if(invalid_matrix(cwtV)) return; + if(invalid_matrix(T)) return; - transmatrix T = cwtV; #if MAXMDIM >= 4 if(GDIM == 3 && WDIM == 2) { geom3::do_auto_eye(); @@ -1412,10 +1423,11 @@ EX void centerpc(ld aspd) { shift_view_towards(H, aspd); fixmatrix(View); + fixmatrix(current_display->which_copy); spinEdge(aspd); } - ors::rerotate(cwtV); ors::rerotate(View); + ors::rerotate(W); ors::rerotate(cwtV); ors::rerotate(View); } EX void optimizeview() { @@ -1477,6 +1489,7 @@ EX void resetview() { View = Id; } cwtV = View; + current_display->which_copy = View; // SDL_LockSurface(s); // SDL_UnlockSurface(s); } @@ -2066,6 +2079,7 @@ EX transmatrix& get_view_orientation() { EX void rotate_view(transmatrix T) { transmatrix& which = get_view_orientation(); which = T * which; + if(&which == &View) current_display->which_copy = T * current_display->which_copy; } /** shift the view according to the given tangent vector */ @@ -2086,17 +2100,24 @@ EX transmatrix get_shift_view_of(const hyperpoint H, const transmatrix V) { /** shift the view according to the given tangent vector */ EX void shift_view(hyperpoint H) { + current_display->which_copy = get_shift_view_of(H, current_display->which_copy); View = get_shift_view_of(H, View); } +void multiply_view(transmatrix T) { + View = T * View; + auto& wc = current_display->which_copy; + wc = T * wc; + } + EX void shift_view_to(hyperpoint H) { - if(!nonisotropic) View = gpushxto0(H) * View; + if(!nonisotropic) multiply_view(gpushxto0(H)); else shift_view(-inverse_exp(H, iTable, false)); } EX void shift_view_towards(hyperpoint H, ld l) { if(!nonisotropic && !prod) - View = rspintox(H) * xpush(-l) * spintox(H) * View; + multiply_view(rspintox(H) * xpush(-l) * spintox(H)); else if(nonisotropic && !nisot::geodesic_movement) shift_view(tangent_length(H-C0, -l)); else { diff --git a/orbs.cpp b/orbs.cpp index 6cad2cd8..c68548ab 100644 --- a/orbs.cpp +++ b/orbs.cpp @@ -558,6 +558,7 @@ void teleportTo(cell *dest) { cell *from = cwt.at; movecost(from, dest, 1); playerMoveEffects(cwt.at, dest); + current_display->which_copy = ggmatrix(dest); cwt.at = dest; cwt.spin = hrand(dest->type); flipplayer = !!(hrand(2)); drainOrb(itOrbTeleport); @@ -602,6 +603,7 @@ EX void jumpTo(cell *dest, eItem byWhat, int bonuskill IS(0), eMonster dashmon I cell *c1 = cwt.at; animateMovement(match(cwt.at, dest), LAYER_SMALL); + current_display->which_copy = ggmatrix(dest); cwt.at = dest; forCellIdEx(c2, i, dest) if(c2->cpdist < dest->cpdist) { cwt.spin = i; diff --git a/shmup.cpp b/shmup.cpp index 3f9af2b8..c133057c 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -172,10 +172,13 @@ void monster::rebasePat(const transmatrix& new_pat, cell *c2) { virtualRebase(this); fix_to_2(at); pat = at; + if(multi::players == 1 && this == shmup::pc[0]) + current_display->which_copy = ggmatrix(base); return; } if(quotient) { at = inverse(gmatrix[base]) * new_pat; + transmatrix old_at = at; virtualRebase(this); fix_to_2(at); if(base != c2) { @@ -183,8 +186,12 @@ void monster::rebasePat(const transmatrix& new_pat, cell *c2) { base = c2; at = inverse(T) * at; } + if(multi::players == 1 && this == shmup::pc[0] && !eqmatrix(old_at, at)) + current_display->which_copy = current_display->which_copy * old_at * inverse(at); return; } + if(multi::players == 1 && this == shmup::pc[0]) + current_display->which_copy = current_display->which_copy * inverse(gmatrix[base]) * gmatrix[c2]; pat = new_pat; // if(c2 != base) printf("rebase %p -> %p\n", base, c2); base = c2;