Skip to content

Commit

Permalink
Merge pull request godotengine#75610 from aaronfranke/sus-travel-m
Browse files Browse the repository at this point in the history
Change VehicleWheel3D suspension travel to use meters internally
  • Loading branch information
akien-mga committed Apr 5, 2023
2 parents 4f30ca3 + dd0eb1a commit e0bff2f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions scene/3d/vehicle_body_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion scene/3d/vehicle_body_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e0bff2f

Please sign in to comment.