pub struct DecalSet { /* private fields */ }Expand description
The decals a backend’s projected-decal pass draws, addressed by the slot id
DecalSet::insert returns. That id is stable until DecalSet::remove
tombstones it, and indexes the backend’s parallel per-decal resources (an
albedo descriptor, a uniform ring slot).
capacity caps the slot table at the backend’s reserved descriptor count;
frames is its frames in flight, which sizes the per-slot upload tracking.
let mut decals = DecalSet::new(2, 2);
let id = decals.insert(record).expect("room for two");
decals.remove(id).expect("live slot");
assert!(decals.is_empty());Implementations§
Source§impl DecalSet
impl DecalSet
Sourcepub fn new(capacity: usize, frames: usize) -> Self
pub fn new(capacity: usize, frames: usize) -> Self
An empty set holding at most capacity slots, tracking uploads for
frames frames in flight.
Sourcepub fn insert(&mut self, record: DecalRecord) -> Result<usize, AtCapacity>
pub fn insert(&mut self, record: DecalRecord) -> Result<usize, AtCapacity>
Place record in a slot and return its id, reusing a tombstoned slot
before growing the table so a spawn / despawn cycle stays bounded. The
new slot is marked stale for every frame in flight.
Sourcepub fn remove(&mut self, id: usize) -> Result<(), RemoveError>
pub fn remove(&mut self, id: usize) -> Result<(), RemoveError>
Tombstone the slot at id, freeing it for the next Self::insert.
Sourcepub fn visible<'a>(
&'a self,
frustum: &'a Frustum,
) -> impl Iterator<Item = VisibleDecal<'a>> + 'a
pub fn visible<'a>( &'a self, frustum: &'a Frustum, ) -> impl Iterator<Item = VisibleDecal<'a>> + 'a
The live decals whose cached world AABB meets frustum, in slot order.
Each decal is tested once: a caller that needs to know whether the pass
draws anything peeks this iterator rather than counting it first.