diff --git a/src/drivers/simplix/src/unitdriver.cpp b/src/drivers/simplix/src/unitdriver.cpp index 325829fe2..c1917785a 100644 --- a/src/drivers/simplix/src/unitdriver.cpp +++ b/src/drivers/simplix/src/unitdriver.cpp @@ -319,6 +319,7 @@ TDriver::TDriver(int Index): oRepairNeeded(0.0), oSideReduction(1.0), oLastSideReduction(1.0), + oAirBrakeLatchTime(0.0), oMinDistLong(FLT_MAX), oSlowRadius(1.0), @@ -1478,10 +1479,13 @@ void TDriver::Drive() } else { - if (oAbsDriftAngle < PI/64) - oWingAngleRear = oWingAngleRearMax; - else - oWingAngleRear = oWingAngleRearBrake; + if (oAirBrakeLatchTime == 0) + { + if (oAbsDriftAngle < PI/64) + oWingAngleRear = oWingAngleRearMax; + else + oWingAngleRear = oWingAngleRearBrake; + } } } @@ -1526,8 +1530,21 @@ void TDriver::Drive() if (oWingControl) { - if (oBrake > 0.25) - oWingAngleRear = oWingAngleRearBrake; + if (oWingAngleRear != oWingAngleRearBrake) + { + if ((oBrake > 0.25) && (oCurrSpeed > 180/3.6f)) + { + oWingAngleRear = oWingAngleRearBrake; + oAirBrakeLatchTime = 0.5; + } + } + else + { + if ((oBrake > 0.25) && (oCurrSpeed > 100/3.6f)) + { + oAirBrakeLatchTime = 0.5; + } + } } // Keep history @@ -1917,6 +1934,8 @@ void TDriver::Update(tCarElt* Car, tSituation* S) oCar = Car; // Update pointers oSituation = S; + oAirBrakeLatchTime = MAX(0, oAirBrakeLatchTime - oSituation->deltaTime); + // Shortcuts oCurrSpeed = myhypot(CarSpeedLong, CarSpeedLat); // Save currend speed if (fabs(oCurrSpeed) < 1) // At slow speeds use diff --git a/src/drivers/simplix/src/unitdriver.h b/src/drivers/simplix/src/unitdriver.h index f5efc014b..e3917c6e1 100644 --- a/src/drivers/simplix/src/unitdriver.h +++ b/src/drivers/simplix/src/unitdriver.h @@ -366,6 +366,8 @@ private: double oRepairNeeded; float oSideReduction; float oLastSideReduction; + double oAirBrakeLatchTime; + double oMinDistLong; float oSlowRadius;