pub struct BroadPhaseBvh { /* private fields */ }Expand description
The broad-phase collision detector that quickly filters out distant object pairs.
The broad-phase is the “first pass” of collision detection. It uses a hierarchical bounding volume tree (BVH) to quickly identify which collider pairs are close enough to potentially collide, avoiding expensive narrow-phase checks for distant objects.
Think of it as a “spatial index” that answers: “Which objects are near each other?”
You typically don’t interact with this directly - it’s managed by PhysicsPipeline.
However, you can use it to create a QueryPipeline for spatial queries.
Implementations§
Source§impl BroadPhaseBvh
impl BroadPhaseBvh
Sourcepub fn with_optimization_strategy(
optimization_strategy: BvhOptimizationStrategy,
) -> Self
pub fn with_optimization_strategy( optimization_strategy: BvhOptimizationStrategy, ) -> Self
Initializes a new empty broad-phase with the specified strategy for incremental BVH optimization.
Sourcepub fn update(
&mut self,
params: &IntegrationParameters,
colliders: &ColliderSet,
bodies: &RigidBodySet,
modified_colliders: &[ColliderHandle],
removed_colliders: &[ColliderHandle],
events: &mut Vec<BroadPhasePairEvent>,
)
pub fn update( &mut self, params: &IntegrationParameters, colliders: &ColliderSet, bodies: &RigidBodySet, modified_colliders: &[ColliderHandle], removed_colliders: &[ColliderHandle], events: &mut Vec<BroadPhasePairEvent>, )
Updates the broad-phase.
The results are output through the events struct. The broad-phase algorithm is only
required to generate new events (i.e. no need to re-send an AddPair event if it was already
sent previously and no RemovePair happened since then). Sending redundant events is allowed
but can result in a slight computational overhead.
§Parameters
params: the integration parameters governing the simulation.colliders: the set of colliders. Change detection withcollider.needs_broad_phase_update()can be relied on at this stage.modified_colliders: colliders that are know to be modified since the last update.removed_colliders: colliders that got removed since the last update. Any associated data in the broad-phase should be removed by this call toupdate.events: the broad-phase’s output. They indicate what collision pairs need to be created and what pairs need to be removed. It is OK to create pairs for colliders that don’t actually collide (though this can increase computational overhead in the narrow-phase) but it is important not to indicate removal of a collision pair if the underlying colliders are still touching or closer thanprediction_distance.
Sourcepub fn set_aabb(
&mut self,
params: &IntegrationParameters,
handle: ColliderHandle,
aabb: Aabb,
)
pub fn set_aabb( &mut self, params: &IntegrationParameters, handle: ColliderHandle, aabb: Aabb, )
Sets the AABB associated to the given collider.
The AABB change will be immediately applied and propagated through the underlying BVH. Change detection will automatically take it into account during the next broad-phase update.
Source§impl BroadPhaseBvh
impl BroadPhaseBvh
Sourcepub fn as_query_pipeline<'a>(
&'a self,
dispatcher: &'a dyn QueryDispatcher,
bodies: &'a RigidBodySet,
colliders: &'a ColliderSet,
filter: QueryFilter<'a>,
) -> QueryPipeline<'a>
pub fn as_query_pipeline<'a>( &'a self, dispatcher: &'a dyn QueryDispatcher, bodies: &'a RigidBodySet, colliders: &'a ColliderSet, filter: QueryFilter<'a>, ) -> QueryPipeline<'a>
Initialize a QueryPipeline for scene queries from this broad-phase.
Sourcepub fn as_query_pipeline_mut<'a>(
&'a self,
dispatcher: &'a dyn QueryDispatcher,
bodies: &'a mut RigidBodySet,
colliders: &'a mut ColliderSet,
filter: QueryFilter<'a>,
) -> QueryPipelineMut<'a>
pub fn as_query_pipeline_mut<'a>( &'a self, dispatcher: &'a dyn QueryDispatcher, bodies: &'a mut RigidBodySet, colliders: &'a mut ColliderSet, filter: QueryFilter<'a>, ) -> QueryPipelineMut<'a>
Initialize a QueryPipelineMut for scene queries from this broad-phase.
Trait Implementations§
Source§impl Clone for BroadPhaseBvh
impl Clone for BroadPhaseBvh
Source§fn clone(&self) -> BroadPhaseBvh
fn clone(&self) -> BroadPhaseBvh
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for BroadPhaseBvh
impl Default for BroadPhaseBvh
Source§fn default() -> BroadPhaseBvh
fn default() -> BroadPhaseBvh
Auto Trait Implementations§
impl Freeze for BroadPhaseBvh
impl RefUnwindSafe for BroadPhaseBvh
impl Send for BroadPhaseBvh
impl Sync for BroadPhaseBvh
impl Unpin for BroadPhaseBvh
impl UnwindSafe for BroadPhaseBvh
Blanket Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>, which can then be
downcast into Box<dyn 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>, which 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> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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 moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.