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];
|
// 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) {
|
ld scale_in_pixels(const transmatrix& V) {
|
||||||
return scale_at(V) * cgi.scalefactor * current_display->radius / 2.5;
|
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) {
|
void queuechr(const transmatrix& V, double size, char chr, color_t col, int frame) {
|
||||||
if(invalid_point(V)) return;
|
int xc, yc, sc;
|
||||||
if(DIM == 3 && invis_point(tC0(V))) return;
|
if(getcoord0_checked(tC0(V), xc, yc, sc))
|
||||||
int xc, yc, sc; getcoord0(tC0(V), xc, yc, sc);
|
queuechr(xc, yc, sc, scale_in_pixels(V) * size, chr, col, frame);
|
||||||
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) {
|
void queuestr(const hyperpoint& h, int size, const string& chr, color_t col, int frame) {
|
||||||
if(invalid_point(h)) return;
|
int xc, yc, sc;
|
||||||
if(DIM == 3 && invis_point(h)) return;
|
if(getcoord0_checked(h, xc, yc, sc))
|
||||||
int xc, yc, sc; getcoord0(h, xc, yc, sc);
|
queuestr(xc, yc, sc, size, chr, col, frame);
|
||||||
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) {
|
void queuestr(const transmatrix& V, double size, const string& chr, color_t col, int frame, int align) {
|
||||||
if(invalid_point(V)) return;
|
int xc, yc, sc;
|
||||||
if(DIM == 3 && invis_point(tC0(V))) return;
|
if(getcoord0_checked(tC0(V), xc, yc, sc))
|
||||||
int xc, yc, sc; getcoord0(tC0(V), xc, yc, sc);
|
queuestr(xc, yc, sc, scale_in_pixels(V) * size, chr, col, frame, align);
|
||||||
// int xs, ys, ss; getcoord0(V * xpush0(.01), xs, ys, ss);
|
|
||||||
|
|
||||||
queuestr(xc, yc, sc, scale_in_pixels(V) * size, chr, col, frame, align);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void queuecircle(const transmatrix& V, double size, color_t col) {
|
void queuecircle(const transmatrix& V, double size, color_t col) {
|
||||||
if(invalid_point(V)) return;
|
int xc, yc, sc;
|
||||||
if(DIM == 3 && invis_point(tC0(V))) return;
|
if(!getcoord0_checked(tC0(V), xc, yc, sc)) return;
|
||||||
int xc, yc, sc; getcoord0(tC0(V), xc, yc, sc);
|
|
||||||
int xs, ys, ss; getcoord0(V * xpush0(.01), xs, ys, ss);
|
int xs, ys, ss; getcoord0(V * xpush0(.01), xs, ys, ss);
|
||||||
queuecircle(xc, yc, scale_in_pixels(V) * size, col);
|
queuecircle(xc, yc, scale_in_pixels(V) * size, col);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4476,12 +4476,12 @@ void shmup_gravity_floor(cell *c) {
|
||||||
ld mousedist(transmatrix T) {
|
ld mousedist(transmatrix T) {
|
||||||
if(GDIM == 2) return intval(mouseh, tC0(T));
|
if(GDIM == 2) return intval(mouseh, tC0(T));
|
||||||
hyperpoint T1 = tC0(mscale(T, cgi.FLOOR));
|
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;
|
hyperpoint h1;
|
||||||
applymodel(T1, h1);
|
applymodel(T1, h1);
|
||||||
using namespace hyperpoint_vec;
|
using namespace hyperpoint_vec;
|
||||||
h1 = h1 - hpxy((mousex - current_display->xcenter) / current_display->radius, (mousey - current_display->ycenter) / current_display->radius);
|
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;
|
vector<hyperpoint> clipping_planes;
|
||||||
|
|
2
hyper.h
2
hyper.h
|
@ -5359,7 +5359,7 @@ extern int cells_drawn;
|
||||||
|
|
||||||
void menuitem_sightrange(char c = 'r');
|
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 hyperpoint h);
|
||||||
bool invalid_point(const transmatrix T);
|
bool invalid_point(const transmatrix T);
|
||||||
bool in_smart_range(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;
|
return (hs.spin || !BITRUNCATED) ? V * spin(hs.spin*2*M_PI/S7 + master_to_c7_angle()) : V;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool invis_point(const hyperpoint h) {
|
bool point_behind(hyperpoint h) {
|
||||||
if(DIM == 2 || sphere || pmodel != mdPerspective) return false;
|
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;
|
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]);
|
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) {
|
bool in_smart_range(const transmatrix& T) {
|
||||||
if(invalid_point(T)) return false;
|
hyperpoint h = tC0(T);
|
||||||
if(pmodel == mdSolPerspective) return solv::in_table_range(tC0(T));
|
if(invalid_point(h)) return false;
|
||||||
|
if(pmodel == mdSolPerspective) return solv::in_table_range(h);
|
||||||
hyperpoint h1;
|
hyperpoint h1;
|
||||||
applymodel(tC0(T), h1);
|
applymodel(h, h1);
|
||||||
for(int i=0; i<DIM; i++)
|
if(invalid_point(h1)) return false;
|
||||||
if(std::isnan(h1[i]) || std::isinf(h1[i])) return false;
|
|
||||||
ld x = current_display->xcenter + current_display->radius * h1[0];
|
ld x = current_display->xcenter + current_display->radius * h1[0];
|
||||||
ld y = current_display->ycenter + current_display->radius * h1[1] * vid.stretch;
|
ld y = current_display->ycenter + current_display->radius * h1[1] * vid.stretch;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue