]> git.mxchange.org Git - flightgear.git/commitdiff
Allow other routines to increment/decrement goal_view_offset while keeping it
authorcurt <curt>
Sun, 8 Jul 2001 23:37:14 +0000 (23:37 +0000)
committercurt <curt>
Sun, 8 Jul 2001 23:37:14 +0000 (23:37 +0000)
in the allowable 0-360 range.

src/Main/fg_props.cxx
src/Main/viewer.hxx

index 9c0bdb66d33e04c6c28133b1e558dcb85cb1939d..32b3f624af0d7edc29a5c61123894a2d4f6181f6 100644 (file)
@@ -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);
 }
 
 
index 4e74425f0896ef0864420f6b33408e806db6c15f..107401a373fa572b73e82251c09718a63caaa104 100644 (file)
@@ -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;