Skip to main content

PhysicsSystem

Struct PhysicsSystem 

Source
pub struct PhysicsSystem { /* private fields */ }
Expand description

ECS system that owns a PhysicsWorld, stores rigid body dynamics data, and runs the integration loop with force providers.

See the module docs for how bodies are stored.

§Integration loop

Each tick(dt) calls step(dt) once with the schedule’s real tick period. Without contacts the caller is responsible for substepping: call step(substep_dt) multiple times per tick to advance physics at a higher rate than the game tick. A system made with_contacts substeps inside step instead, because collision runs once a tick and the solver several times; see step.

§Entities

An Entity here is only a key: a generational crcbl_core::Handle<EntityMarker>, compared and hashed and never looked up anywhere else. It can come from any crcbl_core::Pool<EntityMarker> — a crcbl_ecs::World’s, or one a game allocates its own entities from — and nothing here asks that pool whether a handle is still alive.

That is why remove_entity belongs before the handle is freed. The system never learns that a pool let one go: until it is removed the body keeps stepping, its collider stays in the world, and every query that meets it answers with a handle its pool calls dead. The old handle still removes the right body afterwards — its generation keeps it from naming whatever the pool reissues the slot to — but only a caller that kept it can say which body to remove. A system registered in a crcbl_ecs schedule is told by SystemTrait::sweep, which removes each dead entity for it; a game with its own pool has to do the same itself.

Implementations§

Source§

impl PhysicsSystem

Source

pub fn apply_impulse_at( &mut self, entity: Entity, impulse: DVec3, point: DVec3, ) -> Result<(), ImpulseError>

Applies an impulse immediately and wakes the target body’s island.

impulse and point are world-space, on RigidBody::apply_impulse_at’s terms. Invalid input and missing bodies return ImpulseError without changing velocities or waking an island. A recorded crate::KineticContact has already affected its struck body; transferring it to a newly created ragdoll body is the caller’s explicit action, not an automatic replay onto the original target.

Source§

impl PhysicsSystem

Source

pub fn farthest_clear_point( &mut self, from: DVec3, to: DVec3, radius: f64, skin: f64, filter: QueryFilter, ) -> DVec3

The farthest point from from towards to a sphere of radius can stand, skin metres short of the first collider it would touch.

This is what a camera boom, a held weapon’s muzzle or a spring arm asks: sweep from a point known to be clear — the head, the pivot — towards where the eye wants to be, and stop just in front of the wall. The skin keeps the near plane off the surface it stopped at. to comes back when nothing is in the way and when the path has no length; from when the sweep starts touching something or the skin is longer than the way to the hit. The skin is measured along the path, not along the surface’s normal.

filter leaves colliders out — the character the camera follows, at least — on QueryFilter’s terms. Triggers never stop it.

Source§

impl PhysicsSystem

Source

pub fn set_collision_filter( &mut self, entity: Entity, filter: CollisionFilter, ) -> bool

Sets the categories entity’s body is in and those it collides with, and wakes it. Contacts the new filter forbids end at once; pairs it newly allows are found on the next step. Returns false, changing nothing, if the entity is not registered.

Source

pub fn collision_filter(&self, entity: Entity) -> Option<CollisionFilter>

entity’s collision filter, if it is registered.

Source§

impl PhysicsSystem

Source

pub fn debug_lines(&self, line: &mut impl FnMut(DVec3, DVec3, PhysicsDebugLine))

Hands line every segment of the physics debug view as the last step left it, each tagged with the PhysicsDebugLine it is: the twelve edges of each entity’s collider’s bounding box, telling sleeping bodies and islands apart, then each contact point’s normal, with its impulse and its feature. A plane has no box drawn; a contact with one has its normal drawn as any other.

Source§

impl PhysicsSystem

Source

pub fn ignore_contacts( &mut self, a: Entity, b: Entity, ) -> Result<bool, ContactPairError>

Stops the bodies of a and b colliding with each other, and wakes both: every contact between them is ended, as a joint that keeps its bodies apart ends theirs. Each still collides with everything else. Returns Ok(false) if the pair was already ignored.

This is for bodies that overlap by design without a joint between them, such as two limbs of one ragdoll meeting at its pelvis. The pair is forgotten when either entity is removed.

§Errors

ContactPairError::UnknownBody if either entity is not registered, and ContactPairError::SameBody if the two are one.

§Panics

Panics if this system has no contacts. Build it with_contacts.

