Repository navigation
World queries borrow their context instead of keeping it (#179) - #180
Merged
Merged
Conversation
cast_ray, cast_shape, cast_mover, overlap_aabb, overlap_shape and collide_mover declared context: @keep ptr only because the helper query_recorder took the context and returned it inside a QueryRecorder. None of them keeps the pointer: each lends its local recorder to the internal query for the call. The helper now builds the recorder without a context, and each query sets q.context on its own local, which Aether 0.830's narrowed E0902 accepts. Callers can pass a borrowed pointer again, so Siltreach's blade ray no longer needs @keep climbing four functions. The general form, a parameter that flows into a result without being kept, is aether#2990. test_physics_world forwards a plain borrowed ptr through all six queries; with @keep back on any of them the file fails to build.
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.
Closes #179.
The change
The six world queries no longer declare
context: @keep ptr:cast_ray,cast_shape,cast_mover,overlap_aabb,overlap_shapeandcollide_mover.None of them keeps the pointer. Each lends its local
QueryRecorderto the internal query for the duration of the call.The annotation was forced only by the helper
query_recorder(context: @keep ptr), because it returned the context inside the struct. Now:q.contexton its own local;The general form, a parameter that flows into a result without being kept, is filed as aether#2990.
These keep their annotation, because each really stores the pointer:
set_custom_filter_callbackset_pre_solve_callbackset_user_dataWhy it matters downstream
Siltreach's blade ray passes its own ragdoll, a borrowed pointer, in a
@scopedcontext tocast_ray. Until now,@keephad to climb four of Siltreach's functions for a pointer nobody keeps.Tests
test_physics_worldgainsborrowed_queries: a helper with a plainptrcontext that forwards it through all six queries and counts the visits. It passes 260 of 260.@keepput back oncast_ray, the file fails to build with E0902, so the check guards against a regression.Pins
Aether 0.830.0 and aeb v0.327, both the latest releases.