]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/YASim/Gear.cpp
Add support for a turbo prop condition lever.
[flightgear.git] / src / FDM / YASim / Gear.cpp
index cc27877fdba4064e0b082f794c7becc9a43e6b1e..51492dcfac9d98dcd6b7cfc473323e7fc521020e 100644 (file)
@@ -11,11 +11,12 @@ Gear::Gear()
        _pos[i] = _cmpr[i] = 0;
     _spring = 1;
     _damp = 0;
-    _sfric = 0.8;
-    _dfric = 0.7;
+    _sfric = 0.8f;
+    _dfric = 0.7f;
     _brake = 0;
     _rot = 0;
     _extension = 1;
+    _castering = false;
 }
 
 void Gear::setPosition(float* position)
@@ -65,6 +66,11 @@ void Gear::setExtension(float extension)
     _extension = Math::clamp(extension, 0, 1);
 }
 
+void Gear::setCastering(bool c)
+{
+    _castering = c;
+}
+
 void Gear::getPosition(float* out)
 {
     int i;
@@ -128,6 +134,11 @@ float Gear::getCompressFraction()
     return _frac;
 }
 
+bool Gear::getCastering()
+{
+    return _castering;
+}
+
 void Gear::calcForce(RigidBody* body, float* v, float* rot, float* ground)
 {
     // Init the return values
@@ -191,6 +202,10 @@ void Gear::calcForce(RigidBody* body, float* v, float* rot, float* ground)
     _wow = (fmag - damp) * -Math::dot3(cmpr, ground);
     Math::mul3(-_wow, ground, _force);
 
+    // Castering gear feel no force in the ground plane
+    if(_castering)
+       return;
+
     // Wheels are funky.  Split the velocity along the ground plane
     // into rolling and skidding components.  Assuming small angles,
     // we generate "forward" and "left" unit vectors (the compression
@@ -237,9 +252,9 @@ void Gear::calcForce(RigidBody* body, float* v, float* rot, float* ground)
 
 float Gear::calcFriction(float wgt, float v)
 {
-    // How slow is stopped?  50 cm/second?
-    const float STOP = 0.5;
-    const float iSTOP = 1/STOP;
+    // How slow is stopped?  10 cm/second?
+    const float STOP = 0.1f;
+    const float iSTOP = 1.0f/STOP;
     v = Math::abs(v);
     if(v < STOP) return v*iSTOP * wgt * _sfric;
     else         return wgt * _dfric;