1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 01:00:25 +00:00

tes:: split get_adj into two functions, one with connection specified (inlcuding mirror), and one not

This commit is contained in:
Zeno Rogue 2022-10-08 01:53:02 +02:00
parent 29f6bbbe90
commit d8da9639d0
4 changed files with 25 additions and 16 deletions

View File

@ -1255,7 +1255,7 @@ void connection_debugger() {
dialog::add_action([k, last, con] {
if(euclid) cgflags |= qAFFINE;
debug_polys.emplace_back(last.first * get_adj(debugged, last.second, k, -1, -1), con.sid);
debug_polys.emplace_back(last.first * get_adj(debugged, last.second, k), con.sid);
if(euclid) cgflags &= ~qAFFINE;
});
@ -1319,17 +1319,13 @@ EX bool apeirogon_consistent_coloring = true;
EX bool apeirogon_hide_grid_edges = true;
EX bool apeirogon_simplified_display = false;
EX transmatrix get_adj(arbi_tiling& c, int t, int dl, int t1, int xdl) {
/** get the adj matrix corresponding to the connection of (t,dl) to connection_t{t1, xdl, xmirror} */
EX transmatrix get_adj(arbi_tiling& c, int t, int dl, int t1, int xdl, bool xmirror) {
auto& sh = c.shapes[t];
int dr = gmod(dl+1, sh.size());
auto& co = sh.connections[dl];
if(xdl == -1) xdl = co.eid;
if(t1 == -1) t1 = co.sid;
auto& xsh = c.shapes[t1];
int xdr = gmod(xdl+1, xsh.size());
@ -1359,10 +1355,10 @@ EX transmatrix get_adj(arbi_tiling& c, int t, int dl, int t1, int xdl) {
Res = Res * Tsca;
}
if(co.mirror) Res = Res * MirrorX;
if(xmirror) Res = Res * MirrorX;
Res = Res * spintox(xrm*xvl) * xrm;
if(co.mirror) swap(vl, vr);
if(xmirror) swap(vl, vr);
if(hdist(vl, Res*xvr) + hdist(vr, Res*xvl) > .1 && !c.is_combinatorial) {
println(hlog, "s1 = ", kz(spintox(rm*vr)), " s2 = ", kz(rspintox(xrm*xvr)));
@ -1374,6 +1370,13 @@ EX transmatrix get_adj(arbi_tiling& c, int t, int dl, int t1, int xdl) {
return Res;
}
/** get the adj matrix corresponding to the connection of (t,dl) -- note: it may be incorrect for rotated/symmetric connections */
EX transmatrix get_adj(arbi_tiling& c, int t, int dl) {
auto& sh = c.shapes[t];
auto& co = sh.connections[dl];
return get_adj(c, t, dl, co.sid, co.eid, co.mirror);
}
struct hrmap_arbi : hrmap {
heptagon *origin;
heptagon *getOrigin() override { return origin; }
@ -1415,7 +1418,10 @@ struct hrmap_arbi : hrmap {
void verify() override { }
transmatrix adj(heptagon *h, int dl) override {
return get_adj(current_or_slided(), id_of(h), dl, -1, h->c.move(dl) ? h->c.spin(dl) : -1);
if(h->c.move(dl))
return get_adj(current_or_slided(), id_of(h), dl, id_of(h->c.move(dl)), h->c.spin(dl), h->c.mirror(dl));
else
return get_adj(current_or_slided(), id_of(h), dl);
}
heptagon *create_step(heptagon *h, int d) override {

View File

@ -505,8 +505,8 @@ void geometry_information::generate_floorshapes_for(int id, cell *c, int siid, i
hyperpoint next = actual[j<cor-1?j+1:0];
if(apeirogonal) {
if(j == 0) last = arb::get_adj(arb::current_or_slided(), id, cor-1, id, cor-2) * actual[cor-3];
if(j == cor-2) next = arb::get_adj(arb::current_or_slided(), id, cor-2, id, cor-1) * actual[1];
if(j == 0) last = arb::get_adj(arb::current_or_slided(), id, cor-1, id, cor-2, false) * actual[cor-3];
if(j == cor-2) next = arb::get_adj(arb::current_or_slided(), id, cor-2, id, cor-1, false) * actual[1];
if(j == cor-1) { cornerlist.push_back(sh.vertices.back()); continue; }
}
@ -645,7 +645,7 @@ void geometry_information::generate_floorshapes_for(int id, cell *c, int siid, i
int id = arb::id_of(c->master);
auto &ac = arb::current_or_slided();
auto& sh = ac.shapes[id];
hpcpush(arb::get_adj(arb::current_or_slided(), id, cor-2, id, cor-1) * starting_point);
hpcpush(arb::get_adj(arb::current_or_slided(), id, cor-2, id, cor-1, false) * starting_point);
finish_apeirogon(sh.vertices.back());
}
}

View File

@ -464,7 +464,10 @@ struct hrmap_arbi_full : hrmap {
}
transmatrix adj(heptagon *h, int dl) override {
return arb::get_adj(arb::current_or_slided(), arb::id_of(h), dl, h->c.move(dl) ? arb::id_of(h->c.move(dl)) : -1, h->c.move(dl) ? h->c.spin(dl) : -1);
if(h->c.move(dl))
return arb::get_adj(arb::current_or_slided(), arb::id_of(h), dl, arb::id_of(h->c.move(dl)), h->c.spin(dl), h->c.mirror(dl));
else
return arb::get_adj(arb::current_or_slided(), arb::id_of(h), dl);
}
ld spin_angle(cell *c, int d) override { return SPIN_NOT_AVAILABLE; }

View File

@ -2302,7 +2302,7 @@ struct hrmap_rulegen : hrmap {
transmatrix adj(heptagon *h, int dir) override {
if(h->fieldval == -1)
return arb::get_adj(arb::current_or_slided(), h->zebraval, dir, -1, -1);
return arb::get_adj(arb::current_or_slided(), h->zebraval, dir);
int s = h->fieldval;
int dir0 = get_arb_dir(s, dir);
@ -2316,7 +2316,7 @@ struct hrmap_rulegen : hrmap {
sid1 = treestates[s1].sid;
}
return arb::get_adj(arb::current_or_slided(), treestates[s].sid, dir0, sid1, dir1);
return arb::get_adj(arb::current_or_slided(), treestates[s].sid, dir0, sid1, dir1, false);
}
int shvid(cell *c) override {