pub struct PhysicsIslands {
pub split_candidate: Option<IslandId>,
pub split_candidate_sleep_timer: f32,
/* private fields */
}
Expand description
A resource for the PhysicsIsland
s in the simulation.
Fields§
§split_candidate: Option<IslandId>
The current island candidate for splitting.
This is chosen based on which island with one or more constraints removed has the largest sleep timer.
split_candidate_sleep_timer: f32
The largest SleepTimer
of the split candidate.
Implementations§
Source§impl PhysicsIslands
impl PhysicsIslands
Sourcepub fn create_island_with<F>(&mut self, init: F) -> IslandIdwhere
F: FnOnce(&mut PhysicsIsland),
pub fn create_island_with<F>(&mut self, init: F) -> IslandIdwhere
F: FnOnce(&mut PhysicsIsland),
Creates a new PhysicsIsland
, calling the given init
function before pushing the island to the list.
Sourcepub fn remove_island(&mut self, island_id: IslandId) -> PhysicsIsland
pub fn remove_island(&mut self, island_id: IslandId) -> PhysicsIsland
Removes a PhysicsIsland
with the given ID. The island is assumed to be empty,
§Panics
Panics if island_id
is out of bounds.
Sourcepub fn get(&self, island_id: IslandId) -> Option<&PhysicsIsland>
pub fn get(&self, island_id: IslandId) -> Option<&PhysicsIsland>
Returns a reference to the PhysicsIsland
with the given ID.
Sourcepub fn get_mut(&mut self, island_id: IslandId) -> Option<&mut PhysicsIsland>
pub fn get_mut(&mut self, island_id: IslandId) -> Option<&mut PhysicsIsland>
Returns a mutable reference to the PhysicsIsland
with the given ID.
Sourcepub fn iter(&self) -> impl Iterator<Item = &PhysicsIsland>
pub fn iter(&self) -> impl Iterator<Item = &PhysicsIsland>
Returns an iterator over all PhysicsIsland
s.
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut PhysicsIsland>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut PhysicsIsland>
Returns a mutable iterator over all PhysicsIsland
s.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of PhysicsIsland
s.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if there are no PhysicsIsland
s.
Sourcepub fn add_contact(
&mut self,
contact_id: ContactId,
body_islands: &mut Query<'_, '_, &mut BodyIslandNode, Or<(With<Disabled>, Without<Disabled>)>>,
contact_graph: &mut ContactGraph,
joint_graph: &mut JointGraph,
) -> Option<&PhysicsIsland>
pub fn add_contact( &mut self, contact_id: ContactId, body_islands: &mut Query<'_, '_, &mut BodyIslandNode, Or<(With<Disabled>, Without<Disabled>)>>, contact_graph: &mut ContactGraph, joint_graph: &mut JointGraph, ) -> Option<&PhysicsIsland>
Adds a contact to the island manager. Returns a reference to the island that the contact was added to.
This will merge the islands of the bodies involved in the contact, and link the contact to the resulting island.
Called when a touching contact is created between two bodies.
Sourcepub fn remove_contact(
&mut self,
contact_id: ContactId,
body_islands: &mut Query<'_, '_, &mut BodyIslandNode, Or<(With<Disabled>, Without<Disabled>)>>,
contact_graph: &mut ContactGraphInternal,
joint_graph: &JointGraph,
) -> &PhysicsIsland
pub fn remove_contact( &mut self, contact_id: ContactId, body_islands: &mut Query<'_, '_, &mut BodyIslandNode, Or<(With<Disabled>, Without<Disabled>)>>, contact_graph: &mut ContactGraphInternal, joint_graph: &JointGraph, ) -> &PhysicsIsland
Removes a contact from the island manager. Returns a reference to the island that the contact was removed from.
This will unlink the contact from the island and update the island’s contact list.
The PhysicsIsland::constraints_removed
counter is incremented.
Called when a contact is destroyed or no longer touching.
Sourcepub fn add_joint(
&mut self,
joint_id: JointId,
body_islands: &mut Query<'_, '_, &mut BodyIslandNode, Or<(With<Disabled>, Without<Disabled>)>>,
contact_graph: &mut ContactGraph,
joint_graph: &mut JointGraph,
) -> Option<&PhysicsIsland>
pub fn add_joint( &mut self, joint_id: JointId, body_islands: &mut Query<'_, '_, &mut BodyIslandNode, Or<(With<Disabled>, Without<Disabled>)>>, contact_graph: &mut ContactGraph, joint_graph: &mut JointGraph, ) -> Option<&PhysicsIsland>
Adds a joint to the island manager. Returns a reference to the island that the joint was added to.
This will merge the islands of the bodies connected by the joint, and link the joint to the resulting island.
Called when a joint is created between two bodies.
Sourcepub fn remove_joint(
&mut self,
joint_id: JointId,
body_islands: &mut Query<'_, '_, &mut BodyIslandNode, Or<(With<Disabled>, Without<Disabled>)>>,
contact_graph: &ContactGraph,
joint_graph: &mut JointGraph,
) -> &PhysicsIsland
pub fn remove_joint( &mut self, joint_id: JointId, body_islands: &mut Query<'_, '_, &mut BodyIslandNode, Or<(With<Disabled>, Without<Disabled>)>>, contact_graph: &ContactGraph, joint_graph: &mut JointGraph, ) -> &PhysicsIsland
Removes a joint from the island manager. Returns a reference to the island that the joint was removed from.
This will unlink the joint from the island and update the island’s joint list.
The PhysicsIsland::constraints_removed
counter is incremented.
The joint should be removed from the JointGraph
in concert with calling this method.
Called when a joint is destroyed or no longer connected to the bodies.
Sourcepub fn merge_islands(
&mut self,
body1: Entity,
body2: Entity,
body_islands: &mut Query<'_, '_, &mut BodyIslandNode, Or<(With<Disabled>, Without<Disabled>)>>,
contact_graph: &mut ContactGraph,
joint_graph: &mut JointGraph,
) -> IslandId
pub fn merge_islands( &mut self, body1: Entity, body2: Entity, body_islands: &mut Query<'_, '_, &mut BodyIslandNode, Or<(With<Disabled>, Without<Disabled>)>>, contact_graph: &mut ContactGraph, joint_graph: &mut JointGraph, ) -> IslandId
Merges the PhysicsIsland
s associated with the given bodies. Returns the ID of the resulting island.
If an awake island is merged with a sleeping island, the resulting island will remain sleeping. It is up to the caller to wake up the resulting island if needed.
The bodies and contacts of the smaller island are transferred to the larger island, and the smaller island is removed.
Sourcepub fn split_island(
&mut self,
island_id: IslandId,
body_islands: &mut Query<'_, '_, &mut BodyIslandNode, Or<(With<Disabled>, Without<Disabled>)>>,
body_colliders: &Query<'_, '_, &RigidBodyColliders>,
contact_graph: &mut ContactGraph,
joint_graph: &mut JointGraph,
)
pub fn split_island( &mut self, island_id: IslandId, body_islands: &mut Query<'_, '_, &mut BodyIslandNode, Or<(With<Disabled>, Without<Disabled>)>>, body_colliders: &Query<'_, '_, &RigidBodyColliders>, contact_graph: &mut ContactGraph, joint_graph: &mut JointGraph, )
Splits the PhysicsIsland
associated with the given ID.
Unlike merging, splitting can be deferred and done in parallel with other work.
Trait Implementations§
Source§impl Clone for PhysicsIslands
impl Clone for PhysicsIslands
Source§fn clone(&self) -> PhysicsIslands
fn clone(&self) -> PhysicsIslands
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PhysicsIslands
impl Debug for PhysicsIslands
Source§impl Default for PhysicsIslands
impl Default for PhysicsIslands
Source§fn default() -> PhysicsIslands
fn default() -> PhysicsIslands
impl Resource for PhysicsIslands
Auto Trait Implementations§
impl Freeze for PhysicsIslands
impl RefUnwindSafe for PhysicsIslands
impl Send for PhysicsIslands
impl Sync for PhysicsIslands
impl Unpin for PhysicsIslands
impl UnwindSafe for PhysicsIslands
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self
using default()
.
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
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.