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§
Sourcefn compute_cdot(&self, bodies: &HashMap<BodyHandle, BodyState>) -> f32
fn compute_cdot(&self, bodies: &HashMap<BodyHandle, BodyState>) -> f32
Compute the velocity constraint violation (Cdot = J * v).
Sourcefn compute_c(&self, bodies: &HashMap<BodyHandle, BodyState>) -> f32
fn compute_c(&self, bodies: &HashMap<BodyHandle, BodyState>) -> f32
Compute the position constraint violation (C).
Sourcefn apply_impulse(
&self,
bodies: &mut HashMap<BodyHandle, BodyState>,
lambda: f32,
)
fn apply_impulse( &self, bodies: &mut HashMap<BodyHandle, BodyState>, lambda: f32, )
Apply the corrective impulse to body states.
Sourcefn effective_mass(&self, bodies: &HashMap<BodyHandle, BodyState>) -> f32
fn effective_mass(&self, bodies: &HashMap<BodyHandle, BodyState>) -> f32
Compute effective constraint mass (1 / (J M^-1 J^T)).
Sourcefn accumulated_impulse(&self) -> f32
fn accumulated_impulse(&self) -> f32
Accumulated impulse for warm starting.
fn reset_accumulated(&mut self)
fn add_accumulated(&mut self, delta: f32)
Provided Methods§
Sourcefn get_compliance(&self) -> f32
fn get_compliance(&self) -> f32
XPBD compliance (inverse stiffness). 0 = rigid.
Sourcefn bias(&self, bodies: &HashMap<BodyHandle, BodyState>, dt: f32) -> f32
fn bias(&self, bodies: &HashMap<BodyHandle, BodyState>, dt: f32) -> f32
Baumgarte position bias.
Sourcefn prepare(&mut self, _bodies: &HashMap<BodyHandle, BodyState>, _dt: f32)
fn prepare(&mut self, _bodies: &HashMap<BodyHandle, BodyState>, _dt: f32)
Prepare the constraint for the current step (pre-compute cached values).
Sourcefn solve_velocity(
&mut self,
bodies: &mut HashMap<BodyHandle, BodyState>,
dt: f32,
)
fn solve_velocity( &mut self, bodies: &mut HashMap<BodyHandle, BodyState>, dt: f32, )
Solve velocity constraint (one iteration).
Sourcefn solve_position(
&mut self,
bodies: &mut HashMap<BodyHandle, BodyState>,
dt: f32,
)
fn solve_position( &mut self, bodies: &mut HashMap<BodyHandle, BodyState>, dt: f32, )
Solve position constraint using XPBD (one sub-step).
Sourcefn impulse_bounds(&self) -> (f32, f32)
fn impulse_bounds(&self) -> (f32, f32)
Whether this constraint has an upper/lower impulse clamp.
Sourcefn body_handles(&self) -> Vec<BodyHandle>
fn body_handles(&self) -> Vec<BodyHandle>
Bodies involved in this constraint.