Skip to main content

RapierRigidBodySet

Struct RapierRigidBodySet 

Source
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: RigidBodySet

The set of rigid-bodies part of the simulation.

§soft_bodies: SoftBodySet

The set of soft-bodies part of the simulation.

Implementations§

Source§

impl RapierRigidBodySet

Source

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).

Source

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.

Source

pub fn entity2soft_body(&self) -> &HashMap<Entity, SoftBodyHandle>

The map from entities to soft-body handles.

Source

pub fn soft_body_entity(&self, handle: SoftBodyHandle) -> Option<Entity>

Retrieve the Bevy entity of the given Rapier soft body (identified by its handle).

Source

pub fn soft_body(&self, entity: Entity) -> Option<&RapierSoftBody>

The Rapier soft body attached to the given entity, if any.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn entity2body(&self) -> &HashMap<Entity, RigidBodyHandle>

The map from entities to rigid-body handles.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn mass(&self, entity: Entity) -> Option<f32>

The mass of the rigid-body of entity (including the contributions of its colliders).

This is zero for rigid-bodies without mass. Returns None if entity has no rigid-body.

Trait Implementations§

Source§

impl Clone for RapierRigidBodySet

Source§

fn clone(&self) -> RapierRigidBodySet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Component for RapierRigidBodySet
where Self: Send + Sync + 'static,

Source§

const STORAGE_TYPE: StorageType = ::bevy::ecs::component::StorageType::Table

A constant indicating the storage type used for this component.
Source§

type Mutability = Mutable

A marker type to assist Bevy with determining if this component is mutable, or immutable. Mutable components will have Component<Mutability = Mutable>, while immutable components will instead have Component<Mutability = Immutable>. Read more
Source§

fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )

Registers required components. Read more
Source§

fn clone_behavior() -> ComponentCloneBehavior

Called when registering this component, allowing to override clone function (or disable cloning altogether) for this component. Read more
Source§

fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>

Returns ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read more
Source§

fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_add ComponentHook for this Component if one is defined.
Source§

fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_insert ComponentHook for this Component if one is defined.
Source§

fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_discard ComponentHook for this Component if one is defined.
Source§

fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_remove ComponentHook for this Component if one is defined.
Source§

fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_despawn ComponentHook for this Component if one is defined.
Source§

fn map_entities<E>(_this: &mut Self, _mapper: &mut E)
where E: EntityMapper,

Maps the entities on this component using the given 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 more
Source§

const HAS_SUMMARY_TICK: bool = false

Set this constant to true if the component should track a summary tick. Read more
Source§

impl Default for RapierRigidBodySet

Source§

fn default() -> RapierRigidBodySet

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

Source§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<C> Bundle for C
where C: Component,

Source§

fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>

Source§

fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>

Returns an iterator over this Bundle’s component ids. This will be None if the component has not been registered.
Source§

impl<C> BundleFromComponents for C
where C: Component,

Source§

unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
where F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a>, C: Sized,

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<C> DynamicBundle for C
where C: Component,

Source§

type Effect = ()

An operation on the entity that happens after inserting this bundle.
Source§

unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect

Moves the components out of the bundle. Read more
Source§

unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )

Applies the after-effects of spawning this bundle. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromTemplate for T
where T: Clone + Default + Unpin,

Source§

type Template = T

The Template for this type.
Source§

impl<T> FromWorld for T
where T: Default,

Source§

fn from_world(_world: &mut World) -> T

Creates Self using default().

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> MaybeSync for T
where T: Sync + ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Settings for T
where T: 'static + Send + Sync,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> Template for T
where T: Clone + Unpin,

Source§

type Output = T

The type of value produced by this Template.
Source§

fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>

Uses this template and the given entity context to produce a Template::Output.
Source§

fn clone_template(&self) -> T

Clones this template. See Clone.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

fn clone_type_data(&self) -> Box<dyn TypeData>

Creates a type-erased clone of self.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more