bevy_spatial/
lib.rs

1#![warn(missing_docs)]
2#![deny(clippy::pedantic)]
3
4//! A bevy plugin to track your entities in spatial indices and query them.
5//!
6//! Quickstart using the `kdtree` feature:
7//! ```
8//! use bevy_spatial::{AutomaticUpdate, KDTree3, TransformMode, SpatialAccess};
9//!
10//! #[derive(Component, Default)]
11//! struct TrackedByKDTree;
12//!
13//! fn main() {
14//!    App::new()
15//!        .add_plugin(AutomaticUpdate::<TrackedByKDTree>::new()
16//!             .with_frequency(Duration::from_secs_f32(0.3))
17//!             .with_transform(TransformMode::GlobalTransform))
18//!        .add_system(use_neighbour);
19//!    // ...
20//! }
21//!
22//! type NNTree = KDTree3<TrackedByKDTree>; // type alias for later
23//!
24//! // spawn some entities with the TrackedByKDTree component
25//!
26//! fn use_neighbour(tree: Res<NNTree>){
27//!     if let Some((pos, entity)) = tree.nearest_neighbour(Vec3::ZERO) {
28//!         // pos: Vec3
29//!         // do something with the nearest entity here
30//!     }
31//! }
32//! ```
33//!
34//! For more details see [Examples](https://github.com/laundmo/bevy-spatial/tree/main/examples)
35
36pub mod point;
37mod spatial_access;
38pub use self::spatial_access::SpatialAccess;
39
40use bevy::prelude::Component;
41mod timestep;
42pub use self::timestep::TimestepLength;
43
44pub mod kdtree;
45
46mod plugin;
47pub use plugin::{SpatialStructure, *};
48
49mod automatic_systems;
50pub use automatic_systems::TransformMode;
51
52/// automatically implemented trait for all components which can be used as markers for automatic updates?
53pub trait TComp: Component + Send + Sync + 'static {}
54impl<T> TComp for T where T: Component + Send + Sync + 'static {}