pub struct ConstraintWorld {
pub bodies: HashMap<BodyHandle, BodyState>,
pub constraints: Vec<Box<dyn Constraint>>,
pub solver: ConstraintSolver,
pub gravity: Vec2,
pub use_islands: bool,
pub use_xpbd: bool,
/* private fields */
}Expand description
Manages all bodies and constraints in one place.
Fields§
§bodies: HashMap<BodyHandle, BodyState>§constraints: Vec<Box<dyn Constraint>>§solver: ConstraintSolver§gravity: Vec2§use_islands: boolWhether to use island-based solving.
use_xpbd: boolWhether to use XPBD substep integration.
Implementations§
Source§impl ConstraintWorld
impl ConstraintWorld
pub fn new() -> Self
pub fn add_body(&mut self, state: BodyState) -> BodyHandle
pub fn add_constraint(&mut self, c: Box<dyn Constraint>) -> ConstraintId
pub fn remove_body(&mut self, handle: BodyHandle)
pub fn step(&mut self, dt: f32)
pub fn body(&self, h: BodyHandle) -> Option<&BodyState>
pub fn body_mut(&mut self, h: BodyHandle) -> Option<&mut BodyState>
pub fn body_count(&self) -> usize
pub fn constraint_count(&self) -> usize
Sourcepub fn total_kinetic_energy(&self) -> f32
pub fn total_kinetic_energy(&self) -> f32
Compute total kinetic energy.
Sourcepub fn remove_sleeping(&mut self, threshold: f32)
pub fn remove_sleeping(&mut self, threshold: f32)
Remove all sleeping bodies from the simulation.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConstraintWorld
impl !RefUnwindSafe for ConstraintWorld
impl !Send for ConstraintWorld
impl !Sync for ConstraintWorld
impl Unpin for ConstraintWorld
impl UnsafeUnpin for ConstraintWorld
impl !UnwindSafe for ConstraintWorld
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
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.