![]() |
VR-Forces Developer's Guide
|
Fixed-capacity pool for DtBallisticProjectile objects.
Pre-allocates all projectile slots at initialization to avoid dynamic allocation during simulation. Provides O(1) acquire and release.
Public Member Functions | |
| DtBallisticProjectilePool () | |
| virtual | ~DtBallisticProjectilePool () |
| virtual void | preallocatePool (size_t count) |
| virtual DtBallisticProjectile * | acquire () |
| virtual void | release (DtBallisticProjectile *projectile) |
| virtual size_t | activeCount () const |
| virtual size_t | capacity () const |
| virtual const std::vector < DtBallisticProjectile > & | poolStorage () const |
| virtual std::vector < DtBallisticProjectile > & | poolStorage () |
| virtual const std::vector < DtBallisticProjectile * > & | availableProjectiles () const |
| virtual std::vector < DtBallisticProjectile * > & | availableProjectiles () |
Protected Attributes | |
| std::mutex | myPoolMutex |
| std::vector < DtBallisticProjectile > | myPool |
| std::vector < DtBallisticProjectile * > | myAvailable |
| makVrv::DtBallisticProjectilePool::DtBallisticProjectilePool | ( | ) |
Default constructor.
|
virtual |
Virtual destructor.
|
virtual |
Pre-allocates the pool to the given capacity.
Should be called once during initialization before any projectiles are spawned.
| count | Number of projectile slots to allocate. |
|
virtual |
Acquires an available projectile slot from the pool.
|
virtual |
Returns a projectile to the pool for reuse.
| projectile | Pointer to the projectile to release. |
|
virtual |
Returns the number of projectiles currently acquired from the pool.
|
virtual |
Returns the total number of slots pre-allocated in the pool.
|
virtual |
Returns read-only access to the pool storage.
|
virtual |
Returns mutable access to the pool storage.
|
virtual |
Returns read-only access to the list of currently available projectile slots.
|
virtual |
Returns mutable access to the list of currently available projectile slots.
|
mutableprotected |
Guards myAvailable for thread-safe acquire/release.
|
protected |
Pre-allocated storage for all projectile slots.
|
protected |
Pointers to currently available (unacquired) slots.