pub struct PhysicsWorld3D { /* private fields */ }Expand description
Small deterministic arcade world. Own it in game state and call
step(ctx.tick, &mut events) exactly once per fixed update.
Implementations§
Source§impl PhysicsWorld3D
impl PhysicsWorld3D
Sourcepub fn new(cell_size: f32) -> Self
pub fn new(cell_size: f32) -> Self
Creates an empty world. Cell size should approximate typical bodies.
Sourcepub fn insert(&mut self, body: PhysicsBody3D) -> BodyId
pub fn insert(&mut self, body: PhysicsBody3D) -> BodyId
Inserts a body and returns an identity that is never reused.
Sourcepub fn remove(&mut self, id: BodyId) -> Option<PhysicsBody3D>
pub fn remove(&mut self, id: BodyId) -> Option<PhysicsBody3D>
Removes a collider. Active trigger pairs exit on the next step.
Sourcepub fn body(&self, id: BodyId) -> Option<&PhysicsBody3D>
pub fn body(&self, id: BodyId) -> Option<&PhysicsBody3D>
Reads a collider by stable identity.
Sourcepub fn body_mut(&mut self, id: BodyId) -> Option<&mut PhysicsBody3D>
pub fn body_mut(&mut self, id: BodyId) -> Option<&mut PhysicsBody3D>
Edits a collider. Inputs are validated at the next step.
Sourcepub fn iter(&self) -> impl Iterator<Item = (BodyId, &PhysicsBody3D)>
pub fn iter(&self) -> impl Iterator<Item = (BodyId, &PhysicsBody3D)>
All colliders in stable identity order.
Sourcepub fn step(
&mut self,
tick: Tick,
events: &mut Events<TriggerEvent>,
) -> StepReport
pub fn step( &mut self, tick: Tick, events: &mut Events<TriggerEvent>, ) -> StepReport
Advances one fixed tick; appends trigger transitions to events.
Panics for nonfinite/invalid body properties or negative/nonfinite dt.
Kinematic bodies follow velocity even through static geometry.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PhysicsWorld3D
impl RefUnwindSafe for PhysicsWorld3D
impl Send for PhysicsWorld3D
impl Sync for PhysicsWorld3D
impl Unpin for PhysicsWorld3D
impl UnsafeUnpin for PhysicsWorld3D
impl UnwindSafe for PhysicsWorld3D
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