mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-20 15:40:26 +00:00
2D3D:: fixed grids
This commit is contained in:
parent
ba91bea71c
commit
32626dc0c1
10
graph.cpp
10
graph.cpp
@ -4393,18 +4393,18 @@ void make_clipping_planes() {
|
||||
add_clipping_plane(+tx, -ty, +tx, +ty);
|
||||
}
|
||||
|
||||
void gridline(const hyperpoint h1, const hyperpoint h2, color_t col, int prec) {
|
||||
void gridline(const transmatrix& V1, const hyperpoint h1, const transmatrix& V2, const hyperpoint h2, color_t col, int prec) {
|
||||
if(WDIM == 2 && GDIM == 3) {
|
||||
ld eps = geom3::human_height/100;
|
||||
queueline(orthogonal_move(h1,geom3::FLOOR+eps), orthogonal_move(h2,geom3::FLOOR+eps), col, prec);
|
||||
queueline(orthogonal_move(h1,geom3::WALL-eps), orthogonal_move(h2,geom3::WALL-eps), col, prec);
|
||||
queueline(V1*orthogonal_move(h1,geom3::FLOOR+eps), V2*orthogonal_move(h2,geom3::FLOOR+eps), col, prec);
|
||||
queueline(V1*orthogonal_move(h1,geom3::WALL-eps), V2*orthogonal_move(h2,geom3::WALL-eps), col, prec);
|
||||
}
|
||||
else
|
||||
queueline(h1, h2, col, prec);
|
||||
queueline(V1*h1, V2*h2, col, prec);
|
||||
}
|
||||
|
||||
void gridline(const transmatrix& V, const hyperpoint h1, const hyperpoint h2, color_t col, int prec) {
|
||||
gridline(V*h1, V*h2, col, prec);
|
||||
gridline(V, h1, V, h2, col, prec);
|
||||
}
|
||||
|
||||
void draw_grid_at(cell *c, const transmatrix& V) {
|
||||
|
2
hyper.h
2
hyper.h
@ -5123,7 +5123,7 @@ extern int current_rbuffer;
|
||||
extern bool new_projection_needed;
|
||||
inline void reset_projection() { new_projection_needed = true; }
|
||||
extern ld ptick(int period, ld phase = 0);
|
||||
void gridline(const hyperpoint h1, const hyperpoint h2, color_t col, int prec);
|
||||
void gridline(const transmatrix& V1, const hyperpoint h1, const transmatrix& V2, const hyperpoint h2, color_t col, int prec);
|
||||
void gridline(const transmatrix& V, const hyperpoint h1, const hyperpoint h2, color_t col, int prec);
|
||||
}
|
||||
|
||||
|
@ -531,11 +531,11 @@ bool draw_cell_schematics(cell *c, transmatrix V) {
|
||||
queuestr(V * rgpushxto0(p.p), .1, its(i), isize(p.vertices) > 8 ? 0xFF0000 : 0xFFFFFF);
|
||||
int N = isize(p.vertices);
|
||||
for(int j=0; j<N; j++)
|
||||
gridline(V * p.pusher * p.vertices[j], V * p.pusher * p.vertices[(1+j)%N], 0xFFFFFFFF, 0);
|
||||
gridline(V, p.pusher * p.vertices[j], p.pusher * p.vertices[(1+j)%N], 0xFFFFFFFF, 0);
|
||||
|
||||
gridline(V * p.p, V * C0, 0xFF0000FF, 0);
|
||||
gridline(V, p.p, C0, 0xFF0000FF, 0);
|
||||
if(p.patterndir != -1)
|
||||
gridline(V * p.p, V * calc_relative_matrix(c->master->move(p.patterndir)->c7, c, p.p) * C0, 0x00FF00FF, 0);
|
||||
gridline(V, p.p, calc_relative_matrix(c->master->move(p.patterndir)->c7, c, p.p) * C0, 0x00FF00FF, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
94
pattern2.cpp
94
pattern2.cpp
@ -2166,20 +2166,24 @@ namespace linepatterns {
|
||||
if(lp.id == id) lp.color ^= col;
|
||||
}
|
||||
|
||||
void gridlinef(const hyperpoint& h1, const hyperpoint& h2, color_t col, int par) {
|
||||
void gridlinef(const transmatrix& V1, const hyperpoint& h1, const transmatrix& V2, const hyperpoint& h2, color_t col, int par) {
|
||||
if(!elliptic)
|
||||
gridline(h1, h2, col, par);
|
||||
gridline(V1, h1, V2, h2, col, par);
|
||||
else {
|
||||
ld cros = h1[0]*h2[0] + h1[1]*h2[1] + h1[2]*h2[2];
|
||||
hyperpoint vh1 = V1 * h1;
|
||||
hyperpoint vh2 = V2 * h2;
|
||||
ld cros = vh1[0]*vh2[0] + vh1[1]*vh2[1] + vh1[2]*vh2[2];
|
||||
using namespace hyperpoint_vec;
|
||||
if(cros > 0)
|
||||
gridline(h1, h2, col, par),
|
||||
gridline(-1*h1, -1*h2, col, par);
|
||||
gridline(V1, h1, V2, h2, col, par),
|
||||
gridline(V1, -1*h1, V2, -1*h2, col, par);
|
||||
else
|
||||
gridline(h1, -1*h2, col, par),
|
||||
gridline(-1*h1, h2, col, par);
|
||||
gridline(V1, h1, V2, -1*h2, col, par),
|
||||
gridline(V1, -1*h1, V2, h2, col, par);
|
||||
}
|
||||
}
|
||||
|
||||
void gridlinef(const transmatrix& V, const hyperpoint& h1, const hyperpoint& h2, color_t col, int par) { gridlinef(V, h1, V, h2, col, par); }
|
||||
|
||||
void drawPattern(int id, color_t col, cell *c, const transmatrix& V) {
|
||||
|
||||
@ -2188,25 +2192,25 @@ namespace linepatterns {
|
||||
case patZebraTriangles:
|
||||
if(euclid) {
|
||||
if(patterns::sevenval(c)) break;
|
||||
gridline(tC0(V), V * tC0(eumove(-1, +3)), col, 3 + vid.linequality);
|
||||
gridline(tC0(V), V * tC0(eumove(-3, +2)), col, 3 + vid.linequality);
|
||||
gridline(tC0(V), V * tC0(eumove(-2, -1)), col, 3 + vid.linequality);
|
||||
gridline(tC0(V), V * tC0(eumove(+1, -3)), col, 3 + vid.linequality);
|
||||
gridline(tC0(V), V * tC0(eumove(+3, -2)), col, 3 + vid.linequality);
|
||||
gridline(tC0(V), V * tC0(eumove(+2, +1)), col, 3 + vid.linequality);
|
||||
gridline(V, C0, tC0(eumove(-1, +3)), col, 3 + vid.linequality);
|
||||
gridline(V, C0, tC0(eumove(-3, +2)), col, 3 + vid.linequality);
|
||||
gridline(V, C0, tC0(eumove(-2, -1)), col, 3 + vid.linequality);
|
||||
gridline(V, C0, tC0(eumove(+1, -3)), col, 3 + vid.linequality);
|
||||
gridline(V, C0, tC0(eumove(+3, -2)), col, 3 + vid.linequality);
|
||||
gridline(V, C0, tC0(eumove(+2, +1)), col, 3 + vid.linequality);
|
||||
break;
|
||||
}
|
||||
if(zebra40(c) / 4 == 10) {
|
||||
bool all = true;
|
||||
hyperpoint tri[3];
|
||||
transmatrix tri[3];
|
||||
for(int i=0; i<3; i++) {
|
||||
cell *c2 = createMov(c, i*2);
|
||||
if(!gmatrix.count(c2)) all = false;
|
||||
else tri[i] = tC0(gmatrix[c2]);
|
||||
else tri[i] = gmatrix[c2];
|
||||
}
|
||||
|
||||
if(all) for(int i=0; i<3; i++)
|
||||
gridline(tri[i], tri[(i+1)%3], col, 3 + vid.linequality);
|
||||
gridline(tri[i], C0, tri[(i+1)%3], C0, col, 3 + vid.linequality);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -2221,8 +2225,8 @@ namespace linepatterns {
|
||||
|
||||
double x = hexhexdist / 2; // sphere?.3651:euclid?.2611:.2849;
|
||||
|
||||
gridlinef(V * ddspin(c,i,-M_PI/S3) * xpush0(x),
|
||||
V * ddspin(c,i,M_PI/S3) * xpush0(x),
|
||||
gridlinef(V, ddspin(c,i,-M_PI/S3) * xpush0(x),
|
||||
ddspin(c,i,M_PI/S3) * xpush0(x),
|
||||
col, 1 + vid.linequality);
|
||||
}
|
||||
break;
|
||||
@ -2230,22 +2234,22 @@ namespace linepatterns {
|
||||
case patNormal: {
|
||||
for(int t=0; t<c->type; t++)
|
||||
if(c->move(t) && c->move(t) < c)
|
||||
gridline(V * get_corner_position(c, t),
|
||||
V * get_corner_position(c, (t+1)%c->type),
|
||||
gridline(V, get_corner_position(c, t),
|
||||
get_corner_position(c, (t+1)%c->type),
|
||||
col, 1 + vid.linequality);
|
||||
break;
|
||||
}
|
||||
|
||||
case patTrihepta:
|
||||
if(pseudohept(c)) for(int t=0; t<c->type; t++)
|
||||
gridline(V * get_warp_corner(c, t%c->type),
|
||||
V * get_warp_corner(c, (t+1)%c->type),
|
||||
gridline(V, get_warp_corner(c, t%c->type),
|
||||
get_warp_corner(c, (t+1)%c->type),
|
||||
col, 1 + vid.linequality);
|
||||
break;
|
||||
|
||||
case patDual:
|
||||
forCellEx(c2, c) if(c2 > c) if(gmatrix.count(c2)) {
|
||||
gridlinef(tC0(V), gmatrix[c2]*C0, col, 2 + vid.linequality);
|
||||
gridlinef(V, C0, gmatrix[c2]*C0, col, 2 + vid.linequality);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -2253,32 +2257,32 @@ namespace linepatterns {
|
||||
forCellIdEx(c2, i, c) {
|
||||
if(S3 == 4) c2 = (cellwalker(c, i) + wstep + 1).cpeek();
|
||||
if(c2 > c) if(gmatrix.count(c2) && curr_dist(c) == curr_dist(c2))
|
||||
gridlinef(tC0(V), gmatrix[c2]*C0, col, 2 + vid.linequality);
|
||||
gridlinef(V, C0, gmatrix[c2], C0, col, 2 + vid.linequality);
|
||||
}
|
||||
break;
|
||||
|
||||
case patTriTree: {
|
||||
cell *parent = ts::right_parent(c, curr_dist);
|
||||
if(gmatrix.count(parent))
|
||||
gridlinef(tC0(V), gmatrix[parent]*C0, col, 2 + vid.linequality);
|
||||
gridlinef(V, C0, gmatrix[parent], C0, col, 2 + vid.linequality);
|
||||
break;
|
||||
}
|
||||
|
||||
case patTriOther: {
|
||||
cell *parent = ts::right_parent(c, curr_dist);
|
||||
forCellEx(c2, c) if(gmatrix.count(c2) && curr_dist(c2) < curr_dist(c) && c2 != parent)
|
||||
gridlinef(tC0(V), gmatrix[c2]*C0, col, 2 + vid.linequality);
|
||||
gridlinef(V, C0, gmatrix[c2], C0, col, 2 + vid.linequality);
|
||||
break;
|
||||
}
|
||||
|
||||
case patHepta:
|
||||
forCellEx(c2, c) if(c2 > c) if(gmatrix.count(c2) && pseudohept(c) == pseudohept(c2))
|
||||
gridlinef(tC0(V), gmatrix[c2]*C0, col, 2 + vid.linequality);
|
||||
gridlinef(V, C0, gmatrix[c2], C0, col, 2 + vid.linequality);
|
||||
break;
|
||||
|
||||
case patRhomb:
|
||||
forCellEx(c2, c) if(c2 > c) if(gmatrix.count(c2) && pseudohept(c) != pseudohept(c2))
|
||||
gridlinef(tC0(V), gmatrix[c2]*C0, col, 2 + vid.linequality);
|
||||
gridlinef(V, C0, gmatrix[c2], C0, col, 2 + vid.linequality);
|
||||
break;
|
||||
|
||||
case patPalace: {
|
||||
@ -2287,8 +2291,8 @@ namespace linepatterns {
|
||||
cell *c1 = createMov(c, (i+3) % 7);
|
||||
cell *c2 = createMov(c, (i+4) % 7);
|
||||
if(polarb50(c1) != a && polarb50(c2) != a)
|
||||
gridlinef(V * ddspin(c,i,M_PI*5/7) * xpush0(tessf/2),
|
||||
V * ddspin(c,i,M_PI*9/7) * xpush0(tessf/2),
|
||||
gridlinef(V, ddspin(c,i,M_PI*5/7) * xpush0(tessf/2),
|
||||
ddspin(c,i,M_PI*9/7) * xpush0(tessf/2),
|
||||
col, 1 + vid.linequality);
|
||||
}
|
||||
break;
|
||||
@ -2296,15 +2300,15 @@ namespace linepatterns {
|
||||
|
||||
case patPalacelike:
|
||||
if(pseudohept(c)) for(int i=0; i<7; i++)
|
||||
gridlinef(V * ddspin(c,i,M_PI*5/7) * xpush0(tessf/2),
|
||||
V * ddspin(c,i,M_PI*9/7) * xpush0(tessf/2),
|
||||
gridlinef(V, ddspin(c,i,M_PI*5/7) * xpush0(tessf/2),
|
||||
ddspin(c,i,M_PI*9/7) * xpush0(tessf/2),
|
||||
col, 1 + vid.linequality);
|
||||
break;
|
||||
|
||||
case patBigTriangles: {
|
||||
if(is_master(c) && !euclid) for(int i=0; i<S7; i++)
|
||||
if(c->master->move(i) && c->master->move(i) < c->master) {
|
||||
gridlinef(tC0(V), V*xspinpush0(-2*M_PI*i/S7 - master_to_c7_angle(), tessf), col, 2 + vid.linequality);
|
||||
gridlinef(V, C0, xspinpush0(-2*M_PI*i/S7 - master_to_c7_angle(), tessf), col, 2 + vid.linequality);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -2312,14 +2316,14 @@ namespace linepatterns {
|
||||
case patBigRings: {
|
||||
if(is_master(c) && !euclid) for(int i=0; i<S7; i++)
|
||||
if(c->master->move(i) && c->master->move(i) < c->master && c->master->move(i)->dm4 == c->master->dm4)
|
||||
gridlinef(tC0(V), V*xspinpush0(-2*M_PI*i/S7 - master_to_c7_angle(), tessf), col, 2 + vid.linequality);
|
||||
gridlinef(V, C0, xspinpush0(-2*M_PI*i/S7 - master_to_c7_angle(), tessf), col, 2 + vid.linequality);
|
||||
break;
|
||||
}
|
||||
|
||||
case patTree:
|
||||
if(is_master(c)) {
|
||||
cell *c2 = c->master->move(binarytiling ? 5 : 0)->c7;
|
||||
if(gmatrix.count(c2)) gridlinef(tC0(V), gmatrix[c2]*C0, col, 2 + vid.linequality);
|
||||
if(gmatrix.count(c2)) gridlinef(V, C0, gmatrix[c2], C0, col, 2 + vid.linequality);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -2327,7 +2331,7 @@ namespace linepatterns {
|
||||
if(c->master->alt) {
|
||||
int d = celldistAlt(c);
|
||||
forCellEx(c2, c) if(c2 > c && c2->master->alt && celldistAlt(c2) == d && gmatrix.count(c2))
|
||||
gridlinef(tC0(V), gmatrix[c2]*C0,
|
||||
gridlinef(V, C0, gmatrix[c2], C0,
|
||||
darkena(backcolor ^ 0xFFFFFF, 0, col),
|
||||
2 + vid.linequality);
|
||||
}
|
||||
@ -2338,7 +2342,7 @@ namespace linepatterns {
|
||||
for(int i=0; i<S7; i++)
|
||||
if(c->master->move(i) && c->master->move(i)->alt == c->master->alt->move(0)) {
|
||||
cell *c2 = c->master->move(i)->c7;
|
||||
if(gmatrix.count(c2)) gridlinef(tC0(V), gmatrix[c2]*C0, col, 2 + vid.linequality);
|
||||
if(gmatrix.count(c2)) gridlinef(V, C0, gmatrix[c2], C0, col, 2 + vid.linequality);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -2346,13 +2350,13 @@ namespace linepatterns {
|
||||
case patVine: {
|
||||
if(GOLDBERG) {
|
||||
if(c->master->c7 != c) if(gmatrix.count(c->move(0)))
|
||||
gridlinef(tC0(V), gmatrix[c->move(0)]*C0,
|
||||
gridlinef(V, C0, gmatrix[c->move(0)], C0,
|
||||
darkena(backcolor ^ 0xFFFFFF, 0, col),
|
||||
2 + vid.linequality);
|
||||
}
|
||||
else if(IRREGULAR) {
|
||||
if(c->master->c7 != c) if(gmatrix.count(c->master->c7))
|
||||
gridlinef(tC0(V), gmatrix[c->master->c7]*C0,
|
||||
gridlinef(V, C0, gmatrix[c->master->c7], C0,
|
||||
darkena(backcolor ^ 0xFFFFFF, 0, col),
|
||||
2 + vid.linequality);
|
||||
}
|
||||
@ -2361,8 +2365,8 @@ namespace linepatterns {
|
||||
double hdist = hdist0(heptmove[0] * heptmove[2] * C0);
|
||||
if(pseudohept(c) && (p/4 == 10 || p/4 == 8))
|
||||
for(int i=0; i<S7; i++) if(c->move(i) && emeraldval(c->move(i)) == p-4) {
|
||||
gridlinef(tC0(V), V*tC0(heptmove[i]), col, 2 + vid.linequality);
|
||||
gridlinef(tC0(V), V*xspinpush0(-i * ALPHA, -hdist/2), col, 2 + vid.linequality);
|
||||
gridlinef(V, C0, tC0(heptmove[i]), col, 2 + vid.linequality);
|
||||
gridlinef(V, C0, xspinpush0(-i * ALPHA, -hdist/2), col, 2 + vid.linequality);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -2371,13 +2375,13 @@ namespace linepatterns {
|
||||
case patPower: {
|
||||
if(GOLDBERG) {
|
||||
for(int i=0; i<S7; i++) if(c->move(i) && c->move(i)->master != c->master && gmatrix.count(c->move(i)))
|
||||
gridlinef(tC0(V), gmatrix[c->move(i)]*C0,
|
||||
gridlinef(V, C0, gmatrix[c->move(i)], C0,
|
||||
col,
|
||||
1 + vid.linequality);
|
||||
}
|
||||
else if(archimedean) {
|
||||
if(!pseudohept(c)) for(int i=0; i<c->type; i++) if(c->move(i) && c < c->move(i) && !pseudohept(c->move(i)) && gmatrix.count(c->move(i)))
|
||||
gridlinef(tC0(V), gmatrix[c->move(i)]*C0,
|
||||
gridlinef(V, C0, gmatrix[c->move(i)], C0,
|
||||
col,
|
||||
1 + vid.linequality);
|
||||
}
|
||||
@ -2388,8 +2392,8 @@ namespace linepatterns {
|
||||
heptagon *h2 = c->master->modmove(i-1);
|
||||
if(!h1 || !h2) continue;
|
||||
if(emeraldval(h1->c7)/4 == 8 && emeraldval(h2->c7)/4 == 8)
|
||||
gridlinef(V * ddspin(c,i,M_PI*5/7) * xpush0(tessf/2),
|
||||
V * ddspin(c,i,M_PI*9/7) * xpush0(tessf/2),
|
||||
gridlinef(V, ddspin(c,i,M_PI*5/7) * xpush0(tessf/2),
|
||||
ddspin(c,i,M_PI*9/7) * xpush0(tessf/2),
|
||||
col, 1 + vid.linequality);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user