mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-24 17:10:36 +00:00
2d3d:: mouse reading
This commit is contained in:
parent
0a4ccb2b5c
commit
9c1efae2f6
34
graph.cpp
34
graph.cpp
@ -4149,6 +4149,17 @@ void shmup_gravity_floor(cell *c) {
|
|||||||
set_floor(shFullFloor);
|
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) {
|
void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
||||||
|
|
||||||
cells_drawn++;
|
cells_drawn++;
|
||||||
@ -4230,22 +4241,22 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
|||||||
|
|
||||||
if(1) {
|
if(1) {
|
||||||
|
|
||||||
hyperpoint VC0 = tC0(V);
|
ld dist = mousedist(V);
|
||||||
|
|
||||||
if(inmirrorcount) ;
|
if(inmirrorcount) ;
|
||||||
else if(DIM == 3) ;
|
else if(WDIM == 3) ;
|
||||||
else if(intval(mouseh, VC0) < modist) {
|
else if(dist < modist) {
|
||||||
modist2 = modist; mouseover2 = mouseover;
|
modist2 = modist; mouseover2 = mouseover;
|
||||||
modist = intval(mouseh, VC0);
|
modist = dist;
|
||||||
mouseover = c;
|
mouseover = c;
|
||||||
}
|
}
|
||||||
else if(intval(mouseh, VC0) < modist2) {
|
else if(dist < modist2) {
|
||||||
modist2 = intval(mouseh, VC0);
|
modist2 = dist;
|
||||||
mouseover2 = c;
|
mouseover2 = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!euclid) {
|
if(!euclid) {
|
||||||
double dfc = euclid ? intval(VC0, C0) : VC0[DIM];
|
double dfc = euclid ? intval(tC0(V), C0) : V[GDIM][GDIM];
|
||||||
|
|
||||||
if(dfc < centdist) {
|
if(dfc < centdist) {
|
||||||
centdist = dfc;
|
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)
|
if(c->cpdist <= orbrange) if(multi::players > 1 || multi::alwaysuse)
|
||||||
for(int i=0; i<multi::players; i++) if(multi::playerActive(i)) {
|
for(int i=0; i<multi::players; i++) if(multi::playerActive(i)) {
|
||||||
double dfc = intval(VC0, tC0(multi::crosscenter[i]));
|
double dfc = intval(tC0(V), tC0(multi::crosscenter[i]));
|
||||||
if(dfc < multi::ccdist[i] && celldistance(playerpos(i), c) <= orbrange) {
|
if(dfc < multi::ccdist[i] && celldistance(playerpos(i), c) <= orbrange) {
|
||||||
multi::ccdist[i] = dfc;
|
multi::ccdist[i] = dfc;
|
||||||
multi::ccat[i] = c;
|
multi::ccat[i] = c;
|
||||||
@ -5666,7 +5677,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
|||||||
|
|
||||||
if(usethis) {
|
if(usethis) {
|
||||||
straightDownSeek = c;
|
straightDownSeek = c;
|
||||||
downspin = atan2(VC0[1], VC0[0]);
|
downspin = atan2(V[1][GDIM], V[0][GDIM]);
|
||||||
downspin += (side-1) * M_PI/2;
|
downspin += (side-1) * M_PI/2;
|
||||||
downspin += conformal::rotation * degree;
|
downspin += conformal::rotation * degree;
|
||||||
while(downspin < -M_PI) downspin += 2*M_PI;
|
while(downspin < -M_PI) downspin += 2*M_PI;
|
||||||
@ -6109,7 +6120,7 @@ transmatrix cview() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void precise_mouseover() {
|
void precise_mouseover() {
|
||||||
if(DIM == 3) {
|
if(WDIM == 3) {
|
||||||
mouseover2 = mouseover = viewctr.at->c7;
|
mouseover2 = mouseover = viewctr.at->c7;
|
||||||
ld best = HUGE_VAL;
|
ld best = HUGE_VAL;
|
||||||
hyperpoint h = cpush(2, 1) * C0;
|
hyperpoint h = cpush(2, 1) * C0;
|
||||||
@ -6120,6 +6131,7 @@ void precise_mouseover() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!mouseover) return;
|
if(!mouseover) return;
|
||||||
|
if(GDIM == 3) return;
|
||||||
cell *omouseover = mouseover;
|
cell *omouseover = mouseover;
|
||||||
for(int loop = 0; loop < 10; loop++) {
|
for(int loop = 0; loop < 10; loop++) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
@ -6222,7 +6234,7 @@ void drawthemap() {
|
|||||||
#if ISMOBILE
|
#if ISMOBILE
|
||||||
mouseovers = XLAT("No info about this...");
|
mouseovers = XLAT("No info about this...");
|
||||||
#endif
|
#endif
|
||||||
if(mouseout())
|
if(mouseout() && !mousepan)
|
||||||
modist = -5;
|
modist = -5;
|
||||||
playerfound = false;
|
playerfound = false;
|
||||||
// playerfoundL = false;
|
// playerfoundL = false;
|
||||||
|
@ -668,7 +668,9 @@ bool playerfound; // has player been found in the last drawing?
|
|||||||
double q3 = sqrt(double(3));
|
double q3 = sqrt(double(3));
|
||||||
|
|
||||||
bool outofmap(hyperpoint h) {
|
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;
|
return h[2] < .5; // false; // h[0] * h[0] + h[1] * h[1] > 15 * crossf;
|
||||||
else if(sphere)
|
else if(sphere)
|
||||||
return h[2] < .1 && h[2] > -.1 && h[1] > -.1 && h[1] < .1 && h[0] > -.1 && h[0] < .1;
|
return h[2] < .1 && h[2] > -.1 && h[1] > -.1 && h[1] < .1 && h[0] > -.1 && h[0] < .1;
|
||||||
|
Loading…
Reference in New Issue
Block a user