pub struct RopeChain {
pub points: Vec<VerletPoint>,
pub constraints: Vec<DistanceConstraint>,
pub lifetime: f32,
pub age: f32,
}Expand description
A chain of point masses connected by distance constraints, forming a rope.
Fields§
§points: Vec<VerletPoint>§constraints: Vec<DistanceConstraint>§lifetime: f32Maximum simulation lifetime in seconds. 0 = infinite.
age: f32Implementations§
Source§impl RopeChain
impl RopeChain
Sourcepub fn new(start: Vec3, end: Vec3, segments: usize) -> Self
pub fn new(start: Vec3, end: Vec3, segments: usize) -> Self
Create a rope from start to end with segments links.
Sourcepub fn attach_start(&mut self, pos: Vec3)
pub fn attach_start(&mut self, pos: Vec3)
Fix the start point at a position.
Sourcepub fn attach_end(&mut self, pos: Vec3)
pub fn attach_end(&mut self, pos: Vec3)
Fix the end point at a position.
Sourcepub fn apply_gravity(&mut self)
pub fn apply_gravity(&mut self)
Apply standard gravity to all points.
Sourcepub fn sever_at(&mut self, segment_index: usize) -> Option<RopeChain>
pub fn sever_at(&mut self, segment_index: usize) -> Option<RopeChain>
Sever the rope at a segment index, returning a new RopeChain for the
detached portion (from the cut point to the end). The current rope is
truncated to end at the cut point.
Sourcepub fn get_points(&self) -> Vec<Vec3>
pub fn get_points(&self) -> Vec<Vec3>
Get positions of all points.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if this rope has expired.
Sourcepub fn current_length(&self) -> f32
pub fn current_length(&self) -> f32
Total length of the rope (sum of segment distances).
Sourcepub fn apply_force(&mut self, force: Vec3)
pub fn apply_force(&mut self, force: Vec3)
Apply a force to all points.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RopeChain
impl RefUnwindSafe for RopeChain
impl Send for RopeChain
impl Sync for RopeChain
impl Unpin for RopeChain
impl UnsafeUnpin for RopeChain
impl UnwindSafe for RopeChain
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.