mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 18:32:44 +01:00
Make vehicle wheels steer smoothly
This commit is contained in:
parent
f06d9f5eb2
commit
7715dbaf6e
@ -262,14 +262,23 @@ void VehicleObject::tickPhysics(float dt) {
|
|||||||
physVehicle->setBrake(brakeReal * brakeF, w);
|
physVehicle->setBrake(brakeReal * brakeF, w);
|
||||||
|
|
||||||
if (wi.m_bIsFrontWheel) {
|
if (wi.m_bIsFrontWheel) {
|
||||||
float sign = std::signbit(steerAngle) ? -1.f : 1.f;
|
float currentVal = physVehicle->getSteeringValue(w);
|
||||||
physVehicle->setSteeringValue(
|
float currentSign = std::signbit(currentVal) ? -1.f : 1.f;
|
||||||
std::min(glm::radians(info->handling.steeringLock),
|
float newVal;
|
||||||
std::abs(steerAngle)) *
|
|
||||||
sign,
|
if (std::abs(steerAngle) < 0.001f) { // no steering?
|
||||||
w);
|
newVal = std::max(0.0f,std::abs(currentVal) - 4.f * dt) *
|
||||||
// physVehicle->setSteeringValue(std::min(3.141f/2.f,
|
currentSign;
|
||||||
// std::abs(steerAngle)) * sign, w);
|
} else {
|
||||||
|
newVal = currentVal + steerAngle * dt * 4.f;
|
||||||
|
|
||||||
|
float limit = glm::radians(info->handling.steeringLock);
|
||||||
|
|
||||||
|
if (std::abs(newVal) > limit)
|
||||||
|
newVal = limit * currentSign;
|
||||||
|
}
|
||||||
|
|
||||||
|
physVehicle->setSteeringValue(newVal,w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user