FDebrisPool
The per-scene debris budget. Every shard a break spawns is entered here; when the count would pass the budget the OLDEST shard is recycled first, and no shard outlives the lifetime cap whatever its component asked for. Without this a cascade in a room full of crates spawned bodies until the physics step could not keep its budget, and "keep forever" pieces (a lifetime of 0) never left at all.
- Module
- Destruction
- Header
#include "Destruction/DebrisPool.h"- Namespace
Mowo
Type aliases
| Alias | Description |
|---|---|
using DestroyFn = std::function<void(EntityID)> |
Public functions
| Returns | Name | Description |
|---|---|---|
int32_t | MaxCount | phys.Debris.MaxCount / phys.Debris.MaxLifetime. |
float | MaxLifetime | |
int32_t | MaxSpawnPerFrame | phys.Debris.MaxSpawnPerFrame: shards one update may create across every break. |
void | SetSpawnCapOverride | |
int32_t | EffectiveMaxSpawnPerFrame | |
bool | TryReserveSpawn | |
void | SetBudgetOverride | A test (or a scene that knows better) can pin the budget without touching the cvars; negative restores the cvar. |
int32_t | EffectiveMaxCount | |
float | EffectiveMaxLifetime | |
float | ClampLifetime | 0 means "keep" on the component; under a budget that becomes the cap. |
size_t | Add | Enters a shard, evicting the oldest through destroy when the budget is already full. |
void | Tick | |
void | Forget | The entity went away some other way (its own cascade break, a scene unload) — drop it without destroying anything. |
bool | Contains | |
size_t | Count | |
void | Clear |
Function details
MaxCount
static int32_t MaxCount()phys.Debris.MaxCount / phys.Debris.MaxLifetime.
MaxLifetime
static float MaxLifetime()MaxSpawnPerFrame
static int32_t MaxSpawnPerFrame()phys.Debris.MaxSpawnPerFrame: shards one update may create across every break. A break past it spawns fewer pieces rather than a hitch; the count restarts at each Tick.
SetSpawnCapOverride
void SetSpawnCapOverride(int32_t maxSpawn)EffectiveMaxSpawnPerFrame
int32_t EffectiveMaxSpawnPerFrame() constTryReserveSpawn
bool TryReserveSpawn()SetBudgetOverride
void SetBudgetOverride(int32_t maxCount, float maxLifetime)A test (or a scene that knows better) can pin the budget without touching the cvars; negative restores the cvar.
EffectiveMaxCount
int32_t EffectiveMaxCount() constEffectiveMaxLifetime
float EffectiveMaxLifetime() constClampLifetime
float ClampLifetime(float requested) const0 means "keep" on the component; under a budget that becomes the cap.
Add
size_t Add(EntityID entity, float lifetime, const DestroyFn& destroy)Enters a shard, evicting the oldest through destroy when the budget is already full. Returns how many were evicted.
Tick
void Tick(float deltaTime, const DestroyFn& destroy)Forget
void Forget(EntityID entity)The entity went away some other way (its own cascade break, a scene unload) — drop it without destroying anything.
Contains
bool Contains(EntityID entity) constCount
size_t Count() constClear
void Clear()