Skip to main content

RapierContextJoints

Struct RapierContextJoints 

Source
pub struct RapierContextJoints {
    pub impulse_joints: ImpulseJointSet,
    pub multibody_joints: MultibodyJointSet,
    /* private fields */
}
Expand description

The sets of joints part of the simulation.

This should be attached on an entity with a RapierContextSimulation

With the serde-serialize feature, the entity-to-handle maps aren’t serialized: they are rebuilt from the joints’ user-data on deserialization (see Self::rebuild_entity_maps).

Fields§

§impulse_joints: ImpulseJointSet

The set of impulse joints part of the simulation.

§multibody_joints: MultibodyJointSet

The set of multibody joints part of the simulation.

Implementations§

Source§

impl RapierContextJoints

Source

pub fn rebuild_entity_maps(&mut self)

Rebuilds the maps from entities to impulse and multibody joint handles from the user-data of the joints, which contain the bits of their entity.

This is called automatically when deserializing this component. Call it manually after replacing the joint sets with sets restored in another way.

Source

pub fn entity2impulse_joint(&self) -> &HashMap<Entity, ImpulseJointHandle>

The map from entities to impulse joint handles.

Source

pub fn entity2multibody_joint(&self) -> &HashMap<Entity, MultibodyJointHandle>

The map from entities to multibody joint handles.

Source

pub fn entity_from_impulse_joint(joint: &RapierImpulseJoint) -> Entity

Retrieve the entity containing the ImpulseJoint component the given Rapier impulse joint was created from.

Source

pub fn impulse_joint_entity(&self, handle: ImpulseJointHandle) -> Option<Entity>

Retrieve the entity containing the ImpulseJoint component of the Rapier impulse joint identified by the given handle.

Source

pub fn impulse_joint_impulses( &self, entity: Entity, ) -> Option<ImpulseJointImpulses>

The impulses applied during the last simulation step by the ImpulseJoint of entity.

This is the value written back into the ImpulseJointImpulses component after each step. Returns None if entity has no impulse joint.

Source

pub fn impulse_joints_between<'a>( &'a self, rigidbody_set: &RapierRigidBodySet, body1: Entity, body2: Entity, ) -> impl Iterator<Item = Entity> + 'a

Iterates through the entities of all the impulse joints attaching the rigid-bodies of body1 and body2 (in any order).

Source

pub fn attached_impulse_joints<'a>( &'a self, rigidbody_set: &RapierRigidBodySet, body: Entity, ) -> impl Iterator<Item = Entity> + 'a

Iterates through the entities of all the impulse joints attached to the rigid-body of body, including disabled joints.

Source

pub fn attached_enabled_impulse_joints<'a>( &'a self, rigidbody_set: &RapierRigidBodySet, body: Entity, ) -> impl Iterator<Item = Entity> + 'a

Iterates through the entities of the enabled impulse joints attached to the rigid-body of body.

Source

pub fn entity_from_multibody_joint(joint: &RapierMultibodyJoint) -> Entity

Retrieve the entity containing the MultibodyJoint component the given Rapier multibody joint was created from.

This is also the entity of the rigid-body of the link containing this joint.

Source

pub fn multibody( &self, rigidbody_set: &RapierRigidBodySet, entity: Entity, ) -> Option<(&Multibody, usize)>

The multibody containing the rigid-body of entity, and the index of the link of that rigid-body in the multibody.

The root rigid-body of a multibody is its link 0. Returns None if the rigid-body is not attached to any MultibodyJoint.

Source

pub fn multibody_mut( &mut self, rigidbody_set: &RapierRigidBodySet, entity: Entity, ) -> Option<(&mut Multibody, usize)>

The multibody containing the rigid-body of entity, and the index of the link of that rigid-body in the multibody, for modification.

Note that Rapier doesn’t wake up the multibody automatically after a modification.

Source

pub fn multibody_root( &self, rigidbody_set: &RapierRigidBodySet, entity: Entity, ) -> Option<Entity>

The entity of the root rigid-body of the multibody containing the rigid-body of entity.

Iterates through the entities of the rigid-bodies of all the links of the multibody containing the rigid-body of entity.

The root comes first, and each link is yielded before its descendants. All the entities except the root contain the MultibodyJoint attaching them to their parent link: to remove all the joints of a multibody (like Rapier’s MultibodyJointSet::remove_multibody_articulations), remove the MultibodyJoint component from these entities (for example with .skip(1)).

The entity of the rigid-body of the parent link of the rigid-body of entity in its multibody.

