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:
parent
0d558cb0e1
commit
285211bcf3
2
hyper.h
2
hyper.h
@ -4556,6 +4556,8 @@ extern int cells_drawn;
|
|||||||
|
|
||||||
void menuitem_sightrange(char c = 'r');
|
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);
|
bool in_smart_range(const transmatrix& T);
|
||||||
|
|
||||||
void curvepoint(const hyperpoint& H1);
|
void curvepoint(const hyperpoint& H1);
|
||||||
|
10
hypgraph.cpp
10
hypgraph.cpp
@ -684,8 +684,16 @@ transmatrix applyspin(const heptspin& hs, const transmatrix& V) {
|
|||||||
return hs.spin ? V * spin(hs.spin*2*M_PI/S7) : 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) {
|
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;
|
hyperpoint h1, h2, h3;
|
||||||
applymodel(tC0(T), h1);
|
applymodel(tC0(T), h1);
|
||||||
if(std::isnan(h1[0]) || std::isnan(h1[1])) return false;
|
if(std::isnan(h1[0]) || std::isnan(h1[1])) return false;
|
||||||
|
@ -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) {
|
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);
|
int xc, yc, sc; getcoord0(h, xc, yc, sc);
|
||||||
queuechr(xc, yc, sc, size, chr, col, frame);
|
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) {
|
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);
|
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; getcoord0(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; getcoord0(tC0(V), xc, yc, sc);
|
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);
|
||||||
|
|
||||||
@ -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) {
|
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 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);
|
||||||
|
Loading…
Reference in New Issue
Block a user