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