1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-06-09 01:44:08 +00:00

full cellshape computed in hybrid geometries

This commit is contained in:
Zeno Rogue 2021-07-12 20:54:16 +02:00
parent acce9a596b
commit c4e85c16d3
3 changed files with 67 additions and 42 deletions

View File

@ -118,6 +118,8 @@ struct subcellshape {
transmatrix from_cellcenter; transmatrix from_cellcenter;
/** \brief for adjacent directions a,b, next_dir[a][b] is the next direction adjacent to a, in (counter?)clockwise order from b */ /** \brief for adjacent directions a,b, next_dir[a][b] is the next direction adjacent to a, in (counter?)clockwise order from b */
vector<vector<char>> next_dir; vector<vector<char>> next_dir;
/** useful in product geometries */
vector<hyperpoint> walltester;
/** compute all the properties based on `faces`, for the main heptagon cellshape */ /** compute all the properties based on `faces`, for the main heptagon cellshape */
void compute_hept(); void compute_hept();

View File

@ -3963,21 +3963,13 @@ EX void gridline(const shiftmatrix& V, const hyperpoint h1, const hyperpoint h2,
gridline(V, h1, V, h2, col, prec); gridline(V, h1, V, h2, col, prec);
} }
int hrmap::wall_offset(cell *c) { EX subcellshape& generate_subcellshape_if_needed(cell *c, int id) {
int id = currentmap->full_shvid(c); if(isize(cgi.subshapes) <= id) cgi.subshapes.resize(id+1);
if(WDIM == 3 && !hybri && !reg3::in()) return 0; auto& ss = cgi.subshapes[id];
if(!ss.faces.empty()) return ss;
if(isize(cgi.walloffsets) <= id) cgi.walloffsets.resize(id+1, {-1, nullptr});
auto &wop = cgi.walloffsets[id];
int &wo = wop.first;
if(!wop.second) wop.second = c;
if(wo == -1) {
cell *c1 = hybri ? hybrid::get_where(c).first : c; cell *c1 = hybri ? hybrid::get_where(c).first : c;
wo = isize(cgi.shWall3D);
int won = wo + c->type + (WDIM == 2 ? 2 : 0);
if(!cgi.wallstart.empty()) cgi.wallstart.pop_back();
cgi.reserve_wall3d(won);
if(prod || WDIM == 2) for(int i=0; i<c1->type; i++) { if(prod || WDIM == 2) for(int i=0; i<c1->type; i++) {
hyperpoint w; hyperpoint w;
@ -3993,11 +3985,11 @@ int hrmap::wall_offset(cell *c) {
}; };
if(prod) PIU(f()); if(prod) PIU(f());
else f(); else f();
cgi.walltester[wo + i] = w; ss.walltester.push_back(w);
} }
for(int i=0; i<c1->type; i++) for(int i=0; i<c1->type; i++)
cgi.make_wall(wo + i, {hybrid::get_corner(c1, i, 0, -1), hybrid::get_corner(c1, i, 0, +1), hybrid::get_corner(c1, i, 1, +1), hybrid::get_corner(c1, i, 1, -1)}); ss.faces.push_back({hybrid::get_corner(c1, i, 0, -1), hybrid::get_corner(c1, i, 0, +1), hybrid::get_corner(c1, i, 1, +1), hybrid::get_corner(c1, i, 1, -1)});
for(int a: {0,1}) { for(int a: {0,1}) {
vector<hyperpoint> l; vector<hyperpoint> l;
@ -4015,7 +4007,33 @@ int hrmap::wall_offset(cell *c) {
l.push_back(hybrid::get_corner(c1, i, 0, z)); l.push_back(hybrid::get_corner(c1, i, 0, z));
} }
if(a == 0) std::reverse(l.begin()+1, l.end()); if(a == 0) std::reverse(l.begin()+1, l.end());
cgi.make_wall(won-2+a, l); ss.faces.push_back(l);
}
ss.compute_hept();
return ss;
}
int hrmap::wall_offset(cell *c) {
int id = currentmap->full_shvid(c);
if(WDIM == 3 && !hybri && !reg3::in()) return 0;
if(isize(cgi.walloffsets) <= id) cgi.walloffsets.resize(id+1, {-1, nullptr});
auto &wop = cgi.walloffsets[id];
int &wo = wop.first;
if(!wop.second) wop.second = c;
if(wo == -1) {
auto& ss = generate_subcellshape_if_needed(c, id);
wo = isize(cgi.shWall3D);
if(!cgi.wallstart.empty()) cgi.wallstart.pop_back();
cgi.reserve_wall3d(wo + isize(ss.faces));
for(int i=0; i<isize(ss.faces); i++) {
cgi.make_wall(wo + i, ss.faces[i]);
cgi.walltester[wo + i] = ss.walltester[i];
} }
cgi.wallstart.push_back(isize(cgi.raywall)); cgi.wallstart.push_back(isize(cgi.raywall));

View File

@ -1306,6 +1306,11 @@ EX namespace hybrid {
virtual transmatrix spin_to(cell *c, int d, ld bonus) override { if(d >= c->type-2) return Id; c = get_where(c).first; return in_underlying([&] { return currentmap->spin_to(c, d, bonus); }); } virtual transmatrix spin_to(cell *c, int d, ld bonus) override { if(d >= c->type-2) return Id; c = get_where(c).first; return in_underlying([&] { return currentmap->spin_to(c, d, bonus); }); }
virtual transmatrix spin_from(cell *c, int d, ld bonus) override { if(d >= c->type-2) return Id; c = get_where(c).first; return in_underlying([&] { return currentmap->spin_from(c, d, bonus); }); } virtual transmatrix spin_from(cell *c, int d, ld bonus) override { if(d >= c->type-2) return Id; c = get_where(c).first; return in_underlying([&] { return currentmap->spin_from(c, d, bonus); }); }
subcellshape& get_cellshape(cell *c) override {
int id = full_shvid(c);
return generate_subcellshape_if_needed(c, id);
}
}; };
hrmap_hybrid* hmap() { return (hrmap_hybrid*) currentmap; } hrmap_hybrid* hmap() { return (hrmap_hybrid*) currentmap; }