Returns None if entity is the root of its multibody, or isn’t part of any multibody.

Source

pub fn multibody_joint_between( &self, rigidbody_set: &RapierRigidBodySet, body1: Entity, body2: Entity, ) -> Option<Entity>

The entity of the MultibodyJoint attaching the rigid-bodies of body1 and body2 (in any order), if any.

Source

pub fn attached_multibody_joints<'a>( &'a self, rigidbody_set: &'a RapierRigidBodySet, body: Entity, ) -> impl Iterator<Item = Entity> + 'a

Iterates through the entities of all the multibody joints attached to the rigid-body of body: the joint attaching it to its parent link (if any), and the joints of its child links.

The range of the degrees of freedom of the link of entity in the generalized coordinates, velocities and displacements of its multibody.

The degrees of freedom of a joint are its free axes, in JointAxis order.

Source

pub fn multibody_generalized_velocity( &self, rigidbody_set: &RapierRigidBodySet, entity: Entity, ) -> Option<&[f32]>

The generalized velocities of the multibody containing the rigid-body of entity.

See Self::multibody_link_dofs for the range of each link in this slice.

Source

pub fn multibody_generalized_velocity_mut( &mut self, rigidbody_set: &mut RapierRigidBodySet, entity: Entity, ) -> Option<&mut [f32]>

The generalized velocities of the multibody containing the rigid-body of entity, for modification.

This wakes up the rigid-bodies of the multibody.

Source

pub fn multibody_joint_velocity_mut( &mut self, rigidbody_set: &mut RapierRigidBodySet, entity: Entity, ) -> Option<&mut [f32]>

The generalized velocities of the MultibodyJoint of entity, one per free axis in JointAxis order, for modification.

This is typically used to drive a KinematicMultibodyJoint. This wakes up the rigid-bodies of the multibody.

Source

pub fn multibody_joint_state( &self, entity: Entity, ) -> Option<MultibodyJointState>

The state of the MultibodyJoint of entity.

This is the value written back into the MultibodyJointState component after each step.

Source

pub fn multibody_body_jacobian( &self, rigidbody_set: &RapierRigidBodySet, entity: Entity, ) -> Option<&Jacobian<f32>>

The jacobian of the link of entity, mapping the generalized velocities of its multibody to the link’s world-space linear and angular velocities.

This is computed by the last forward kinematics (see Self::multibody_forward_kinematics), which runs at each simulation step.

Source

pub fn multibody_apply_displacements( &mut self, rigidbody_set: &RapierRigidBodySet, entity: Entity, displacements: &[f32], ) -> bool

Applies displacements, in generalized coordinates, to the multibody containing the rigid-body of entity.

displacements must contain one value per degree of freedom of the multibody. This only modifies the joint coordinates: call Self::multibody_forward_kinematics to update the rigid-bodies. Returns false if entity isn’t part of a multibody or the number of displacements doesn’t match.

Source

pub fn multibody_forward_kinematics( &mut self, rigidbody_set: &mut RapierRigidBodySet, entity: Entity, read_root_pose_from_rigid_body: bool, ) -> bool

Runs forward kinematics on the multibody containing the rigid-body of entity, and moves its rigid-bodies to the resulting poses.

Set read_root_pose_from_rigid_body if the root rigid-body was moved and the multibody should follow. The Transform of the rigid-bodies are updated during the next writeback (after the next simulation step). Returns false if entity isn’t part of a multibody.

Source

pub fn multibody_inverse_kinematics( &self, rigidbody_set: &RapierRigidBodySet, link: Entity, target: Transform, options: &InverseKinematicsOption, joint_can_move: impl Fn(Entity) -> bool, displacements: &mut Vec<f32>, ) -> bool

Computes the displacements, in generalized coordinates, moving the link of link as close as possible to the world-space target pose, with a jacobian-based inverse kinematics solver.

displacements is an output buffer: it is cleared and resized to the number of degrees of freedom of the multibody (see Self::multibody_link_dofs), so the solver always starts from the current configuration, then filled with the result, which can then be applied with Self::multibody_apply_displacements. The same buffer can be reused across calls without resetting it. Only the joints for which joint_can_move returns true are moved; it is called with the entity of each link between the root (included) and link. Returns false if link isn’t part of a multibody.

Trait Implementations§

Source§

impl Clone for RapierContextJoints

Source§

fn clone(&self) -> RapierContextJoints

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 RapierContextJoints
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 Debug for RapierContextJoints

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RapierContextJoints

Source§

fn default() -> RapierContextJoints

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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