]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/performancedata.cxx
#248: support enabling AI module at run-time
[flightgear.git] / src / AIModel / performancedata.cxx
index 2a291967143962a41ea492819f2ed0d067426fe9..f8da70de615ac9c2566fa46b1bfeb0b84c2aead6 100644 (file)
@@ -6,6 +6,13 @@
 #include "performancedata.hxx"
 #include "AIAircraft.hxx"
 
+
+// For now, make this a define
+// Later on, additional class variables can simulate settings such as braking power
+// also, the performance parameters can be tweaked a little to add some personality
+// to the AIAircraft.
+#define BRAKE_SETTING 1.6
+
 PerformanceData::PerformanceData(double acceleration,
                                 double deceleration,
                                 double climbRate,
@@ -42,7 +49,7 @@ PerformanceData::PerformanceData( const std::string& filename)
 PerformanceData::~PerformanceData()
 {}
 
-double PerformanceData::actualSpeed(FGAIAircraft* ac, double tgt_speed, double dt) {
+double PerformanceData::actualSpeed(FGAIAircraft* ac, double tgt_speed, double dt, bool maxBrakes) {
     // if (tgt_speed > _vTaxi & ac->onGround()) // maximum taxi speed on ground
     //    tgt_speed = _vTaxi;
     // bad idea for a take off roll :-)
@@ -59,7 +66,13 @@ double PerformanceData::actualSpeed(FGAIAircraft* ac, double tgt_speed, double d
     } else if (speed_diff < 0.0) { // decelerate
         if (ac->onGround()) {
             // deceleration performance is better due to wheel brakes.
-            speed -= 3 * _deceleration * dt;
+            double brakePower = 0;
+            if (maxBrakes) {
+                brakePower = 3;
+            } else {
+                brakePower = BRAKE_SETTING;
+            }
+            speed -= brakePower * _deceleration * dt;
         } else {
             speed -= _deceleration * dt;
         }