Fix SoftBody3D
for double-precision builds
#88402
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Forgive the issue-and-PR-rolled-into-one, but I figured this was pretty straight-forward.
It turns out that my previous PR (#81298) that changed the interface for
PhysicsServer3DRenderingServerHandler
also brokeSoftBody3D
forprecision=double
builds entirely.The issue is that #81298 changed the
memcpy
that happens inPhysicsServer3DRenderingServerHandler::set_vertex
to copy the incoming vertex position bysizeof(Vector3)
, which obviously changes depending on theprecision
of the build, but the vertex buffer itself is always single-precision, leading to thememcpy
writing nonsense (and eventually onto the normals part of the vertex buffer) inprecision=double
builds, which in turn leads to the mesh "exploding" as soon as theSoftBody3D
updates the rendering server with the new particle positions.This PR fixes this by explicitly casting each vector component to
float
instead of doing amemcpy
.