Merge pull request #75610 from aaronfranke/sus-travel-m

Change VehicleWheel3D suspension travel to use meters internally
This commit is contained in:
Rémi Verschelde 2023-04-05 12:03:23 +02:00
commit e0bff2fa06
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 5 additions and 5 deletions

View File

@ -160,11 +160,11 @@ real_t VehicleWheel3D::get_suspension_rest_length() const {
}
void VehicleWheel3D::set_suspension_travel(real_t p_length) {
m_maxSuspensionTravelCm = p_length / 0.01;
m_maxSuspensionTravel = p_length;
}
real_t VehicleWheel3D::get_suspension_travel() const {
return m_maxSuspensionTravelCm * 0.01;
return m_maxSuspensionTravel;
}
void VehicleWheel3D::set_suspension_stiffness(real_t p_value) {
@ -429,8 +429,8 @@ real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState3D *s) {
wheel.m_raycastInfo.m_suspensionLength = hitDistance - wheel.m_wheelRadius;
//clamp on max suspension travel
real_t minSuspensionLength = wheel.m_suspensionRestLength - wheel.m_maxSuspensionTravelCm * real_t(0.01);
real_t maxSuspensionLength = wheel.m_suspensionRestLength + wheel.m_maxSuspensionTravelCm * real_t(0.01);
real_t minSuspensionLength = wheel.m_suspensionRestLength - wheel.m_maxSuspensionTravel;
real_t maxSuspensionLength = wheel.m_suspensionRestLength + wheel.m_maxSuspensionTravel;
if (wheel.m_raycastInfo.m_suspensionLength < minSuspensionLength) {
wheel.m_raycastInfo.m_suspensionLength = minSuspensionLength;
}

View File

@ -50,7 +50,7 @@ class VehicleWheel3D : public Node3D {
Vector3 m_wheelAxleCS; // const or modified by steering
real_t m_suspensionRestLength = 0.15;
real_t m_maxSuspensionTravelCm = 20.0;
real_t m_maxSuspensionTravel = 0.2;
real_t m_wheelRadius = 0.5;
real_t m_suspensionStiffness = 5.88;