From 988161d7dd2a62a67de2415b558575cfec3e057f Mon Sep 17 00:00:00 2001 From: PiCode <122909224+PiCode9560@users.noreply.github.com> Date: Fri, 27 Dec 2024 14:49:46 +0300 Subject: [PATCH] Update SoftBodyMotionProperties.cpp --- modules/jolt_physics/objects/jolt_soft_body_3d.cpp | 2 -- .../Jolt/Physics/SoftBody/SoftBodyMotionProperties.cpp | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/jolt_physics/objects/jolt_soft_body_3d.cpp b/modules/jolt_physics/objects/jolt_soft_body_3d.cpp index c7fc714a65f9..21bacf7111bc 100644 --- a/modules/jolt_physics/objects/jolt_soft_body_3d.cpp +++ b/modules/jolt_physics/objects/jolt_soft_body_3d.cpp @@ -528,8 +528,6 @@ void JoltSoftBody3D::apply_central_force(const Vector3 &p_force) { return; } - wake_up(); - JPH::BodyInterface &body_iface = space->get_body_iface(); const JPH::Vec3 force = to_jolt(p_force); diff --git a/thirdparty/jolt_physics/Jolt/Physics/SoftBody/SoftBodyMotionProperties.cpp b/thirdparty/jolt_physics/Jolt/Physics/SoftBody/SoftBodyMotionProperties.cpp index 78eacd485a96..80871375e1c6 100644 --- a/thirdparty/jolt_physics/Jolt/Physics/SoftBody/SoftBodyMotionProperties.cpp +++ b/thirdparty/jolt_physics/Jolt/Physics/SoftBody/SoftBodyMotionProperties.cpp @@ -315,7 +315,7 @@ void SoftBodyMotionProperties::IntegratePositions(const SoftBodyUpdateContext &i // Integrate Vec3 sub_step_gravity = inContext.mGravity * dt; - Vec3 sub_step_impulse = GetAccumulatedForce() * dt; + Vec3 sub_step_impulse = GetAccumulatedForce() * dt / max(float(mVertices.size()), 1.0f); for (Vertex &v : mVertices) if (v.mInvMass > 0.0f) { @@ -765,7 +765,7 @@ void SoftBodyMotionProperties::UpdateSoftBodyState(SoftBodyUpdateContext &ioCont // Calculate linear/angular velocity of the body by averaging all vertices and bringing the value to world space float num_vertices_divider = float(max(int(mVertices.size()), 1)); - SetLinearVelocity(ioContext.mCenterOfMassTransform.Multiply3x3(linear_velocity / num_vertices_divider)); + SetLinearVelocityClamped(ioContext.mCenterOfMassTransform.Multiply3x3(linear_velocity / num_vertices_divider)); SetAngularVelocity(ioContext.mCenterOfMassTransform.Multiply3x3(angular_velocity / num_vertices_divider)); if (mUpdatePosition)