1
0
Fork 0

Allow other routines to increment/decrement goal_view_offset while keeping it

in the allowable 0-360 range.
This commit is contained in:
curt 2001-07-08 23:37:14 +00:00
parent 297241c318
commit 4520173d9b
2 changed files with 19 additions and 2 deletions

View file

@ -180,6 +180,17 @@ getGoalViewOffset ()
static void static void
setGoalViewOffset (double offset) setGoalViewOffset (double offset)
{ {
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() globals->get_current_view()
->set_goal_view_offset(offset * SGD_DEGREES_TO_RADIANS); ->set_goal_view_offset(offset * SGD_DEGREES_TO_RADIANS);
} }

View file

@ -142,6 +142,12 @@ public:
inline void set_goal_view_offset( double a) { inline void set_goal_view_offset( double a) {
set_dirty(); set_dirty();
goal_view_offset = a; 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 ) { inline void set_reverse_view_offset( bool val ) {
reverse_view_offset = val; reverse_view_offset = val;