Source

pub fn restore_contacts( &mut self, a: Entity, b: Entity, ) -> Result<bool, ContactPairError>

Lets the bodies of a and b collide with each other again, unless a joint still keeps them apart, and wakes both. Returns Ok(false) if the pair was not ignored.

§Errors

As ignore_contacts’s.

§Panics

Panics if this system has no contacts.

Source

pub fn ignores_contacts(&self, a: Entity, b: Entity) -> bool

Whether ignore_contacts keeps the bodies of a and b apart. A joint’s own rule is not counted here.

Source§

impl PhysicsSystem

Source

pub fn add_joint(&mut self, joint: Joint) -> Result<JointId, JointError>

Adds joint and wakes both its bodies — decision 4’s “a new joint” wake rule. Unless it lets them collide, every contact between them is ended.

§Errors

JointError::UnknownBody if either entity is not registered — a fixed anchor is an entity given a transform with set_transform — JointError::SameBody if the two are one, and JointError::Invalid for a setting out of range.

§Panics

Panics if this system has no contacts: joints are constraints in the contact solver. Build it with_contacts.

Source

pub fn remove_joint(&mut self, id: JointId) -> Option<Joint>

Takes joint id out, waking both its bodies, and returns it; None if it is not there — never added, removed, or broken.

Source

pub fn joint(&self, id: JointId) -> Option<&Joint>

Joint id, if it is there.

Source

pub fn set_joint( &mut self, id: JointId, joint: Joint, ) -> Result<bool, JointError>

Replaces joint id with joint — a new motor speed, new limits, other bodies — waking its bodies old and new. What it carries is kept for the warm start while it stays the same kind between the same bodies. Returns Ok(false) if id names no joint.

§Errors

As add_joint’s, and the joint is left as it was.

Source

pub fn joints(&self) -> impl Iterator<Item = (JointId, &Joint)>

Every joint and its id, in the order they were added into the pool’s slots.

Source

pub fn joint_count(&self) -> usize

How many joints there are.

Source

pub fn joint_reaction(&self, id: JointId) -> Option<(f64, f64)>

The force, in newtons, and torque, in newton-metres, joint id carried over the last substep it was solved in: what its thresholds are held to.

Source

pub fn joint_anchors(&self, id: JointId) -> Option<(DVec3, DVec3)>

Where joint id’s frames are in the world now: its anchor on body A and its anchor on body B, which it holds together or apart.

Source

pub fn joint_drift(&self, id: JointId) -> Option<JointDrift>

How far joint id is from holding, with its bodies where they are now: see JointDrift.

Source

pub fn broken_joints(&self) -> &[JointBreak]

The joints the last step broke, and took out.

Source

pub fn set_substeps(&mut self, entity: Entity, substeps: u32) -> bool

Asks the solver to give entity’s body substeps substeps a tick, and every body it is joined to by a contact or a joint the same: decision 1’s extra substeps per group. A group runs the most any of its bodies asked for, and never fewer than crate::ContactSettings::substeps, so zero is the system’s own; its constraints are stiffer in proportion — see the solver’s groups in crates/crcbl-phys/src/contact/group.rs. Returns false if the entity is not registered.

A bridge’s planks or a tall column ask for more, and the rest of the system pays nothing for it.

Source

pub fn substeps(&self, entity: Entity) -> Option<u32>

The substeps entity asked for with set_substeps, or None if it is not registered.

Source§

impl PhysicsSystem

Source

pub const NAME: &'static str = "physics"

The system’s name, and so the key its replicated transforms travel under: a client finds them by this name’s replicated id.

Source

pub fn new() -> Self

Create an empty physics system.

Integration is SemiImplicitEuler; see PhysicsSystem::step.

Source

pub fn with_contacts(settings: ContactSettings) -> Self

Create an empty physics system whose bodies collide: see crate::contact.

Every collider that is not a trigger takes part, and step becomes a whole tick of ContactSettings::substeps solver substeps rather than one integration.

Source

pub fn contact_settings(&self) -> Option<&ContactSettings>

The contact settings, or None in a system without contacts.

Source

pub fn contact_settings_mut(&mut self) -> Option<&mut ContactSettings>

The contact settings to change, or None in a system without contacts. A change takes effect on the next step.

Source

pub fn add_plane( &mut self, normal: DVec3, offset: f64, material: SurfaceMaterial, ) -> PlaneId

