mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-11 18:00:34 +00:00
simplified ddspin/iddspin/cellgfxdist, replaced cellrelmatrix with adj/iadj
This commit is contained in:
parent
ef9e2236ba
commit
109dd9823c
@ -145,6 +145,8 @@ struct hrmap_asonov : hrmap {
|
|||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transmatrix adj(cell *c, int i) override { return adjmatrix(i); }
|
||||||
|
|
||||||
virtual transmatrix relative_matrix(heptagon *h2, heptagon *h1) override {
|
virtual transmatrix relative_matrix(heptagon *h2, heptagon *h1) override {
|
||||||
for(int a=0; a<S7; a++) if(h2 == h1->move(a)) return adjmatrix(a);
|
for(int a=0; a<S7; a++) if(h2 == h1->move(a)) return adjmatrix(a);
|
||||||
return Id;
|
return Id;
|
||||||
|
2
cell.cpp
2
cell.cpp
@ -34,6 +34,8 @@ struct hrmap {
|
|||||||
virtual struct transmatrix relative_matrix(cell *c2, cell *c1, const struct hyperpoint& point_hint) {
|
virtual struct transmatrix relative_matrix(cell *c2, cell *c1, const struct hyperpoint& point_hint) {
|
||||||
return relative_matrix(c2->master, c1->master);
|
return relative_matrix(c2->master, c1->master);
|
||||||
}
|
}
|
||||||
|
virtual struct transmatrix adj(cell *c, int i);
|
||||||
|
virtual struct transmatrix iadj(cell *c, int i) { return adj(c->cmove(i), c->c.spin(i)); }
|
||||||
virtual void draw() {
|
virtual void draw() {
|
||||||
printf("undrawable\n");
|
printf("undrawable\n");
|
||||||
}
|
}
|
||||||
|
@ -260,10 +260,7 @@ void virtualRebase_cell(cell*& base, T& at, const U& check) {
|
|||||||
while(true) {
|
while(true) {
|
||||||
cell *newbase = NULL;
|
cell *newbase = NULL;
|
||||||
forCellIdCM(c2, i, base) {
|
forCellIdCM(c2, i, base) {
|
||||||
transmatrix V2 =
|
transmatrix V2 = currentmap->iadj(base, i);
|
||||||
nil ? nilv::adjmatrix(base->c.spin(i)) :
|
|
||||||
asonov::in() ? asonov::adjmatrix(base->c.spin(i)) :
|
|
||||||
calc_relative_matrix(base, c2, C0);
|
|
||||||
T cand_at = V2 * at;
|
T cand_at = V2 * at;
|
||||||
horo_distance newz(check(cand_at));
|
horo_distance newz(check(cand_at));
|
||||||
if(newz < currz) {
|
if(newz < currz) {
|
||||||
@ -420,17 +417,50 @@ EX void virtualRebaseSimple(heptagon*& base, transmatrix& at) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EX bool no_easy_spin() {
|
||||||
|
return NONSTDVAR || archimedean || WDIM == 3 || binarytiling || penrose;
|
||||||
|
}
|
||||||
|
|
||||||
|
double hexshiftat(cell *c) {
|
||||||
|
if(binarytiling) return 0;
|
||||||
|
if(ctof(c) && S7==6 && S3 == 4 && BITRUNCATED) return cgi.hexshift + 2*M_PI/S7;
|
||||||
|
if(ctof(c) && (S7==8 || S7 == 4) && S3 == 3 && BITRUNCATED) return cgi.hexshift + 2*M_PI/S7;
|
||||||
|
if(cgi.hexshift && ctof(c)) return cgi.hexshift;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
EX transmatrix ddspin(cell *c, int d, ld bonus IS(0)) {
|
||||||
|
if(no_easy_spin()) {
|
||||||
|
if(hybri) return PIU( ddspin(c, d, bonus) );
|
||||||
|
transmatrix T = rspintox(tC0(currentmap->adj(c, d)));
|
||||||
|
if(WDIM == 3) return T * cspin(2, 0, bonus);
|
||||||
|
return T * spin(bonus);
|
||||||
|
}
|
||||||
|
return spin(displayspin(c, d) + bonus - hexshiftat(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
EX transmatrix iddspin(cell *c, int d, ld bonus IS(0)) {
|
||||||
|
if(no_easy_spin()) {
|
||||||
|
if(hybri) return PIU( iddspin(c, d, bonus) );
|
||||||
|
transmatrix T = spintox(tC0(currentmap->iadj(c, d)));
|
||||||
|
if(WDIM == 3) return T * cspin(2, 0, bonus);
|
||||||
|
return T * spin(bonus);
|
||||||
|
}
|
||||||
|
return spin(hexshiftat(c) - displayspin(c, d) + bonus);
|
||||||
|
}
|
||||||
|
|
||||||
EX double cellgfxdist(cell *c, int i) {
|
EX double cellgfxdist(cell *c, int i) {
|
||||||
if(euclid && !penrose && !archimedean) {
|
if(no_easy_spin())
|
||||||
|
return hdist0(tC0(currentmap->adj(c, i)));
|
||||||
|
if(euclid) {
|
||||||
if(c->type == 8 && (i&1)) return cgi.crossf * sqrt(2);
|
if(c->type == 8 && (i&1)) return cgi.crossf * sqrt(2);
|
||||||
return cgi.crossf;
|
return cgi.crossf;
|
||||||
}
|
}
|
||||||
if(NONSTDVAR || archimedean || WDIM == 3 || binarytiling || penrose) return hdist0(tC0(calc_relative_matrix(c->move(i), c, i)));
|
|
||||||
return !BITRUNCATED ? cgi.tessf : (c->type == 6 && (i&1)) ? cgi.hexhexdist : cgi.crossf;
|
return !BITRUNCATED ? cgi.tessf : (c->type == 6 && (i&1)) ? cgi.hexhexdist : cgi.crossf;
|
||||||
}
|
}
|
||||||
|
|
||||||
EX transmatrix cellrelmatrix(cell *c, int i) {
|
transmatrix hrmap::adj(cell *c, int i) {
|
||||||
if(NONSTDVAR || archimedean || penrose) return calc_relative_matrix(c->move(i), c, i);
|
if(no_easy_spin()) return calc_relative_matrix(c->move(i), c, i);
|
||||||
double d = cellgfxdist(c, i);
|
double d = cellgfxdist(c, i);
|
||||||
transmatrix T = ddspin(c, i) * xpush(d);
|
transmatrix T = ddspin(c, i) * xpush(d);
|
||||||
if(c->c.mirror(i)) T = T * Mirror;
|
if(c->c.mirror(i)) T = T * Mirror;
|
||||||
@ -439,6 +469,8 @@ EX transmatrix cellrelmatrix(cell *c, int i) {
|
|||||||
return T;
|
return T;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EX transmatrix cellrelmatrix(cell *c, int i) { return currentmap->adj(c, i); }
|
||||||
|
|
||||||
EX double randd() { return (rand() + .5) / (RAND_MAX + 1.); }
|
EX double randd() { return (rand() + .5) / (RAND_MAX + 1.); }
|
||||||
|
|
||||||
EX hyperpoint randomPointIn(int t) {
|
EX hyperpoint randomPointIn(int t) {
|
||||||
|
22
graph.cpp
22
graph.cpp
@ -345,28 +345,6 @@ EX ld displayspin(cell *c, int d) {
|
|||||||
return M_PI - d * 2 * M_PI / c->type;
|
return M_PI - d * 2 * M_PI / c->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
double hexshiftat(cell *c) {
|
|
||||||
if(binarytiling) return 0;
|
|
||||||
if(ctof(c) && S7==6 && S3 == 4 && BITRUNCATED) return cgi.hexshift + 2*M_PI/S7;
|
|
||||||
if(ctof(c) && (S7==8 || S7 == 4) && S3 == 3 && BITRUNCATED) return cgi.hexshift + 2*M_PI/S7;
|
|
||||||
if(cgi.hexshift && ctof(c)) return cgi.hexshift;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
EX transmatrix ddspin(cell *c, int d, ld bonus IS(0)) {
|
|
||||||
if(hybri) return PIU( ddspin(c, d, bonus) );
|
|
||||||
if(WDIM == 3 && d < c->type) return rspintox(tC0(calc_relative_matrix(c->cmove(d), c, C0))) * cspin(2, 0, bonus);
|
|
||||||
if(WDIM == 2 && (binarytiling || penrose) && d < c->type) return spin(bonus) * rspintox(nearcorner(c, d));
|
|
||||||
return spin(displayspin(c, d) + bonus - hexshiftat(c));
|
|
||||||
}
|
|
||||||
|
|
||||||
EX transmatrix iddspin(cell *c, int d, ld bonus IS(0)) {
|
|
||||||
if(hybri) return PIU( iddspin(c, d, bonus) );
|
|
||||||
if(WDIM == 3 && d < c->type) return cspin(0, 2, bonus) * spintox(tC0(calc_relative_matrix(c->cmove(d), c, C0)));
|
|
||||||
if(WDIM == 2 && (binarytiling || penrose) && d < c->type) return spin(bonus) * spintox(nearcorner(c, d));
|
|
||||||
return spin(hexshiftat(c) - displayspin(c, d) + bonus);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define UNTRANS (GDIM == 3 ? 0x000000FF : 0)
|
#define UNTRANS (GDIM == 3 ? 0x000000FF : 0)
|
||||||
|
|
||||||
EX void drawPlayerEffects(const transmatrix& V, cell *c, bool onplayer) {
|
EX void drawPlayerEffects(const transmatrix& V, cell *c, bool onplayer) {
|
||||||
|
@ -821,6 +821,8 @@ EX namespace nilv {
|
|||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transmatrix adj(cell *c, int i) override { return adjmatrix(i); }
|
||||||
|
|
||||||
virtual transmatrix relative_matrix(heptagon *h2, heptagon *h1) override {
|
virtual transmatrix relative_matrix(heptagon *h2, heptagon *h1) override {
|
||||||
for(int a=0; a<S7; a++) if(h2 == h1->move(a)) return adjmatrix(a);
|
for(int a=0; a<S7; a++) if(h2 == h1->move(a)) return adjmatrix(a);
|
||||||
return nisot::translate(mvec_to_point(coords[h1].inverse() * coords[h2]));
|
return nisot::translate(mvec_to_point(coords[h1].inverse() * coords[h2]));
|
||||||
|
@ -857,10 +857,7 @@ EX void cast() {
|
|||||||
GLERR("uniform IPD");
|
GLERR("uniform IPD");
|
||||||
|
|
||||||
vector<transmatrix> ms;
|
vector<transmatrix> ms;
|
||||||
for(int j=0; j<S7; j++) ms.push_back(
|
for(int j=0; j<S7; j++) ms.push_back(currentmap->iadj(cwt.at, j));
|
||||||
asonov::in() ? asonov::adjmatrix((j+S7/2)%S7) :
|
|
||||||
nil ? nilv::adjmatrix((j+S7/2)%S7) :
|
|
||||||
prod ? currentmap->relative_matrix(cwt.at, cwt.at->cmove(j), Hypc) : currentmap->relative_matrix(cwt.at->master, cwt.at->cmove(j)->master));
|
|
||||||
if(prod) ms.push_back(Id);
|
if(prod) ms.push_back(Id);
|
||||||
if(prod) ms.push_back(Id);
|
if(prod) ms.push_back(Id);
|
||||||
|
|
||||||
@ -924,7 +921,7 @@ EX void cast() {
|
|||||||
connections[u][2] = (S7+.5) / 1024.;
|
connections[u][2] = (S7+.5) / 1024.;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
transmatrix T = (asonov::in() || nil) ? Id : (prod ? currentmap->relative_matrix(c, c1, C0) : currentmap->relative_matrix(c->master, c1->master)) * inverse(ms[i]);
|
transmatrix T = currentmap->iadj(c, i) * inverse(ms[i]);
|
||||||
for(int k=0; k<=isize(ms); k++) {
|
for(int k=0; k<=isize(ms); k++) {
|
||||||
if(k < isize(ms) && !eqmatrix(ms[k], T)) continue;
|
if(k < isize(ms) && !eqmatrix(ms[k], T)) continue;
|
||||||
if(k == isize(ms)) ms.push_back(T);
|
if(k == isize(ms)) ms.push_back(T);
|
||||||
|
Loading…
Reference in New Issue
Block a user