mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-12-14 18:18:05 +00:00
moved zpush from 3dmodels to hyperpoint
This commit is contained in:
@@ -479,7 +479,7 @@ namespace binary {
|
||||
}
|
||||
|
||||
void build_tmatrix() {
|
||||
if(geometry == gBinaryTiling) return; // unused
|
||||
if(among(geometry, gBinaryTiling, gSol)) return; // unused
|
||||
use_direct = (1 << S7) - 1;
|
||||
if(geometry == gBinary4) {
|
||||
use_direct = 3;
|
||||
@@ -865,4 +865,139 @@ auto hooksw = addHook(hooks_swapdim, 100, [] {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
namespace solv {
|
||||
|
||||
struct hrmap_sol : hrmap {
|
||||
hrmap *binary_map;
|
||||
unordered_map<pair<heptagon*, heptagon*>, heptagon*> at;
|
||||
unordered_map<heptagon*, pair<heptagon*, heptagon*>> coords;
|
||||
|
||||
heptagon *origin;
|
||||
|
||||
heptagon *getOrigin() override { return origin; }
|
||||
|
||||
heptagon *get_at(heptagon *x, heptagon *y) {
|
||||
auto& h = at[make_pair(x, y)];
|
||||
if(h) return h;
|
||||
h = tailored_alloc<heptagon> (S7);
|
||||
h->c7 = newCell(S7, h);
|
||||
coords[h] = make_pair(x, y);
|
||||
return h;
|
||||
h->distance = 0;
|
||||
h->dm4 = 0;
|
||||
h->zebraval = 0;
|
||||
h->emeraldval = 0;
|
||||
h->fieldval = 0;
|
||||
h->cdata = NULL;
|
||||
}
|
||||
|
||||
hrmap_sol() {
|
||||
|
||||
heptagon *alt;
|
||||
|
||||
if(true) {
|
||||
dynamicval<eGeometry> g(geometry, gBinary4);
|
||||
alt = tailored_alloc<heptagon> (S7);
|
||||
alt->s = hsOrigin;
|
||||
alt->alt = alt;
|
||||
alt->cdata = NULL;
|
||||
alt->c7 = NULL;
|
||||
alt->zebraval = 0;
|
||||
binary_map = binary::new_alt_map(alt);
|
||||
}
|
||||
|
||||
origin = get_at(alt, alt);
|
||||
}
|
||||
|
||||
heptagon *altstep(heptagon *h, int d) {
|
||||
dynamicval<eGeometry> g(geometry, gBinary4);
|
||||
dynamicval<hrmap*> cm(currentmap, binary_map);
|
||||
return h->cmove(d);
|
||||
}
|
||||
|
||||
heptagon *create_step(heptagon *parent, int d) override {
|
||||
auto p = coords[parent];
|
||||
auto pf = p.first, ps = p.second;
|
||||
auto rule = [&] (heptagon *c1, heptagon *c2, int d1) {
|
||||
auto g = get_at(c1, c2);
|
||||
parent->c.connect(d, g, d1, false);
|
||||
return g;
|
||||
};
|
||||
|
||||
switch(d) {
|
||||
case 0: // right
|
||||
return rule(altstep(pf, 2), ps, 4);
|
||||
case 1: // up
|
||||
return rule(pf, altstep(ps, 2), 5);
|
||||
case 2: // front left
|
||||
return rule(altstep(pf, 0), altstep(ps, 3), ps->zebraval ? 7 : 6);
|
||||
case 3: // front right
|
||||
return rule(altstep(pf, 1), altstep(ps, 3), ps->zebraval ? 7 : 6);
|
||||
case 4: // left
|
||||
return rule(altstep(pf, 4), ps, 0);
|
||||
case 5: // down
|
||||
return rule(pf, altstep(ps, 4), 1);
|
||||
case 6: // back down
|
||||
return rule(altstep(pf, 3), altstep(ps, 0), pf->zebraval ? 3 : 2);
|
||||
case 7: // back up
|
||||
return rule(altstep(pf, 3), altstep(ps, 1), pf->zebraval ? 3 : 2);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
~hrmap_sol() {
|
||||
delete binary_map;
|
||||
}
|
||||
|
||||
transmatrix adjmatrix(int i, int j) {
|
||||
ld z = log(2);
|
||||
ld bw = vid.binary_width * z;
|
||||
ld bwh = bw / 4;
|
||||
switch(i) {
|
||||
case 0: return xpush(+bw);
|
||||
case 1: return ypush(+bw);
|
||||
case 2: return xpush(-bwh) * zpush(+z) * ypush(j == 6 ? +bwh : -bwh);
|
||||
case 3: return xpush(+bwh) * zpush(+z) * ypush(j == 6 ? +bwh : -bwh);
|
||||
case 4: return xpush(-bw);
|
||||
case 5: return ypush(-bw);
|
||||
case 6: return ypush(-bwh) * zpush(-z) * xpush(j == 2 ? +bwh : -bwh);
|
||||
case 7: return ypush(+bwh) * zpush(-z) * xpush(j == 2 ? +bwh : -bwh);
|
||||
default:return Id;
|
||||
}
|
||||
}
|
||||
|
||||
virtual transmatrix relative_matrix(heptagon *h2, heptagon *h1) override {
|
||||
for(int i=0; i<h1->type; i++) if(h1->move(i) == h2) return adjmatrix(i, h1->c.spin(i));
|
||||
return Id;
|
||||
}
|
||||
|
||||
void draw() override {
|
||||
dq::visited.clear();
|
||||
dq::enqueue(viewctr.at, cview());
|
||||
|
||||
while(!dq::drawqueue.empty()) {
|
||||
auto& p = dq::drawqueue.front();
|
||||
heptagon *h = get<0>(p);
|
||||
transmatrix V = get<1>(p);
|
||||
dq::drawqueue.pop();
|
||||
|
||||
cell *c = h->c7;
|
||||
if(!do_draw(c, V)) continue;
|
||||
drawcell(c, V, 0, false);
|
||||
|
||||
for(int i=0; i<S7; i++) {
|
||||
// note: need do cmove before c.spin
|
||||
heptagon *h1 = h->cmove(i);
|
||||
dq::enqueue(h1, V * adjmatrix(i, h->c.spin(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
hrmap *new_map() { return new hrmap_sol; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user