From: curt Date: Sun, 8 Jul 2001 23:37:14 +0000 (+0000) Subject: Allow other routines to increment/decrement goal_view_offset while keeping it X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4520173d9be567eac7ca55e5a604a322b9b0e43d;p=flightgear.git Allow other routines to increment/decrement goal_view_offset while keeping it in the allowable 0-360 range. --- diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index 9c0bdb66d..32b3f624a 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -180,8 +180,19 @@ getGoalViewOffset () static void setGoalViewOffset (double offset) { - globals->get_current_view() - ->set_goal_view_offset(offset * SGD_DEGREES_TO_RADIANS); + while ( offset < 0 ) { + offset += 360.0; + } + while ( offset > 360.0 ) { + offset -= 360.0; + } + // Snap to center if we are close + if ( fabs( offset ) < 1.0 ) { + offset = 0.0; + } + + globals->get_current_view() + ->set_goal_view_offset(offset * SGD_DEGREES_TO_RADIANS); } diff --git a/src/Main/viewer.hxx b/src/Main/viewer.hxx index 4e74425f0..107401a37 100644 --- a/src/Main/viewer.hxx +++ b/src/Main/viewer.hxx @@ -142,6 +142,12 @@ public: inline void set_goal_view_offset( double a) { set_dirty(); goal_view_offset = a; + while ( goal_view_offset < 0 ) { + goal_view_offset += 360.0; + } + while ( goal_view_offset > 360.0 ) { + goal_view_offset -= 360.0; + } } inline void set_reverse_view_offset( bool val ) { reverse_view_offset = val;