pub struct VoronoiFracture {
pub cells: Vec<VoronoiCell>,
pub bounds_min: Vec3,
pub bounds_max: Vec3,
pub num_cells: usize,
pub material_strength: f32,
pub toughness: f32,
pub density: f32,
pub cracks: Vec<(usize, usize)>,
pub debris_particles: Vec<DebrisParticle>,
pub fractured: bool,
}Fields§
§cells: Vec<VoronoiCell>§bounds_min: Vec3§bounds_max: Vec3§num_cells: usize§material_strength: f32§toughness: f32§density: f32§cracks: Vec<(usize, usize)>§debris_particles: Vec<DebrisParticle>§fractured: boolImplementations§
Source§impl VoronoiFracture
impl VoronoiFracture
pub fn new( bounds_min: Vec3, bounds_max: Vec3, num_cells: usize, seed: u64, ) -> Self
Sourcepub fn find_cell(&self, point: Vec3) -> usize
pub fn find_cell(&self, point: Vec3) -> usize
For each point, find the nearest Voronoi seed (Lloyd-style cell assignment)
Sourcepub fn accumulate_stress(
&mut self,
cell_idx: usize,
force_magnitude: f32,
contact_area: f32,
)
pub fn accumulate_stress( &mut self, cell_idx: usize, force_magnitude: f32, contact_area: f32, )
Accumulate stress on a cell given an impulse force
Sourcepub fn check_fracture(&mut self) -> Vec<usize>
pub fn check_fracture(&mut self) -> Vec<usize>
Check if any cells exceed strength threshold and initiate fracture
Sourcepub fn propagate_cracks(&mut self, initial_cells: &[usize])
pub fn propagate_cracks(&mut self, initial_cells: &[usize])
Propagate crack from a fractured cell to neighbors
Sourcepub fn spawn_debris(&mut self, impact_velocity: Vec3, rng: &mut FractureRng)
pub fn spawn_debris(&mut self, impact_velocity: Vec3, rng: &mut FractureRng)
Spawn debris from fractured cells
Sourcepub fn integrate_debris(&mut self, dt: f32)
pub fn integrate_debris(&mut self, dt: f32)
Integrate debris particles
Sourcepub fn are_connected(&self, a: usize, b: usize) -> bool
pub fn are_connected(&self, a: usize, b: usize) -> bool
Check if two cells are still connected (no crack between them)
Trait Implementations§
Source§impl Clone for VoronoiFracture
impl Clone for VoronoiFracture
Auto Trait Implementations§
impl Freeze for VoronoiFracture
impl RefUnwindSafe for VoronoiFracture
impl Send for VoronoiFracture
impl Sync for VoronoiFracture
impl Unpin for VoronoiFracture
impl UnsafeUnpin for VoronoiFracture
impl UnwindSafe for VoronoiFracture
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.