pub struct QuadTreePlugin<P, const N: usize, const W: usize, const H: usize, const K: usize = 10, const ID: usize = 0>where
P: TrackingPair,{ /* private fields */ }
Expand description
A Bevy plugin for quadtree.
§Type Parameters
P
: (S, C)
pair (or tuple of (S, C)
s) where S
(collision shape) can updated by C
(component).
S: Component + DynCollision + UpdateCollision<C> + Clone
,
such as CollisionCircle, CollisionRect, CollisionRotatedRect
.
are used to perform Collision Detection,
storing the shape and position info, also serving as a marker component in ECS queries.
Add the shapes which you wanna include into QuadTree
and auto-upgrade.
(Do not need to include those only used in the QuadTree::query
)
C: Component
, such as GlobalTransform
.
N
: The max number of objects each node.
W
: The width of the root node boundary.
H
: The height of the root node boundary.
The boundary’s center is (0, 0).
K
: For LooseQuadTree
, K / 10 = outlet_boundary / inlet_boundary. Set K to 10 by default and 20 is founded best.
K should >= 10. Only if the object move and is no longer completely contained by the outlet_boundary will it be inserted again.
ID
: If you want different quadtree for different use cases with the same other parameters, set ID to different values.
§Example
use bevy::prelude::*;
use bevy_quadtree::{CollisionCircle, CollisionRect, CollisionRotatedRect, QuadTreePlugin};
#[cfg(feature = "sprite")]
App::new()
.add_plugins(QuadTreePlugin::<(
(CollisionCircle, GlobalTransform),
(CollisionRotatedRect, GlobalTransform),
(CollisionRect, Sprite),
),
40, 100, 100, 20>::default());
Trait Implementations§
Source§impl<P, const N: usize, const W: usize, const H: usize, const K: usize, const ID: usize> Debug for QuadTreePlugin<P, N, W, H, K, ID>where
P: TrackingPair + Debug,
impl<P, const N: usize, const W: usize, const H: usize, const K: usize, const ID: usize> Debug for QuadTreePlugin<P, N, W, H, K, ID>where
P: TrackingPair + Debug,
Source§impl<P, const N: usize, const W: usize, const H: usize, const K: usize, const ID: usize> Default for QuadTreePlugin<P, N, W, H, K, ID>where
P: TrackingPair,
impl<P, const N: usize, const W: usize, const H: usize, const K: usize, const ID: usize> Default for QuadTreePlugin<P, N, W, H, K, ID>where
P: TrackingPair,
Source§impl<P, const N: usize, const W: usize, const H: usize, const K: usize, const ID: usize> Plugin for QuadTreePlugin<P, N, W, H, K, ID>where
P: TrackingPair,
impl<P, const N: usize, const W: usize, const H: usize, const K: usize, const ID: usize> Plugin for QuadTreePlugin<P, N, W, H, K, ID>where
P: TrackingPair,
Source§fn ready(&self, _app: &App) -> bool
fn ready(&self, _app: &App) -> bool
finish
should be called.Source§fn finish(&self, _app: &mut App)
fn finish(&self, _app: &mut App)
App
, once all plugins registered are ready. This can
be useful for plugins that depends on another plugin asynchronous setup, like the renderer.Source§fn cleanup(&self, _app: &mut App)
fn cleanup(&self, _app: &mut App)
Auto Trait Implementations§
impl<P, const N: usize, const W: usize, const H: usize, const K: usize, const ID: usize> Freeze for QuadTreePlugin<P, N, W, H, K, ID>
impl<P, const N: usize, const W: usize, const H: usize, const K: usize, const ID: usize> RefUnwindSafe for QuadTreePlugin<P, N, W, H, K, ID>where
P: RefUnwindSafe,
impl<P, const N: usize, const W: usize, const H: usize, const K: usize, const ID: usize> Send for QuadTreePlugin<P, N, W, H, K, ID>
impl<P, const N: usize, const W: usize, const H: usize, const K: usize, const ID: usize> Sync for QuadTreePlugin<P, N, W, H, K, ID>
impl<P, const N: usize, const W: usize, const H: usize, const K: usize, const ID: usize> Unpin for QuadTreePlugin<P, N, W, H, K, ID>where
P: Unpin,
impl<P, const N: usize, const W: usize, const H: usize, const K: usize, const ID: usize> UnwindSafe for QuadTreePlugin<P, N, W, H, K, ID>where
P: UnwindSafe,
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self
using default()
.
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more