mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-24 17:10:36 +00:00
precise mouseh in 2.5D
This commit is contained in:
parent
8a63307ed5
commit
2c59aa0e14
31
hypgraph.cpp
31
hypgraph.cpp
@ -89,20 +89,14 @@ EX hyperpoint space_to_perspective(hyperpoint z, ld alpha IS(pconf.alpha)) {
|
||||
return z;
|
||||
}
|
||||
|
||||
EX shiftpoint gethyper(ld x, ld y) {
|
||||
EX shiftpoint find_on_screen(hyperpoint hxy, shiftpoint hint) {
|
||||
shiftmatrix T = rgpushxto0(hint);
|
||||
|
||||
ld hx = (x - current_display->xcenter) / current_display->radius;
|
||||
ld hy = (y - current_display->ycenter) / current_display->radius / pconf.stretch;
|
||||
hyperpoint hxy = point3(hx, hy, 0);
|
||||
|
||||
if(pmodel) {
|
||||
ghxy = hxy;
|
||||
|
||||
shiftmatrix T = rgpushxto0(ghpm);
|
||||
hyperpoint rel = WDIM == 2 && GDIM == 3 ? zpush0(cgi.FLOOR) : C0;
|
||||
|
||||
auto distance_at = [&] (const shiftmatrix& T1) {
|
||||
hyperpoint h1;
|
||||
applymodel(tC0(T1), h1);
|
||||
applymodel(T1*rel, h1);
|
||||
return sqhypot_d(2, hxy - h1);
|
||||
};
|
||||
|
||||
@ -124,7 +118,22 @@ EX shiftpoint gethyper(ld x, ld y) {
|
||||
}
|
||||
}
|
||||
|
||||
return tC0(T);
|
||||
return T*rel;
|
||||
}
|
||||
|
||||
EX shiftpoint gethyper(ld x, ld y) {
|
||||
|
||||
ld hx = (x - current_display->xcenter) / current_display->radius;
|
||||
ld hy = (y - current_display->ycenter) / current_display->radius / pconf.stretch;
|
||||
hyperpoint hxy = point3(hx, hy, 0);
|
||||
|
||||
if(WDIM == 2 && GDIM == 3) {
|
||||
return mouseover ? find_on_screen(hxy, ggmatrix(mouseover) * C0) : shiftless(Hypc);
|
||||
}
|
||||
|
||||
if(pmodel) {
|
||||
ghxy = hxy;
|
||||
return find_on_screen(hxy, ghpm);
|
||||
}
|
||||
|
||||
if(pconf.camera_angle) camrotate(hx, hy);
|
||||
|
Loading…
Reference in New Issue
Block a user