pub struct SoftBodyBlob {
pub points: Vec<VerletPoint>,
pub constraints: Vec<DistanceConstraint>,
pub center_index: usize,
pub perimeter_count: usize,
pub spring_stiffness: f32,
pub shape_a: Vec<Vec3>,
pub shape_b: Vec<Vec3>,
pub morph_frequency: f32,
pub morph_time: f32,
pub morphing: bool,
pub lifetime: f32,
pub age: f32,
}Expand description
A spring-connected mesh of points forming a deformable 2D blob (circle of perimeter points plus a center point).
Fields§
§points: Vec<VerletPoint>§constraints: Vec<DistanceConstraint>§center_index: usize§perimeter_count: usize§spring_stiffness: f32§shape_a: Vec<Vec3>Morph target shapes: each is a list of offsets from center.
shape_b: Vec<Vec3>§morph_frequency: f32§morph_time: f32§morphing: bool§lifetime: f32Maximum simulation lifetime in seconds. 0 = infinite.
age: f32Implementations§
Source§impl SoftBodyBlob
impl SoftBodyBlob
Sourcepub fn new(center: Vec3, radius: f32, resolution: usize) -> Self
pub fn new(center: Vec3, radius: f32, resolution: usize) -> Self
Create a blob centered at center with the given radius and
resolution (number of perimeter points).
Sourcepub fn apply_hit(&mut self, direction: Vec3, force: f32)
pub fn apply_hit(&mut self, direction: Vec3, force: f32)
Apply a hit that deforms the blob in a direction.
Sourcepub fn oscillate_between(
&mut self,
shape_a: Vec<Vec3>,
shape_b: Vec<Vec3>,
frequency: f32,
)
pub fn oscillate_between( &mut self, shape_a: Vec<Vec3>, shape_b: Vec<Vec3>, frequency: f32, )
Set up oscillation between two shape configurations.
shape_a and shape_b are lists of offsets from center for each point.
Sourcepub fn set_stiffness(&mut self, stiffness: f32)
pub fn set_stiffness(&mut self, stiffness: f32)
Set spring stiffness (affects constraint solving pressure and morph force).
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if this blob has expired.
Sourcepub fn center_position(&self) -> Vec3
pub fn center_position(&self) -> Vec3
Get the center position.
Trait Implementations§
Source§impl Clone for SoftBodyBlob
impl Clone for SoftBodyBlob
Auto Trait Implementations§
impl Freeze for SoftBodyBlob
impl RefUnwindSafe for SoftBodyBlob
impl Send for SoftBodyBlob
impl Sync for SoftBodyBlob
impl Unpin for SoftBodyBlob
impl UnsafeUnpin for SoftBodyBlob
impl UnwindSafe for SoftBodyBlob
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
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>
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.