Repository navigation
Mover queries hand their visitors planes and segments of their own - #98
Merged
Merged
Conversation
…of their own collide_mover passed its visitor the per-worker mover-plane scratch, and body_collide_mover wrote into the same block; cast_mover's proxy pointed at the per-worker segment scratch, which body_time_of_impact_mover and any nested cast_mover rewrote. A visitor or filter that queried the mover again -- a character checking a moving platform mid-query -- found the outer query's planes (or the capsule it was sweeping) silently replaced. The reference keeps them on each call's stack. Now: - collide_mover gives its visitor a planes block of its own, allocated for the query and freed after it; - cast_mover keeps the segment in its context and points the proxy there; - body_collide_mover writes each plane straight into the caller's result. The shared plane scratch is gone (test_physics_world's permanent allocations drop by one). test_mover_world's test_nested_mover_queries: a visitor asking a platform body for its plane mid-query keeps its own plane (on main it reads the platform's). Found by an audit of the mover and the height field against Box3D e77352c, which found them otherwise faithful.
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.
I audited the character mover and the height field against Box3D
e77352c. Both match upstream line for line, apart from one reentrancy hazard, which this fixes.The hazard:
collide_moverpassed its visitor the per-worker mover-plane scratch block, andbody_collide_moverwrote into that same block.cast_mover's proxy pointed at the per-worker segment scratch, whichbody_time_of_impact_moverand any nestedcast_moverrewrote.So a visitor or filter that queried the mover again (a character checking a moving platform mid-query, say) found the outer query's planes, or the capsule it was sweeping, silently replaced. Upstream keeps them on each call's stack.
The fix:
collide_movergives its visitor a planes block of its own, allocated for the query and freed after it.cast_moverkeeps the segment in its own context and points the proxy there.body_collide_moverwrites each plane straight into the caller's result.The shared plane scratch is gone, so
test_physics_world's count of permanent allocations drops by one.test_mover_world's newtest_nested_mover_querieshas a visitor ask a platform body for its plane mid-query and checks its own plane is unchanged. On main it reads the platform's plane instead.All 28 test programs pass locally on aether 0.772.0, with no warnings.