Add a static plane: the half-space normal · x ≤ offset is solid to every body with contacts.

A plane is solver geometry only. It has no entity and no collider in world, so a ray, a sweep or an overlap query passes straight through it.

§Panics

Panics if this system has no contacts, or if normal is not of unit length.

Source

pub fn contact_counters(&self) -> ContactCounters

What the last step of the contact pipeline did, or every counter zero in a system without contacts.

Source

pub fn kinetic_contacts(&self) -> &[KineticContact]

The KineticContacts the last step raised, in the order its contacts were solved.

Source

pub fn contacts(&self) -> Vec<ContactReport>

Every contact, touching or not, as the last step left it, in the pool’s order.

Source

pub fn collider_count(&self) -> usize

Number of entities with colliders registered.

Source

pub fn body_count(&self) -> usize

Number of entities with rigid bodies registered, sleeping ones included.

Source

pub fn is_sleeping(&self, entity: Entity) -> bool

Whether entity’s body sleeps: its island has been still long enough that nothing steps it until something wakes it — see crate::contact. false for an entity with no body, and always in a system without contacts.

Source

pub fn put_to_sleep(&mut self, entity: Entity) -> bool

Puts entity’s island to sleep now, without stepping: its bodies stop where they are, with their velocities zeroed and their forces cleared, exactly as an island that fell asleep on its own does. Returns whether the entity’s body sleeps afterwards.

This is for restoring a snapshot taken while a body slept: stepping it awake instead would re-settle it for ContactSettings::time_to_sleep and leave it a hair from where it was saved. Register the body first (set_body, set_transform, set_collider), then call this. A body registered since the last step is an island of its own, so each restored body sleeps alone; one already linked to others by touching contacts takes its whole island with it, as sleep never splits an island.

It wakes by every rule a sleeping island wakes by — a contact from an awake body, set_transform, body_mut, a force. What a snapshot does not restore is the contacts’ warm-start impulses: they are rebuilt cold when it wakes.

false, and nothing changes, for an entity with no dynamic body, in a system without contacts, or with ContactSettings::sleep off.

Source

pub fn set_body(&mut self, entity: Entity, body: RigidBody)

Register a rigid body for entity.

Replaces any existing body. The entity will participate in the integration loop, from the transform it already has or from Transform::IDENTITY if it has none. A sleeping body’s island wakes.

§Panics

Panics if body is dynamic and entity’s collider is a ColliderComponent::Mesh: a mesh is for static and kinematic bodies.

Source

pub fn set_transform(&mut self, entity: Entity, transform: Transform)

Set the world-space transform for entity.

If the entity has a collider, it is repositioned immediately. A teleport wakes the entity’s island and every sleeping island touching it where it was; one that lands a static body on a sleeping one wakes that too, on the next step.

Source

pub fn body(&self, entity: Entity) -> Option<&RigidBody>

Get a reference to an entity’s rigid body. Reading a sleeping body does not wake it.

Source

pub fn body_mut(&mut self, entity: Entity) -> Option<&mut RigidBody>

Get a mutable reference to an entity’s rigid body, for a game that chooses a velocity rather than having one integrated onto it.

set_body is the wrong tool for that: it replaces the whole body to change one DVec3, and a crowd sample does it once per agent per tick. apply_force is not the tool either — a kinematic body has zero inverse mass, so a force on it is a no-op by construction, and kinematic is exactly what a steered agent is.

It hands back the body and nothing else, so it cannot move a collider: position lives in the transform, and changing that still goes through set_transform, which repositions the broadphase.

A sleeping body’s island wakes: whatever is written — a velocity, a force — must be stepped. Read with body to leave it asleep.

Source

pub fn transform(&self, entity: Entity) -> Option<&Transform>

Get a reference to an entity’s transform.

Source

pub fn set_material( &mut self, entity: Entity, material: SurfaceMaterial, ) -> bool

Set the surface material of entity’s body or collider. Returns false if the entity is not registered.

Every registered entity starts with SurfaceMaterial::DEFAULT. In a system with contacts, each contact combines its two surfaces’ materials every tick, so a change takes effect on the next step; see crate::material. It wakes the entity’s island and every sleeping island touching it, whose friction may no longer hold them.

Source

pub fn material(&self, entity: Entity) -> Option<SurfaceMaterial>

The surface material of entity, if it is registered.

Source

pub fn add_force_provider(&mut self, provider: Box<dyn ForceProvider>)

