1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-02-25 07:20:09 +00:00

fixed the combinations of Archimedean, fake, and embedding

This commit is contained in:
Zeno Rogue 2023-06-10 10:33:42 +02:00
parent e68cd6736e
commit 59dd09173a
7 changed files with 121 additions and 51 deletions

View File

@ -432,7 +432,6 @@ void archimedean_tiling::compute_geometry() {
if(gg.kind == gcHyperbolic) arr[gArchimedean].g = arr[gNormal].g; if(gg.kind == gcHyperbolic) arr[gArchimedean].g = arr[gNormal].g;
set_flag(arr[gArchimedean].flags, qCLOSED, gg.kind == gcSphere); set_flag(arr[gArchimedean].flags, qCLOSED, gg.kind == gcSphere);
} }
if(geom3::flipped) swap(geom3::ginf_backup[gArchimedean].g, ginf[gArchimedean].g);
DEBB(DF_GEOM, (format("euclidean_angle_sum = %f\n", float(euclidean_angle_sum)))); DEBB(DF_GEOM, (format("euclidean_angle_sum = %f\n", float(euclidean_angle_sum))));
@ -573,13 +572,14 @@ EX bool use_gmatrix = true;
* not used by arcm itself, but used in fake arcm * not used by arcm itself, but used in fake arcm
*/ */
EX geometry_information *alt_cgip; EX geometry_information *alt_cgip[2];
EX geometry_information *find_alt_cgip() { EX geometry_information *find_alt_cgip() {
if(alt_cgip) return alt_cgip; auto& galt_cgip = alt_cgip[embedded_plane];
if(galt_cgip) return galt_cgip;
check_cgi(); check_cgi();
cgi.require_basics(); cgi.require_basics();
return alt_cgip = cgip; return galt_cgip = cgip;
} }
struct hrmap_archimedean : hrmap { struct hrmap_archimedean : hrmap {
@ -601,16 +601,24 @@ struct hrmap_archimedean : hrmap {
heptagon *alt = NULL; heptagon *alt = NULL;
if(hyperbolic) { if(hyperbolic) {
dynamicval<eGeometry> g(geometry, gNormal); bool f = geom3::flipped;
dynamicval<eVariation> gv(variation, eVariation::pure); if(f) geom3::light_flip(false);
dynamicval<geometry_information*> gi(cgip, find_alt_cgip()); if(1) {
alt = init_heptagon(S7); dynamicval<eGeometry> g(geometry, gNormal);
alt->s = hsOrigin; dynamicval<eVariation> gv(variation, eVariation::pure);
alt->alt = alt; dynamicval<geometry_information*> gi(cgip, find_alt_cgip());
current_altmap = newAltMap(alt); alt = init_heptagon(S7);
alt->s = hsOrigin;
alt->alt = alt;
current_altmap = newAltMap(alt);
}
if(f) geom3::light_flip(true);
} }
bool f = geom3::flipped;
if(f) geom3::light_flip(false);
transmatrix T = lxpush(.01241) * spin(1.4117) * lxpush(0.1241) * Id; transmatrix T = lxpush(.01241) * spin(1.4117) * lxpush(0.1241) * Id;
if(f) geom3::light_flip(true);
archimedean_gmatrix[origin] = make_pair(alt, T); archimedean_gmatrix[origin] = make_pair(alt, T);
altmap[alt].emplace_back(origin, T); altmap[alt].emplace_back(origin, T);
@ -661,6 +669,19 @@ struct hrmap_archimedean : hrmap {
heptagon *create_step(heptagon *h, int d) override { heptagon *create_step(heptagon *h, int d) override {
bool f = geom3::flipped;
if(f) {
dynamicval<int> uc(cgip->use_count, cgip->use_count+1);
auto bcgip = cgip;
geom3::light_flip(false);
check_cgi();
cgi.require_basics();
auto h1 = create_step(h, d);
geom3::light_flip(true);
cgip = bcgip;
return h1;
}
DEBB(DF_GEOM, (heptspin(h,d), " ~ ?")); DEBB(DF_GEOM, (heptspin(h,d), " ~ ?"));
dynamicval<geometryinfo1> gi(ginf[geometry].g, ginf[gArchimedean].g); dynamicval<geometryinfo1> gi(ginf[geometry].g, ginf[gArchimedean].g);
@ -681,6 +702,7 @@ struct hrmap_archimedean : hrmap {
transmatrix U = Id; transmatrix U = Id;
if(hyperbolic) { if(hyperbolic) {
dynamicval<int> uc(cgip->use_count, cgip->use_count+1);
dynamicval<eGeometry> g(geometry, gNormal); dynamicval<eGeometry> g(geometry, gNormal);
dynamicval<eVariation> gv(variation, eVariation::pure); dynamicval<eVariation> gv(variation, eVariation::pure);
dynamicval<geometry_information*> gi(cgip, find_alt_cgip()); dynamicval<geometry_information*> gi(cgip, find_alt_cgip());
@ -1096,12 +1118,17 @@ auto hooksw = addHook(hooks_swapdim, 100, [] {
dynamicval<eGeometry> g(geometry, gNormal); dynamicval<eGeometry> g(geometry, gNormal);
dynamicval<eVariation> gv(variation, eVariation::pure); dynamicval<eVariation> gv(variation, eVariation::pure);
alt_cgip[0] = nullptr;
alt_cgip[1] = nullptr;
dynamicval<geometry_information*> gi(cgip, find_alt_cgip()); dynamicval<geometry_information*> gi(cgip, find_alt_cgip());
for(auto& p: altmap) for(auto& pp: p.second) swapmatrix(pp.second); for(auto& p: altmap) for(auto& pp: p.second) swapmatrix(pp.second);
for(auto& p: archimedean_gmatrix) swapmatrix(p.second.second); for(auto& p: archimedean_gmatrix) swapmatrix(p.second.second);
alt_cgip = nullptr; alt_cgip[0] = nullptr;
alt_cgip[1] = nullptr;
}); });
#endif #endif

View File

@ -554,8 +554,10 @@ EX void initcells() {
if(embedded_plane) { if(embedded_plane) {
geom3::swap_direction = -1; geom3::swap_direction = -1;
check_cgi();
for(auto& m: cgi.heptmove) swapmatrix(m); for(auto& m: cgi.heptmove) swapmatrix(m);
IPF(initcells()); IPF(initcells());
check_cgi();
geom3::swap_direction = +1; geom3::swap_direction = +1;
for(auto& m: cgi.heptmove) swapmatrix(m); for(auto& m: cgi.heptmove) swapmatrix(m);
currentmap->on_dim_change(); currentmap->on_dim_change();

View File

@ -132,13 +132,30 @@ EX namespace geom3 {
EX geometry_information* unflipped; EX geometry_information* unflipped;
EX void light_flip_geom() {
indenter ind(2);
swap(ginf[geometry].g, geom3::ginf_backup[geometry].g);
swap(ginf[geometry].flags, geom3::ginf_backup[geometry].flags);
if(fake::in()) {
// println(hlog, "warning: flipping while still in fake");
FPIU(light_flip_geom());
}
// hyperbolic arcm needs gNormal for cdata. Also swap gSphere and gEuclid for compute_geometry
else if(arcm::in()) {
dynamicval<eGeometry> g(geometry, gNormal); light_flip_geom();
geometry = gSphere; light_flip_geom();
geometry = gEuclid; light_flip_geom();
}
}
EX void light_flip(bool f) { EX void light_flip(bool f) {
if(f != flipped) { if(f != flipped) {
if(!flipped) cgip->use_count++;
if(!flipped) unflipped = cgip; if(!flipped) unflipped = cgip;
swap(ginf[geometry].g, geom3::ginf_backup[geometry].g); light_flip_geom();
swap(ginf[geometry].flags, geom3::ginf_backup[geometry].flags);
if(!flipped) cgip = unflipped;
flipped = f; flipped = f;
if(!flipped) cgip = unflipped;
if(!flipped) cgip->use_count--;
} }
} }
@ -165,40 +182,43 @@ EX namespace geom3 {
} }
if(vid.always3 && ginf_backup.empty()) { if(vid.always3 && ginf_backup.empty()) {
ginf_backup = ginf; ginf_backup = ginf;
for(geometryinfo& gi: ginf) { for(geometryinfo& gi: ginf)
auto &g = gi.g; apply_always3_to(gi);
if(vid.always3 && g.gameplay_dimension == 2 && g.graphical_dimension == 2) { }
/* same-in-same by default */ }
auto og = g;
g.graphical_dimension++;
g.homogeneous_dimension++;
g.sig[3] = g.sig[2];
g.sig[2] = g.sig[1];
bool ieuclid = g.kind == gcEuclid; EX void apply_always3_to(geometryinfo& gi) {
bool isphere = g.kind == gcSphere; auto &g = gi.g;
bool ieuc_or_binary = ieuclid || (gi.flags & qBINARY); if(vid.always3 && g.gameplay_dimension == 2 && g.graphical_dimension == 2) {
/* same-in-same by default */
auto og = g;
g.graphical_dimension++;
g.homogeneous_dimension++;
g.sig[3] = g.sig[2];
g.sig[2] = g.sig[1];
if(spatial_embedding == seProduct && !ieuclid) g = giProduct, g.sig[2] = og.sig[2]; bool ieuclid = g.kind == gcEuclid;
if(spatial_embedding == seProductH && ieuclid) g = giProductH; bool isphere = g.kind == gcSphere;
if(spatial_embedding == seProductS && ieuclid) g = giProductS; bool ieuc_or_binary = ieuclid || (gi.flags & qBINARY);
if(spatial_embedding == seLowerCurvature) g = (isphere ? giEuclid3 : giHyperb3);
if(spatial_embedding == seMuchLowerCurvature) g = giHyperb3;
if(spatial_embedding == seNil && ieuclid) g = giNil;
if(spatial_embedding == seCliffordTorus && ieuclid) g = giSphere3;
if(spatial_embedding == seSol && ieuc_or_binary) g = giSol;
if(spatial_embedding == seNIH && ieuc_or_binary) g = giNIH;
if(spatial_embedding == seSolN && ieuc_or_binary) g = giSolN;
if(spatial_embedding == seSL2 && ieuclid) g = giSL2;
if(spatial_embedding == seCylinderH && ieuclid) g = giHyperb3;
if(spatial_embedding == seCylinderHE && ieuclid) g = giProductH;
if(spatial_embedding == seCylinderHoro && ieuclid) g = giProductH;
if(spatial_embedding == seCylinderNil && ieuclid) g = giNil;
if(spatial_embedding == seCylinderSL2 && ieuclid) g = giSL2;
g.gameplay_dimension = 2; if(spatial_embedding == seProduct && !ieuclid) g = giProduct, g.sig[2] = og.sig[2];
} if(spatial_embedding == seProductH && ieuclid) g = giProductH;
} if(spatial_embedding == seProductS && ieuclid) g = giProductS;
if(spatial_embedding == seLowerCurvature) g = (isphere ? giEuclid3 : giHyperb3);
if(spatial_embedding == seMuchLowerCurvature) g = giHyperb3;
if(spatial_embedding == seNil && ieuclid) g = giNil;
if(spatial_embedding == seCliffordTorus && ieuclid) g = giSphere3;
if(spatial_embedding == seSol && ieuc_or_binary) g = giSol;
if(spatial_embedding == seNIH && ieuc_or_binary) g = giNIH;
if(spatial_embedding == seSolN && ieuc_or_binary) g = giSolN;
if(spatial_embedding == seSL2 && ieuclid) g = giSL2;
if(spatial_embedding == seCylinderH && ieuclid) g = giHyperb3;
if(spatial_embedding == seCylinderHE && ieuclid) g = giProductH;
if(spatial_embedding == seCylinderHoro && ieuclid) g = giProductH;
if(spatial_embedding == seCylinderNil && ieuclid) g = giNil;
if(spatial_embedding == seCylinderSL2 && ieuclid) g = giSL2;
g.gameplay_dimension = 2;
} }
} }

View File

@ -54,6 +54,7 @@ EX namespace fake {
dynamicval<hrmap*> gpm(pmap, this); dynamicval<hrmap*> gpm(pmap, this);
dynamicval<eGeometry> gag(actual_geometry, geometry); dynamicval<eGeometry> gag(actual_geometry, geometry);
dynamicval<eGeometry> g(geometry, underlying); dynamicval<eGeometry> g(geometry, underlying);
dynamicval<int> uc(cgip->use_count, cgip->use_count+1);
dynamicval<geometry_information*> gc(cgip, underlying_cgip); dynamicval<geometry_information*> gc(cgip, underlying_cgip);
dynamicval<hrmap*> gu(currentmap, underlying_map); dynamicval<hrmap*> gu(currentmap, underlying_map);
return t(); return t();
@ -90,6 +91,13 @@ EX namespace fake {
hyperpoint get_corner(cell *c, int cid, ld cf=3) override { hyperpoint get_corner(cell *c, int cid, ld cf=3) override {
if(embedded_plane) {
geom3::light_flip(true);
hyperpoint h = get_corner(c, cid, cf);
geom3::light_flip(false);
return cgi.emb->base_to_actual(h);
}
if(arcm::in() || hat::in()) { if(arcm::in() || hat::in()) {
return underlying_map->get_corner(c, cid, cf); return underlying_map->get_corner(c, cid, cf);
} }
@ -100,6 +108,12 @@ EX namespace fake {
} }
transmatrix adj(cell *c, int d) override { transmatrix adj(cell *c, int d) override {
if(embedded_plane) {
geom3::light_flip(true);
transmatrix T = adj(c, d);
geom3::light_flip(false);
return cgi.emb->base_to_actual(T);
}
if(hat::in()) return underlying_map->adj(c, d); if(hat::in()) return underlying_map->adj(c, d);
if(variation == eVariation::coxeter) { if(variation == eVariation::coxeter) {
array<int, 3> which; array<int, 3> which;
@ -592,12 +606,16 @@ EX void compute_scale() {
ginf[gFake].g = geometry_of_curvature(good - around, WDIM); ginf[gFake].g = geometry_of_curvature(good - around, WDIM);
geom3::apply_always3();
ld around_ideal = 1/(1/2. - 1./get_middle()); ld around_ideal = 1/(1/2. - 1./get_middle());
bool have_ideal = abs(around_ideal - around) < 1e-6; bool have_ideal = abs(around_ideal - around) < 1e-6;
if(underlying == gRhombic3 || underlying == gBitrunc3) have_ideal = false; if(underlying == gRhombic3 || underlying == gBitrunc3) have_ideal = false;
finalizer f([&] {if(vid.always3 && WDIM == 2) {
geom3::ginf_backup[gFake] = ginf[gFake];
geom3::apply_always3_to(ginf[gFake]);
}});
if(arcm::in()) { if(arcm::in()) {
ginf[gFake].tiling_name = "(" + ginf[gArchimedean].tiling_name + ")^" + fts(around / around_orig()); ginf[gFake].tiling_name = "(" + ginf[gArchimedean].tiling_name + ")^" + fts(around / around_orig());
return; return;

View File

@ -1092,6 +1092,7 @@ EX void ensure_floorshape_generated(int id, cell *c) {
hpcshape nul; nul.s = -1; hpcshape nul; nul.s = -1;
sizeto(cgi.shFloor.b, id, nul); sizeto(cgi.shFloor.b, id, nul);
if(cgi.shFloor.b[id].s == -1) { if(cgi.shFloor.b[id].s == -1) {
cgi.require_shapes();
if(BITRUNCATED) if(BITRUNCATED)
cgi.generate_floorshapes_for(id, c, !arcm::pseudohept(c), arcm::pseudohept(c) ? 0 : 1^(id&1)); cgi.generate_floorshapes_for(id, c, !arcm::pseudohept(c), arcm::pseudohept(c) ? 0 : 1^(id&1));
else if(geosupport_football() == 2) else if(geosupport_football() == 2)

View File

@ -1335,7 +1335,8 @@ EX void check_cgi() {
if(mhybrid) hybrid::underlying_cgip->timestamp = ntimestamp; if(mhybrid) hybrid::underlying_cgip->timestamp = ntimestamp;
if(fake::in()) fake::underlying_cgip->timestamp = ntimestamp; if(fake::in()) fake::underlying_cgip->timestamp = ntimestamp;
#if CAP_ARCM #if CAP_ARCM
if(arcm::alt_cgip) arcm::alt_cgip->timestamp = ntimestamp; if(arcm::alt_cgip[0]) arcm::alt_cgip[0]->timestamp = ntimestamp;
if(arcm::alt_cgip[1]) arcm::alt_cgip[1]->timestamp = ntimestamp;
#endif #endif
int limit = 4; int limit = 4;

View File

@ -719,6 +719,7 @@ EX void make_air() {
} }
check_cgi(); check_cgi();
calcparam(); calcparam();
cgi.require_basics();
GLERR("after make_air"); GLERR("after make_air");
current_display->set_viewport(0); current_display->set_viewport(0);
current_display->set_all(0,0); current_display->set_all(0,0);