mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-20 15:40:26 +00:00
cleaned up invis_point -> point_behind and invalid_point(transmatrix), also implemented for Solv
This commit is contained in:
parent
4a8ec3b3c4
commit
44b9968ff8
50
drawing.cpp
50
drawing.cpp
@ -1636,44 +1636,44 @@ void getcoord0(const hyperpoint& h, int& xc, int &yc, int &sc) {
|
||||
// EYETODO sc = vid.eye * current_display->radius * hscr[2];
|
||||
}
|
||||
|
||||
void queuechr(const hyperpoint& h, int size, char chr, color_t col, int frame) {
|
||||
if(invalid_point(h)) return;
|
||||
if(DIM == 3 && invis_point(h)) return;
|
||||
int xc, yc, sc; getcoord0(h, xc, yc, sc);
|
||||
queuechr(xc, yc, sc, size, chr, col, frame);
|
||||
}
|
||||
|
||||
ld scale_in_pixels(const transmatrix& V) {
|
||||
return scale_at(V) * cgi.scalefactor * current_display->radius / 2.5;
|
||||
}
|
||||
|
||||
|
||||
bool getcoord0_checked(const hyperpoint& h, int& xc, int &yc, int &zc) {
|
||||
if(invalid_point(h)) return false;
|
||||
if(point_behind(h)) return false;
|
||||
getcoord0(h, xc, yc, zc);
|
||||
return true;
|
||||
}
|
||||
|
||||
void queuechr(const hyperpoint& h, int size, char chr, color_t col, int frame) {
|
||||
int xc, yc, sc;
|
||||
if(getcoord0_checked(h, xc, yc, sc))
|
||||
queuechr(xc, yc, sc, size, chr, col, frame);
|
||||
}
|
||||
|
||||
void queuechr(const transmatrix& V, double size, char chr, color_t col, int frame) {
|
||||
if(invalid_point(V)) return;
|
||||
if(DIM == 3 && invis_point(tC0(V))) return;
|
||||
int xc, yc, sc; getcoord0(tC0(V), xc, yc, sc);
|
||||
queuechr(xc, yc, sc, scale_in_pixels(V) * size, chr, col, frame);
|
||||
int xc, yc, sc;
|
||||
if(getcoord0_checked(tC0(V), xc, yc, sc))
|
||||
queuechr(xc, yc, sc, scale_in_pixels(V) * size, chr, col, frame);
|
||||
}
|
||||
|
||||
void queuestr(const hyperpoint& h, int size, const string& chr, color_t col, int frame) {
|
||||
if(invalid_point(h)) return;
|
||||
if(DIM == 3 && invis_point(h)) return;
|
||||
int xc, yc, sc; getcoord0(h, xc, yc, sc);
|
||||
queuestr(xc, yc, sc, size, chr, col, frame);
|
||||
int xc, yc, sc;
|
||||
if(getcoord0_checked(h, xc, yc, sc))
|
||||
queuestr(xc, yc, sc, size, chr, col, frame);
|
||||
}
|
||||
|
||||
void queuestr(const transmatrix& V, double size, const string& chr, color_t col, int frame, int align) {
|
||||
if(invalid_point(V)) return;
|
||||
if(DIM == 3 && invis_point(tC0(V))) return;
|
||||
int xc, yc, sc; getcoord0(tC0(V), xc, yc, sc);
|
||||
// int xs, ys, ss; getcoord0(V * xpush0(.01), xs, ys, ss);
|
||||
|
||||
queuestr(xc, yc, sc, scale_in_pixels(V) * size, chr, col, frame, align);
|
||||
int xc, yc, sc;
|
||||
if(getcoord0_checked(tC0(V), xc, yc, sc))
|
||||
queuestr(xc, yc, sc, scale_in_pixels(V) * size, chr, col, frame, align);
|
||||
}
|
||||
|
||||
void queuecircle(const transmatrix& V, double size, color_t col) {
|
||||
if(invalid_point(V)) return;
|
||||
if(DIM == 3 && invis_point(tC0(V))) return;
|
||||
int xc, yc, sc; getcoord0(tC0(V), xc, yc, sc);
|
||||
int xc, yc, sc;
|
||||
if(!getcoord0_checked(tC0(V), xc, yc, sc)) return;
|
||||
int xs, ys, ss; getcoord0(V * xpush0(.01), xs, ys, ss);
|
||||
queuecircle(xc, yc, scale_in_pixels(V) * size, col);
|
||||
}
|
||||
|
@ -4476,12 +4476,12 @@ void shmup_gravity_floor(cell *c) {
|
||||
ld mousedist(transmatrix T) {
|
||||
if(GDIM == 2) return intval(mouseh, tC0(T));
|
||||
hyperpoint T1 = tC0(mscale(T, cgi.FLOOR));
|
||||
if(mouseaim_sensitivity) return sqhypot_d(2, T1) + (invis_point(T1) ? 1e10 : 0);
|
||||
if(mouseaim_sensitivity) return sqhypot_d(2, T1) + (point_behind(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);
|
||||
return sqhypot_d(2, h1) + (point_behind(T1) ? 1e10 : 0);
|
||||
}
|
||||
|
||||
vector<hyperpoint> clipping_planes;
|
||||
|
2
hyper.h
2
hyper.h
@ -5359,7 +5359,7 @@ extern int cells_drawn;
|
||||
|
||||
void menuitem_sightrange(char c = 'r');
|
||||
|
||||
bool invis_point(const hyperpoint h);
|
||||
bool point_behind(const hyperpoint h);
|
||||
bool invalid_point(const hyperpoint h);
|
||||
bool invalid_point(const transmatrix T);
|
||||
bool in_smart_range(const transmatrix& T);
|
||||
|
21
hypgraph.cpp
21
hypgraph.cpp
@ -879,8 +879,11 @@ transmatrix actualV(const heptspin& hs, const transmatrix& V) {
|
||||
return (hs.spin || !BITRUNCATED) ? V * spin(hs.spin*2*M_PI/S7 + master_to_c7_angle()) : V;
|
||||
}
|
||||
|
||||
bool invis_point(const hyperpoint h) {
|
||||
if(DIM == 2 || sphere || pmodel != mdPerspective) return false;
|
||||
bool point_behind(hyperpoint h) {
|
||||
if(sphere) return false;
|
||||
if(!in_perspective()) return false;
|
||||
if(pmodel == mdSolPerspective) h = solv::inverse_exp(h, true);
|
||||
if(solv::local_perspective_used()) h = solv::local_perspective * h;
|
||||
return h[2] < 0;
|
||||
}
|
||||
|
||||
@ -900,17 +903,13 @@ bool invalid_point(const hyperpoint h) {
|
||||
return std::isnan(h[DIM]) || h[DIM] > 1e8 || std::isinf(h[DIM]);
|
||||
}
|
||||
|
||||
bool invalid_point(const transmatrix T) {
|
||||
return std::isnan(T[DIM][DIM]) || T[DIM][DIM] > 1e8 || std::isinf(T[DIM][DIM]);
|
||||
}
|
||||
|
||||
bool in_smart_range(const transmatrix& T) {
|
||||
if(invalid_point(T)) return false;
|
||||
if(pmodel == mdSolPerspective) return solv::in_table_range(tC0(T));
|
||||
hyperpoint h = tC0(T);
|
||||
if(invalid_point(h)) return false;
|
||||
if(pmodel == mdSolPerspective) return solv::in_table_range(h);
|
||||
hyperpoint h1;
|
||||
applymodel(tC0(T), h1);
|
||||
for(int i=0; i<DIM; i++)
|
||||
if(std::isnan(h1[i]) || std::isinf(h1[i])) return false;
|
||||
applymodel(h, h1);
|
||||
if(invalid_point(h1)) return false;
|
||||
ld x = current_display->xcenter + current_display->radius * h1[0];
|
||||
ld y = current_display->ycenter + current_display->radius * h1[1] * vid.stretch;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user