1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 03:12:36 +01:00

rwgame: Adapt the friction slip based on handling data to ease steering

A constant friction slip for all vehicles does not seem to work very
well and most are rather hard to steer with. This introduces a somewhat
empirical formula to get a rather sane friction slip value based on
handling data, where coefficients are used in a way compatible with the
required friction slip value for most vehicles.

This is by far not a perfect approach and the steering on some vehicles
still feels out of line with the realistic expected behaviour, but most
remain fairly drivable.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
This commit is contained in:
Paul Kocialkowski 2018-08-02 21:36:36 +02:00
parent e3e8b3acb9
commit 17b6c13a6a

View File

@ -104,7 +104,20 @@ VehicleObject::VehicleObject(GameWorld* engine, const glm::vec3& pos,
float travel = fabs(info->handling.suspensionUpperLimit -
info->handling.suspensionLowerLimit);
tuning.m_frictionSlip = 3.f;
float maxVelocity = info->handling.maxVelocity;
float accelerationFloor = std::max(info->handling.acceleration, 30.f);
float massFloor = std::min(info->handling.mass, 3000.f);
// The friction slip represents the friction coefficient between each wheel
// and the ground. The higher the coefficient, the more slippery the contact
// gets between the wheel and the ground. Fast vehicles (with a significant
// acceleration and max speed for a low mass) tend to need a high
// coefficient (> 5.f) to allow properly turning when steering. On the other
// hand, slow vehicles tend to need a lower coefficient or they will be too
// reactive when turning. This (purely empirical) formula is an attempt to
// apply this idea, with floors to avoid too much divergence.
// For some reason, the calculation with handling info gives us a value in
// the right range, with an offset to set a sane base.
tuning.m_frictionSlip = 1.8f + maxVelocity * accelerationFloor / massFloor;
tuning.m_maxSuspensionTravelCm = travel * 100.f;
physVehicle =