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

Fix SoftBody3D for double-precision builds #88402

Merged
merged 1 commit into from
Feb 16, 2024

Conversation

mihe
Copy link
Contributor

@mihe mihe commented Feb 16, 2024

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 broke SoftBody3D for precision=double builds entirely.

The issue is that #81298 changed the memcpy that happens in PhysicsServer3DRenderingServerHandler::set_vertex to copy the incoming vertex position by sizeof(Vector3), which obviously changes depending on the precision of the build, but the vertex buffer itself is always single-precision, leading to the memcpy writing nonsense (and eventually onto the normals part of the vertex buffer) in precision=double builds, which in turn leads to the mesh "exploding" as soon as the SoftBody3D updates the rendering server with the new particle positions.

This PR fixes this by explicitly casting each vector component to float instead of doing a memcpy.

@mihe mihe requested a review from a team as a code owner February 16, 2024 14:53
@Mickeon Mickeon added this to the 4.3 milestone Feb 16, 2024
Copy link
Contributor

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@mihe
Copy link
Contributor Author

mihe commented Feb 16, 2024

This would probably also be a good thing to cherry-pick to the 4.2 branch if/when merged.

@dsnopek dsnopek added the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Feb 16, 2024
@akien-mga akien-mga merged commit d094b86 into godotengine:master Feb 16, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@mihe mihe deleted the double-soft-body branch February 16, 2024 23:49
@akien-mga
Copy link
Member

Cherry-picked for 4.2.2.

@akien-mga akien-mga removed the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants