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: ImpulseJointSetThe set of impulse joints part of the simulation.
multibody_joints: MultibodyJointSetThe set of multibody joints part of the simulation.
Implementations§
Source§impl RapierContextJoints
impl RapierContextJoints
Sourcepub fn rebuild_entity_maps(&mut self)
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.
Sourcepub fn entity2impulse_joint(&self) -> &HashMap<Entity, ImpulseJointHandle>
pub fn entity2impulse_joint(&self) -> &HashMap<Entity, ImpulseJointHandle>
The map from entities to impulse joint handles.
Sourcepub fn entity2multibody_joint(&self) -> &HashMap<Entity, MultibodyJointHandle>
pub fn entity2multibody_joint(&self) -> &HashMap<Entity, MultibodyJointHandle>
The map from entities to multibody joint handles.
Sourcepub fn entity_from_impulse_joint(joint: &RapierImpulseJoint) -> Entity
pub fn entity_from_impulse_joint(joint: &RapierImpulseJoint) -> Entity
Retrieve the entity containing the ImpulseJoint component the given Rapier impulse
joint was created from.
Sourcepub fn impulse_joint_entity(&self, handle: ImpulseJointHandle) -> Option<Entity>
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.
Sourcepub fn impulse_joint_impulses(
&self,
entity: Entity,
) -> Option<ImpulseJointImpulses>
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.
Sourcepub fn impulse_joints_between<'a>(
&'a self,
rigidbody_set: &RapierRigidBodySet,
body1: Entity,
body2: Entity,
) -> impl Iterator<Item = Entity> + 'a
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).
Sourcepub fn attached_impulse_joints<'a>(
&'a self,
rigidbody_set: &RapierRigidBodySet,
body: Entity,
) -> impl Iterator<Item = Entity> + 'a
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.
Sourcepub fn attached_enabled_impulse_joints<'a>(
&'a self,
rigidbody_set: &RapierRigidBodySet,
body: Entity,
) -> impl Iterator<Item = Entity> + 'a
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.
Sourcepub fn entity_from_multibody_joint(joint: &RapierMultibodyJoint) -> Entity
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.
Sourcepub fn multibody(
&self,
rigidbody_set: &RapierRigidBodySet,
entity: Entity,
) -> Option<(&Multibody, usize)>
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.
Sourcepub fn multibody_mut(
&mut self,
rigidbody_set: &RapierRigidBodySet,
entity: Entity,
) -> Option<(&mut Multibody, usize)>
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.
Sourcepub fn multibody_root(
&self,
rigidbody_set: &RapierRigidBodySet,
entity: Entity,
) -> Option<Entity>
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.
Sourcepub fn multibody_links<'a>(
&'a self,
rigidbody_set: &'a RapierRigidBodySet,
entity: Entity,
) -> impl Iterator<Item = Entity> + 'a
pub fn multibody_links<'a>( &'a self, rigidbody_set: &'a RapierRigidBodySet, entity: Entity, ) -> impl Iterator<Item = Entity> + 'a
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)).
Sourcepub fn multibody_parent_link(
&self,
rigidbody_set: &RapierRigidBodySet,
entity: Entity,
) -> Option<Entity>
pub fn multibody_parent_link( &self, rigidbody_set: &RapierRigidBodySet, entity: Entity, ) -> Option<Entity>
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.
Sourcepub fn multibody_joint_between(
&self,
rigidbody_set: &RapierRigidBodySet,
body1: Entity,
body2: Entity,
) -> Option<Entity>
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.
Sourcepub fn attached_multibody_joints<'a>(
&'a self,
rigidbody_set: &'a RapierRigidBodySet,
body: Entity,
) -> impl Iterator<Item = Entity> + 'a
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.
Sourcepub fn multibody_link_dofs(
&self,
rigidbody_set: &RapierRigidBodySet,
entity: Entity,
) -> Option<Range<usize>>
pub fn multibody_link_dofs( &self, rigidbody_set: &RapierRigidBodySet, entity: Entity, ) -> Option<Range<usize>>
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.
Sourcepub fn multibody_generalized_velocity(
&self,
rigidbody_set: &RapierRigidBodySet,
entity: Entity,
) -> Option<&[f32]>
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.
Sourcepub fn multibody_generalized_velocity_mut(
&mut self,
rigidbody_set: &mut RapierRigidBodySet,
entity: Entity,
) -> Option<&mut [f32]>
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.
Sourcepub fn multibody_joint_velocity_mut(
&mut self,
rigidbody_set: &mut RapierRigidBodySet,
entity: Entity,
) -> Option<&mut [f32]>
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.
Sourcepub fn multibody_joint_state(
&self,
entity: Entity,
) -> Option<MultibodyJointState>
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.
Sourcepub fn multibody_body_jacobian(
&self,
rigidbody_set: &RapierRigidBodySet,
entity: Entity,
) -> Option<&Jacobian<f32>>
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.
Sourcepub fn multibody_apply_displacements(
&mut self,
rigidbody_set: &RapierRigidBodySet,
entity: Entity,
displacements: &[f32],
) -> bool
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.
Sourcepub fn multibody_forward_kinematics(
&mut self,
rigidbody_set: &mut RapierRigidBodySet,
entity: Entity,
read_root_pose_from_rigid_body: bool,
) -> bool
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.
Sourcepub 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
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
impl Clone for RapierContextJoints
Source§fn clone(&self) -> RapierContextJoints
fn clone(&self) -> RapierContextJoints
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 RapierContextJoints
impl Component for RapierContextJoints
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 Debug for RapierContextJoints
impl Debug for RapierContextJoints
Source§impl Default for RapierContextJoints
impl Default for RapierContextJoints
Source§fn default() -> RapierContextJoints
fn default() -> RapierContextJoints
Auto Trait Implementations§
impl Freeze for RapierContextJoints
impl RefUnwindSafe for RapierContextJoints
impl Send for RapierContextJoints
impl Sync for RapierContextJoints
impl Unpin for RapierContextJoints
impl UnsafeUnpin for RapierContextJoints
impl UnwindSafe for RapierContextJoints
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
Source§impl<T> Pointable for T
impl<T> Pointable 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.