pub struct ClothStrip {
pub points: Vec<VerletPoint>,
pub structural_constraints: Vec<DistanceConstraint>,
pub bend_constraints: Vec<DistanceConstraint>,
pub width: usize,
pub height: usize,
pub spacing: f32,
pub lifetime: f32,
pub age: f32,
}Expand description
A rectangular grid of Verlet-integrated point masses connected by distance and bend constraints, simulating cloth or fabric.
Fields§
§points: Vec<VerletPoint>§structural_constraints: Vec<DistanceConstraint>§bend_constraints: Vec<DistanceConstraint>§width: usize§height: usize§spacing: f32§lifetime: f32Maximum simulation lifetime in seconds. 0 = infinite.
age: f32Implementations§
Source§impl ClothStrip
impl ClothStrip
Sourcepub fn new(
width_points: usize,
height_points: usize,
spacing: f32,
anchor_pos: Vec3,
) -> Self
pub fn new( width_points: usize, height_points: usize, spacing: f32, anchor_pos: Vec3, ) -> Self
Create a cloth grid of width_points x height_points, anchored at
anchor_pos (top-left corner). Points are spaced spacing apart.
Sourcepub fn step(&mut self, dt: f32, iterations: usize)
pub fn step(&mut self, dt: f32, iterations: usize)
Advance simulation by dt with iterations constraint relaxation passes.
Sourcepub fn apply_force(&mut self, force: Vec3)
pub fn apply_force(&mut self, force: Vec3)
Apply a uniform force to all unpinned points.
Sourcepub fn apply_wind(&mut self, direction: Vec3, strength: f32, turbulence: f32)
pub fn apply_wind(&mut self, direction: Vec3, strength: f32, turbulence: f32)
Apply wind with directional bias plus turbulence noise.
Sourcepub fn unpin_point(&mut self, index: usize)
pub fn unpin_point(&mut self, index: usize)
Unpin a point so it can move freely.
Sourcepub fn tear_at(&mut self, index: usize)
pub fn tear_at(&mut self, index: usize)
Tear the cloth at a point by deactivating all constraints referencing it.
Sourcepub fn get_render_data(&self) -> Vec<[f32; 3]>
pub fn get_render_data(&self) -> Vec<[f32; 3]>
Return all point positions as [f32; 3] arrays for rendering.
Sourcepub fn set_point_position(&mut self, index: usize, pos: Vec3)
pub fn set_point_position(&mut self, index: usize, pos: Vec3)
Move a pinned point to a new position (useful for anchoring to entities).
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if this cloth has expired (lifetime > 0 and age exceeded).
Sourcepub fn active_constraint_count(&self) -> usize
pub fn active_constraint_count(&self) -> usize
Number of active structural constraints.
Trait Implementations§
Source§impl Clone for ClothStrip
impl Clone for ClothStrip
Auto Trait Implementations§
impl Freeze for ClothStrip
impl RefUnwindSafe for ClothStrip
impl Send for ClothStrip
impl Sync for ClothStrip
impl Unpin for ClothStrip
impl UnsafeUnpin for ClothStrip
impl UnwindSafe for ClothStrip
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
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,
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>. 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>
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)
&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.