PxF32 processDigitalValue (const PxU32 inputType, const PxVehicleKeySmoothingData& keySmoothing, const bool digitalValue, const PxF32 timestep, const PxF32 analogVal) { PxF32 newAnalogVal=analogVal; if(digitalValue) { newAnalogVal+=keySmoothing.mRiseRates[inputType]*timestep; } else { newAnalogVal-=keySmoothing.mFallRates[inputType]*timestep; } return PxClamp(newAnalogVal,0.0f,1.0f); }
void ParticleEmitterPressure::stepInternal(ParticleData& particles, PxReal dt, const PxVec3& externalAcceleration, PxReal maxParticleVelocity) { PX_ASSERT(mNumX > 0 && mNumY > 0); mSimulationAcceleration = externalAcceleration; mSimulationMaxVelocity = maxParticleVelocity; PxU32 numEmittedParticles = 0; PxU32 maxParticlesPerStep = (PxU32)physx::shdfnd::floor(mMaxRate*dt); PxU32 maxParticles = PxMin(particles.maxParticles - particles.numParticles, maxParticlesPerStep); PxU32 siteNr = 0; for(PxU32 y = 0; y != mNumY; y++) { PxReal offset = 0.0f; if (y%2) offset = mSpacingX * 0.5f; for(PxU32 x = 0; x != mNumX; x++) { if (isOutsideShape(x,y,offset)) continue; SiteData& siteData = mSites[siteNr]; //position noise PxVec3 posNoise; posNoise.x = randInRange(-mRandomPos.x, mRandomPos.x); posNoise.y = randInRange(-mRandomPos.y, mRandomPos.y); //special code for Z noise if (!siteData.predecessor) siteData.noiseZ = randInRange(-mRandomPos.z, mRandomPos.z); else { PxReal noiseZOffset = PxMin(mMaxZNoiseOffset, mRandomPos.z); siteData.noiseZ += randInRange(-noiseZOffset, noiseZOffset); siteData.noiseZ = PxClamp(siteData.noiseZ, mRandomPos.z, -mRandomPos.z); } posNoise.z = siteData.noiseZ; //set position PxVec3 sitePos = mBasePos + mAxisX*(offset+mSpacingX*x) + mAxisY*(mSpacingY*y) + mAxisZ*siteData.noiseZ; PxVec3 particlePos = sitePos + mAxisX*posNoise.x + mAxisY*posNoise.y; PxVec3 siteVel; computeSiteVelocity(siteVel, particlePos); if (siteData.predecessor) { predictPredecessorPos(siteData, dt); } else { bool isSpawned = spawnParticle(particles, numEmittedParticles, maxParticles, particlePos, siteVel); if(isSpawned) { updatePredecessor(siteData, particlePos, siteVel); } else { siteData.predecessor = false; return; } } bool allSpawned = stepEmissionSite(siteData, particles, numEmittedParticles, maxParticles, sitePos, siteVel, dt); if(!allSpawned) return; siteNr++; } } }