Add a force provider. Providers are applied in order before integration.

Providers are global: every dynamic body gets every provider. That is right for a field force — gravity, drag — and wrong for one that belongs to a single entity, such as the thrust of the one ship among a screenful of rocks. For that, use PhysicsSystem::apply_force.

Source

pub fn apply_force(&mut self, entity: Entity, force: DVec3) -> bool

Add a world-space force to one entity’s accumulator for the next PhysicsSystem::step. Returns false if the entity has no body.

This is how a game applies a force only some entities feel — the player’s thrust, a shove from a pickup — without a provider that would apply it to everything. Like a provider’s contribution it lasts one substep: the integrator clears the accumulator, so a force held down over time is re-applied each tick.

crate::ThrustForce::world_force computes the thrust vector to pass here from a body’s orientation, so a per-entity thrust and a pipeline one are the same model either way.

A sleeping body’s island wakes, as it does for apply_torque: a force applied every tick keeps a body awake.

Source

pub fn apply_torque(&mut self, entity: Entity, torque: DVec3) -> bool

Add a world-space torque to one entity’s accumulator for the next PhysicsSystem::step, on apply_force’s terms. Returns false if the entity has no body.

A body with no rotational inertia accepts the torque and ignores it; see RigidBody.

Source

pub fn set_collider( &mut self, entity: Entity, component: &ColliderComponent, transform: &Transform, )

Add or replace a collider for entity.

The collider sits at transform.position plus the component’s offset turned by transform.rotation, as the contact pipeline places it. The component is cached so PhysicsSystem::step can reposition the collider after integration.

The new collider has a new ColliderId — read it again with collider_of — but keeps the entity’s query layers.

Replacing a collider wakes on remove_collider’s terms.

§Panics

Panics if component is a ColliderComponent::Mesh and entity has a dynamic body: a mesh is for static and kinematic bodies.

Source

pub fn remove_entity(&mut self, entity: Entity)

Remove the collider and dynamics data for entity, its joints, and the pairs ignore_contacts kept it in.

Its island wakes, and so does every sleeping island that touched it: see remove_collider.

Source

pub fn remove_collider(&mut self, entity: Entity)

Remove only the collider (no-op if none).

A body losing its collider is a support taken away: its island wakes, and so does every sleeping island touching it — a crate pulled out from under a sleeping stack drops the stack.

Source

pub fn set_collider_layers(&mut self, entity: Entity, bits: u32) -> bool

Put entity’s query collider on the layers in bits: see PhysicsWorld::set_layers. For a compound that is the one collider holding all its parts. Returns false, and changes nothing, if the entity has no collider.

The layers belong to the entity rather than to one ColliderId: they stay while step moves the collider, and a collider that set_collider replaces — or sets again after remove_collider — is put back on them. Keeping them is the rule because a replacement is almost always the same thing changing shape: an item re-shaped on pickup is still an item, and a rule that reset it would put it back on every layer, blocking every sweep, until the caller noticed. Only remove_entity forgets them.

Layers filter queries only. The contact pipeline does not read them, so a body on a layer a character’s mask leaves out still collides with other bodies.

Source

pub fn collider_of(&self, entity: Entity) -> Option<ColliderId>

The query collider set_collider made for entity — for a compound, the one collider holding all its parts — or None if the entity has no collider.

The id changes when the collider is replaced, so read it again after a set_collider rather than keeping it: an old one resolves to nothing. It is what a QueryFilter excludes, and what world’s own queries answer with.

Source

pub fn entity_of(&self, collider: ColliderId) -> Option<Entity>

The entity whose query collider collider is, or None if it is no entity’s — a collider added straight to world_mut, or an id that was removed or replaced since.

The inverse of collider_of, for turning a hit from world’s own queries back into an entity.

Source

pub fn step(&mut self, dt: f64)

Advance dynamics by dt seconds.

Without contacts this is one substep: all force providers, then every body integrated — position, velocity, orientation and angular velocity — with SemiImplicitEuler. A caller wanting substeps calls this n times with dt / n.

With contacts (with_contacts) this is one tick: the force providers, then the contact broadphase and every manifold once, then ContactSettings::substeps solver substeps of dt / substeps, each integrating the bodies with the same SemiImplicitEuler split around the contact impulses. A force applied before the call is held for the whole tick. A body that touches nothing integrates exactly as the same number of contact-free substeps would, short of the speed and rotation caps and of the sweep that follows, which stops a fast body or a bullet where its path met something. An island that has been still long enough sleeps, and a sleeping body is not stepped at all. See crate::contact.

Either way, collider positions are synced to the new transforms, and bodies are visited in the awake set’s own order, which is the order of the calls that registered them; see the module docs.

Source

pub fn step_timed(&mut self, dt: f64, clock: &mut dyn FnMut() -> f64)

step, reading clock — seconds from any fixed origin — between the stages, so ContactCounters::stages reports what each took.

The clock is the caller’s because this crate reads none: a step’s results must not depend on time, and std::time::Instant does not exist in a browser. A system without contacts has no stages and never reads it.

Source

pub fn cast_ray(&mut self, ray: &Ray) -> Option<(Entity, ShapeHit)>

Cast a ray, returning the closest hit entity and details.

Source

pub fn cast_ray_filtered( &mut self, ray: &Ray, filter: QueryFilter, ) -> Option<(Entity, ShapeHit)>

cast_ray over only the colliders filter admits — see QueryFilter and set_collider_layers.

Source

pub fn sweep_sphere( &mut self, segment: &Segment, radius: f64, ) -> Option<(Entity, ShapeHit)>

Sweep a sphere, returning the closest hit entity and details.

Every collider in the world is a candidate. A caller sweeping a body along its own path wants sweep_body instead, which builds the same segment and leaves that body out of the answer.

Source

pub fn sweep_sphere_filtered( &mut self, segment: &Segment, radius: f64, filter: QueryFilter, ) -> Option<(Entity, ShapeHit)>

sweep_sphere over only the colliders filter admits — see QueryFilter.

Source

pub fn sweep_body( &mut self, entity: Entity, dt: f64, radius: f64, ) -> Option<(Entity, ShapeHit)>

Sweep the body at entity along the segment it covers in dt: from where it was (position − velocity·dt) to where it is (position), with the given radius. Returns the closest hit.

This is the “never miss at any speed” half of CCD — a body moving faster than its own radius in one tick would tunnel through anything it crossed between steps, and the swept volume is what catches it.

§The swept entity is left out of its own answer

The segment ends where the body is, so the body’s own collider sits on the end of it: swept against itself it is a hit at t = 0, closer than anything it was actually heading for. This excludes it — see PhysicsWorld::sweep_sphere_excluding, which drops it in the narrow phase so the next-closest hit survives. An entity with a collider is therefore swept exactly like one without, and neither the caller nor this method has to lift a collider out of the world to ask.

Source

pub fn sweep_body_filtered( &mut self, entity: Entity, dt: f64, radius: f64, mask: u32, ) -> Option<(Entity, ShapeHit)>

sweep_body looking only at the colliders on a layer in mask — see set_collider_layers.

A mask and not a whole QueryFilter, because the exclusion is not the caller’s to choose: it is always the swept body’s own collider.

Source

pub fn overlap_sphere( &mut self, centre: DVec3, radius: f64, ) -> Vec<(Entity, OverlapHit)>

Overlap query: every entity whose collider the sphere is inside, each with how deep, which way out and where (OverlapHit).

§An overlap’s hit is a push-out, not an impact

This once answered (Entity, ShapeHit) with the hit filled in as t: 0.0, normal: DVec3::Y and started_inside: true whatever the geometry, and then bare entities, on the argument that an overlap has no impact time, point or single normal. The first half of that holds, and is why the hit is not a ShapeHit. The second does not: the shortest move that takes the sphere out of a shape is one direction and one depth, which is what Unity’s Physics.ComputePenetration and PhysX’s PxGeometryQuery::computePenetration answer, and the point it is pushed out from is one point. Of a compound, the deepest part answers. A collider the sphere only touches is not inside it and is not returned.

A caller that wants only the entities maps the pairs, unless it is a crowd pass running one query per body per tick: that wants EntityOverlapQueries::overlap_sphere_entities_into, which answers the same entities without building the hits.

§The query is shape-aware, and radius is expanded by each collider

The query sphere is tested against every collider’s shape, so a sphere collider of radius r_b is returned iff its centre is within radius + r_b of centre (and a box or capsule by the extent of its own shape). A caller that wants “everything whose centre is within radius” has to subtract the largest collider radius itself. This is not a corner of the API — apps/horde‘s separation query is only correct because it omits the neighbour’s radius on purpose and lets this expansion supply it; the boundary is pinned by world::tests’ a_sphere_overlap_is_expanded_by_the_colliders_own_radius.

