#include <PxParticleExt.h>
Classes | |
class | IndexPool |
Class to manage particle indices. Extension particle index management can be useful if no application side particle index allocation functionality is available. An PxParticleExt::IndexPool instance is meant to be used for one PxParticleSystem/PxParticleFluid instance. The instance can be created with PxParticleExt::createIndexPool(). More... | |
struct | ParticleBounds |
Static Public Member Functions | |
static PxU32 | buildBoundsHash (PxU32 *sortedParticleIndices, ParticleBounds *particleBounds, const PxStrideIterator< const PxVec3 > &positionBuffer, const PxU32 validParticleRange, const PxU32 *validParticleBitmap, const PxU32 hashSize, const PxU32 maxBounds, const PxReal gridSpacing) |
Computes particle bounds by sorting particle positions into a spatial hash grid. More... | |
static IndexPool * | createIndexPool (PxU32 maxParticles) |
Creates a PxParticlesExt::IndexPool instance. More... | |
static IndexPool * | createIndexPool (PxU32 maxParticles, PxU32 validParticleRange, const PxU32 *validParticleBitmap) |
Creates a PxParticlesExt::IndexPool instance initialized with a preallocated set of indices specified with a bitmap. More... | |
|
static |
Computes particle bounds by sorting particle positions into a spatial hash grid.
Given a strided array of particle positions, this function partitions the particles into subsets of nearby particles by mapping the particle positions onto a 3-dimensional grid and creating ParticleBounds data structures for each occupied grid cell.
Each returned ParticleBounds data structure can be used to determine the indices of the particles belonging to the same grid cell. Particle indices of one grid cell are returned as contiguous blocks in the sortedParticleIndices buffer and can be found within the range [firstParticle, firstParticle + numParticles - 1]. Each returned ParticleBounds further contains an AABB "bounds" that tightly fits all particle positions within the grid cell.
The number of created ParticleBounds can be retrieved via the return value. The user can cap the maximum amount of generated ParticleBounds via the maxBounds parameter. Particles that would cause this maximum to be exceeded will be skipped over and will not be part of any returned ParticleBounds. (Note that this also hold when maxBounds is equal to hashSize. Thus, in the worst case, if no particle should ever be skipped over by the algorithm "hashSize" must be at least equal to numParticles)
The user is responsible for allocating the output buffers sortedParticleIndices (for at least numParticles entries) and particleBounds (for at least maxBounds entries).
The size of a cubical grid cell can be tuned by setting the gridSpacing parameter.
The user supplied hashSize must be a power of two.
[out] | sortedParticleIndices | Pointer to user allocated array of size numParticles where the sorted particle indices will be written to. |
[out] | particleBounds | Pointer to user allocated array of size maxBounds where the ParticleBounds will be written to. |
[in] | positionBuffer | Strided data of input particle positions. |
[in] | validParticleRange | Range of valid particles within validParticleBitmap. (See PxParticleReadData.validParticleRange). |
[in] | validParticleBitmap | Bitmap specifying valid slots in positionBuffer. (See PxParticleReadData.validParticleBitmap). |
[in] | hashSize | Hash size used internally by the hashing algorithm. Must be a power of two. |
[in] | maxBounds | Maximum number of bounds to be returned. Must be smaller or equal than hashSize. |
[in] | gridSpacing | Side length of each cubical grid cell. |
Creates a PxParticlesExt::IndexPool instance.
[in] | maxParticles | Maximum number of available indices. |
|
static |
Creates a PxParticlesExt::IndexPool instance initialized with a preallocated set of indices specified with a bitmap.
[in] | maxParticles | Maximum number of available indices. |
[in] | validParticleRange | Range of indices represented in validParticleBitmap. (See PxParticleReadData.validParticleRange). |
[in] | validParticleBitmap | Bitmap specifying the valid particle indices that should be preallocated. (See PxParticleReadData.validParticleBitmap). |