pub struct RapierState {Show 15 fields
pub integration_params: IntegrationParameters,
pub pipeline: PhysicsPipeline,
pub islands: IslandManager,
pub broad_phase: BroadPhaseBvh,
pub narrow_phase: NarrowPhase,
pub bodies: RigidBodySet,
pub colliders: ColliderSet,
pub impulse_joints: ImpulseJointSet,
pub multibody_joints: MultibodyJointSet,
pub ccd_solver: CCDSolver,
pub gravity: Vector,
pub node_to_body: IndexMap<NodeId, RigidBodyHandle>,
pub body_to_node: IndexMap<RigidBodyHandle, NodeId>,
pub node_to_collider: IndexMap<NodeId, ColliderHandle>,
pub collider_to_node: IndexMap<ColliderHandle, NodeId>,
}Expand description
Shared world state: every rapier set the simulation needs, plus the
NodeId-to-handle maps that keep scene identity in sync with rapier’s
handle namespace.
The four maps are IndexMaps (insertion-ordered) rather than
HashMap so iteration order is the same
on every run. The simulate plugin walks node_to_body to drive its
writeback and event-translation passes, so this gives deterministic
writeback and RapierContactEvent order within a single process.
For cross-platform floating-point determinism (different CPUs
producing the same bits), enable rapier’s enhanced-determinism Cargo
feature on the rapier3d dependency. That is a compile-time feature,
not a runtime switch.
Fields are public; reach in via crate::RapierPlugin::with_state_mut
for anything not covered by the curated handle API.
Fields§
§integration_params: IntegrationParameters§pipeline: PhysicsPipeline§islands: IslandManager§broad_phase: BroadPhaseBvh§narrow_phase: NarrowPhase§bodies: RigidBodySet§colliders: ColliderSet§impulse_joints: ImpulseJointSet§multibody_joints: MultibodyJointSet§ccd_solver: CCDSolver§gravity: Vector§node_to_body: IndexMap<NodeId, RigidBodyHandle>§body_to_node: IndexMap<RigidBodyHandle, NodeId>§node_to_collider: IndexMap<NodeId, ColliderHandle>§collider_to_node: IndexMap<ColliderHandle, NodeId>Implementations§
Source§impl RapierState
impl RapierState
pub fn new(gravity: Vector) -> Self
Sourcepub fn add_body(&mut self, node_id: NodeId, body: RigidBody, collider: Collider)
pub fn add_body(&mut self, node_id: NodeId, body: RigidBody, collider: Collider)
Insert a rigid body + collider pair and bind them to a scene node. The
body and collider should already be configured (use rapier’s
RigidBodyBuilder / ColliderBuilder).
Sourcepub fn remove_body(&mut self, node_id: NodeId)
pub fn remove_body(&mut self, node_id: NodeId)
Remove the body bound to node_id (and its collider). No-op if the
node was never registered.
Uses shift_remove on every map so the insertion order of the
remaining entries is preserved; this is what gives the simulate
plugin’s writeback a deterministic order across runs.
Sourcepub fn clear_bodies(&mut self)
pub fn clear_bodies(&mut self)
Remove every registered body.
Sourcepub fn node_for_collider(&self, handle: ColliderHandle) -> Option<NodeId>
pub fn node_for_collider(&self, handle: ColliderHandle) -> Option<NodeId>
NodeId bound to a collider handle, if any.
Sourcepub fn node_for_body(&self, handle: RigidBodyHandle) -> Option<NodeId>
pub fn node_for_body(&self, handle: RigidBodyHandle) -> Option<NodeId>
NodeId bound to a rigid body handle, if any.
Auto Trait Implementations§
impl !RefUnwindSafe for RapierState
impl !UnwindSafe for RapierState
impl Freeze for RapierState
impl Send for RapierState
impl Sync for RapierState
impl Unpin for RapierState
impl UnsafeUnpin for RapierState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn 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>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which 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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.