1
0
Fork 0
Commit Graph

19 Commits

Author SHA1 Message Date
Jorrit Rouwe 09fcaa7db4 Fixed crash when rendering a soft body 3d
When a mesh is provided that has vertices that are not referenced by any face, these vertices will be discarded. In the internal 'mesh_to_physics' map, this led to uninitialized data which could result in a crash. Now we initialize the map with -1 and report an error when users try to manipulate these vertices.

Fixes #109883
2025-08-24 15:38:11 +02:00
Adam Simpkins cb25b933e7 Document some deadlocks in the physics server code
Add some comments documenting locations where
PhysicsServer3D::soft_body_set_mesh() can deadlock.

godotengine/godot-proposals#12670 has a proposal for some alternate
thread-safe soft body APIs.  In the meantime it seems worth at least
documenting some of the current pitfalls in the code.
2025-07-13 13:44:48 -07:00
Adam Simpkins 71e3a229f6 Jolt physics: wake up a soft body when its transform changes
This updates `JoltSoftBody3D::set_transform()` to wake up the
soft body after changing the transform.

Previously, if you had a soft body that was sleeping in a steady state
on a ground plane, and you then translated it upwards by 1 meter it
would just hang in the air.  Now it falls to the ground correctly.

Issue #108090 has some details and an MRP (although that issue is mostly
about other problems in SoftBody3D iteself).
2025-06-28 16:34:51 -07:00
Rémi Verschelde f97c51132e
Merge pull request #107832 from simpkins/soft_body_normals
Fix Jolt Physics soft body vertex normal calculation
2025-06-28 13:03:01 +02:00
Adam Simpkins dd80a3aa19 Fix jolt_physics soft body vertex normal calculation
The code previously iterated through each face and set all vertices to
that face's normal.  This resulted in each vertex getting the normal
from just one face that it belonged to (whichever face was last in this
array).  This caused weird shading artifacts.

This fixes the code so that the vertex normal is now the average normal
of all faces that it belongs to.  This results in "smooth shading"
behavior for soft body meshes.  This is still somewhat undesirable if
the input mesh was using flat shading, but it looks less bad than the
previous behavior of picking a normal at random from one attached face.

This matches the behavior of GodotPhysicsServer3D.

Fixes #107831.
2025-06-27 17:04:15 -07:00
Mikael Hermansson 50e24e24ed Fix crash when disabling `SoftBody3D` while using Jolt Physics 2025-06-27 12:52:47 +02:00
Mikael Hermansson 89f9a23d9e Batch the adding of Jolt Physics bodies
Co-authored-by: Jorrit Rouwe <jrouwe@gmail.com>
2025-06-14 14:11:07 +02:00
Thaddeus Crews 05ceab6b7b
Merge pull request #106321 from elzewyr/shrink-factor
SoftBody3D: Add a property for scaling rest lengths of edge constraints
2025-05-27 09:39:29 -05:00
Thaddeus Crews de2cd663fd
Merge pull request #100463 from PiCode9560/softbody-apply-force-and-impulse
Add ability to apply forces and impulses to `SoftBody3D`
2025-05-26 11:24:45 -05:00
PiCode fe3aaa2ae3 Add functions to apply impulse and force to SoftBody on GodotPhysics and JoltPhysics 2025-05-23 22:04:52 +03:00
Mikael Hermansson d153a267b0 Remove error for degenerate soft body faces when using Jolt Physics 2025-05-22 20:17:47 +02:00
Elzewyr 9f67bf96fa SoftBody3D: Add a property for scaling rest lengths of edge constraints 2025-05-16 18:38:00 +03:00
Jorrit Rouwe c529f36532 Jolt physics: Setting position instead of velocity in JoltSoftBody3D::set_vertex_position
This fixes a discrepancy between godot physics and Jolt physics where in Jolt a vertex pinned to a body only gets its velocity updated while in godot it gets its position updated. This causes it to lag one frame behind.

Fixes #106301
2025-05-13 22:45:58 +02:00
Mikael Hermansson 2b88477efc Remove no-op locking in Jolt Physics module 2025-04-29 12:23:24 +02:00
Thaddeus Crews 768d75a248
Merge pull request #101254 from mihe/jolt/better-settings
Refactor Jolt-related project settings to only be loaded as needed
2025-03-13 08:57:43 -05:00
Mikael Hermansson 1006fa9c42 Skip `Object::to_string` when Jolt Physics is on separate thread 2025-02-11 22:55:32 +01:00
Mikael Hermansson 3b78ff564a Refactor Jolt-related project settings to only be loaded as needed 2025-01-25 12:18:52 +01:00
Mikael Hermansson 7beaddc9c0 Improve performance with many static/sleeping bodies when using Jolt Physics 2025-01-01 21:30:02 +01:00
Mikael Hermansson d470c2ac6a Add Jolt Physics as an alternative 3D physics engine
Co-authored-by: Jorrit Rouwe <jrouwe@gmail.com>
2024-12-11 13:57:25 +01:00