Trait pixel_game_lib::physics::constraint::Constraint

source ·
pub trait Constraint<const RIGIDBODIES: usize> {
    // Required methods
    fn lambda(&self) -> f64;
    fn set_lambda(&mut self, lambda: f64);
    fn solve(&mut self, rigidbodies: &mut View<'_, RigidBodyQuery<'_>>, dt: f64);

    // Provided methods
    fn reset(&mut self) { ... }
    fn delta_lambda<const AMOUNT: usize>(
        lambda: f64,
        magnitude: f64,
        compliance: f64,
        gradients: [Vec2<f64>; AMOUNT],
        attachments: [Vec2<f64>; AMOUNT],
        bodies: [(InvMass, Inertia); AMOUNT],
        dt: f64
    ) -> f64 { ... }
}
Expand description

XPBD constraint between one or more rigid bodies.

Required Methods§

source

fn lambda(&self) -> f64

Current stored lambda.

source

fn set_lambda(&mut self, lambda: f64)

Set the lambda.

source

fn solve(&mut self, rigidbodies: &mut View<'_, RigidBodyQuery<'_>>, dt: f64)

Solve the constraint.

Applies the force immediately to the rigidbodies.

Provided Methods§

source

fn reset(&mut self)

Reset the constraint at the beginning of a step (not a sub-step).

source

fn delta_lambda<const AMOUNT: usize>( lambda: f64, magnitude: f64, compliance: f64, gradients: [Vec2<f64>; AMOUNT], attachments: [Vec2<f64>; AMOUNT], bodies: [(InvMass, Inertia); AMOUNT], dt: f64 ) -> f64

Calculate a generic form of the lambda update.

Object Safety§

This trait is not object safe.

Implementors§