From de3ad6d718f274907dd9deca9283935c5358a322 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 16 Jun 2024 17:46:56 +0200 Subject: [PATCH] renamed gRotSpace to gTwistedProduct, and similar --- classes.cpp | 4 ++-- geom-exp.cpp | 20 ++++++++++---------- hud.cpp | 2 +- hyperpoint.cpp | 2 +- landlock.cpp | 2 +- legacy.cpp | 6 ++++++ mapeditor.cpp | 4 ++-- nonisotropic.cpp | 43 ++++++++++++++++++++++++++++++++++--------- polygons.cpp | 4 ++-- racing.cpp | 2 +- raycaster.cpp | 18 +++++++++--------- system.cpp | 10 ++-------- 12 files changed, 71 insertions(+), 46 deletions(-) diff --git a/classes.cpp b/classes.cpp index 0839bc0b..ee54f5f5 100644 --- a/classes.cpp +++ b/classes.cpp @@ -745,7 +745,7 @@ enum eGeometry { gHoroTris, gHoroRec, gHoroHex, gField435, gField534, gBinary4, gSol, - gKiteDart2, gKiteDart3, gNil, gProduct, gRotSpace, + gKiteDart2, gKiteDart3, gNil, gProduct, gTwistedProduct, gTernary, gNIH, gSolN, gInfOrder, gSpace336, gSpace344, gCrystal344, gArnoldCat, gArbitrary, gInfOrder4, gCrystal534, gSpace535, gSpace536, gSeifertCover, gSeifertWeber, gHomologySphere, @@ -939,7 +939,7 @@ EX vector ginf = { {"kd3", "none", "kite-and-dart on horospheres", "kd3", 12, 3, qsBP, giHyperb3, {{7, 3}}, eVariation::pure}, {"nil", "none", "Nil geometry", "nil", 6, 3, qOPTQ, giNil, {{7, 5}}, eVariation::pure}, {"product","none", "product space", "product", 7, 3, qHYBRID, giProduct, {{7, 3}}, eVariation::pure}, - {"twisted","none", "rotation space", "twisted", 7, 3, qHYBRID, giSL2, {{6, 4}}, eVariation::pure}, + {"twisted","none", "twisted product space", "twisted", 7, 3, qHYBRID, giSL2, {{6, 4}}, eVariation::pure}, {"ternary","none", "standard ternary tiling", "ternary", 6, 3, qBINARY, giHyperb2, {{6, 4}}, eVariation::pure}, {"3x2", "none", "stretched hyperbolic", "3:2", 11, 3, qBINARY|qNIH, giNIH, {{6, 3}}, eVariation::pure}, {"3x1/2", "none", "stretched Solv", "3:1/2", 9, 3, (qBINARY|qSOL|qNIH), giSolN, {{7, 3}}, eVariation::pure}, diff --git a/geom-exp.cpp b/geom-exp.cpp index 57046d41..397108c9 100644 --- a/geom-exp.cpp +++ b/geom-exp.cpp @@ -314,16 +314,16 @@ void set_or_configure_geometry(eGeometry g) { else if(g == gArbitrary) arb::choose(); else { - if(among(g, gProduct, gRotSpace)) { - if(WDIM == 3 || (g == gRotSpace && euclid)) { + if(among(g, gProduct, gTwistedProduct)) { + if(WDIM == 3 || (g == gTwistedProduct && euclid)) { addMessage( - g == gRotSpace ? + g == gTwistedProduct ? XLAT("Only works with 2D non-Euclidean geometries") : XLAT("Only works with 2D geometries") ); return; } - if(g == gRotSpace) { + if(g == gTwistedProduct) { bool ok = true; if(arcm::in()) ok = PURE; else if(bt::in() || aperiodic) ok = false; @@ -387,7 +387,7 @@ void ge_select_tiling() { for(int i=0; i choices; @@ -1068,8 +1068,8 @@ EX void showEuclideanMenu() { dialog::addSelItem(XLAT("view the underlying geometry"), r > 0 ? fts(r)+"x" : ONOFF(false), '6'); dialog::add_action([] { dialog::editNumber(rots::underlying_scale, 0, 1, 0.05, 0.25, XLAT("view the underlying geometry"), - geometry == gRotSpace ? - XLAT("The space you are currently in is the space of rotations of the underlying hyperbolic or spherical geometry. ") + geometry == gTwistedProduct ? + XLAT("The space you are currently in a twisted product space. ") : XLAT("You are currently in a product space.") + XLAT( "This option lets you see the underlying space. Lands and some walls (e.g. in the Graveyard) are based on " diff --git a/hud.cpp b/hud.cpp index 76866273..59951374 100644 --- a/hud.cpp +++ b/hud.cpp @@ -492,7 +492,7 @@ EX void drawStats() { bool cornermode = (vid.xres > vid.yres * 85/100 && vid.yres > vid.xres * 85/100); #if MAXMDIM >= 4 - if(geometry == gRotSpace || geometry == gProduct) rots::draw_underlying(!cornermode); + if(among(geometry, gProduct, gTwistedProduct)) rots::draw_underlying(!cornermode); #endif { diff --git a/hyperpoint.cpp b/hyperpoint.cpp index db052ebe..ff38217e 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -420,7 +420,7 @@ EX hyperpoint hpxy(ld x, ld y) { return cgi.emb->base_to_actual(h); } if(sl2) return hyperpoint(x, y, 0, sqrt(1+x*x+y*y)); - if(rotspace) return hyperpoint(x, y, 0, sqrt(1-x*x-y*y)); + if(mtwisted) return hyperpoint(x, y, 0, sqrt(1-x*x-y*y)); return PIU(hpxyz(x,y, translatable ? 1 : sphere ? sqrt(1-x*x-y*y) : sqrt(1+x*x+y*y))); } diff --git a/landlock.cpp b/landlock.cpp index 73b8c9a8..94bbcfe3 100644 --- a/landlock.cpp +++ b/landlock.cpp @@ -1062,7 +1062,7 @@ EX land_validity_t& land_validity(eLand l) { return lv::not_implemented; if(among(l, laReptile, laDragon, laTortoise)) return lv::bad_graphics; - if((hybrid::actual_geometry == gRotSpace || geometry == gRotSpace) && l == laDryForest) + if((hybrid::actual_geometry == gTwistedProduct || geometry == gTwistedProduct) && l == laDryForest) return lv::hedgehogs; if(mhybrid && hybrid::underlying && hybrid::underlying_cgip) { return *PIU(&land_validity(l)); diff --git a/legacy.cpp b/legacy.cpp index 70286e4b..b3707df1 100644 --- a/legacy.cpp +++ b/legacy.cpp @@ -5,6 +5,12 @@ namespace hr { #if CAP_LEGACY + +#if HDR +/** legacy name */ +constexpr eGeometry gRotSpace = gTwistedProduct; +#endif + namespace shmup { void scanchar(FILE *f, char& c) { diff --git a/mapeditor.cpp b/mapeditor.cpp index f1578dfb..3bf9036c 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -556,7 +556,7 @@ EX namespace mapstream { f.write(product::cmirror); f.write(vid.plevel_factor); } - if(rotspace) { + if(mtwisted) { f.write(hybrid::csteps); } if(mhybrid) { @@ -695,7 +695,7 @@ EX namespace mapstream { if(vernum >= 0xA833) f.read(product::cmirror); if(vernum >= 0xA908) f.read(vid.plevel_factor); } - if(geometry == gRotSpace && vernum >= 0xA833) { + if(geometry == gTwistedProduct && vernum >= 0xA833) { f.read(hybrid::csteps); } if(mhybrid && vernum >= 0xA80C) { diff --git a/nonisotropic.cpp b/nonisotropic.cpp index 6f8d2f25..b4c811e3 100644 --- a/nonisotropic.cpp +++ b/nonisotropic.cpp @@ -1189,11 +1189,12 @@ EX namespace hybrid { underlying = geometry; underlying_cgip = cgip; bool sph = sphere; + bool euc = euclid; auto keep = ginf[g].menu_displayed_name; ginf[g] = ginf[underlying]; ginf[g].menu_displayed_name = keep; - if(g == gRotSpace) { - ginf[g].g = sph ? giSphere3 : giSL2; + if(g == gTwistedProduct) { + ginf[g].g = euc ? giNil : sph ? giSphere3 : giSL2; ginf[g].tiling_name = "Iso(" + ginf[g].tiling_name + ")"; string& qn = ginf[g].quotient_name; if(csteps && csteps != (sph ? cgi.psl_steps*2 : 0)) { @@ -1211,7 +1212,7 @@ EX namespace hybrid { ginf[g].flags |= qANYQ; } else { - ginf[g].cclass = g == gRotSpace ? gcSL2 : gcProduct; + ginf[g].cclass = gcProduct; ginf[g].g.gameplay_dimension++; ginf[g].g.graphical_dimension++; ginf[g].tiling_name += "xZ"; @@ -1229,6 +1230,25 @@ EX namespace hybrid { geometry = g; } + EX void enable_rotspace() { + if(euclid) { + start_game(); + int q = cwt.at->type; + stop_game(); + hybrid::csteps = q; + set_plevel(TAU / q); + set_geometry(gProduct); + hybrid::reconfigure(); + } + else { + stop_game(); + set_geometry(gTwistedProduct); + check_cgi(); cgi.require_basics(); + hybrid::csteps = cgi.psl_steps; + hybrid::reconfigure(); + } + } + EX hrmap *pmap; EX geometry_information *pcgip; EX eGeometry actual_geometry; @@ -1356,7 +1376,7 @@ EX namespace hybrid { } EX void fix_bounded_cycles() { - if(!rotspace) return; + if(!mtwisted) return; if(!closed_manifold) return; in_underlying([&] { cellwalker final(currentmap->gamestart(), 0); @@ -1474,7 +1494,7 @@ EX namespace hybrid { auto cu1 = m->in_underlying([&] { return cu->cmove(d); }); int d1 = cu->c.spin(d); int s = 0; - if(geometry == gRotSpace) { + if(geometry == gTwistedProduct) { auto cm = (hrmap_hybrid*)currentmap; m->in_underlying([&] { cm->ensure_shifts(cu); }); s = ((hrmap_hybrid*)currentmap)->get_shift(cellwalker(cu, d)); @@ -1660,7 +1680,7 @@ EX namespace hybrid { static int s; s = csteps / cgi.single_step; string str = ""; - if(rotspace) + if(mtwisted) str = XLAT( "If the 2D underlying manifold is bounded, the period should be a divisor of the 'rotation space' " "value (PSL(2,R)) times the Euler characteristics of the underlying manifold. " @@ -1680,7 +1700,7 @@ EX namespace hybrid { }; }; dialog::get_di().extra_options = [=] () { - if(rotspace) { + if(mtwisted) { int e_steps = cgi.psl_steps / gcd(cgi.single_step, cgi.psl_steps); bool ubounded = PIU(closed_manifold); dialog::addSelItem( sphere ? XLAT("elliptic") : XLAT("PSL(2,R)"), its(e_steps), 'P'); @@ -2627,7 +2647,7 @@ EX namespace stretch { } EX bool applicable() { - return rotspace || (cgflags & qSTRETCHABLE); + return mtwisted || (cgflags & qSTRETCHABLE); } EX bool in() { @@ -3065,9 +3085,14 @@ EX namespace nisot { shift(); s2xe::qrings = argi(); return 0; } + else if(argis("-twisted-product")) { + PHASEFROM(2); + set_geometry(gTwistedProduct); + return 0; + } else if(argis("-rotspace")) { PHASEFROM(2); - set_geometry(gRotSpace); + hybrid::enable_rotspace(); return 0; } else if(argis("-rot_uscale")) { diff --git a/polygons.cpp b/polygons.cpp index c8fa00e8..7f6790b0 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -879,7 +879,7 @@ void geometry_information::compute_cornerbonus() { } EX int kleinize_sides; -hyperpoint ray_kleinize_rotspace(hyperpoint h, int ks, int id) { +hyperpoint ray_kleinize_twisted(hyperpoint h, int ks, int id) { /* todo: in Archimedean tilings it may be the case that pispin is incorrect, as shown by `angle of zero` -- need to carry it to raycaster */ h = pispin * h; @@ -923,7 +923,7 @@ hyperpoint ray_kleinize_rotspace(hyperpoint h, int ks, int id) { hyperpoint ray_kleinize(hyperpoint h, int id, ld pz) { if(nil && nilv::nil_structure_index == 0 && among(id, 2, 5)) h[2] = 0; if(nil && nilv::nil_structure_index == 2 && among(id, 6, 7)) h[2] = 0; - if(rotspace) return ray_kleinize_rotspace(h, kleinize_sides, id); + if(mtwisted) return ray_kleinize_twisted(h, kleinize_sides, id); #if CAP_BT if(hyperbolic && bt::in()) { // ld co = vid.binary_width / log(2) / 4; diff --git a/racing.cpp b/racing.cpp index 2c7fae59..c4c75e7b 100644 --- a/racing.cpp +++ b/racing.cpp @@ -1106,7 +1106,7 @@ void race_projection() { add_thurston_race(XLAT("S2xE"), [] { set_geometry(gSphere); set_variation(eVariation::bitruncated); set_geometry(gProduct); }); add_thurston_race(XLAT("H2xE"), [] { set_geometry(gNormal); set_variation(eVariation::bitruncated); set_geometry(gProduct); }); add_thurston_race(XLAT("Nil"), [] { stop_game(); nilv::nilperiod[0] = 0; set_geometry(gNil); }); - add_thurston_race(XLAT("PSL(2,R)"), [] { set_geometry(gNormal); set_variation(eVariation::pure); set_geometry(gRotSpace); }); + add_thurston_race(XLAT("PSL(2,R)"), [] { set_geometry(gNormal); set_variation(eVariation::pure); hybrid::enable_rotspace(); }); } else { #if CAP_SOLV diff --git a/raycaster.cpp b/raycaster.cpp index 1e6f7057..199643d4 100644 --- a/raycaster.cpp +++ b/raycaster.cpp @@ -80,7 +80,7 @@ EX bool is_eyes() { } EX bool is_stepbased() { - return nonisotropic || stretch::in() || is_eyes() || rotspace; + return nonisotropic || stretch::in() || is_eyes() || mtwisted; } EX bool horos() { @@ -153,7 +153,7 @@ EX bool requested() { #endif if(!available()) return false; if(want_use == 2) return true; - if(rotspace) return false; // not very good + if(mtwisted) return false; // not very good, sometimes if(WDIM == 2) return false; // not very good return racing::on || quotient || fake::in(); } @@ -341,7 +341,7 @@ struct raygen { void create(); string f_xpush() { return hyperbolic ? "xpush_h3" : "xpush_s3"; } - string f_len() { return hyperbolic ? "len_h3" : rotspace ? "rot_flatdist" : sphere ? "len_s3" : "len_x"; } + string f_len() { return hyperbolic ? "len_h3" : mtwisted ? "rot_flatdist" : sphere ? "len_s3" : "len_x"; } string f_len_prod() { return in_h2xe() ? "len_h2" : in_s2xe() ? "len_s2" : "len_e2"; } void add_functions(); }; @@ -858,14 +858,14 @@ void raygen::move_forward() { bool reg = hyperbolic || sphere || euclid || sl2 || gproduct; if(reg) { - string s = (rotspace || gproduct) ? "-2" : ""; + string s = (mtwisted || gproduct) ? "-2" : ""; fmain += " mediump float best = "+f_len()+"(nposition);\n" " for(int i=0; i uPLevel) which = sides-1;\n" @@ -1283,7 +1283,7 @@ void raygen::emit_iterate(int gid1) { fmain += " const mediump float uPLevel = " + to_glsl(cgi.plevel/2) + ";\n"; int flat1 = 0, flat2 = deg; - if(gproduct || rotspace) flat2 -= 2; + if(gproduct || mtwisted) flat2 -= 2; #if CAP_BT if(horos()) { @@ -1407,7 +1407,7 @@ void raygen::emit_iterate(int gid1) { fmain += " mediump vec4 pos = position;\n"; if(nil && nilv::nil_structure_index == 0) fmain += "if(which == 2 || which == 5) pos.z = 0.;\n"; if(nil && nilv::nil_structure_index == 2) fmain += "if(which == 6 || which == 7) pos.z = 0.;\n"; - else if(rotspace) { + else if(mtwisted) { fmain += "pos = rot_coordinates(pos, sides-2, which);\n"; string spinner = "h = cspin(0, 1, PI) * h;\n"; string calc_dxy = sl2 ? @@ -1482,7 +1482,7 @@ void raygen::emit_iterate(int gid1) { if(!volumetric::on) fmain += " col.xyz = col.xyz * d + uFogColor.xyz * (1.-d);\n"; - if(rotspace) fmain += + if(mtwisted) fmain += " if(rot_dark(position, sides-2)) col.xyz /= 2.;\n"; if(nil && nilv::nil_structure_index == 0) fmain += " if(abs(abs(position.x)-abs(position.y)) < .005) col.xyz /= 2.;\n"; @@ -2044,7 +2044,7 @@ void raygen::create() { if((gproduct || intra::in) && vid.stereo_mode != sODS) fsh += "uniform mediump mat4 uLP;\n"; - if(gproduct || intra::in || rotspace) fsh += + if(gproduct || intra::in || mtwisted) fsh += "uniform mediump float uPLevel;\n"; if(many_cell_types) fsh += diff --git a/system.cpp b/system.cpp index f72d7708..ec998f40 100644 --- a/system.cpp +++ b/system.cpp @@ -988,7 +988,7 @@ constexpr int MODECODE_BOX = 387; modecode_t fill_modecode() { dynamicval sp1(multi::players, save.box[197]); dynamicval sp2(geometry, (eGeometry) save.box[116]); - if(among(geometry, gArchimedean, gProduct, gRotSpace, gArbitrary)) + if(among(geometry, gArchimedean, gProduct, gTwistedProduct, gArbitrary)) return 6; /* these would not be saved nor loaded correctly */ dynamicval sp3(shmup::on, save.box[119]); dynamicval sp4(land_structure, (eLandStructure) save.box[196]); @@ -1451,9 +1451,8 @@ EX void set_geometry(eGeometry target) { if(geometry != target) { stop_game(); ors::reset(); - if(among(target, gProduct, gRotSpace)) { + if(among(target, gProduct, gTwistedProduct)) { if(vid.always3) { vid.always3 = false; geom3::apply_always3(); } - if(target == gRotSpace) hybrid::csteps = 0; hybrid::configure(target); } geometry = target; @@ -1485,11 +1484,6 @@ EX void set_geometry(eGeometry target) { arb::convert::base_geometry = geometry; arb::convert::base_variation = variation; } - - if(rotspace) { - check_cgi(); cgi.require_basics(); - hybrid::csteps = cgi.psl_steps; - } } }