1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-01-29 10:24:52 +00:00

shift_method gets more possible arguments

This commit is contained in:
Zeno Rogue 2022-12-17 11:47:10 +01:00
parent 5da1b8f88e
commit 814467082f
3 changed files with 21 additions and 15 deletions

View File

@ -5042,11 +5042,11 @@ EX ld wall_radar(cell *c, transmatrix T, transmatrix LPe, ld max) {
ld step = max / 20; ld step = max / 20;
ld fixed_yshift = 0; ld fixed_yshift = 0;
for(int i=0; i<20; i++) { 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); virtualRebase(c, T);
color_t col; color_t col;
if(isWall3(c, col) || (WDIM == 2 && GDIM == 3 && tC0(T)[2] > cgi.FLOOR)) { 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; step /= 2; i = 17;
if(step < 1e-3) break; if(step < 1e-3) break;
} }

View File

@ -1629,24 +1629,30 @@ EX ld xcross(ld x1, ld y1, ld x2, ld y2) { return x1 + (x2 - x1) * y1 / (y1 - y2
#if HDR #if HDR
enum eShiftMethod { smProduct, smIsometric, smEmbedded, smLie, smGeodesic }; enum eShiftMethod { smProduct, smIsometric, smEmbedded, smLie, smGeodesic };
enum eEmbeddedShiftMethodChoice { smcNone, smcBoth, smcAuto }; enum eEmbeddedShiftMethodChoice { smcNone, smcBoth, smcAuto };
enum eShiftMethodApplication { smaManualCamera, smaAutocenter, smaObject, smaWallRadar };
#endif #endif
EX eEmbeddedShiftMethodChoice embedded_shift_method_choice = smcBoth; EX eEmbeddedShiftMethodChoice embedded_shift_method_choice = smcBoth;
EX bool use_embedded_shift(bool automatic) { EX bool use_embedded_shift(eShiftMethodApplication sma) {
if(automatic) return embedded_shift_method_choice; switch(sma) {
return embedded_shift_method_choice == smcBoth; 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(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(!nonisotropic && !stretch::in()) return smIsometric;
if(!nisot::geodesic_movement && !embedded_plane) return smLie; if(!nisot::geodesic_movement && !embedded_plane) return smLie;
return smGeodesic; 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) { switch(sm) {
case smGeodesic: case smGeodesic:
return nisot::parallel_transport(Position, direction); 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); Position = shift_object(Position, orientation, direction, sm);
} }

View File

@ -2115,9 +2115,9 @@ EX void centerpc(ld aspd) {
if(R < aspd) fix_whichcopy_if_near(); if(R < aspd) fix_whichcopy_if_near();
if(R < aspd) if(R < aspd)
shift_view_to(shiftless(H), shift_method(true)); shift_view_to(shiftless(H), shift_method(smaAutocenter));
else else
shift_view_towards(shiftless(H), aspd, shift_method(true)); shift_view_towards(shiftless(H), aspd, shift_method(smaAutocenter));
fixmatrix(View); fixmatrix(View);
fixmatrix(current_display->which_copy); fixmatrix(current_display->which_copy);
@ -3207,7 +3207,7 @@ EX hyperpoint lie_log(hyperpoint h) {
} }
/** shift the view according to the given tangent vector */ /** 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) { switch(sm) {
case smProduct: case smProduct:
return rgpushxto0(direct_exp(lp_iapply(H))) * V; 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 */ /** 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; if(callhandlers(false, hooks_shift_view, H)) return;
static bool recursive = false; static bool recursive = false;
if(!recursive && intra::in) { if(!recursive && intra::in) {
@ -3310,7 +3310,7 @@ EX transmatrix map_relative_push(hyperpoint h) {
return rgpushxto0(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) { switch(sm) {
case smIsometric: case smIsometric:
case smEmbedded: 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) { switch(sm) {
case smIsometric: case smIsometric:
case smEmbedded: case smEmbedded: