Skip to content

Fix crash in Jolt Physics when switching scenes in editor #108239

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

Merged
merged 1 commit into from
Jul 4, 2025

Conversation

mihe
Copy link
Contributor

@mihe mihe commented Jul 3, 2025

This fixes the crash (and performance degradation) shown in this MRP, and arguably fixes the most pressing part about #107951, but does not fix the issue as a whole.

This makes it so that Jolt's broad phase gets cleaned up (i.e. quadtree nodes made available) whenever a scene is emptied out completely, like it is when switching scenes in the editor, meaning we get a full "reset" on such scene switches, which should prevent us from running out of broad phase nodes and crashing.

This also cherrypicks jrouwe/JoltPhysics#1682 in order to fix a bug in JPH::PhysicsSystem::OptimizeBroadPhase that would otherwise prevent this from working.

CC @jrouwe

@mihe mihe added this to the 4.5 milestone Jul 3, 2025
@mihe mihe requested review from a team as code owners July 3, 2025 15:03
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Code looks good to me.

@Repiteo Repiteo merged commit 8f81661 into godotengine:master Jul 4, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jul 4, 2025

Thanks!

@mihe mihe deleted the jolt/scene-switch-crash branch July 7, 2025 08:30
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