summaryrefslogtreecommitdiffstats
path: root/src/vehicles/HandlingMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vehicles/HandlingMgr.cpp')
-rw-r--r--src/vehicles/HandlingMgr.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/vehicles/HandlingMgr.cpp b/src/vehicles/HandlingMgr.cpp
index 3ac6f057..00aaa682 100644
--- a/src/vehicles/HandlingMgr.cpp
+++ b/src/vehicles/HandlingMgr.cpp
@@ -143,7 +143,7 @@ cHandlingDataMgr::LoadHandlingData(void)
case 11: handling->fTractionBias = strtod(word, nil); break;
case 12: handling->Transmission.nNumberOfGears = atoi(word); break;
case 13: handling->Transmission.fMaxVelocity = strtod(word, nil); break;
- case 14: handling->Transmission.fEngineAcceleration = strtod(word, nil) * 0.4f; break;
+ case 14: handling->Transmission.fEngineAcceleration = strtod(word, nil) * 0.4; break;
case 15: handling->Transmission.nDriveType = word[0]; break;
case 16: handling->Transmission.nEngineType = word[0]; break;
case 17: handling->fBrakeDeceleration = strtod(word, nil); break;
@@ -191,7 +191,7 @@ void
cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling)
{
// acceleration is in ms^-2, but we need mf^-2 where f is one frame time (50fps)
- float velocity, a, b, specificVolume;
+ float velocity, a, b;
handling->Transmission.fEngineAcceleration *= 1.0f/(50.0f*50.0f);
handling->Transmission.fMaxVelocity *= 1000.0f/(60.0f*60.0f * 50.0f);
@@ -202,21 +202,27 @@ cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling)
handling->fInvMass = 1.0f/handling->fMass;
handling->fBuoyancy = 100.0f/handling->nPercentSubmerged * GRAVITY*handling->fMass;
- // What the hell is going on here?
- specificVolume = handling->Dimension.x*handling->Dimension.z*0.5f / handling->fMass; // ?
+ // Don't quite understand this. What seems to be going on is that
+ // we calculate a drag (air resistance) deceleration for a given velocity and
+ // find the intersection between that and the max engine acceleration.
+ // at that point the car cannot accelerate any further and we've found the max velocity.
a = 0.0f;
b = 100.0f;
velocity = handling->Transmission.fMaxVelocity;
while(a < b && velocity > 0.0f){
velocity -= 0.01f;
+ // what's the 1/6?
a = handling->Transmission.fEngineAcceleration/6.0f;
- b = -velocity * (1.0f/(specificVolume * sq(velocity) + 1.0f) - 1.0f);
+ // no density or drag coefficient here...
+ float a_drag = 0.5f*SQR(velocity) * handling->Dimension.x*handling->Dimension.z / handling->fMass;
+ // can't make sense of this... maybe v - v/(drag + 1) ? but that doesn't make so much sense either
+ b = -velocity * (1.0f/(a_drag + 1.0f) - 1.0f);
}
if(handling->nIdentifier == HANDLING_RCBANDIT){
- handling->Transmission.fUnkMaxVelocity = handling->Transmission.fMaxVelocity;
+ handling->Transmission.fMaxCruiseVelocity = handling->Transmission.fMaxVelocity;
}else{
- handling->Transmission.fUnkMaxVelocity = velocity;
+ handling->Transmission.fMaxCruiseVelocity = velocity;
handling->Transmission.fMaxVelocity = velocity * 1.2f;
}
handling->Transmission.fMaxReverseVelocity = -0.2f;