From 3d9c4c838e63d7f6ca697f54a88d974cd76d4150 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 16 Jun 2024 18:12:52 +0200 Subject: [PATCH] moved underlying space drawer from rots to hybrid, and renamed the rest of rots:: to twist:: --- config.cpp | 4 +- geom-exp.cpp | 6 +- graph.cpp | 2 +- hud.cpp | 2 +- hyperpoint.cpp | 2 +- hypgraph.cpp | 2 +- nonisotropic.cpp | 166 +++++++++++++++++++++++----------------------- raycaster.cpp | 2 +- rogueviz/qtm.cpp | 8 +-- rogueviz/snow.cpp | 6 +- 10 files changed, 100 insertions(+), 100 deletions(-) diff --git a/config.cpp b/config.cpp index 5dd21dff..c805a1f6 100644 --- a/config.cpp +++ b/config.cpp @@ -1598,8 +1598,8 @@ EX void initConfig() { }); param_i(s2xe::qrings, "s2xe-rings"); - param_f(rots::underlying_scale, "rots-underlying-scale"); - param_b(rots::underlying_as_pc, "underlying_as_pc") + param_f(hybrid::underlying_scale, "rots-underlying-scale"); + param_b(hybrid::underlying_as_pc, "underlying_as_pc") -> editable("draw PC on the underlying map", 'P'); param_b(vid.bubbles_special, "bubbles-special", 1); diff --git a/geom-exp.cpp b/geom-exp.cpp index a54fd44e..f63420e3 100644 --- a/geom-exp.cpp +++ b/geom-exp.cpp @@ -1069,10 +1069,10 @@ EX void showEuclideanMenu() { #if MAXMDIM >= 4 if(mhybrid) { - auto r = rots::underlying_scale; + auto r = hybrid::underlying_scale; 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"), + dialog::editNumber(hybrid::underlying_scale, 0, 1, 0.05, 0.25, XLAT("view the underlying geometry"), geometry == gTwistedProduct ? XLAT("The space you are currently in a twisted product space. ") : XLAT("You are currently in a product space.") + @@ -1083,7 +1083,7 @@ EX void showEuclideanMenu() { ); dialog::bound_low(0); dialog::bound_up(1); - dialog::get_di().extra_options = [] () { rots::draw_underlying(true); }; + dialog::get_di().extra_options = [] () { hybrid::draw_underlying(true); }; }); } #endif diff --git a/graph.cpp b/graph.cpp index bde22297..400c58d5 100644 --- a/graph.cpp +++ b/graph.cpp @@ -5575,7 +5575,7 @@ EX void calcparam() { ld aradius = sphere ? cd->radius / (pconf.alpha - 1) : cd->radius; #if MAXMDIM >= 4 - if(euclid && rots::drawing_underlying) aradius *= 2.5; + if(euclid && hybrid::drawing_underlying) aradius *= 2.5; #endif if(dronemode) { cd->ycenter -= cd->radius; cd->ycenter += vid.fsize/2; cd->ycenter += vid.fsize/2; cd->radius *= 2; } diff --git a/hud.cpp b/hud.cpp index 59951374..b5355817 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(among(geometry, gProduct, gTwistedProduct)) rots::draw_underlying(!cornermode); + if(mhybrid) hybrid::draw_underlying(!cornermode); #endif { diff --git a/hyperpoint.cpp b/hyperpoint.cpp index ff38217e..8fed119b 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -1648,7 +1648,7 @@ EX hyperpoint direct_exp(hyperpoint v) { #endif #if MAXMDIM >= 4 if(nil) return nilv::formula_exp(v); - if(sl2 || stretch::in()) return stretch::mstretch ? nisot::numerical_exp(v) : rots::formula_exp(v); + if(sl2 || stretch::in()) return stretch::mstretch ? nisot::numerical_exp(v) : twist::formula_exp(v); #endif if(gproduct) return product::direct_exp(v); ld d = hypot_d(GDIM, v); diff --git a/hypgraph.cpp b/hypgraph.cpp index bf032d8b..c7b9cc66 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -3276,7 +3276,7 @@ EX bool do_draw(cell *c, const shiftmatrix& T) { } #if MAXMDIM >= 4 - if(rots::drawing_underlying && euclid && hdist0(tC0(T)) > 6) return false; + if(hybrid::drawing_underlying && euclid && hdist0(tC0(T)) > 6) return false; #endif if(just_gmatrix && sphere) return true; if(!do_draw(c)) return false; diff --git a/nonisotropic.cpp b/nonisotropic.cpp index 8fef1057..0f14c3ca 100644 --- a/nonisotropic.cpp +++ b/nonisotropic.cpp @@ -1730,6 +1730,85 @@ EX namespace hybrid { }; } + EX ld underlying_scale = 0; + EX bool drawing_underlying = false; + EX bool underlying_as_pc = true; + + EX void draw_underlying(bool cornermode) { + if(underlying_scale <= 0) return; + ld d = hybrid::get_where(centerover).second; + d *= cgi.plevel; + transmatrix T = twist::uzpush(-d) * spin(-2*d); + + if(det(T) < 0) T = centralsym * T; + + ld orig_d = d; + if(mproduct) d = 0; + + hyperpoint h = inverse(View * spin(master_to_c7_angle()) * T) * C0; + + auto g = std::move(gmatrix); + auto g0 = std::move(gmatrix0); + + ld alpha = atan2(ortho_inverse(NLP) * point3(1, 0, 0)); + + dynamicval dn(NLP); + dynamicval dv(View); + + bool inprod = mproduct; + transmatrix pView = View; + + if(inprod) { + ld z = zlevel(tC0(View)); + + /* special case when we are actually in E2xE as a rotation space */ + if(in_e2xe() && abs(cgi.plevel * hybrid::csteps - TAU) < 1e-6) alpha = orig_d - z; + + println(hlog, "depth = ", cgi.plevel * hybrid::csteps, " orig_d = ", orig_d, " z = ", z); + + pView = spin(alpha) * View; + + for(int a=0; a<3; a++) pView[a] *= exp(-z); + } + + cell *co = hybrid::get_where(centerover).first; + + hybrid::in_underlying_geometry([&] { + cgi.require_shapes(); + dynamicval pcc(corner_centering, cornermode ? 1 : 2); + dynamicval pf(playerfound, true); + dynamicval m5(centerover, co); + dynamicval m2(View, inprod ? pView : ypush(0) * twist::qtm(h)); + if(PURE && !inprod) View = View * pispin; + View = inverse(stretch::mstretch_matrix) * spin(2*d) * View; + dynamicval m3(playerV, shiftless(Id)); + dynamicval m4(actual_view_transform, Id); + dynamicval m6(cwtV, shiftless(Id)); + dynamicval pm(pmodel, mdDisk); + dynamicval pss(pconf.scale, (sphere ? 10 : euclid ? .4 : 1) * underlying_scale); + dynamicval psa(pconf.alpha, sphere ? 10 : 1); + dynamicval p(hybrid::pmap, NULL); + dynamicval psr(sightrange_bonus, 0); + + dynamicval psx(vid.use_smart_range, 2); + dynamicval psy(vid.smart_range_detail, 1); + dynamicval pdu(drawing_underlying, true); + + calcparam(); + reset_projection(); current_display->set_all(0, 0); + ptds.clear(); + drawthemap(); + if(underlying_as_pc) drawPlayer(moPlayer, centerover, sphere ? shiftless(xpush(M_PI) * spin90()) : shiftless(spin90()), 0xFFFFFFFF, 0); + drawqueue(); + if(!underlying_as_pc) displaychr(current_display->xcenter, current_display->ycenter, 0, 24 * mapfontscale / 100, '+', 0xFFFFFFFF); + glflush(); + }); + gmatrix = std::move(g); + gmatrix0 = std::move(g0); + calcparam(); + reset_projection(); current_display->set_all(0, 0); make_actual_view(); + } + EX } EX namespace product { @@ -2243,8 +2322,7 @@ EX namespace slr { EX } -EX namespace rots { - EX ld underlying_scale = 0; +EX namespace twist { #if MAXMDIM >= 4 EX transmatrix uxpush(ld x) { @@ -2280,7 +2358,7 @@ EX namespace rots { EX std::map saved_matrices_ray; - struct hrmap_rotation_space : hybrid::hrmap_hybrid { + struct hrmap_twisted : hybrid::hrmap_hybrid { std::map saved_matrices; @@ -2389,84 +2467,6 @@ EX namespace rots { return M; } - - EX bool drawing_underlying = false; - EX bool underlying_as_pc = true; - - EX void draw_underlying(bool cornermode) { - if(underlying_scale <= 0) return; - ld d = hybrid::get_where(centerover).second; - d *= cgi.plevel; - transmatrix T = rots::uzpush(-d) * spin(-2*d); - - if(det(T) < 0) T = centralsym * T; - - ld orig_d = d; - if(mproduct) d = 0; - - hyperpoint h = inverse(View * spin(master_to_c7_angle()) * T) * C0; - - auto g = std::move(gmatrix); - auto g0 = std::move(gmatrix0); - - ld alpha = atan2(ortho_inverse(NLP) * point3(1, 0, 0)); - - dynamicval dn(NLP); - dynamicval dv(View); - - bool inprod = mproduct; - transmatrix pView = View; - - if(inprod) { - ld z = zlevel(tC0(View)); - - /* special case when we are actually in E2xE as a rotation space */ - if(in_e2xe() && abs(cgi.plevel * hybrid::csteps - TAU) < 1e-6) alpha = orig_d - z; - - println(hlog, "depth = ", cgi.plevel * hybrid::csteps, " orig_d = ", orig_d, " z = ", z); - - pView = spin(alpha) * View; - - for(int a=0; a<3; a++) pView[a] *= exp(-z); - } - - cell *co = hybrid::get_where(centerover).first; - - hybrid::in_underlying_geometry([&] { - cgi.require_shapes(); - dynamicval pcc(corner_centering, cornermode ? 1 : 2); - dynamicval pf(playerfound, true); - dynamicval m5(centerover, co); - dynamicval m2(View, inprod ? pView : ypush(0) * qtm(h)); - if(PURE && !inprod) View = View * pispin; - View = inverse(stretch::mstretch_matrix) * spin(2*d) * View; - dynamicval m3(playerV, shiftless(Id)); - dynamicval m4(actual_view_transform, Id); - dynamicval m6(cwtV, shiftless(Id)); - dynamicval pm(pmodel, mdDisk); - dynamicval pss(pconf.scale, (sphere ? 10 : euclid ? .4 : 1) * underlying_scale); - dynamicval psa(pconf.alpha, sphere ? 10 : 1); - dynamicval p(hybrid::pmap, NULL); - dynamicval psr(sightrange_bonus, 0); - - dynamicval psx(vid.use_smart_range, 2); - dynamicval psy(vid.smart_range_detail, 1); - dynamicval pdu(drawing_underlying, true); - - calcparam(); - reset_projection(); current_display->set_all(0, 0); - ptds.clear(); - drawthemap(); - if(underlying_as_pc) drawPlayer(moPlayer, centerover, sphere ? shiftless(xpush(M_PI) * spin90()) : shiftless(spin90()), 0xFFFFFFFF, 0); - drawqueue(); - if(!underlying_as_pc) displaychr(current_display->xcenter, current_display->ycenter, 0, 24 * mapfontscale / 100, '+', 0xFFFFFFFF); - glflush(); - }); - gmatrix = std::move(g); - gmatrix0 = std::move(g0); - calcparam(); - reset_projection(); current_display->set_all(0, 0); make_actual_view(); - } /** @brief exponential function for both slr and Berger sphere */ @@ -3047,7 +3047,7 @@ EX namespace nisot { #endif if(mproduct) return new product::hrmap_product; #if MAXMDIM >= 4 - if(mhybrid) return new rots::hrmap_rotation_space; + if(mhybrid) return new twist::hrmap_twisted; if(nil) return new nilv::hrmap_nil; #endif return NULL; @@ -3105,7 +3105,7 @@ EX namespace nisot { } else if(argis("-rot_uscale")) { PHASEFROM(2); - shift_arg_formula(rots::underlying_scale); + shift_arg_formula(hybrid::underlying_scale); return 0; } else if(argis("-nilperiod")) { diff --git a/raycaster.cpp b/raycaster.cpp index 5faca088..45370f91 100644 --- a/raycaster.cpp +++ b/raycaster.cpp @@ -2641,7 +2641,7 @@ EX int rmap_get_id_of(cell *c) { EX void reset_raycaster() { our_raycaster = nullptr; reset_rmap = true; - rots::saved_matrices_ray = {}; + twist::saved_matrices_ray = {}; } EX void reset_raycaster_map() { diff --git a/rogueviz/qtm.cpp b/rogueviz/qtm.cpp index 1a818979..15c5d819 100644 --- a/rogueviz/qtm.cpp +++ b/rogueviz/qtm.cpp @@ -240,8 +240,8 @@ auto hooks = if(mode == pmStart) { set_geometry(gSphere); set_variation(eVariation::bitruncated); - set_geometry(gRotSpace); - slide_backup(rots::underlying_scale, .25); + hybrid::enable_rotspace(); + slide_backup(hybrid::underlying_scale, .25); slide_backup(qmode, m); IF_RAY( slide_backup(ray::max_cells, 32768); @@ -266,8 +266,8 @@ auto hooks = if(mode == pmStart) { set_geometry(gKleinQuartic); set_variation(eVariation::bitruncated); - set_geometry(gRotSpace); - slide_backup(rots::underlying_scale, .25); + hybrid::enable_rotspace(); + slide_backup(hybrid::underlying_scale, .25); slide_backup(qmode, m); IF_RAY( slide_backup(ray::max_cells, 32768); diff --git a/rogueviz/snow.cpp b/rogueviz/snow.cpp index 4c3f05c0..f4ff440c 100644 --- a/rogueviz/snow.cpp +++ b/rogueviz/snow.cpp @@ -99,8 +99,8 @@ transmatrix random_snow_matrix(cell *c) { transmatrix T = PIU(random_snow_matrix(c)); return orthogonal_move(T, (randd() - .5) * cgi.plevel); } - else if(mhybrid && !mproduct) { - return rots::lift_matrix(PIU(random_snow_matrix(c))); // * zpush((randd() - .5) * cgi.plevel); + else if(mtwisted) { + return twist::lift_matrix(PIU(random_snow_matrix(c))); // * zpush((randd() - .5) * cgi.plevel); } else if(nonisotropic || bt::in()) { @@ -384,7 +384,7 @@ auto hchook = addHook(hooks_drawcell, 100, draw_snow) snow_slide(v, "SL(2,R)", "Here is SL(2,R), like Nil but based on hyperbolic plane instead. Geometric lensing effects are strong in both Nil and SL(2,R). (Starting with S^2 yields spherical geometry.)", [] { set_geometry(gNormal); set_variation(eVariation::pure); - set_geometry(gRotSpace); + set_geometry(gTwistedProduct); snow_lambda = 5; }); IF_SOLV(snow_slide(v, "Solv", "Solv geometry. Like the non-isotropic hyperbolic geometry but where the horizontal and vertical curvatures work in the other way.", [] {