Make SpatialQuery more generic across colliders#975
Draft
NiseVoid wants to merge 5 commits into
Draft
Conversation
Jondolf
reviewed
Apr 18, 2026
Member
Jondolf
left a comment
There was a problem hiding this comment.
Thanks! This largely looks like the right shape for this sort of thing. I did my first pass on this, initial thoughts are mainly that some of the APIs and trait bounds may need some more thought to figure out if we can make them a bit nicer somehow
Comment on lines
+139
to
+161
| /// A trait to indicate the [`Entity`] usage of a [`BoundedCollider`] `Context`. See [`NoEntity`] and [`NeedsEntity`]. | ||
| pub trait EntityUsage { | ||
| /// The type the [`Entity`] is stored in ([`()`] vs [`Entity`]) | ||
| type Entity: Clone + Copy; | ||
| /// Convert an [`Entity`] to the stored type | ||
| fn to_field(e: Entity) -> Self::Entity; | ||
| } | ||
|
|
||
| /// A type indicating an entity is required for a [`BoundedCollider`]'s `Context` | ||
| pub struct NeedsEntity; | ||
| impl EntityUsage for NeedsEntity { | ||
| type Entity = Entity; | ||
| fn to_field(e: Entity) -> Self::Entity { | ||
| e | ||
| } | ||
| } | ||
|
|
||
| /// A type indicating no entity is used for a [`BoundedCollider`]'s `Context` | ||
| pub struct NoEntity; | ||
| impl EntityUsage for NoEntity { | ||
| type Entity = (); | ||
| fn to_field(_: Entity) {} | ||
| } |
Member
There was a problem hiding this comment.
This feels quite nasty, but I can see why something like this may be needed for AabbContext 🤔 I'll have to think if there's a better way to handle this
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.
Objective
SpatialQuerycannot be used with non-parry collider types.Solution
Add a trait to let types use
SpatialQuery, and add a generic param in a few placesTesting
SpatialQueryto ensure nothing brokeNext steps
ShapeCastandRayCastcomponents work with the new approachQueryColliderimplQueryColliderwithoutAnyCollider