1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-17 02:34:48 +00:00

invalid_point functions, and using them in smart_range and queuestr/chr

This commit is contained in:
Zeno Rogue 2018-12-04 22:40:29 +01:00
parent 0d558cb0e1
commit 285211bcf3
3 changed files with 16 additions and 1 deletions

View File

@ -4556,6 +4556,8 @@ extern int cells_drawn;
void menuitem_sightrange(char c = 'r');
bool invalid_point(const hyperpoint h);
bool invalid_point(const transmatrix T);
bool in_smart_range(const transmatrix& T);
void curvepoint(const hyperpoint& H1);

View File

@ -684,8 +684,16 @@ transmatrix applyspin(const heptspin& hs, const transmatrix& V) {
return hs.spin ? V * spin(hs.spin*2*M_PI/S7) : V;
}
bool invalid_point(const hyperpoint h) {
return std::isnan(h[2]) || h[2] > 1e8 || std::isinf(h[2]);
}
bool invalid_point(const transmatrix T) {
return std::isnan(T[2][2]) || T[2][2] > 1e8 || std::isinf(T[2][2]);
}
bool in_smart_range(const transmatrix& T) {
if(std::isnan(T[2][2]) || std::isinf(T[2][2]) || T[2][2] > 1e8) return false;
if(invalid_point(T)) return false;
hyperpoint h1, h2, h3;
applymodel(tC0(T), h1);
if(std::isnan(h1[0]) || std::isnan(h1[1])) return false;

View File

@ -2789,6 +2789,7 @@ void getcoord0(const hyperpoint& h, int& xc, int &yc, int &sc) {
}
void queuechr(const hyperpoint& h, int size, char chr, color_t col, int frame) {
if(invalid_point(h)) return;
int xc, yc, sc; getcoord0(h, xc, yc, sc);
queuechr(xc, yc, sc, size, chr, col, frame);
}
@ -2798,16 +2799,19 @@ ld scale_in_pixels(const transmatrix& V) {
}
void queuechr(const transmatrix& V, double size, char chr, color_t col, int frame) {
if(invalid_point(V)) return;
int xc, yc, sc; getcoord0(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;
int xc, yc, sc; getcoord0(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;
int xc, yc, sc; getcoord0(tC0(V), xc, yc, sc);
// int xs, ys, ss; getcoord0(V * xpush0(.01), xs, ys, ss);
@ -2815,6 +2819,7 @@ void queuestr(const transmatrix& V, double size, const string& chr, color_t col,
}
void queuecircle(const transmatrix& V, double size, color_t col) {
if(invalid_point(V)) return;
int xc, yc, sc; getcoord0(tC0(V), xc, yc, sc);
int xs, ys, ss; getcoord0(V * xpush0(.01), xs, ys, ss);
queuecircle(xc, yc, scale_in_pixels(V) * size, col);