pub struct PhysicsWorld {
pub gravity: Vec2,
pub substeps: u32,
pub sleep_threshold: f32,
pub fixed_dt: f32,
/* private fields */
}Expand description
The physics simulation world.
Maintains a list of bodies and constraints, steps them each frame, performs collision detection and resolution.
Fields§
§gravity: Vec2§substeps: u32§sleep_threshold: f32§fixed_dt: f32Implementations§
Source§impl PhysicsWorld
impl PhysicsWorld
pub fn new() -> Self
Sourcepub fn remove_body(&mut self, id: BodyId)
pub fn remove_body(&mut self, id: BodyId)
Remove a body by ID.
Sourcepub fn add_constraint(&mut self, c: Constraint)
pub fn add_constraint(&mut self, c: Constraint)
Add a constraint.
Sourcepub fn body_mut(&mut self, id: BodyId) -> Option<&mut RigidBody>
pub fn body_mut(&mut self, id: BodyId) -> Option<&mut RigidBody>
Get a body by ID (mutable reference).
Sourcepub fn set_gravity_3d(&mut self, g: Vec3)
pub fn set_gravity_3d(&mut self, g: Vec3)
Apply gravity from Vec3 (ignores Z).
Sourcepub fn contacts(&self) -> &[ContactManifold]
pub fn contacts(&self) -> &[ContactManifold]
Returns all contact manifolds from the last step.
pub fn body_count(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PhysicsWorld
impl RefUnwindSafe for PhysicsWorld
impl Send for PhysicsWorld
impl Sync for PhysicsWorld
impl Unpin for PhysicsWorld
impl UnsafeUnpin for PhysicsWorld
impl UnwindSafe for PhysicsWorld
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.