Source

pub fn overlap_sphere_into( &mut self, centre: DVec3, radius: f64, out: &mut Vec<(Entity, OverlapHit)>, )

overlap_sphere writing into a buffer the caller owns, for a game that queries once per body per tick.

Same shape-aware semantics as overlap_sphere: a sphere collider of radius r_b is returned iff its centre is within radius + r_b of centre.

out is cleared and then filled, so the buffer is hoisted out of the loop and reused. Nothing below this allocates either: the world’s hits land in a scratch buffer of this system’s, and the BVH’s descent stack and candidate list are the world’s own. A crowd of ten thousand therefore steers without a single allocation, where the owned form is three per agent per tick.

Source

pub fn overlap_sphere_filtered( &mut self, centre: DVec3, radius: f64, filter: QueryFilter, ) -> Vec<(Entity, OverlapHit)>

overlap_sphere naming only the entities whose collider filter admits — see QueryFilter.

Source

pub fn overlap_sphere_filtered_into( &mut self, centre: DVec3, radius: f64, filter: QueryFilter, out: &mut Vec<(Entity, OverlapHit)>, )

overlap_sphere_into naming only the entities whose collider filter admits — see QueryFilter.

Source

pub fn overlap_queries(&mut self) -> EntityOverlapQueries<'_>

Builds the broadphase and hands back a shared view that can query it by entity.

The system-level twin of PhysicsWorld::overlap_queries, and the entry point a data-parallel pass over a crowd wants: it is what lets every chunk of a crcbl_jobs par_for run its own neighbourhood queries at the same time. See EntityOverlapQueries.

Source

pub fn overlap_aabb(&mut self, aabb: &Aabb) -> Vec<Entity> ⓘ

Overlap query: return all entities whose collider meets aabb, as PhysicsWorld::overlap_aabb answers it — a box, a compound or a mesh where its shape meets it, a sphere or a capsule wherever the world-axis box around it does.

Source

pub fn overlap_aabb_filtered( &mut self, aabb: &Aabb, filter: QueryFilter, ) -> Vec<Entity> ⓘ

overlap_aabb naming only the entities whose collider filter admits — see QueryFilter.

Source

pub fn world(&self) -> &PhysicsWorld

Direct access to the underlying PhysicsWorld for advanced use.

Source

pub fn world_mut(&mut self) -> &mut PhysicsWorld

Mutable access to the underlying PhysicsWorld for advanced use.

Trait Implementations§

Source§

impl Debug for PhysicsSystem

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for PhysicsSystem

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl SystemTrait for PhysicsSystem

Source§

fn access(&self) -> Access

Nothing shared: a step works on the bodies, colliders and force providers this system owns.

Source§

fn debug_draw(&mut self, _ctx: &DebugCtx)

Draws nothing: DebugCtx carries nothing to draw into, so the view is debug_lines, for a caller to draw.

Source§

fn hash_state(&self, hasher: &mut dyn Hasher)

Feed transform and rigid-body state into the determinism hash.

Entities are visited in ascending to_bits() order rather than in the sets’ order, which depends on the history of calls that built them, and every float goes in canonicalised — -0.0 as +0.0, every NaN as one — so the hash is a function of the simulation state and nothing else.

In a system with contacts each body’s sleep goes in too — whether it sleeps, and if not how long it has been still — since two states that differ only there step differently.

Source§

fn name(&self) -> &str

Human-readable name for the inspector / debug overlay.
Source§

fn tick(&mut self, dt: f64)

Called once per tick by the schedule. Read more
Source§

fn entity_count(&self) -> usize

Number of entities currently registered with this system.
Source§

fn sweep(&mut self, dead: &[Entity])

Remove every entity listed in dead from this system. Read more
Source§

fn contributes_to_hash(&self) -> bool

Whether this system’s SystemTrait::hash_state contributes component data to the determinism hash. Read more
Source§

fn replicate(&self, out: &mut Vec<u8>) -> bool

Serialise this system’s per-entity component data for replication. Read more
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Downcast support for callers that hold &mut dyn SystemTrait (e.g. through Schedule::iter_mut) and need the concrete system type. Implementations are the one-liner self.
Source§

fn debug_fields( &self, _entity: Handle<EntityMarker>, ) -> Option<&(dyn Reflect + 'static)>

What this system holds for entity, for a debug overlay to show. 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> 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.