From d2c20fee224503452f390446d915e7a81b7c92d4 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 13 May 2019 15:09:24 +0200 Subject: [PATCH] redone spinEdge so that fixed_yz works in gravity lands --- graph.cpp | 15 +++++++-------- hyper.h | 4 +++- hypgraph.cpp | 28 +++++++++++++++++++++------- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/graph.cpp b/graph.cpp index 1de34a39..42f94c2c 100644 --- a/graph.cpp +++ b/graph.cpp @@ -2644,8 +2644,9 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, color_t col) { return false; } -double downspin; cell *straightDownSeek; +hyperpoint straightDownPoint; +ld straightDownSpeed; #define AURA 180 @@ -5958,12 +5959,10 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { if(usethis) { straightDownSeek = c; - downspin = atan2(V[1][GDIM], V[0][GDIM]); - downspin += (side-1) * M_PI/2; - downspin += conformal::rotation * degree; - while(downspin < -M_PI) downspin += 2*M_PI; - while(downspin > +M_PI) downspin -= 2*M_PI; - downspin = downspin * min(spd, (double)1); + straightDownPoint = tC0(V); + straightDownSpeed = spd; + if(side == 2) for(int i=0; i<3; i++) straightDownPoint[i] = -straightDownPoint[i]; + if(side == 1) straightDownPoint = spin(-M_PI/2) * straightDownPoint; } } @@ -6529,7 +6528,7 @@ void drawthemap() { multi::ccdist[i] = 1e20; multi::ccat[i] = NULL; } - straightDownSeek = NULL; downspin = 0; + straightDownSeek = NULL; #if ISMOBILE mouseovers = XLAT("No info about this..."); diff --git a/hyper.h b/hyper.h index be5e720b..544ecfec 100644 --- a/hyper.h +++ b/hyper.h @@ -2678,7 +2678,9 @@ void preparesort(); bool dodrawcell(cell *c); void drawcell(cell *c, transmatrix V, int spinv, bool mirrored); -extern double downspin; +extern cell* straightDownSeek; +extern hyperpoint straightDownPoint; +extern ld straightDownSpeed; extern int frameid; extern bool leftclick; diff --git a/hypgraph.cpp b/hypgraph.cpp index 6c5ca083..507d8b7a 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1063,7 +1063,7 @@ transmatrix eumovedir(int d) { } void spinEdge(ld aspd) { - + ld downspin = 0; if(playerfound && vid.fixed_facing) { hyperpoint H = gpushxto0(playerV * C0) * playerV * xpush0(5); downspin = atan2(H[1], H[0]); @@ -1073,14 +1073,28 @@ void spinEdge(ld aspd) { while(downspin > +M_PI) downspin -= 2*M_PI; aspd = (1 + 2 * abs(downspin)) * aspd; } + else if(WDIM == 2 && GDIM == 3 && vid.fixed_yz) { + aspd = 999999; + if(straightDownSeek) { + if(straightDownPoint[0]) + downspin = conformal::rotation * degree - atan2(straightDownPoint[0], straightDownPoint[1]); + } + else { + if(View[0][2]) + downspin = -atan2(View[0][2], View[1][2]); + } + } + else if(straightDownSeek) { + downspin = atan2(straightDownPoint[1], straightDownPoint[0]); + downspin -= M_PI/2; + downspin += conformal::rotation * degree; + while(downspin < -M_PI) downspin += 2*M_PI; + while(downspin > +M_PI) downspin -= 2*M_PI; + downspin = downspin * min(straightDownSpeed, (double)1); + } if(downspin > aspd) downspin = aspd; if(downspin < -aspd) downspin = -aspd; - View = spin(downspin) * View; - - if(WDIM == 2 && GDIM == 3 && vid.fixed_yz && View[0][2]) { - ld d12 = atan2(View[0][2], View[1][2]); - View = cspin(1, 0, d12) * View; - } + View = spin(downspin) * View; } void centerpc(ld aspd) {