Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-05-10 21:44:58 +0000
committerStijn Buys <ingar@osirion.org>2008-05-10 21:44:58 +0000
commit17e9ce54ee3972b9804174b874652ec0856efcd0 (patch)
tree33ec140d65fdcf42a467e3903647efc1be0d4e02 /src/game
parentd3afb677b6ea5942c042b8a83aa5d9ace1dec787 (diff)
interpolation & oscilating debugging
Diffstat (limited to 'src/game')
-rw-r--r--src/game/ship.cc33
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);