Skip to main content

Constraint

Trait Constraint 

Source
pub trait Constraint: Debug {
Show 14 methods // Required methods fn compute_cdot(&self, bodies: &HashMap<BodyHandle, BodyState>) -> f32; fn compute_c(&self, bodies: &HashMap<BodyHandle, BodyState>) -> f32; fn apply_impulse( &self, bodies: &mut HashMap<BodyHandle, BodyState>, lambda: f32, ); fn effective_mass(&self, bodies: &HashMap<BodyHandle, BodyState>) -> f32; fn accumulated_impulse(&self) -> f32; fn reset_accumulated(&mut self); fn add_accumulated(&mut self, delta: f32); // Provided methods fn get_compliance(&self) -> f32 { ... } fn bias(&self, bodies: &HashMap<BodyHandle, BodyState>, dt: f32) -> f32 { ... } fn prepare(&mut self, _bodies: &HashMap<BodyHandle, BodyState>, _dt: f32) { ... } fn solve_velocity( &mut self, bodies: &mut HashMap<BodyHandle, BodyState>, dt: f32, ) { ... } fn solve_position( &mut self, bodies: &mut HashMap<BodyHandle, BodyState>, dt: f32, ) { ... } fn impulse_bounds(&self) -> (f32, f32) { ... } fn body_handles(&self) -> Vec<BodyHandle> { ... }
}
Expand description

A constraint imposes a restriction on body state.

Required Methods§

Source

fn compute_cdot(&self, bodies: &HashMap<BodyHandle, BodyState>) -> f32

Compute the velocity constraint violation (Cdot = J * v).

Source

fn compute_c(&self, bodies: &HashMap<BodyHandle, BodyState>) -> f32

Compute the position constraint violation (C).

Source

fn apply_impulse( &self, bodies: &mut HashMap<BodyHandle, BodyState>, lambda: f32, )

Apply the corrective impulse to body states.

Source

fn effective_mass(&self, bodies: &HashMap<BodyHandle, BodyState>) -> f32

Compute effective constraint mass (1 / (J M^-1 J^T)).

Source

fn accumulated_impulse(&self) -> f32

Accumulated impulse for warm starting.

Source

fn reset_accumulated(&mut self)

Source

fn add_accumulated(&mut self, delta: f32)

Provided Methods§

Source

fn get_compliance(&self) -> f32

XPBD compliance (inverse stiffness). 0 = rigid.

Source

fn bias(&self, bodies: &HashMap<BodyHandle, BodyState>, dt: f32) -> f32

Baumgarte position bias.

Source

fn prepare(&mut self, _bodies: &HashMap<BodyHandle, BodyState>, _dt: f32)

Prepare the constraint for the current step (pre-compute cached values).

Source

fn solve_velocity( &mut self, bodies: &mut HashMap<BodyHandle, BodyState>, dt: f32, )

Solve velocity constraint (one iteration).

Source

fn solve_position( &mut self, bodies: &mut HashMap<BodyHandle, BodyState>, dt: f32, )

Solve position constraint using XPBD (one sub-step).

Source

fn impulse_bounds(&self) -> (f32, f32)

Whether this constraint has an upper/lower impulse clamp.

Source

fn body_handles(&self) -> Vec<BodyHandle>

Bodies involved in this constraint.

Implementors§