pub struct RapierRigidBodySet {
pub bodies: RigidBodySet,
pub soft_bodies: SoftBodySet,
/* private fields */
}Expand description
The set of rigid-bodies part of the simulation.
This should be attached on an entity with a RapierContextSimulation
With the serde-serialize feature, the entity-to-handle map isn’t serialized: it is rebuilt
from the rigid-bodies’ user-data on deserialization (see Self::rebuild_entity_maps).
Fields§
§bodies: RigidBodySetThe set of rigid-bodies part of the simulation.
soft_bodies: SoftBodySetThe set of soft-bodies part of the simulation.
Implementations§
Source§impl RapierRigidBodySet
impl RapierRigidBodySet
Sourcepub fn rebuild_entity_maps(&mut self)
pub fn rebuild_entity_maps(&mut self)
Rebuilds the map from entities to rigid-body handles from the user-data of the rigid-bodies, which contain the bits of their entity.
This is called automatically when deserializing this component. Call it manually after
replacing Self::bodies with a set restored in another way. The transform change
detection state is reset, so the next GlobalTransform change of a rigid-body entity
is applied to its rigid-body.
The soft-body map is rebuilt from the soft bodies’ user-data too. The hidden proxy
rigid-bodies of the soft bodies are not mapped, except the proxies of the clusters that
have their own entity (see SoftBodyCluster) and the
whole-body proxy of each soft body (see Self::soft_body_whole_proxy).
Sourcepub fn soft_body_colliders(
&self,
colliders: &ColliderSet,
entity: Entity,
) -> Option<Vec<ColliderHandle>>
pub fn soft_body_colliders( &self, colliders: &ColliderSet, entity: Entity, ) -> Option<Vec<ColliderHandle>>
The colliders standing for the soft body of entity: the colliders of its collision
meshes (or of its particles), attached to its proxies and reporting entity as their
entity. The colliders attached by the user to its proxies (e.g. DeformableColliders or
children colliders) are not included.
Returns None if entity has no soft body.
Sourcepub fn entity2soft_body(&self) -> &HashMap<Entity, SoftBodyHandle>
pub fn entity2soft_body(&self) -> &HashMap<Entity, SoftBodyHandle>
The map from entities to soft-body handles.
Sourcepub fn soft_body_entity(&self, handle: SoftBodyHandle) -> Option<Entity>
pub fn soft_body_entity(&self, handle: SoftBodyHandle) -> Option<Entity>
Retrieve the Bevy entity of the given Rapier soft body (identified by its handle).
Sourcepub fn soft_body(&self, entity: Entity) -> Option<&RapierSoftBody>
pub fn soft_body(&self, entity: Entity) -> Option<&RapierSoftBody>
The Rapier soft body attached to the given entity, if any.
Sourcepub fn soft_body_mut(&mut self, entity: Entity) -> Option<&mut RapierSoftBody>
pub fn soft_body_mut(&mut self, entity: Entity) -> Option<&mut RapierSoftBody>
The Rapier soft body attached to the given entity, if any.
This gives access to every setter of the soft body (particle positions, velocities and
kinematic targets, pinning, forces, impulses, clusters…). Prefer the soft-body components
(e.g. SoftBodyMaterial) for the properties they
cover, since they are applied again whenever they change.
Sourcepub fn soft_body_particle_positions(
&self,
entity: Entity,
) -> Option<impl ExactSizeIterator<Item = Vect> + '_>
pub fn soft_body_particle_positions( &self, entity: Entity, ) -> Option<impl ExactSizeIterator<Item = Vect> + '_>
The world-space positions of the particles of the soft body of entity.
Returns None if entity has no soft body.
Sourcepub fn soft_body_particle_velocities(
&self,
entity: Entity,
) -> Option<impl ExactSizeIterator<Item = Vect> + '_>
pub fn soft_body_particle_velocities( &self, entity: Entity, ) -> Option<impl ExactSizeIterator<Item = Vect> + '_>
The world-space velocities of the particles of the soft body of entity.
Returns None if entity has no soft body.
Sourcepub fn soft_body_volume(&self, entity: Entity) -> Option<f32>
pub fn soft_body_volume(&self, entity: Entity) -> Option<f32>
The area (2D) or volume (3D) currently enclosed by the soft body of entity (0.0 for a
soft body without closed boundary).
Returns None if entity has no soft body.
Sourcepub fn soft_body_mass(&self, entity: Entity) -> Option<f32>
pub fn soft_body_mass(&self, entity: Entity) -> Option<f32>
The total mass of the particles of the soft body of entity.
Returns None if entity has no soft body.
Sourcepub fn soft_body_center_of_mass(&self, entity: Entity) -> Option<Vect>
pub fn soft_body_center_of_mass(&self, entity: Entity) -> Option<Vect>
The world-space, mass-weighted, center of the particles of the soft body of entity.
Returns None if entity has no soft body.
Sourcepub fn is_soft_body_sleeping(&self, entity: Entity) -> Option<bool>
pub fn is_soft_body_sleeping(&self, entity: Entity) -> Option<bool>
Whether the soft body of entity is sleeping.
Returns None if entity has no soft body.
Sourcepub fn wake_up_soft_body(&mut self, entity: Entity, strong: bool) -> bool
pub fn wake_up_soft_body(&mut self, entity: Entity, strong: bool) -> bool
Wakes up the soft body of entity (effective at the start of the next step, together
with the island of the bodies it touches).
Returns false if entity has no soft body.
Sourcepub fn soft_body_cluster_proxy(
&self,
entity: Entity,
cluster: u32,
) -> Option<RigidBodyHandle>
pub fn soft_body_cluster_proxy( &self, entity: Entity, cluster: u32, ) -> Option<RigidBodyHandle>
The proxy rigid-body of the cluster cluster of the soft body of entity.
The cluster 0 is the whole-body cluster created with the soft body. Returns None if
entity has no soft body or if that cluster doesn’t exist.
Sourcepub fn soft_body_whole_proxy(&self, entity: Entity) -> Option<RigidBodyHandle>
pub fn soft_body_whole_proxy(&self, entity: Entity) -> Option<RigidBodyHandle>
The whole-body proxy rigid-body of the soft body of entity: the proxy of its cluster
covering all its particles, which entity is mapped to in Self::entity2body.
This lets the soft body entity be used like a rigid-body entity by impulse joints (as
their parent, or on the soft body entity itself). Returns None if entity has no soft
body.
Sourcepub fn soft_body_cluster_index(
&self,
entity: Entity,
) -> Option<(SoftBodyHandle, u32)>
pub fn soft_body_cluster_index( &self, entity: Entity, ) -> Option<(SoftBodyHandle, u32)>
The soft body and the index of the cluster standing for entity: a
SoftBodyCluster entity, or a soft body entity (for
its whole-body cluster).
The index can be given to the cluster methods of RapierSoftBody (e.g.
RapierSoftBody::set_cluster_pinned). It may change when the soft body tears, so it
should not be stored. Returns None if entity doesn’t stand for a live cluster.
Sourcepub fn entity2body(&self) -> &HashMap<Entity, RigidBodyHandle>
pub fn entity2body(&self) -> &HashMap<Entity, RigidBodyHandle>
The map from entities to rigid-body handles.
Sourcepub fn rigid_body_entity(&self, handle: RigidBodyHandle) -> Option<Entity>
pub fn rigid_body_entity(&self, handle: RigidBodyHandle) -> Option<Entity>
Retrieve the Bevy entity the given Rapier rigid-body (identified by its handle) is attached.
Sourcepub fn propagate_modified_body_positions_to_colliders(
&self,
colliders: &mut RapierContextColliders,
)
pub fn propagate_modified_body_positions_to_colliders( &self, colliders: &mut RapierContextColliders, )
This method makes sure that the rigid-body positions have been propagated to their attached colliders, without having to perform a simulation step.
Sourcepub fn impulse_revolute_joint_angle(
&self,
joints: &RapierContextJoints,
entity: Entity,
) -> Option<f32>
pub fn impulse_revolute_joint_angle( &self, joints: &RapierContextJoints, entity: Entity, ) -> Option<f32>
Computes the angle between the two bodies attached by the RevoluteJoint component (if any) referenced by the given entity.
The angle is computed along the revolute joint’s principal axis.
Parameter entity should have a ImpulseJoint component with a TypedJoint::RevoluteJoint variant as data.
Sourcepub fn velocity_at_point(&self, entity: Entity, point: Vect) -> Option<Vect>
pub fn velocity_at_point(&self, entity: Entity, point: Vect) -> Option<Vect>
The linear velocity of the given world-space point, assuming it is rigidly attached to the
rigid-body of entity.
Unlike crate::dynamics::Velocity::linear_velocity_at_point, this uses the center of mass
computed by Rapier. Returns None if entity has no rigid-body.
Sourcepub fn is_moving(&self, entity: Entity) -> Option<bool>
pub fn is_moving(&self, entity: Entity) -> Option<bool>
Returns true if the rigid-body of entity has a non-zero linear or angular velocity.
Returns None if entity has no rigid-body.
Sourcepub fn is_ccd_active(&self, entity: Entity) -> Option<bool>
pub fn is_ccd_active(&self, entity: Entity) -> Option<bool>
Returns true if CCD is active for the rigid-body of entity, i.e., if it moved fast
enough during the last step to justify a CCD run.
Returns None if entity has no rigid-body.
Sourcepub fn next_position(&self, entity: Entity) -> Option<Transform>
pub fn next_position(&self, entity: Entity) -> Option<Transform>
The next position of the rigid-body of entity.
For kinematic rigid-bodies, this is the position set by the user for the next step. For
other rigid-bodies, this value is currently unspecified. The returned transform has a unit
scale. Returns None if entity has no rigid-body.
Sourcepub fn predict_position_using_velocity_and_forces(
&self,
entity: Entity,
dt: f32,
) -> Option<Transform>
pub fn predict_position_using_velocity_and_forces( &self, entity: Entity, dt: f32, ) -> Option<Transform>
Predicts the position of the rigid-body of entity after dt seconds, by integrating its
current velocity and forces (including gravity).
The returned transform has a unit scale. Returns None if entity has no rigid-body.
Sourcepub fn predict_position_using_velocity(
&self,
entity: Entity,
dt: f32,
) -> Option<Transform>
pub fn predict_position_using_velocity( &self, entity: Entity, dt: f32, ) -> Option<Transform>
Predicts the position of the rigid-body of entity after dt seconds, by integrating its
current velocity only (forces are ignored).
The returned transform has a unit scale. Returns None if entity has no rigid-body.
Sourcepub fn kinetic_energy(&self, entity: Entity) -> Option<f32>
pub fn kinetic_energy(&self, entity: Entity) -> Option<f32>
The kinetic energy of the rigid-body of entity.
Returns None if entity has no rigid-body.
Sourcepub fn gravitational_potential_energy(
&self,
entity: Entity,
dt: f32,
gravity: Vect,
) -> Option<f32>
pub fn gravitational_potential_energy( &self, entity: Entity, dt: f32, gravity: Vect, ) -> Option<f32>
The gravitational potential energy of the rigid-body of entity.
The position is projected back by half a timestep dt so the result is synchronized with
Self::kinetic_energy. Returns None if entity has no rigid-body.
Sourcepub fn user_force(&self, entity: Entity) -> Option<Vect>
pub fn user_force(&self, entity: Entity) -> Option<Vect>
The total user force applied to the rigid-body of entity (e.g. from its
crate::dynamics::ExternalForce component).
This is zero for non-dynamic rigid-bodies. Returns None if entity has no rigid-body.
Sourcepub fn user_torque(&self, entity: Entity) -> Option<f32>
pub fn user_torque(&self, entity: Entity) -> Option<f32>
The total user torque applied to the rigid-body of entity (e.g. from its
crate::dynamics::ExternalForce component).
This is zero for non-dynamic rigid-bodies. Returns None if entity has no rigid-body.
Sourcepub fn effective_dominance_group(&self, entity: Entity) -> Option<i16>
pub fn effective_dominance_group(&self, entity: Entity) -> Option<i16>
The dominance group actually used by the solver for the rigid-body of entity.
This is i8::MAX + 1 for non-dynamic rigid-bodies. Returns None if entity has no
rigid-body.
Sourcepub fn center_of_mass(&self, entity: Entity) -> Option<Vect>
pub fn center_of_mass(&self, entity: Entity) -> Option<Vect>
The world-space center of mass of the rigid-body of entity.
Returns None if entity has no rigid-body.
Trait Implementations§
Source§impl Clone for RapierRigidBodySet
impl Clone for RapierRigidBodySet
Source§fn clone(&self) -> RapierRigidBodySet
fn clone(&self) -> RapierRigidBodySet
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Component for RapierRigidBodySet
impl Component for RapierRigidBodySet
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_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> 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 moreSource§const HAS_SUMMARY_TICK: bool = false
const HAS_SUMMARY_TICK: bool = false
Source§impl Default for RapierRigidBodySet
impl Default for RapierRigidBodySet
Source§fn default() -> RapierRigidBodySet
fn default() -> RapierRigidBodySet
Auto Trait Implementations§
impl Freeze for RapierRigidBodySet
impl RefUnwindSafe for RapierRigidBodySet
impl Send for RapierRigidBodySet
impl Sync for RapierRigidBodySet
impl Unpin for RapierRigidBodySet
impl UnsafeUnpin for RapierRigidBodySet
impl UnwindSafe for RapierRigidBodySet
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,
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
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> FromTemplate for T
impl<T> FromTemplate 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, 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>
impl<T> MaybeSync for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Settings for T
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.Source§impl<T> Template for T
impl<T> Template for T
Source§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
self.