From c70db33417360d9c27c3d0337ab2deceba4aa81e Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 23 Jul 2018 16:08:08 +0200 Subject: [PATCH] improved mobile compass --- control.cpp | 8 +++++--- hud.cpp | 25 +++++++++++++++++-------- hyper.h | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/control.cpp b/control.cpp index bf4abd71..18600991 100644 --- a/control.cpp +++ b/control.cpp @@ -898,9 +898,11 @@ bool handleCompass() { if(h < rad) { if(h < rad*SKIPFAC) movepcto(MD_WAIT); else { - double d = vid.revcontrol ? -1 : 1; - mouseh = hpxy(dx * d / rad, dy * d / rad); - mousemovement(); + hyperpoint param = hpxy(dx * 1. / rad, dy * 1. / rad); + + movedir md = vectodir(param); + + if(!canmove) movepcto(md), remission(); else movepcto(md); } getcstat = 0; return true; diff --git a/hud.cpp b/hud.cpp index 2c61e69c..039b34b3 100644 --- a/hud.cpp +++ b/hud.cpp @@ -301,12 +301,18 @@ bool nohud, nomenukey; hookset *hooks_prestats; -void drawMobileArrow(cell *c, transmatrix V) { +void drawMobileArrow(int i) { + + int dir = i; + cell *c = cwt.c->mov[i]; + if(!c) return; + + transmatrix T; + if(!compute_relamatrix(c, cwt.c, i, T)) return; // int col = getcs().uicolor; // col -= (col & 0xFF) >> 1; - int dir = neighborId(cwt.c, c); bool invalid = !legalmoves[dir]; int col = cellcolor(c); @@ -317,12 +323,15 @@ void drawMobileArrow(cell *c, transmatrix V) { poly_outline = OUTLINE_DEFAULT; // transmatrix m2 = Id; - ld scale = vid.mobilecompasssize * 5; + ld scale = vid.mobilecompasssize * (sphere ? 7 : euclid ? 6 : 5); // m2[0][0] = scale; m2[1][1] = scale; m2[2][2] = 1; - - transmatrix Centered = rgpushxto0(tC0(cwtV * sphereflip)); - transmatrix t = inverse(Centered) * V; - double alpha = atan2(tC0(t)[1], tC0(t)[0]); + + transmatrix U = shmup::ggmatrix(cwt.c); + hyperpoint H = sphereflip * tC0(U); + transmatrix Centered = sphereflip * rgpushxto0(H); + + hyperpoint P = inverse(Centered) * U * T * C0; + double alpha = atan2(P[1], P[0]); using namespace shmupballs; @@ -390,7 +399,7 @@ void drawStats() { queuecircle(xmove, yb, rad*SKIPFAC, legalmoves[MAX_EDGE] ? 0xFF0000FF : 0xFF000080 ); - forCellEx(c2, cwt.c) if(gmatrix.count(c2)) drawMobileArrow(c2, gmatrix[c2]); + for(int i=0; itype; i++) drawMobileArrow(i); if(hypot(mousex-xmove, mousey-yb) <= rad) getcstat = '-'; quickqueue(); } diff --git a/hyper.h b/hyper.h index 4da606e4..13221546 100644 --- a/hyper.h +++ b/hyper.h @@ -3738,5 +3738,5 @@ namespace ors { void rerotate(transmatrix& T); void reset(); } - + }