pub struct RapierContextSimulation {
pub islands: IslandManager,
pub broad_phase: DefaultBroadPhase,
pub narrow_phase: NarrowPhase,
pub ccd_solver: CCDSolver,
pub pipeline: PhysicsPipeline,
pub integration_parameters: IntegrationParameters,
/* private fields */
}Expand description
The Rapier context, containing parts of the state of the physics engine, specific to the simulation step.
This is the main driver for a rapier context, which will create other required components if needed.
Additionally to its required components, this component is also always paired with a RapierConfiguration component.
Fields§
§islands: IslandManagerThe island manager, which detects what object is sleeping (not moving much) to reduce computations.
broad_phase: DefaultBroadPhaseThe broad-phase, which detects potential contact pairs.
narrow_phase: NarrowPhaseThe narrow-phase, which computes contact points, tests intersections, and maintain the contact and intersection graphs.
ccd_solver: CCDSolverThe solver, which handles Continuous Collision Detection (CCD).
pipeline: PhysicsPipelineThe physics pipeline, which advance the simulation step by step.
integration_parameters: IntegrationParametersThe integration parameters, controlling various low-level coefficient of the simulation.
Implementations§
Source§impl RapierContextSimulation
impl RapierContextSimulation
Sourcepub fn step_simulation(
&mut self,
colliders: &mut RapierContextColliders,
joints: &mut RapierContextJoints,
rigidbody_set: &mut RapierRigidBodySet,
gravity: Vect,
timestep_mode: TimestepMode,
events: Option<(&MessageWriter<'_, CollisionEvent>, &MessageWriter<'_, ContactForceEvent>)>,
hooks: &dyn PhysicsHooks,
time: &Time,
sim_to_render_time: &mut SimulationToRenderTime,
interpolation_query: Option<&mut Query<'_, '_, (&RapierRigidBodyHandle, &mut TransformInterpolation)>>,
)
pub fn step_simulation( &mut self, colliders: &mut RapierContextColliders, joints: &mut RapierContextJoints, rigidbody_set: &mut RapierRigidBodySet, gravity: Vect, timestep_mode: TimestepMode, events: Option<(&MessageWriter<'_, CollisionEvent>, &MessageWriter<'_, ContactForceEvent>)>, hooks: &dyn PhysicsHooks, time: &Time, sim_to_render_time: &mut SimulationToRenderTime, interpolation_query: Option<&mut Query<'_, '_, (&RapierRigidBodyHandle, &mut TransformInterpolation)>>, )
Advance the simulation, based on the given timestep mode.
Sourcepub fn send_bevy_events(
&mut self,
collision_event_writer: &mut MessageWriter<'_, CollisionEvent>,
contact_force_event_writer: &mut MessageWriter<'_, ContactForceEvent>,
)
pub fn send_bevy_events( &mut self, collision_event_writer: &mut MessageWriter<'_, CollisionEvent>, contact_force_event_writer: &mut MessageWriter<'_, ContactForceEvent>, )
Generates bevy events for any physics interactions that have happened that are stored in the events list
Sourcepub fn move_shape(
&mut self,
rapier_colliders: &RapierContextColliders,
rapier_query_pipeline: &mut RapierQueryPipelineMut<'_>,
movement: Vect,
shape: &dyn Shape,
shape_translation: Vect,
shape_rotation: Rot,
shape_mass: f32,
options: &MoveShapeOptions,
events: impl FnMut(CharacterCollision),
) -> MoveShapeOutput
pub fn move_shape( &mut self, rapier_colliders: &RapierContextColliders, rapier_query_pipeline: &mut RapierQueryPipelineMut<'_>, movement: Vect, shape: &dyn Shape, shape_translation: Vect, shape_rotation: Rot, shape_mass: f32, options: &MoveShapeOptions, events: impl FnMut(CharacterCollision), ) -> MoveShapeOutput
Attempts to move shape, optionally sliding or climbing obstacles.
§Parameters
movement: the translational movement to apply.shape: the shape to move.shape_translation: the initial position of the shape.shape_rotation: the rotation of the shape.shape_mass: the mass of the shape to be considered by the impulse calculation ifMoveShapeOptions::apply_impulse_to_dynamic_bodiesis set to true.options: configures the behavior of the automatic sliding and climbing.events: callback run on each obstacle hit by the shape on its path.
Source§impl RapierContextSimulation
impl RapierContextSimulation
Sourcepub fn contact_pairs_with<'a, 'b: 'a>(
&'a self,
context_colliders: &'b RapierContextColliders,
rigidbody_set: &'b RapierRigidBodySet,
collider: Entity,
) -> impl Iterator<Item = ContactPairView<'a>>
pub fn contact_pairs_with<'a, 'b: 'a>( &'a self, context_colliders: &'b RapierContextColliders, rigidbody_set: &'b RapierRigidBodySet, collider: Entity, ) -> impl Iterator<Item = ContactPairView<'a>>
All the contact pairs involving the non-sensor collider attached to the given entity.
The returned contact pairs identify pairs of colliders with intersecting bounding-volumes.
To check if any geometric contact happened between the collider shapes, check
ContactPairView::has_any_active_contact.
Sourcepub fn intersection_pairs_with<'a, 'b: 'a>(
&'a self,
rapier_colliders: &'b RapierContextColliders,
collider: Entity,
) -> impl Iterator<Item = (Entity, Entity, bool)> + 'a
pub fn intersection_pairs_with<'a, 'b: 'a>( &'a self, rapier_colliders: &'b RapierContextColliders, collider: Entity, ) -> impl Iterator<Item = (Entity, Entity, bool)> + 'a
All the intersection pairs involving the collider attached to the given entity, where at least one collider involved in the intersection is a sensor.
The returned contact pairs identify pairs of colliders (where at least one is a sensor) with intersecting bounding-volumes. To check if any geometric overlap happened between the collider shapes, check the returned boolean.
Sourcepub fn contact_pair<'a, 'b: 'a>(
&'a self,
context_colliders: &'b RapierContextColliders,
rigidbody_set: &'b RapierRigidBodySet,
collider1: Entity,
collider2: Entity,
) -> Option<ContactPairView<'a>>
pub fn contact_pair<'a, 'b: 'a>( &'a self, context_colliders: &'b RapierContextColliders, rigidbody_set: &'b RapierRigidBodySet, collider1: Entity, collider2: Entity, ) -> Option<ContactPairView<'a>>
The contact pair involving two specific colliders.
If this returns None, there is no contact between the two colliders.
If this returns Some, then there may be a contact between the two colliders. Check the
result ContactPairView::has_any_active_contact method to see if there is an actual contact.
Sourcepub fn intersection_pair(
&self,
rapier_colliders: &RapierContextColliders,
collider1: Entity,
collider2: Entity,
) -> Option<bool>
pub fn intersection_pair( &self, rapier_colliders: &RapierContextColliders, collider1: Entity, collider2: Entity, ) -> Option<bool>
The intersection pair involving two specific colliders (at least one being a sensor).
If this returns None or Some(false), then there is no intersection between the two colliders.
If this returns Some(true), then there may be an intersection between the two colliders.
Sourcepub fn contact_pairs<'a, 'b: 'a>(
&'a self,
context_colliders: &'b RapierContextColliders,
rigidbody_set: &'b RapierRigidBodySet,
) -> impl Iterator<Item = ContactPairView<'a>>
pub fn contact_pairs<'a, 'b: 'a>( &'a self, context_colliders: &'b RapierContextColliders, rigidbody_set: &'b RapierRigidBodySet, ) -> impl Iterator<Item = ContactPairView<'a>>
All the contact pairs detected during the last timestep.
Sourcepub fn intersection_pairs<'a, 'b: 'a>(
&'a self,
rapier_colliders: &'b RapierContextColliders,
) -> impl Iterator<Item = (Entity, Entity, bool)> + 'a
pub fn intersection_pairs<'a, 'b: 'a>( &'a self, rapier_colliders: &'b RapierContextColliders, ) -> impl Iterator<Item = (Entity, Entity, bool)> + 'a
All the intersection pairs detected during the last timestep.
Trait Implementations§
Source§impl Component for RapierContextSimulation
Required Components: RapierContextColliders, RapierRigidBodySet, RapierContextJoints, SimulationToRenderTime.
impl Component for RapierContextSimulation
Required Components: RapierContextColliders, RapierRigidBodySet, RapierContextJoints, SimulationToRenderTime.
A component’s Required Components are inserted whenever it is inserted. Note that this will also insert the required components of the required components, recursively, in depth-first order.
Source§const STORAGE_TYPE: StorageType = ::bevy::ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = ::bevy::ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read moreSource§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreAuto Trait Implementations§
impl Freeze for RapierContextSimulation
impl !RefUnwindSafe for RapierContextSimulation
impl Send for RapierContextSimulation
impl Sync for RapierContextSimulation
impl Unpin for RapierContextSimulation
impl !UnwindSafe for RapierContextSimulation
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<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Source§fn get_component_ids(
components: &Components,
) -> impl Iterator<Item = Option<ComponentId>>
fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
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<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
Source§unsafe fn get_components(
ptr: MovingPtr<'_, C>,
func: &mut impl FnMut(StorageType, OwningPtr<'_>),
) -> <C as DynamicBundle>::Effect
unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
Source§unsafe fn apply_effect(
_ptr: MovingPtr<'_, MaybeUninit<C>>,
_entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )
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, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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 moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§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.