Each particle can be explicitly accessed for updating its position and velocity immediately.
The code snippet for updating the positions of particles is given as follows:
PxVec3 particlePositions[] = {...}; PxU32 particleIndices[] = {...}; PxU32 numParticles = ...; PxStrideIterator<const PxVec3> newPositionBuff (particlePositions); PxStrideIterator<const PxU32> indexBuff (particleIndices); //ps is the instance of PxParticleSystem or PxParticleFluid ps->setPositions(numParticles, indexBuff, newPositionBuff);
We can also update the forces on the particles by using addForces()
, as follows:
PxU32 numParticles = ...; PxStrideIterator<const PxVec3> forceBuffer = ...; PxStrideIterator<const PxU32> indexBuffer = ...; //ps is the instance of PxParticleSystem or PxParticleFluid ps->addForces(numParticles, indexBuffer,forceBuffer, PxForceMode::eFORCE);
The particle rest-offset can be updated if the PxParticleBaseFlag::ePER_PARTICLE_REST_OFFSET
function...