From 814467082f0875151c4f40598e54206fd0a176b7 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 17 Dec 2022 11:47:10 +0100 Subject: [PATCH] shift_method gets more possible arguments --- graph.cpp | 4 ++-- hyperpoint.cpp | 20 +++++++++++++------- hypgraph.cpp | 12 ++++++------ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/graph.cpp b/graph.cpp index 77e76211..a59abc06 100644 --- a/graph.cpp +++ b/graph.cpp @@ -5042,11 +5042,11 @@ EX ld wall_radar(cell *c, transmatrix T, transmatrix LPe, ld max) { ld step = max / 20; ld fixed_yshift = 0; for(int i=0; i<20; i++) { - T = shift_object(T, ori, ztangent(-step), shift_method(false)); + T = shift_object(T, ori, ztangent(-step), shift_method(smaWallRadar)); virtualRebase(c, T); color_t col; if(isWall3(c, col) || (WDIM == 2 && GDIM == 3 && tC0(T)[2] > cgi.FLOOR)) { - T = shift_object(T, ori, ztangent(step), shift_method(false)); + T = shift_object(T, ori, ztangent(step), shift_method(smaWallRadar)); step /= 2; i = 17; if(step < 1e-3) break; } diff --git a/hyperpoint.cpp b/hyperpoint.cpp index 89b8f787..57ba838a 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -1629,24 +1629,30 @@ EX ld xcross(ld x1, ld y1, ld x2, ld y2) { return x1 + (x2 - x1) * y1 / (y1 - y2 #if HDR enum eShiftMethod { smProduct, smIsometric, smEmbedded, smLie, smGeodesic }; enum eEmbeddedShiftMethodChoice { smcNone, smcBoth, smcAuto }; +enum eShiftMethodApplication { smaManualCamera, smaAutocenter, smaObject, smaWallRadar }; #endif EX eEmbeddedShiftMethodChoice embedded_shift_method_choice = smcBoth; -EX bool use_embedded_shift(bool automatic) { - if(automatic) return embedded_shift_method_choice; - return embedded_shift_method_choice == smcBoth; +EX bool use_embedded_shift(eShiftMethodApplication sma) { + switch(sma) { + case smaAutocenter: return embedded_shift_method_choice != smcNone; + case smaManualCamera: return embedded_shift_method_choice == smcBoth; + case smaObject: return true; + case smaWallRadar: return among(pmodel, mdLiePerspective, mdLieOrthogonal); + default: throw hr_exception("unknown sma"); + } } -EX eShiftMethod shift_method(bool automatic IS(false)) { +EX eShiftMethod shift_method(eShiftMethodApplication sma) { if(gproduct) return smProduct; - if(embedded_plane && use_embedded_shift(automatic)) return nonisotropic ? smLie : smEmbedded; + if(embedded_plane && use_embedded_shift(sma)) return nonisotropic ? smLie : smEmbedded; if(!nonisotropic && !stretch::in()) return smIsometric; if(!nisot::geodesic_movement && !embedded_plane) return smLie; return smGeodesic; } -EX transmatrix shift_object(const transmatrix Position, const transmatrix& ori, const hyperpoint direction, eShiftMethod sm IS(shift_method(true))) { +EX transmatrix shift_object(const transmatrix Position, const transmatrix& ori, const hyperpoint direction, eShiftMethod sm IS(shift_method(smaObject))) { switch(sm) { case smGeodesic: return nisot::parallel_transport(Position, direction); @@ -1665,7 +1671,7 @@ EX transmatrix shift_object(const transmatrix Position, const transmatrix& ori, } } -EX void apply_shift_object(transmatrix& Position, const transmatrix orientation, const hyperpoint direction, eShiftMethod sm IS(shift_method(true))) { +EX void apply_shift_object(transmatrix& Position, const transmatrix orientation, const hyperpoint direction, eShiftMethod sm IS(shift_method(smaObject))) { Position = shift_object(Position, orientation, direction, sm); } diff --git a/hypgraph.cpp b/hypgraph.cpp index 73b9ed90..d9252172 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -2115,9 +2115,9 @@ EX void centerpc(ld aspd) { if(R < aspd) fix_whichcopy_if_near(); if(R < aspd) - shift_view_to(shiftless(H), shift_method(true)); + shift_view_to(shiftless(H), shift_method(smaAutocenter)); else - shift_view_towards(shiftless(H), aspd, shift_method(true)); + shift_view_towards(shiftless(H), aspd, shift_method(smaAutocenter)); fixmatrix(View); fixmatrix(current_display->which_copy); @@ -3207,7 +3207,7 @@ EX hyperpoint lie_log(hyperpoint h) { } /** shift the view according to the given tangent vector */ -EX transmatrix get_shift_view_of(const hyperpoint H, const transmatrix V, eShiftMethod sm IS(shift_method())) { +EX transmatrix get_shift_view_of(const hyperpoint H, const transmatrix V, eShiftMethod sm IS(shift_method(smaManualCamera))) { switch(sm) { case smProduct: return rgpushxto0(direct_exp(lp_iapply(H))) * V; @@ -3230,7 +3230,7 @@ EX transmatrix get_shift_view_of(const hyperpoint H, const transmatrix V, eShift } /** shift the view according to the given tangent vector */ -EX void shift_view(hyperpoint H, eShiftMethod sm IS(shift_method())) { +EX void shift_view(hyperpoint H, eShiftMethod sm IS(shift_method(smaManualCamera))) { if(callhandlers(false, hooks_shift_view, H)) return; static bool recursive = false; if(!recursive && intra::in) { @@ -3310,7 +3310,7 @@ EX transmatrix map_relative_push(hyperpoint h) { return rgpushxto0(h); } -EX void shift_view_to(shiftpoint H, eShiftMethod sm IS(shift_method())) { +EX void shift_view_to(shiftpoint H, eShiftMethod sm IS(shift_method(smaManualCamera))) { switch(sm) { case smIsometric: case smEmbedded: @@ -3328,7 +3328,7 @@ EX void shift_view_to(shiftpoint H, eShiftMethod sm IS(shift_method())) { } } -EX void shift_view_towards(shiftpoint H, ld l, eShiftMethod sm IS(shift_method())) { +EX void shift_view_towards(shiftpoint H, ld l, eShiftMethod sm IS(shift_method(smaManualCamera))) { switch(sm) { case smIsometric: case smEmbedded: