Skip to main content

DestructibleSet

Struct DestructibleSet 

Source
pub struct DestructibleSet { /* private fields */ }
Expand description

Main orchestrator for destructible structures with Rapier integration.

Manages the stress solver and the mapping between solver actors and Rapier bodies. Call step() each frame to advance the simulation.

Implementations§

Source§

impl DestructibleSet

Source

pub fn new(config: DestructibleConfig) -> Option<Self>

Create a new destructible set.

You must call initialize() after creating the Rapier world to set up the initial bodies.

Source

pub fn from_scenario( scenario: &ScenarioDesc, settings: SolverSettings, gravity: Vec3, policy: FracturePolicy, ) -> Option<Self>

Create a destructible set from a scenario description.

Node sizes are estimated from volume (cube root).

Source

pub fn initialize( &mut self, bodies: &mut RigidBodySet, colliders: &mut ColliderSet, ) -> Vec<RigidBodyHandle>

Set up initial Rapier bodies from the solver’s actor table.

Must be called once before the first step().

Source

pub fn step( &mut self, bodies: &mut RigidBodySet, colliders: &mut ColliderSet, island_manager: &mut IslandManager, impulse_joints: &mut ImpulseJointSet, multibody_joints: &mut MultibodyJointSet, ) -> StepResult

Run one simulation step:

  1. Apply gravity
  2. Update stress solver
  3. Generate and apply fractures (rate-limited by policy)
  4. Create/destroy Rapier bodies for split events
  5. Apply excess forces to newly separated actors
Source

pub fn step_with_time( &mut self, now_secs: f32, bodies: &mut RigidBodySet, colliders: &mut ColliderSet, island_manager: &mut IslandManager, impulse_joints: &mut ImpulseJointSet, multibody_joints: &mut MultibodyJointSet, ) -> StepResult

Source

pub fn add_force(&mut self, node_index: u32, position: Vec3, force: Vec3)

Apply an external force to a node (e.g., from a projectile impact).

Source

pub fn add_acceleration( &mut self, node_index: u32, position: Vec3, acceleration: Vec3, )

Apply an external acceleration to a node.

Source

pub fn node_body(&self, node_index: u32) -> Option<RigidBodyHandle>

Get the Rapier body handle for a node.

Source

pub fn node_collider(&self, node_index: u32) -> Option<ColliderHandle>

Get the Rapier collider handle for a node.

Source

pub fn collider_node(&self, collider: ColliderHandle) -> Option<u32>

Get the node index owning a collider.

Source

pub fn node_local_offset(&self, node_index: u32) -> Option<Vec3>

Get the node’s local offset relative to its owning Rapier body.

Source

pub fn body_nodes(&self, body_handle: RigidBodyHandle) -> Vec<u32>

Get the node indices attached to a Rapier body.

Source

pub fn body_nodes_slice(&self, body_handle: RigidBodyHandle) -> &[u32]

Source

pub fn body_node_count(&self, body_handle: RigidBodyHandle) -> usize

Source

pub fn body_has_support(&self, body_handle: RigidBodyHandle) -> bool

Source

pub fn is_support(&self, node_index: u32) -> bool

Whether a node is a fixed support.

Source

pub fn actor_count(&self) -> u32

Current actor count in the stress graph.

Source

pub fn active_bond_count(&self) -> usize

Number of bonds still considered active by the Rust-side fracture tracking.

Source

pub fn body_count(&self) -> usize

Number of tracked Rapier bodies.

Source

pub fn collider_count(&self) -> usize

Source

pub fn dynamic_body_count(&self, bodies: &RigidBodySet) -> usize

Source

pub fn awake_dynamic_body_count(&self, bodies: &RigidBodySet) -> usize

Source

pub fn sleeping_dynamic_body_count(&self, bodies: &RigidBodySet) -> usize

Source

pub fn support_body_count(&self) -> usize

Source

pub fn ccd_enabled_body_count(&self, bodies: &RigidBodySet) -> usize

Source

pub fn solver(&self) -> &ExtStressSolver

Access the underlying solver for advanced use.

Source

pub fn solver_mut(&mut self) -> &mut ExtStressSolver

Mutable access to the underlying solver.

Source

pub fn policy(&self) -> &FracturePolicy

Access the fracture policy.

Source

pub fn set_policy(&mut self, policy: FracturePolicy)

Mutable access to the fracture policy.

Source

pub fn resimulation_options(&self) -> ResimulationOptions

Source

pub fn set_resimulation_options(&mut self, options: ResimulationOptions)

Source

pub fn skip_single_bodies(&self) -> bool

Source

pub fn set_skip_single_bodies(&mut self, enabled: bool)

Source

pub fn sleep_thresholds(&self) -> SleepThresholdOptions

Source

pub fn set_sleep_thresholds(&mut self, options: SleepThresholdOptions)

Source

pub fn small_body_damping(&self) -> SmallBodyDampingOptions

Source

pub fn set_small_body_damping(&mut self, options: SmallBodyDampingOptions)

Source

pub fn debris_cleanup(&self) -> DebrisCleanupOptions

Source

pub fn set_debris_cleanup(&mut self, options: DebrisCleanupOptions)

Source

pub fn debris_collision_mode(&self) -> DebrisCollisionMode

Source

pub fn set_debris_collision_mode(&mut self, mode: DebrisCollisionMode)

Source

pub fn ground_body_handle(&self) -> Option<RigidBodyHandle>

Source

pub fn set_ground_body_handle(&mut self, handle: Option<RigidBodyHandle>)

Source

pub fn refresh_collision_groups( &self, bodies: &RigidBodySet, colliders: &mut ColliderSet, )

Source

pub fn dynamic_body_ccd_enabled(&self) -> bool

Source

pub fn set_dynamic_body_ccd_enabled(&mut self, enabled: bool)

Source

pub fn set_split_child_recentering_enabled(&mut self, enabled: bool)

Source

pub fn set_split_child_velocity_fit_enabled(&mut self, enabled: bool)

Source

pub fn pending_split_event_count(&self) -> usize

Source

pub fn pending_new_body_count(&self, bodies: &RigidBodySet) -> usize

Source

pub fn pending_collider_migration_count(&self, bodies: &RigidBodySet) -> usize

Source

pub fn needs_resimulation_snapshot(&self) -> bool

Source

pub fn capture_resimulation_snapshot( &self, bodies: &RigidBodySet, ) -> BodySnapshots

Source

pub fn mark_body_support_contact( &mut self, body_handle: RigidBodyHandle, now_secs: f32, bodies: &mut RigidBodySet, colliders: &mut ColliderSet, ) -> bool

Source

pub fn process_optimizations( &mut self, now_secs: f32, bodies: &mut RigidBodySet, colliders: &mut ColliderSet, island_manager: &mut IslandManager, impulse_joints: &mut ImpulseJointSet, multibody_joints: &mut MultibodyJointSet, ) -> OptimizationResult

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &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)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.