Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/ship.cc36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/game/ship.cc b/src/game/ship.cc
index af98513..9a7c059 100644
--- a/src/game/ship.cc
+++ b/src/game/ship.cc
@@ -52,10 +52,13 @@ void Ship::frame(float seconds)
} else if (current_target_pitch > target_pitch) {
current_target_pitch -= direction_change_speed * seconds;
}
- math::clamp(current_target_pitch, -1.0f, 1.0f);
- float pitch_offset = seconds * current_target_pitch;
- if (pitch_offset)
+ if (fabs(current_target_pitch) < 0.005f) {
+ current_target_pitch = 0.0f;
+ } else {
+ math::clamp(current_target_pitch, -1.0f, 1.0f);
+ float pitch_offset = seconds * current_target_pitch;
entity_axis.change_pitch(360.0f * ship_shipmodel->turnspeed() * pitch_offset);
+ }
// update direction
math::clamp(target_direction, -1.0f, 1.0f);
@@ -64,10 +67,13 @@ void Ship::frame(float seconds)
} else if (current_target_direction > target_direction) {
current_target_direction -= direction_change_speed * seconds;
}
- math::clamp(current_target_direction, -1.0f, 1.0f);
- float direction_offset = seconds * current_target_direction;
- if (direction_offset)
+ if (fabs(current_target_direction) < 0.005f) {
+ current_target_direction = 0.0f;
+ } else {
+ math::clamp(current_target_direction, -1.0f, 1.0f);
+ float direction_offset = seconds * current_target_direction;
entity_axis.change_direction(360.0f * ship_shipmodel->turnspeed() * direction_offset);
+ }
// update roll
math::clamp(target_roll, -1.0f, 1.0f);
@@ -76,10 +82,13 @@ void Ship::frame(float seconds)
} else if (current_target_roll > target_roll) {
current_target_roll -= direction_change_speed * seconds;
}
- math::clamp(current_target_roll, -1.0f, 1.0f);
- float roll_offset = seconds * current_target_roll;
- if (roll_offset)
+ if (fabs(current_target_roll) < 0.005f) {
+ current_target_roll = 0.0f;
+ } else {
+ math::clamp(current_target_roll, -1.0f, 1.0f);
+ float roll_offset = seconds * current_target_roll;
entity_axis.change_roll(360.0f * ship_shipmodel->turnspeed() * roll_offset);
+ }
// update speed
if (entity_speed < entity_thrust * ship_shipmodel->maxspeed()) {
@@ -92,9 +101,12 @@ void Ship::frame(float seconds)
if (entity_speed < 0.0f) entity_speed = 0.0f;
}
- entity_location += entity_axis.forward() * entity_speed * seconds;
-
- entity_dirty = true;
+ if (entity_speed != 0.0f) {
+ entity_location += entity_axis.forward() * entity_speed * seconds;
+ entity_dirty = true;
+ } else if ((current_target_pitch != 0.0f) || (current_target_direction != 0.0f) || (current_target_roll != 0.0f)) {
+ entity_dirty = true;
+ }
}
} // namespace game