pub struct LayeredScratch { /* private fields */ }Expand description
Advance every pedestrian in peds by dt using planar_step as the
per-floor physics and space for walls and connectors.
Semantics:
- Pedestrians currently riding a connector have their
remainingtime decremented; when it reaches zero they are teleported to the connector’sto_flooratto_posand grounded. - Grounded pedestrians are grouped by floor. For each floor the provided planar step function is called with that floor’s walls.
- After planar motion, each grounded pedestrian is checked against
the floor’s connectors; if its 2-D position lands inside a
connector’s boarding zone and its target is on the connector’s
destination floor, it boards (a new
ActiveTransitionbegins).
Boarding is only triggered for pedestrians whose target destination
(z-planar) is on a different floor; the selection of which connector
to take is the responsibility of the rustsim-mobility crate, which
would instead set the pedestrian’s destination to the connector’s
from_pos directly.
Reusable scratch buffers for step_layered_scratch.
step_layered is convenient but allocates four Vecs per tick
(floors, idxs, buf, walls). For a 30–60 Hz station sim with
multiple floors this is measurable allocator traffic. Allocate one
LayeredScratch per simulation, pass it to step_layered_scratch
every tick, and the heap is untouched on the steady state.
The individual fields are pub(crate) so the wrapper can reuse
them; external callers should treat the type as opaque.
Implementations§
Source§impl LayeredScratch
impl LayeredScratch
Sourcepub fn with_capacity(n_peds: usize) -> Self
pub fn with_capacity(n_peds: usize) -> Self
Create a scratch pre-sized for n_peds pedestrians. Vecs are
only reserved, not populated.