Skip to main content

World

Struct World 

Source
pub struct World<S: PhysicsSpace> {
    pub narrowphase: Narrowphase<S>,
    pub field_narrowphase: FieldNarrowphase<S>,
    /* private fields */
}

Fields§

§narrowphase: Narrowphase<S>§field_narrowphase: FieldNarrowphase<S>

Implementations§

Source§

impl<S: PhysicsSpace> World<S>

Source

pub fn new(space: S) -> Self

Source

pub fn counters(&self) -> StepCounters

From the last step or broadphase_into.

Source

pub fn bodies(&self) -> &BodyArena<S>

Source

pub fn space(&self) -> &S

Source

pub fn gravity(&self) -> Option<S::Vector>

Source

pub fn set_gravity( &mut self, gravity: Option<S::Vector>, ) -> Result<(), EditError>

Source

pub fn solver_iterations(&self) -> usize

Source

pub fn set_solver_iterations(&mut self, iterations: usize)

Source

pub fn solver_tolerance(&self) -> f32

Source

pub fn set_solver_tolerance(&mut self, tolerance: f32) -> Result<(), EditError>

Source

pub fn time(&self) -> f32

Source

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

Source

pub fn manifolds( &self, ) -> impl ExactSizeIterator<Item = (&PairKey, &Manifold<S>)>

Source

pub fn manifold(&self, key: PairKey) -> Option<&Manifold<S>>

Source

pub fn solve_report(&self) -> SolveReport

Source

pub fn push_body(&mut self, body: BodyDef<S>) -> BodyId

Source

pub fn insert_field( &mut self, anchor: BodyId, field: Box<dyn DistanceField>, ) -> Result<FieldId, EditError>

anchor must be static; it leaves every collision group so the broadphase never pairs it, and it owns the field’s contacts.

Source

pub fn bind_field( &mut self, body: BodyId, field: FieldId, ) -> Result<(), EditError>

Every step queries the field for body; a contact lands in the manifold keyed by the body and the field’s anchor.

Source

pub fn field_bindings(&self) -> &[(BodyId, FieldId)]

Source

pub fn geometry(&self) -> &GeometryStore

Source

pub fn reclaim_geometry(&mut self) -> Option<Collider>

Pops the newest of the last two released shapes so its buffer can be reused.

Source

pub fn collider(&self, body: &RigidBody<S>) -> Option<&Collider>

Source

pub fn despawn_body(&mut self, id: BodyId) -> Result<(), EditError>

Also removes every manifold the body takes part in.

Source

pub fn set_pose( &mut self, id: BodyId, position: S::Point, orientation: S::Iso, ) -> Result<(), EditError>

Drops the body’s contacts.

Source

pub fn set_velocity( &mut self, id: BodyId, velocity: S::Vector, angular_velocity: S::AngVel, ) -> Result<(), EditError>

Source

pub fn set_restitution( &mut self, id: BodyId, restitution: f32, ) -> Result<(), EditError>

Source

pub fn set_collision_filter( &mut self, id: BodyId, group: u32, mask: u32, ) -> Result<(), EditError>

Source

pub fn set_mass_properties( &mut self, id: BodyId, mass: f32, inertia: S::Inertia, ) -> Result<(), EditError>

Drops the body’s contacts.

Source

pub fn set_collider( &mut self, id: BodyId, collider: Collider, inertia: S::Inertia, ) -> Result<(), EditError>

Drops the body’s contacts.

Source

pub fn apply_impulse( &mut self, id: BodyId, impulse: S::Vector, ) -> Result<(), EditError>
where S::Vector: Add<Output = S::Vector> + Mul<f32, Output = S::Vector>,

Source

pub fn apply_impulse_at_point( &mut self, id: BodyId, impulse: S::Vector, point: S::Point, ) -> Result<(), EditError>
where S::Vector: Add<Output = S::Vector> + Mul<f32, Output = S::Vector>,

Source

pub fn sleep_body(&mut self, id: BodyId) -> Result<(), EditError>
where S::Vector: Default,

Source

pub fn wake_body(&mut self, id: BodyId) -> Result<(), EditError>

Source

pub fn drain_dirty(&mut self) -> DirtyDrain<'_, S> ⓘ

Yields each body spawned, integrated, edited, or restored since the last drain, skipping despawned ones.

Source

pub fn snapshot(&self) -> WorldState<S>

Source

pub fn check_restore(&self, state: &WorldState<S>) -> Result<(), EditError>
where S::Vector: VectorOps, S::AngVel: PartialEq, S::Point: Copy + Sub<Output = S::Vector>,

Source

pub fn restore(&mut self, state: &WorldState<S>) -> Result<(), EditError>
where S::Vector: VectorOps, S::AngVel: PartialEq, S::Point: Copy + Sub<Output = S::Vector>,

Refuses, unchanged, whatever check_restore refuses.

Source

pub fn step(&mut self, dt: f32) -> Result<(), EditError>
where S::Vector: VectorOps, S::Point: Copy + Sub<Output = S::Vector>,

dt is in seconds.

Source

pub fn broadphase_into(&mut self, pairs: &mut Vec<PairKey>)

Replaces pairs with the sorted candidates: bounding-ball overlaps under a certified bound, every masked non-static pair otherwise.

Source

pub fn hash_contacts(&self, hash: &mut StateHash)

Hashes contact keys, point counts, and normal impulses in key order.

Source

pub fn state_hash( &self, sample_body: impl Fn(&RigidBody<S>, &mut Vec<u32>), ) -> u64

Hashes bodies by handle, then contacts; sample_body must emit fixed-width records.

Source

pub fn islands(&self) -> Vec<Island>

Returns islands by id; stale manifold handles panic after a bare BodyArena::despawn.

Auto Trait Implementations§

§

impl<S> Freeze for World<S>
where S: Freeze, <S as Space>::Vector: Freeze,

§

impl<S> !RefUnwindSafe for World<S>

§

impl<S> Send for World<S>

§

impl<S> Sync for World<S>

§

impl<S> Unpin for World<S>
where S: Unpin, <S as Space>::Vector: Unpin, <S as Space>::Point: Unpin, <S as IsometryGroup>::Iso: Unpin, <S as PhysicsSpace>::AngVel: Unpin, <S as PhysicsSpace>::Inertia: Unpin,

§

impl<S> UnsafeUnpin for World<S>
where S: UnsafeUnpin, <S as Space>::Vector: UnsafeUnpin,

§

impl<S> !UnwindSafe for World<S>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more