pub trait BroadPhase:
Send
+ Sync
+ 'static
+ DowncastSync {
// Required method
fn update(
&mut self,
params: &IntegrationParameters,
colliders: &ColliderSet,
bodies: &RigidBodySet,
modified_colliders: &[ColliderHandle],
removed_colliders: &[ColliderHandle],
events: &mut Vec<BroadPhasePairEvent>,
);
}
Expand description
Trait implemented by broad-phase algorithms supported by Rapier.
The task of a broad-phase algorithm is to detect potential collision pairs, usually based on bounding volumes. The pairs must be conservative: it is OK to create a collision pair if two objects don’t actually touch, but it is incorrect to remove a pair between two objects that are still touching. In other words, it can have false-positive (though these induce some computational overhead on the narrow-phase), but cannot have false-negative.
Required Methods§
Sourcefn update(
&mut self,
params: &IntegrationParameters,
colliders: &ColliderSet,
bodies: &RigidBodySet,
modified_colliders: &[ColliderHandle],
removed_colliders: &[ColliderHandle],
events: &mut Vec<BroadPhasePairEvent>,
)
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 must be 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.
The colliders
set is mutable only to provide access to
[collider.set_internal_broad_phase_proxy_index
]. Other properties of the collider should
not be modified during the broad-phase update.
§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
.
Implementations§
Source§impl dyn BroadPhase
impl dyn BroadPhase
Sourcepub fn is<__T: BroadPhase>(&self) -> bool
pub fn is<__T: BroadPhase>(&self) -> bool
Returns true if the trait object wraps an object of type __T
.
Sourcepub fn downcast<__T: BroadPhase>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>
pub fn downcast<__T: BroadPhase>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>
Returns a boxed object from a boxed trait object if the underlying object is of type
__T
. Returns the original boxed trait if it isn’t.
Sourcepub fn downcast_rc<__T: BroadPhase>(self: Rc<Self>) -> Result<Rc<__T>, Rc<Self>>
pub fn downcast_rc<__T: BroadPhase>(self: Rc<Self>) -> Result<Rc<__T>, Rc<Self>>
Returns an Rc
-ed object from an Rc
-ed trait object if the underlying object is of
type __T
. Returns the original Rc
-ed trait if it isn’t.
Sourcepub fn downcast_ref<__T: BroadPhase>(&self) -> Option<&__T>
pub fn downcast_ref<__T: BroadPhase>(&self) -> Option<&__T>
Returns a reference to the object within the trait object if it is of type __T
, or
None
if it isn’t.
Sourcepub fn downcast_mut<__T: BroadPhase>(&mut self) -> Option<&mut __T>
pub fn downcast_mut<__T: BroadPhase>(&mut self) -> Option<&mut __T>
Returns a mutable reference to the object within the trait object if it is of type
__T
, or None
if it isn’t.
Sourcepub fn downcast_arc<__T: BroadPhase + Any + Send + Sync>(
self: Arc<Self>,
) -> Result<Arc<__T>, Arc<Self>>
pub fn downcast_arc<__T: BroadPhase + Any + Send + Sync>( self: Arc<Self>, ) -> Result<Arc<__T>, Arc<Self>>
Returns an Arc
-ed object from an Arc
-ed trait object if the underlying object is of
type __T
. Returns the original Arc
-ed trait if it isn’t.