Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change VehicleWheel3D suspension travel to use meters internally #75610

Merged
merged 1 commit into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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