pub struct ImpulseJointSet { /* private fields */ }Expand description
The collection that stores all joints connecting rigid bodies in your physics world.
Joints constrain how two bodies can move relative to each other. This set manages all joint instances (hinges, sliders, springs, etc.) using handles for safe access.
§Common joint types
FixedJoint: Weld two bodies togetherRevoluteJoint: Hinge (rotation around axis)PrismaticJoint: Slider (translation along axis)SpringJoint: Elastic connectionRopeJoint: Maximum distance limit
§Example
let mut joints = ImpulseJointSet::new();
// Create a hinge connecting two bodies
let joint = RevoluteJointBuilder::new(Vector::y_axis())
.local_anchor1(point![1.0, 0.0, 0.0])
.local_anchor2(point![-1.0, 0.0, 0.0])
.build();
let handle = joints.insert(body1, body2, joint, true);Implementations§
Source§impl ImpulseJointSet
impl ImpulseJointSet
Sourcepub fn joint_graph(&self) -> &InteractionGraph<RigidBodyHandle, ImpulseJoint>
pub fn joint_graph(&self) -> &InteractionGraph<RigidBodyHandle, ImpulseJoint>
Returns the internal graph structure (nodes=bodies, edges=joints).
Advanced usage - most users should use attached_joints() instead.
Sourcepub fn joints_between(
&self,
body1: RigidBodyHandle,
body2: RigidBodyHandle,
) -> impl Iterator<Item = (ImpulseJointHandle, &ImpulseJoint)>
pub fn joints_between( &self, body1: RigidBodyHandle, body2: RigidBodyHandle, ) -> impl Iterator<Item = (ImpulseJointHandle, &ImpulseJoint)>
Returns all joints connecting two specific bodies.
Usually returns 0 or 1 joint, but multiple joints can connect the same pair.
§Example
for (handle, joint) in joints.joints_between(body1, body2) {
println!("Found joint {:?}", handle);
}Sourcepub fn attached_joints(
&self,
body: RigidBodyHandle,
) -> impl Iterator<Item = (RigidBodyHandle, RigidBodyHandle, ImpulseJointHandle, &ImpulseJoint)>
pub fn attached_joints( &self, body: RigidBodyHandle, ) -> impl Iterator<Item = (RigidBodyHandle, RigidBodyHandle, ImpulseJointHandle, &ImpulseJoint)>
Returns all joints attached to a specific body.
Each result is (body1, body2, joint_handle, joint) where one of the bodies
matches the queried body.
§Example
for (b1, b2, j_handle, joint) in joints.attached_joints(body_handle) {
println!("Body connected to {:?} via {:?}", b2, j_handle);
}Sourcepub fn map_attached_joints_mut(
&mut self,
body: RigidBodyHandle,
f: impl FnMut(RigidBodyHandle, RigidBodyHandle, ImpulseJointHandle, &mut ImpulseJoint),
)
pub fn map_attached_joints_mut( &mut self, body: RigidBodyHandle, f: impl FnMut(RigidBodyHandle, RigidBodyHandle, ImpulseJointHandle, &mut ImpulseJoint), )
Iterates through all the impulse joints attached to the given rigid-body.
Sourcepub fn attached_enabled_joints(
&self,
body: RigidBodyHandle,
) -> impl Iterator<Item = (RigidBodyHandle, RigidBodyHandle, ImpulseJointHandle, &ImpulseJoint)>
pub fn attached_enabled_joints( &self, body: RigidBodyHandle, ) -> impl Iterator<Item = (RigidBodyHandle, RigidBodyHandle, ImpulseJointHandle, &ImpulseJoint)>
Returns only the enabled joints attached to a body.
Same as attached_joints() but filters out disabled joints.
Sourcepub fn contains(&self, handle: ImpulseJointHandle) -> bool
pub fn contains(&self, handle: ImpulseJointHandle) -> bool
Checks if the given joint handle is valid (joint still exists).
Sourcepub fn get(&self, handle: ImpulseJointHandle) -> Option<&ImpulseJoint>
pub fn get(&self, handle: ImpulseJointHandle) -> Option<&ImpulseJoint>
Returns a read-only reference to the joint with the given handle.
Sourcepub fn get_mut(
&mut self,
handle: ImpulseJointHandle,
wake_up_connected_bodies: bool,
) -> Option<&mut ImpulseJoint>
pub fn get_mut( &mut self, handle: ImpulseJointHandle, wake_up_connected_bodies: bool, ) -> Option<&mut ImpulseJoint>
Returns a mutable reference to the joint with the given handle.
§Parameters
wake_up_connected_bodies- Iftrue, wakes up both bodies connected by this joint
Sourcepub fn get_unknown_gen(
&self,
i: u32,
) -> Option<(&ImpulseJoint, ImpulseJointHandle)>
pub fn get_unknown_gen( &self, i: u32, ) -> Option<(&ImpulseJoint, ImpulseJointHandle)>
Gets a joint by index without knowing the generation (advanced/unsafe).
⚠️ Prefer get() instead! This bypasses generation checks.
See RigidBodySet::get_unknown_gen for details on the ABA problem.
Sourcepub fn get_unknown_gen_mut(
&mut self,
i: u32,
) -> Option<(&mut ImpulseJoint, ImpulseJointHandle)>
pub fn get_unknown_gen_mut( &mut self, i: u32, ) -> Option<(&mut ImpulseJoint, ImpulseJointHandle)>
Gets a mutable joint by index without knowing the generation (advanced/unsafe).
⚠️ Prefer get_mut() instead! This bypasses generation checks.
Sourcepub fn iter(&self) -> impl Iterator<Item = (ImpulseJointHandle, &ImpulseJoint)>
pub fn iter(&self) -> impl Iterator<Item = (ImpulseJointHandle, &ImpulseJoint)>
Iterates over all joints in this collection.
Each iteration yields (joint_handle, &joint).
Sourcepub fn iter_mut(
&mut self,
) -> impl Iterator<Item = (ImpulseJointHandle, &mut ImpulseJoint)>
pub fn iter_mut( &mut self, ) -> impl Iterator<Item = (ImpulseJointHandle, &mut ImpulseJoint)>
Iterates over all joints with mutable access.
Each iteration yields (joint_handle, &mut joint).
Sourcepub fn insert(
&mut self,
body1: RigidBodyHandle,
body2: RigidBodyHandle,
data: impl Into<GenericJoint>,
wake_up: bool,
) -> ImpulseJointHandle
pub fn insert( &mut self, body1: RigidBodyHandle, body2: RigidBodyHandle, data: impl Into<GenericJoint>, wake_up: bool, ) -> ImpulseJointHandle
Adds a joint connecting two bodies and returns its handle.
The joint constrains how the two bodies can move relative to each other.
§Parameters
body1,body2- The two bodies to connectdata- The joint configuration (FixedJoint, RevoluteJoint, etc.)wake_up- Iftrue, wakes up both bodies
§Example
let joint = RevoluteJointBuilder::new(Vector::y_axis())
.local_anchor1(point![1.0, 0.0, 0.0])
.local_anchor2(point![-1.0, 0.0, 0.0])
.build();
let handle = joints.insert(body1, body2, joint, true);Sourcepub fn remove(
&mut self,
handle: ImpulseJointHandle,
wake_up: bool,
) -> Option<ImpulseJoint>
pub fn remove( &mut self, handle: ImpulseJointHandle, wake_up: bool, ) -> Option<ImpulseJoint>
Removes a joint from the world.
Returns the removed joint if it existed, or None if the handle was invalid.
§Parameters
wake_up- Iftrue, wakes up both bodies that were connected by this joint
§Example
if let Some(joint) = joints.remove(joint_handle, true) {
println!("Removed joint between {:?} and {:?}", joint.body1, joint.body2);
}Sourcepub fn remove_joints_attached_to_rigid_body(
&mut self,
handle: RigidBodyHandle,
) -> Vec<ImpulseJointHandle>
pub fn remove_joints_attached_to_rigid_body( &mut self, handle: RigidBodyHandle, ) -> Vec<ImpulseJointHandle>
Deletes all the impulse_joints attached to the given rigid-body.
The provided rigid-body handle is not required to identify a rigid-body that
is still contained by the bodies component set.
Returns the (now invalid) handles of the removed impulse_joints.
Trait Implementations§
Source§impl Clone for ImpulseJointSet
impl Clone for ImpulseJointSet
Source§fn clone(&self) -> ImpulseJointSet
fn clone(&self) -> ImpulseJointSet
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ImpulseJointSet
impl Debug for ImpulseJointSet
Source§impl Default for ImpulseJointSet
impl Default for ImpulseJointSet
Source§fn default() -> ImpulseJointSet
fn default() -> ImpulseJointSet
Source§impl<'de> Deserialize<'de> for ImpulseJointSet
impl<'de> Deserialize<'de> for ImpulseJointSet
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ImpulseJointSet
impl RefUnwindSafe for ImpulseJointSet
impl Send for ImpulseJointSet
impl Sync for ImpulseJointSet
impl Unpin for ImpulseJointSet
impl UnwindSafe for ImpulseJointSet
Blanket Implementations§
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<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> Pointable for T
impl<T> Pointable 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.