pub struct DistanceConstraint {
pub rest_length: f32,
pub stiffness: f32,
pub damping: f32,
pub allow_compression: bool,
pub allow_extension: bool,
}Expand description
Maintains a target distance between two points, with spring-based correction.
Used to connect two particles or bones with a stiff but springy constraint.
Fields§
§rest_length: f32Rest distance between point A and point B.
stiffness: f32How stiff the constraint is (0 = free, 1 = rigid solve).
damping: f32Damping ratio applied to constraint correction impulses.
allow_compression: boolWhether to allow compression (shorter than rest_length).
allow_extension: boolWhether to allow extension (longer than rest_length).
Implementations§
Source§impl DistanceConstraint
impl DistanceConstraint
pub fn new(rest_length: f32, stiffness: f32) -> Self
Sourcepub fn solve(
&self,
pa: Vec3,
pb: Vec3,
mass_a: f32,
mass_b: f32,
) -> (Vec3, Vec3)
pub fn solve( &self, pa: Vec3, pb: Vec3, mass_a: f32, mass_b: f32, ) -> (Vec3, Vec3)
Compute position corrections to apply to points A and B.
pa, pb — current positions.
mass_a, mass_b — masses (constraint splits correction by mass ratio).
Returns (delta_a, delta_b) — offsets to add to each point position.
Trait Implementations§
Source§impl Clone for DistanceConstraint
impl Clone for DistanceConstraint
Source§fn clone(&self) -> DistanceConstraint
fn clone(&self) -> DistanceConstraint
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DistanceConstraint
impl RefUnwindSafe for DistanceConstraint
impl Send for DistanceConstraint
impl Sync for DistanceConstraint
impl Unpin for DistanceConstraint
impl UnsafeUnpin for DistanceConstraint
impl UnwindSafe for DistanceConstraint
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
Mutably borrows from an owned value. Read more
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>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<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>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> 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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.