From 6ac17b31f1982becdacde3281035b60fccee5f40 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 11 Oct 2022 20:00:51 +0200 Subject: [PATCH] hybrid:: new options for switching --- nonisotropic.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/nonisotropic.cpp b/nonisotropic.cpp index c65f9d0f..c1dc1cdf 100644 --- a/nonisotropic.cpp +++ b/nonisotropic.cpp @@ -1120,6 +1120,7 @@ EX namespace hybrid { #if HDR template auto in_actual(const T& t) -> decltype(t()) { + if(pmap == nullptr) return t(); dynamicval g(geometry, actual_geometry); dynamicval gc(cgip, pcgip); dynamicval gu(currentmap, pmap); @@ -1364,6 +1365,7 @@ EX namespace hybrid { #if HDR template auto in_underlying_geometry(const T& f) -> decltype(f()) { if(!hybri) return f(); + pcgip = cgip; dynamicval gag(actual_geometry, geometry); dynamicval g(geometry, underlying); dynamicval gss(underlying_cgip->single_step, cgi.single_step); @@ -1377,6 +1379,29 @@ EX namespace hybrid { #define PIU(x) hr::hybrid::in_underlying_geometry([&] { return (x); }) #endif + /** like in_underlying_geometry but does not return */ + EX void switch_to_underlying() { + if(!hybri) return; + auto m = hmap(); + pmap = m; + actual_geometry = geometry; + geometry = underlying; + underlying_cgip->single_step = cgi.single_step; + underlying_cgip->psl_steps = cgi.psl_steps; + pcgip = cgip; + cgip = underlying_cgip; + currentmap = m->underlying_map; + } + + /** like in_actual but does not return */ + EX void switch_to_actual() { + if(!pmap) return; + geometry = actual_geometry; + cgip = pcgip; + currentmap = pmap; + pmap = nullptr; + } + // next: 0 = i-th corner, 1 = next corner, 2 = center of the wall EX hyperpoint get_corner(cell *c, int i, int next, ld z) { ld lev = cgi.plevel * z / 2;