pub struct DeformableBody {
pub positions: Vec<Vec3Fix>,
pub velocities: Vec<Vec3Fix>,
pub inv_masses: Vec<Fix128>,
pub tetrahedra: Vec<[usize; 4]>,
pub surface_triangles: Vec<[usize; 3]>,
pub config: DeformableConfig,
/* private fields */
}Expand description
Deformable body simulation
Fields§
§positions: Vec<Vec3Fix>Particle positions
velocities: Vec<Vec3Fix>Velocities
inv_masses: Vec<Fix128>Inverse mass per particle
tetrahedra: Vec<[usize; 4]>Tetrahedra (4 vertex indices each)
surface_triangles: Vec<[usize; 3]>Surface triangles (for rendering/collision)
config: DeformableConfigConfiguration
Implementations§
Source§impl DeformableBody
impl DeformableBody
Sourcepub fn new(
positions: Vec<Vec3Fix>,
tetrahedra: &[[usize; 4]],
surface_triangles: Vec<[usize; 3]>,
mass_per_particle: Fix128,
) -> Self
pub fn new( positions: Vec<Vec3Fix>, tetrahedra: &[[usize; 4]], surface_triangles: Vec<[usize; 3]>, mass_per_particle: Fix128, ) -> Self
Create from particle positions and tetrahedra
Sourcepub fn new_cube(center: Vec3Fix, half_extent: Fix128, mass: Fix128) -> Self
pub fn new_cube(center: Vec3Fix, half_extent: Fix128, mass: Fix128) -> Self
Create a simple cube deformable (for testing)
Sourcepub fn particle_count(&self) -> usize
pub fn particle_count(&self) -> usize
Number of particles
Sourcepub fn step_with_sdf(&mut self, dt: Fix128, sdf_colliders: &[SdfCollider])
pub fn step_with_sdf(&mut self, dt: Fix128, sdf_colliders: &[SdfCollider])
Step with SDF collision
Sourcepub fn center_of_mass(&self) -> Vec3Fix
pub fn center_of_mass(&self) -> Vec3Fix
Centroid of the particle positions. Every constructor gives all particles the same
mass, for which this is the centre of mass; it is not mass weighted if
inv_masses are edited to differ. Zero for a body without particles.
Sourcepub fn resolve_rigid_body_collisions(
&mut self,
rigid_bodies: &mut [RigidBody],
body_radii: &[Fix128],
dt: Fix128,
)
pub fn resolve_rigid_body_collisions( &mut self, rigid_bodies: &mut [RigidBody], body_radii: &[Fix128], dt: Fix128, )
Resolve collisions between deformable body particles and rigid bodies
Treats each rigid body as a sphere with given radius for simplicity. Applies two-way coupling: deformable particles are pushed out, and rigid bodies receive reaction impulses.
The correction and the (perfectly inelastic) normal impulse are shared by inverse
mass, w_p / (w_p + w_b) to the particle and w_b / (w_p + w_b) to the body; a body
with zero inverse mass (static, kinematic) takes none, so a particle pressed into it
ends exactly on its surface with zero approach speed. A particle exactly at the
centre of a body has no push direction and is left untouched; pinned particles
(zero inverse mass) are skipped. dt only gates the call (zero is a no-op).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DeformableBody
impl RefUnwindSafe for DeformableBody
impl Send for DeformableBody
impl Sync for DeformableBody
impl Unpin for DeformableBody
impl UnsafeUnpin for DeformableBody
impl UnwindSafe for DeformableBody
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more