Repository navigation
Fix crash when a physical component is removed from its own collision….. - #869
Closed
Paaanaaamaaa wants to merge 7 commits into
Closed
Paaanaaamaaa wants to merge 7 commits into
Paaanaaamaaa wants to merge 7 commits into
Conversation
added 7 commits
October 1, 2026 16:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes a crash caused by scripts removing an actor's physical component directly inside a collision or trigger callback
Cause: The callback fires mid-step inside Bullet's
stepSimulationandEvent::Invoke.Actor::RemoveComponentwas deleting the component immediately on the spot. This tore down itsPhysicalObject, its Bullet body, and the active event iterator while Bullet was still actively referencing them. In the editor, there was a second crash: the Inspector tried to draw another frame of widgets bound to the destroyed component because its UI refresh was delayed by a frame.Fix:
PhysicsEnginenow tracks when it's actively dispatching (IsDispatching()) and queues items for deferred destruction (DeferDestruction()), which gets flushed at the start of the nextUpdate()and in the destructor.Actor::RemoveComponentdetaches the component from the actor right away. If it's aCPhysicalObjectand physics is currently dispatching, a new private helper (Actor::ReleaseRemovedComponent) keeps it alive until the next flush.CPhysicalObject::MarkForRemoval()stops pending components from forwarding subsequent collision/trigger events to scripts.ComponentRemovedEventlistener now refreshes in the same frame (DelayAction(..., 0)), preventing it from drawing widgets for dead components.Scene::DestroyActorandScene::CollectGarbagesto stop them from running during physics dispatches.Related Issue(s)
Fixes #866
Review Guidance
OnCollisionExitfor the removed component.Screenshots/GIFs
N/A
AI Usage Disclosure
NA
Checklist