Skip to main content

PhysicsWorld3D

Struct PhysicsWorld3D 

Source
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

Source

pub fn new(cell_size: f32) -> Self

Creates an empty world. Cell size should approximate typical bodies.

Source

pub fn insert(&mut self, body: PhysicsBody3D) -> BodyId

Inserts a body and returns an identity that is never reused.

Source

pub fn remove(&mut self, id: BodyId) -> Option<PhysicsBody3D>

Removes a collider. Active trigger pairs exit on the next step.

Source

pub fn body(&self, id: BodyId) -> Option<&PhysicsBody3D>

Reads a collider by stable identity.

Source

pub fn body_mut(&mut self, id: BodyId) -> Option<&mut PhysicsBody3D>

Edits a collider. Inputs are validated at the next step.

Source

pub fn iter(&self) -> impl Iterator<Item = (BodyId, &PhysicsBody3D)>

All colliders in stable identity order.

Source

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§

Source§

impl Debug for PhysicsWorld3D

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Component for T
where T: Send + Sync + 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.