diff options
author | Stijn Buys <ingar@osirion.org> | 2008-05-10 21:44:58 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-05-10 21:44:58 +0000 |
commit | 17e9ce54ee3972b9804174b874652ec0856efcd0 (patch) | |
tree | 33ec140d65fdcf42a467e3903647efc1be0d4e02 /src/game | |
parent | d3afb677b6ea5942c042b8a83aa5d9ace1dec787 (diff) |
interpolation & oscilating debugging
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/ship.cc | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/game/ship.cc b/src/game/ship.cc index 525bf71..5c36205 100644 --- a/src/game/ship.cc +++ b/src/game/ship.cc @@ -47,12 +47,17 @@ void Ship::frame(float seconds) // update pitch math::clamp(target_pitch, -1.0f, 1.0f); - if (current_target_pitch - target_pitch < 0) { + if (current_target_pitch < target_pitch) { current_target_pitch += direction_change_speed * seconds; - } else if (current_target_pitch - target_pitch > 0) { + if (current_target_pitch > target_pitch) + current_target_pitch = target_pitch; + } else if (current_target_pitch > target_pitch) { current_target_pitch -= direction_change_speed * seconds; + if (current_target_pitch < target_pitch) + current_target_pitch = target_pitch; } - if (fabs(current_target_pitch) < direction_change_speed * seconds) { + + if (fabs(seconds*current_target_pitch) < 0.00005f) { current_target_pitch = 0.0f; } else { math::clamp(current_target_pitch, -1.0f, 1.0f); @@ -62,12 +67,18 @@ void Ship::frame(float seconds) // update direction math::clamp(target_direction, -1.0f, 1.0f); - if (current_target_direction - target_direction < 0) { + if (current_target_direction < target_direction) { current_target_direction += direction_change_speed * seconds; - } else if (current_target_direction - target_direction > 0) { + if (current_target_direction > target_direction) { + current_target_direction = target_direction; + } + } else if (current_target_direction > target_direction) { current_target_direction -= direction_change_speed * seconds; + if (current_target_direction < target_direction) { + current_target_direction = target_direction; + } } - if (fabs(current_target_direction) < direction_change_speed * seconds) { + if (fabs(seconds*current_target_direction) < 0.00005f) { current_target_direction = 0.0f; } else { math::clamp(current_target_direction, -1.0f, 1.0f); @@ -77,12 +88,16 @@ void Ship::frame(float seconds) // update roll math::clamp(target_roll, -1.0f, 1.0f); - if (current_target_roll - target_roll < 0) { + if (current_target_roll < target_roll) { current_target_roll += direction_change_speed * seconds; - } else if (current_target_roll - target_roll > 0) { + if (current_target_roll > target_roll) + current_target_roll = target_roll; + } else if (current_target_roll > target_roll) { current_target_roll -= direction_change_speed * seconds; + if (current_target_roll < target_roll) + current_target_roll = target_roll; } - if (fabs(current_target_roll) < direction_change_speed * seconds) { + if (fabs(current_target_roll) < 0.00005f) { current_target_roll = 0.0f; } else { math::clamp(current_target_roll, -1.0f, 1.0f); |