Struct Joint

Source
pub struct Joint { /* private fields */ }

Implementations§

Source§

impl Joint

Source

pub fn peak_load(&self) -> JointLoad

Source

pub fn bodies(&self) -> [RigidBodyHandle; 2]

Source

pub fn description(&self) -> JointDesc

Source

pub fn set_motor( &mut self, motor: Option<JointMotor>, ) -> Result<(), PhysicsError>

Replaces the motor transactionally, preserving the existing error type. Use Self::set_limits_and_motor for field-specific errors.

Source

pub fn set_limits( &mut self, limits: Option<[f32; 2]>, ) -> Result<(), PhysicsError>

Replaces angular limits transactionally, preserving the existing error type. Use Self::set_limits_and_motor for field-specific errors.

Source

pub fn set_limits_and_motor( &mut self, limits: Option<[f32; 2]>, motor: Option<JointMotor>, ) -> Result<(), JointValidationError>

Replaces angular limits and the motor together, or changes nothing.

None removes the corresponding setting. Nonempty settings require a hinge; finite limits must satisfy -pi <= lower <= upper <= pi. Equal endpoints are allowed. Motor bounds are checked by JointMotor::validate. Position targets outside the limits retain the solver’s target clamping.

A rejected edit leaves the description and solver state intact. An identical edit does not wake the bodies or invalidate cached impulses. An accepted change uses the existing dirty flag so the next physics step clears cached impulses and wakes connected bodies. Handles, anchors and the captured reference rotation are preserved.

use ferravex_physics::{d2, JointMotor};
let mut world = d2::PhysicsWorld::default();
let anchor = world.insert_body(d2::RigidBodyBuilder::fixed()).unwrap();
let rotor = world.add_box([0.; 2], [0.5, 0.2], true);
let handle = world.insert_joint(anchor, rotor, d2::JointBuilder::hinge()).unwrap();
let joint = world.joints.get_mut(handle).unwrap();
joint.set_limits_and_motor(
    Some([-0.6, 0.8]), Some(JointMotor::position(0.5, 20., 8., 80.)),
).unwrap();
let before = joint.description();
assert!(joint.set_limits_and_motor(Some([1., -1.]), None).is_err());
assert_eq!(joint.description(), before);
world.step(1. / 120.);
Source

pub fn set_enabled(&mut self, enabled: bool)

Source

pub fn set_contacts_enabled(&mut self, enabled: bool)

Trait Implementations§

Source§

impl Clone for Joint

Source§

fn clone(&self) -> Joint

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Joint

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Joint

§

impl RefUnwindSafe for Joint

§

impl Send for Joint

§

impl Sync for Joint

§

impl Unpin for Joint

§

impl UnwindSafe for Joint

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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