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/base/game.cc8
-rw-r--r--src/game/base/ship.cc5
-rw-r--r--src/game/base/shipmodel.cc16
-rw-r--r--src/game/base/shipmodel.h29
4 files changed, 53 insertions, 5 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index c171711..7ed01e1 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -461,6 +461,7 @@ void Game::func_specs(core::Player *player, const std::string &args)
con_print << " ^Nradius = ^B" << ship->radius() << std::endl;
con_print << " ^Ncargo = ^B" << ship->inventory()->capacity() << std::endl;
con_print << "Engines:" << std::endl;
+ con_print << " ^Ndamping = ^B" << ship->body()->getLinearDamping() << " " << ship->body()->getAngularDamping() << std::endl;
con_print << " ^Nthrust = ^B" << ship->thrust_force() << std::endl;
con_print << " ^Nimpulse = ^B" << ship->impulse_force() << std::endl;
con_print << " ^Nstrafe = ^B" << ship->strafe_force() << std::endl;
@@ -502,6 +503,13 @@ void Game::func_specs(core::Player *player, const std::string &args)
} else if (str.compare("roll") == 0) {
ship->set_roll_force(value);
msgstr << "Ship roll force set to " << value;
+
+ } else if (str.compare("damping") == 0) {
+ float a;
+ if (!(is >> a)) {
+ a = value;
+ }
+ ship->body()->setDamping(value, a);
} else {
msgstr << "^WUnknown ship engine specification '" << str << "'";
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 40b7812..86a467b 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -92,9 +92,7 @@ Ship::Ship(core::Player *owner, const ShipModel *shipmodel) : core::EntityContro
// initialize physics
reset();
- const float linear_damp = 0.8f;
- const float angular_damp = 0.8f;
- body()->setDamping(linear_damp, angular_damp);
+ body()->setDamping(ship_shipmodel->linear_damping(), ship_shipmodel->angular_damping());
}
Ship::~Ship()
@@ -370,7 +368,6 @@ void Ship::frame(float seconds)
math::Vector3f n; // normal of a plane
math::Axis target_axis(axis()); // target axis
- entity_movement = 0;
/* -- update state ----------------------------------------- */
diff --git a/src/game/base/shipmodel.cc b/src/game/base/shipmodel.cc
index 4d5db69..126557c 100644
--- a/src/game/base/shipmodel.cc
+++ b/src/game/base/shipmodel.cc
@@ -116,6 +116,20 @@ bool ShipModel::init()
} else if (inifile.got_key_float("radius", f)) {
shipmodel->set_radius(f);
continue;
+ } else if (inifile.got_key_string("damping", str)) {
+ float linear, angular;
+ std::istringstream sstr("str");
+ if (sstr >> linear) {
+ if (sstr >> angular) {
+ shipmodel->set_linear_damping(linear);
+ shipmodel->set_angular_damping(angular);
+ } else {
+ shipmodel->set_linear_damping(linear);
+ shipmodel->set_angular_damping(linear);
+ }
+ } else {
+ inifile.unknown_value();
+ }
} else if (inifile.got_key_label("template", str)) {
Template *entitytemplate = Template::find(str);
if (!entitytemplate) {
@@ -184,6 +198,8 @@ ShipModel::ShipModel() : core::Info(shipmodel_infotype)
//default specifications
shipmodel_radius = 0.0f;
shipmodel_mass = 0.0f;
+ shipmodel_linear_damping = 0.8f;
+ shipmodel_angular_damping = 0.8f;
shipmodel_thrust_force = 0.8f;
shipmodel_impulse_force = 4.0f;
diff --git a/src/game/base/shipmodel.h b/src/game/base/shipmodel.h
index bbb5798..f790bcd 100644
--- a/src/game/base/shipmodel.h
+++ b/src/game/base/shipmodel.h
@@ -70,6 +70,16 @@ public:
return shipmodel_roll_force;
}
+ /// linear damping factor
+ inline const float linear_damping() const {
+ return shipmodel_linear_damping;
+ }
+
+ /// angular damping factor
+ inline const float angular_damping() const {
+ return shipmodel_angular_damping;
+ }
+
/// maximum thrust speed
inline const float maxspeed() const {
return shipmodel_maxspeed;
@@ -127,7 +137,7 @@ protected:
shipmodel_strafe_force = strafe;
}
- /// set turn force
+ /// set turn forceshipmodel_lineardamping
inline void set_turn_force(const float turn) {
shipmodel_turn_force = turn;
}
@@ -167,6 +177,20 @@ protected:
shipmodel_template = model_template;
}
+ /**
+ * @brief set physics linear damping factor
+ */
+ inline void set_linear_damping(const float linear_damping) {
+ shipmodel_linear_damping = linear_damping;
+ }
+
+ /**
+ * @brief set physics linear damping factor
+ */
+ inline void set_angular_damping(const float angular_damping) {
+ shipmodel_angular_damping = angular_damping;
+ }
+
public:
void generate_info();
@@ -193,6 +217,9 @@ private:
float shipmodel_radius;
float shipmodel_mass;
+ float shipmodel_linear_damping;
+ float shipmodel_angular_damping;
+
float shipmodel_impulse_force;
float shipmodel_thrust_force;
float shipmodel_strafe_force;