Allow other routines to increment/decrement goal_view_offset while keeping it
in the allowable 0-360 range.
This commit is contained in:
parent
297241c318
commit
4520173d9b
2 changed files with 19 additions and 2 deletions
|
@ -180,8 +180,19 @@ getGoalViewOffset ()
|
||||||
static void
|
static void
|
||||||
setGoalViewOffset (double offset)
|
setGoalViewOffset (double offset)
|
||||||
{
|
{
|
||||||
globals->get_current_view()
|
while ( offset < 0 ) {
|
||||||
->set_goal_view_offset(offset * SGD_DEGREES_TO_RADIANS);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue