From 9c1efae2f653e72e1436cd636f0acca79cf57981 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 9 May 2019 17:02:50 +0200 Subject: [PATCH] 2d3d:: mouse reading --- graph.cpp | 34 +++++++++++++++++++++++----------- hypgraph.cpp | 4 +++- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/graph.cpp b/graph.cpp index 51e4caee..6393c5fa 100644 --- a/graph.cpp +++ b/graph.cpp @@ -4149,6 +4149,17 @@ void shmup_gravity_floor(cell *c) { set_floor(shFullFloor); } +ld mousedist(transmatrix T) { + if(GDIM == 2) return intval(mouseh, tC0(T)); + hyperpoint T1 = tC0(mscale(T, geom3::FLOOR)); + if(mouseaim_sensitivity) return sqhypot_d(2, T1) + (invis_point(T1) ? 1e10 : 0); + hyperpoint h1; + applymodel(T1, h1); + using namespace hyperpoint_vec; + h1 = h1 - hpxy((mousex - current_display->xcenter) / current_display->radius, (mousey - current_display->ycenter) / current_display->radius); + return sqhypot_d(2, h1) + (invis_point(T1) ? 1e10 : 0); + } + void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { cells_drawn++; @@ -4230,22 +4241,22 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { if(1) { - hyperpoint VC0 = tC0(V); + ld dist = mousedist(V); if(inmirrorcount) ; - else if(DIM == 3) ; - else if(intval(mouseh, VC0) < modist) { + else if(WDIM == 3) ; + else if(dist < modist) { modist2 = modist; mouseover2 = mouseover; - modist = intval(mouseh, VC0); + modist = dist; mouseover = c; } - else if(intval(mouseh, VC0) < modist2) { - modist2 = intval(mouseh, VC0); + else if(dist < modist2) { + modist2 = dist; mouseover2 = c; } if(!euclid) { - double dfc = euclid ? intval(VC0, C0) : VC0[DIM]; + double dfc = euclid ? intval(tC0(V), C0) : V[GDIM][GDIM]; if(dfc < centdist) { centdist = dfc; @@ -4257,7 +4268,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { if(c->cpdist <= orbrange) if(multi::players > 1 || multi::alwaysuse) for(int i=0; ic7; ld best = HUGE_VAL; hyperpoint h = cpush(2, 1) * C0; @@ -6120,6 +6131,7 @@ void precise_mouseover() { return; } if(!mouseover) return; + if(GDIM == 3) return; cell *omouseover = mouseover; for(int loop = 0; loop < 10; loop++) { bool found = false; @@ -6222,7 +6234,7 @@ void drawthemap() { #if ISMOBILE mouseovers = XLAT("No info about this..."); #endif - if(mouseout()) + if(mouseout() && !mousepan) modist = -5; playerfound = false; // playerfoundL = false; diff --git a/hypgraph.cpp b/hypgraph.cpp index c172935e..4e27e71d 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -668,7 +668,9 @@ bool playerfound; // has player been found in the last drawing? double q3 = sqrt(double(3)); bool outofmap(hyperpoint h) { - if(euclid) + if(GDIM == 3) + return false; + else if(euclid) return h[2] < .5; // false; // h[0] * h[0] + h[1] * h[1] > 15 * crossf; else if(sphere) return h[2] < .1 && h[2] > -.1 && h[1] > -.1 && h[1] < .1 && h[0] > -.1 && h[0] < .1;