Expand description
Spatially aware Queries for the Bevy game engine
fn change_color_on_hover(
mouse: Single<&Mouse>,
mut circles: SpatialQuery<&mut Circle>,
) {
for mut circle in circles.in_radius(mouse.position, 10.) {
// Do something with the circle..
}
}
This crate aims to provide an ergonomic and fast way of performing spatial queries, i.e.
“nearby entities” -type queries. “Spatial” here refers purely to the GlobalPosition
of an
entity, and does not consider things like meshes or collision shapes.
By default, this crate uses a naive lookup algorithm as it outperforms more advanced algorithms
for simple (less than 1 000 000 entities) scenes with few (less than 100) queries. A BVH-based
algorithm is also provided, but it is only useful for scenes with many (100 000 000+) entities
or very many queries (10 000+). Users can implement their own lookup algorithms by implementing
the SpatialLookupAlgorithm
trait, and inserting the SpatialLookupState
resource like so:
app.insert_resource(SpatialLookupState::with_algorithm(YourAwesomeAlgorithm));
Modules§
- algorithms
- Spatial lookup algorithms
- prelude
Structs§
- Prepare
Spatial Lookup - System set for systems used to set up the spatial lookup.
- Spatial
Lookup State - Resource which holds the configured
SpatialLookupAlgorithm
and relevant state. - Spatial
Queries Plugin - Adds
SpatialQuery
support to bevy.
Traits§
- Spatial
Lookup Algorithm - Trait for defining Spatial Lookup Algorithms to be used with
SpatialQuery<_>
.
Functions§
- draw_
spatial_ lookup_ gizmos - prepare_
spatial_ lookup - Prepares the configured spatial lookup algorithm.