Crate bevy_mod_spatial_query

Source
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 BVH-based lookup algorithm as a compromise between lookup speed and lookup preparation. 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§

prelude

Structs§

PrepareSpatialLookup
System set for systems used to set up the spatial lookup.
SpatialLookupState
Resource which holds the configured SpatialLookupAlgorithm and relevant state.
SpatialQueriesPlugin
Adds SpatialQuery support to bevy.

Traits§

SpatialLookupAlgorithm
Trait for defining Spatial Lookup Algorithms to be used with SpatialQuery<_>.