aboutsummaryrefslogtreecommitdiff
path: root/APEX_1.4/module/pxparticleios/src
diff options
context:
space:
mode:
authorgit perforce import user <a@b>2016-10-25 12:29:14 -0600
committerSheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees>2016-10-25 18:56:37 -0500
commit3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch)
treefa6485c169e50d7415a651bf838f5bcd0fd3bfbd /APEX_1.4/module/pxparticleios/src
downloadphysx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz
physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip
Initial commit:
PhysX 3.4.0 Update @ 21294896 APEX 1.4.0 Update @ 21275617 [CL 21300167]
Diffstat (limited to 'APEX_1.4/module/pxparticleios/src')
-rw-r--r--APEX_1.4/module/pxparticleios/src/ModuleParticleIosImpl.cpp398
-rw-r--r--APEX_1.4/module/pxparticleios/src/ParticleIosActorCPU.cpp442
-rw-r--r--APEX_1.4/module/pxparticleios/src/ParticleIosActorGPU.cpp993
-rw-r--r--APEX_1.4/module/pxparticleios/src/ParticleIosActorImpl.cpp818
-rw-r--r--APEX_1.4/module/pxparticleios/src/ParticleIosAssetImpl.cpp152
-rw-r--r--APEX_1.4/module/pxparticleios/src/ParticleIosScene.cpp459
-rw-r--r--APEX_1.4/module/pxparticleios/src/autogen/FluidParticleSystemParams.cpp361
-rw-r--r--APEX_1.4/module/pxparticleios/src/autogen/ParticleIosAssetParam.cpp1339
-rw-r--r--APEX_1.4/module/pxparticleios/src/autogen/ParticleIosDebugRenderParams.cpp333
-rw-r--r--APEX_1.4/module/pxparticleios/src/autogen/ParticleIosModuleParameters.cpp318
-rw-r--r--APEX_1.4/module/pxparticleios/src/autogen/SimpleParticleSystemParams.cpp435
11 files changed, 6048 insertions, 0 deletions
diff --git a/APEX_1.4/module/pxparticleios/src/ModuleParticleIosImpl.cpp b/APEX_1.4/module/pxparticleios/src/ModuleParticleIosImpl.cpp
new file mode 100644
index 00000000..f720247b
--- /dev/null
+++ b/APEX_1.4/module/pxparticleios/src/ModuleParticleIosImpl.cpp
@@ -0,0 +1,398 @@
+/*
+ * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
+ *
+ * NVIDIA CORPORATION and its licensors retain all intellectual property
+ * and proprietary rights in and to this software, related documentation
+ * and any modifications thereto. Any use, reproduction, disclosure or
+ * distribution of this software and related documentation without an express
+ * license agreement from NVIDIA CORPORATION is strictly prohibited.
+ */
+
+
+#include "Apex.h"
+
+#include "ModuleParticleIosImpl.h"
+#include "ModuleParticleIosRegistration.h"
+#include "ParticleIosScene.h"
+#include "ParticleIosAssetImpl.h"
+#include "ParticleIosActorImpl.h"
+#include "SceneIntl.h"
+#include "ModuleIofxIntl.h"
+#include "ModuleFieldSamplerIntl.h"
+#include "PsMemoryBuffer.h"
+#include "ModulePerfScope.h"
+using namespace pxparticleios;
+
+#include "ReadCheck.h"
+#include "WriteCheck.h"
+#include "ApexSDKIntl.h"
+#include "ApexUsingNamespace.h"
+
+#include "Lock.h"
+
+namespace nvidia
+{
+namespace apex
+{
+
+#if defined(_USRDLL)
+
+/* Modules don't have to link against the framework, they keep their own */
+ApexSDKIntl* gApexSdk = 0;
+ApexSDK* GetApexSDK()
+{
+ return gApexSdk;
+}
+ApexSDKIntl* GetInternalApexSDK()
+{
+ return gApexSdk;
+}
+
+APEX_API Module* CALL_CONV createModule(
+ ApexSDKIntl* inSdk,
+ ModuleIntl** niRef,
+ uint32_t APEXsdkVersion,
+ uint32_t PhysXsdkVersion,
+ ApexCreateError* errorCode)
+{
+ if (APEXsdkVersion != APEX_SDK_VERSION)
+ {
+ if (errorCode)
+ {
+ *errorCode = APEX_CE_WRONG_VERSION;
+ }
+ return NULL;
+ }
+
+ if (PhysXsdkVersion != PX_PHYSICS_VERSION)
+ {
+ if (errorCode)
+ {
+ *errorCode = APEX_CE_WRONG_VERSION;
+ }
+ return NULL;
+ }
+
+ gApexSdk = inSdk;
+ ModuleParticleIosImpl* impl = PX_NEW(ModuleParticleIos)(inSdk);
+ *niRef = (ModuleIntl*) impl;
+ return (Module*) impl;
+}
+#else
+/* Statically linking entry function */
+void instantiateModuleParticleIos()
+{
+ ApexSDKIntl* sdk = GetInternalApexSDK();
+ pxparticleios::ModuleParticleIosImpl* impl = PX_NEW(pxparticleios::ModuleParticleIosImpl)(sdk);
+ sdk->registerExternalModule((Module*) impl, (ModuleIntl*) impl);
+}
+#endif
+}
+namespace pxparticleios
+{
+
+/* =================== ModuleParticleIosImpl =================== */
+
+
+AuthObjTypeID ParticleIosAssetImpl::mAssetTypeID;
+
+#ifdef WITHOUT_APEX_AUTHORING
+
+class ParticleIosAssetDummyAuthoring : public AssetAuthoring, public UserAllocated
+{
+public:
+ ParticleIosAssetDummyAuthoring(ModuleParticleIosImpl* module, ResourceList& list, NvParameterized::Interface* params, const char* name)
+ {
+ PX_UNUSED(module);
+ PX_UNUSED(list);
+ PX_UNUSED(params);
+ PX_UNUSED(name);
+ }
+
+ ParticleIosAssetDummyAuthoring(ModuleParticleIosImpl* module, ResourceList& list, const char* name)
+ {
+ PX_UNUSED(module);
+ PX_UNUSED(list);
+ PX_UNUSED(name);
+ }
+
+ ParticleIosAssetDummyAuthoring(ModuleParticleIosImpl* module, ResourceList& list)
+ {
+ PX_UNUSED(module);
+ PX_UNUSED(list);
+ }
+
+ virtual void setToolString(const char* /*toolName*/, const char* /*toolVersion*/, uint32_t /*toolChangelist*/)
+ {
+
+ }
+
+
+ virtual void release()
+ {
+ destroy();
+ }
+
+ // internal
+ void destroy()
+ {
+ delete this;
+ }
+
+ /**
+ * \brief Save asset configuration to a stream
+ */
+ virtual PxFileBuf& serialize(PxFileBuf& stream) const
+ {
+ PX_ASSERT(0);
+ return stream;
+ }
+
+ /**
+ * \brief Load asset configuration from a stream
+ */
+ virtual PxFileBuf& deserialize(PxFileBuf& stream)
+ {
+ PX_ASSERT(0);
+ return stream;
+ }
+
+ /**
+ * \brief Returns the name of this APEX authorable object type
+ */
+ virtual const char* getObjTypeName() const
+ {
+ return ParticleIosAssetImpl::getClassName();
+ }
+
+ /**
+ * \brief Prepares a fully authored Asset Authoring object for a specified platform
+ */
+ virtual bool prepareForPlatform(nvidia::apex::PlatformTag)
+ {
+ PX_ASSERT(0);
+ return false;
+ }
+
+ const char* getName(void) const
+ {
+ return NULL;
+ }
+
+ /**
+ * \brief Save asset's NvParameterized interface, may return NULL
+ */
+ virtual NvParameterized::Interface* getNvParameterized() const
+ {
+ PX_ASSERT(0);
+ return NULL;
+ }
+
+ virtual NvParameterized::Interface* releaseAndReturnNvParameterizedInterface(void)
+ {
+ PX_ALWAYS_ASSERT();
+ return NULL;
+ }
+};
+
+typedef ApexAuthorableObject<ModuleParticleIosImpl, ParticleIosAssetImpl, ParticleIosAssetDummyAuthoring> ParticleIosAO;
+
+#else
+typedef ApexAuthorableObject<ModuleParticleIosImpl, ParticleIosAssetImpl, ParticleIosAssetAuthoringImpl> ParticleIosAO;
+#endif
+
+ModuleParticleIosImpl::ModuleParticleIosImpl(ApexSDKIntl* sdk)
+{
+ mSdk = sdk;
+ mApiProxy = this;
+ mName = "ParticleIOS";
+ mModuleParams = NULL;
+ mIofxModule = NULL;
+ mFieldSamplerModule = NULL;
+
+ /* Register this module's authorable object types and create their namespaces */
+ const char* pName = ParticleIosAssetParam::staticClassName();
+ ParticleIosAO* eAO = PX_NEW(ParticleIosAO)(this, mAuthorableObjects, pName);
+ ParticleIosAssetImpl::mAssetTypeID = eAO->getResID();
+
+ /* Register the NvParameterized factories */
+ NvParameterized::Traits* traits = mSdk->getParameterizedTraits();
+ ModuleParticleIosRegistration::invokeRegistration(traits);
+}
+
+AuthObjTypeID ModuleParticleIosImpl::getModuleID() const
+{
+ return ParticleIosAssetImpl::mAssetTypeID;
+}
+
+ModuleParticleIosImpl::~ModuleParticleIosImpl()
+{
+}
+
+void ModuleParticleIosImpl::destroy()
+{
+ NvParameterized::Traits* traits = mSdk->getParameterizedTraits();
+
+ if (mModuleParams)
+ {
+ mModuleParams->destroy();
+ mModuleParams = NULL;
+ }
+
+ ModuleBase::destroy();
+
+ if (traits)
+ {
+ /* Remove the NvParameterized factories */
+ ModuleParticleIosRegistration::invokeUnregistration(traits);
+ }
+ delete this;
+}
+
+
+void ModuleParticleIosImpl::init(const ModuleParticleIosDesc&)
+{
+ WRITE_ZONE();
+}
+
+void ModuleParticleIosImpl::init(NvParameterized::Interface&)
+{
+ WRITE_ZONE();
+ ModuleParticleIosDesc desc;
+ init(desc);
+}
+
+NvParameterized::Interface* ModuleParticleIosImpl::getDefaultModuleDesc()
+{
+ WRITE_ZONE();
+ NvParameterized::Traits* traits = mSdk->getParameterizedTraits();
+
+ if (!mModuleParams)
+ {
+ mModuleParams = DYNAMIC_CAST(ParticleIosModuleParameters*)
+ (traits->createNvParameterized("ParticleIosModuleParameters"));
+ PX_ASSERT(mModuleParams);
+ }
+ else
+ {
+ mModuleParams->initDefaults();
+ }
+
+ return mModuleParams;
+}
+
+uint32_t ModuleParticleIosImpl::forceLoadAssets()
+{
+ return 0;
+}
+
+ParticleIosScene* ModuleParticleIosImpl::getParticleIosScene(const Scene& apexScene)
+{
+ const SceneIntl* niScene = DYNAMIC_CAST(const SceneIntl*)(&apexScene);
+ for (uint32_t i = 0 ; i < mParticleIosSceneList.getSize() ; i++)
+ {
+ ParticleIosScene* ps = DYNAMIC_CAST(ParticleIosScene*)(mParticleIosSceneList.getResource(i));
+ if (ps->mApexScene == niScene)
+ {
+ return ps;
+ }
+ }
+
+ PX_ASSERT(!"Unable to locate an appropriate ParticleIosScene");
+ return NULL;
+}
+
+const ParticleIosScene* ModuleParticleIosImpl::getParticleIosScene(const Scene& apexScene) const
+{
+ const SceneIntl* niScene = DYNAMIC_CAST(const SceneIntl*)(&apexScene);
+ for (uint32_t i = 0 ; i < mParticleIosSceneList.getSize() ; i++)
+ {
+ ParticleIosScene* ps = DYNAMIC_CAST(ParticleIosScene*)(mParticleIosSceneList.getResource(i));
+ if (ps->mApexScene == niScene)
+ {
+ return ps;
+ }
+ }
+
+ PX_ASSERT(!"Unable to locate an appropriate ParticleIosScene");
+ return NULL;
+}
+
+RenderableIterator* ModuleParticleIosImpl::createRenderableIterator(const Scene& apexScene)
+{
+ WRITE_ZONE();
+ ParticleIosScene* ps = getParticleIosScene(apexScene);
+ if (ps)
+ {
+ return ps->createRenderableIterator();
+ }
+
+ return NULL;
+}
+
+ModuleSceneIntl* ModuleParticleIosImpl::createInternalModuleScene(SceneIntl& scene, RenderDebugInterface* renderDebug)
+{
+#if APEX_CUDA_SUPPORT
+ READ_LOCK(scene);
+ if (scene.getTaskManager()->getGpuDispatcher() && scene.isUsingCuda())
+ {
+ return PX_NEW(ParticleIosSceneGPU)(*this, scene, renderDebug, mParticleIosSceneList);
+ }
+ else
+#endif
+ {
+ return PX_NEW(ParticleIosSceneCPU)(*this, scene, renderDebug, mParticleIosSceneList);
+ }
+}
+
+void ModuleParticleIosImpl::releaseModuleSceneIntl(ModuleSceneIntl& scene)
+{
+ ParticleIosScene* ps = DYNAMIC_CAST(ParticleIosScene*)(&scene);
+ ps->destroy();
+}
+
+const char* ModuleParticleIosImpl::getParticleIosTypeName()
+{
+ READ_ZONE();
+ return ParticleIosAssetImpl::getClassName();
+}
+
+
+ApexActor* ModuleParticleIosImpl::getApexActor(Actor* nxactor, AuthObjTypeID type) const
+{
+ if (type == ParticleIosAssetImpl::mAssetTypeID)
+ {
+ return (ParticleIosActorImpl*) nxactor;
+ }
+
+ return NULL;
+}
+
+ModuleIofxIntl* ModuleParticleIosImpl::getInternalModuleIofx()
+{
+ if (!mIofxModule)
+ {
+ ModuleIntl* nim = mSdk->getInternalModuleByName("IOFX");
+ if (nim)
+ {
+ mIofxModule = DYNAMIC_CAST(ModuleIofxIntl*)(nim);
+ }
+ }
+ return mIofxModule;
+}
+
+ModuleFieldSamplerIntl* ModuleParticleIosImpl::getInternalModuleFieldSampler()
+{
+ if (!mFieldSamplerModule )
+ {
+ ModuleIntl* nim = mSdk->getInternalModuleByName("FieldSampler");
+ if (nim)
+ {
+ mFieldSamplerModule = DYNAMIC_CAST(ModuleFieldSamplerIntl*)(nim);
+ }
+ }
+ return mFieldSamplerModule;
+}
+
+}
+} // namespace nvidia
diff --git a/APEX_1.4/module/pxparticleios/src/ParticleIosActorCPU.cpp b/APEX_1.4/module/pxparticleios/src/ParticleIosActorCPU.cpp
new file mode 100644
index 00000000..b2ba89ed
--- /dev/null
+++ b/APEX_1.4/module/pxparticleios/src/ParticleIosActorCPU.cpp
@@ -0,0 +1,442 @@
+/*
+ * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
+ *
+ * NVIDIA CORPORATION and its licensors retain all intellectual property
+ * and proprietary rights in and to this software, related documentation
+ * and any modifications thereto. Any use, reproduction, disclosure or
+ * distribution of this software and related documentation without an express
+ * license agreement from NVIDIA CORPORATION is strictly prohibited.
+ */
+
+
+#include "ApexDefs.h"
+#include "Apex.h"
+#include "SceneIntl.h"
+#include "ApexSDKIntl.h"
+
+#include "ParticleIosActor.h"
+#include "ParticleIosActorCPU.h"
+#include "ParticleIosAssetImpl.h"
+#include "IofxAsset.h"
+#include "IofxActor.h"
+#include "ModuleParticleIosImpl.h"
+#include "ParticleIosScene.h"
+#include "RenderDebugInterface.h"
+#include "AuthorableObjectIntl.h"
+#include "FieldSamplerQueryIntl.h"
+#include "PxMath.h"
+#include "ApexMirroredArray.h"
+
+#include "PxParticleSystem.h"
+#include "PxParticleCreationData.h"
+#include "PxParticleReadData.h"
+#include "PxParticleDeviceExclusive.h"
+
+namespace nvidia
+{
+namespace pxparticleios
+{
+using namespace physx;
+
+#pragma warning(disable: 4355) // 'this' : used in base member initializer list
+
+ParticleIosActorCPU::ParticleIosActorCPU(
+ ResourceList& list,
+ ParticleIosAssetImpl& asset,
+ ParticleIosScene& scene,
+ IofxAsset& iofxAsset)
+ : ParticleIosActorImpl(list, asset, scene, iofxAsset, false)
+ , mSimulateTask(*this)
+{
+ initStorageGroups(mSimulationStorage);
+
+ mField.reserve(mMaxParticleCount);
+ mLifeTime.setSize(mMaxParticleCount);
+ mLifeSpan.setSize(mMaxTotalParticleCount);
+ mInjector.setSize(mMaxTotalParticleCount);
+ mBenefit.setSize(mMaxTotalParticleCount);
+
+ mNewIndices.resize(mMaxParticleCount);
+ mAddedParticleList.reserve(mMaxParticleCount);
+ mRemovedParticleList.reserve(mMaxParticleCount);
+ mInputIdToParticleIndex.setSize(mMaxParticleCount, ApexMirroredPlace::CPU);
+
+ mIndexPool = PxParticleExt::createIndexPool(mMaxParticleCount);
+
+ mUpdateIndexBuffer.reserve(mMaxParticleCount);
+ mUpdateVelocityBuffer.reserve(mMaxParticleCount);
+}
+ParticleIosActorCPU::~ParticleIosActorCPU()
+{
+ if (mIndexPool)
+ {
+ mIndexPool->release();
+ mIndexPool = NULL;
+ }
+
+}
+
+PxTaskID ParticleIosActorCPU::submitTasks(PxTaskManager* tm)
+{
+ ParticleIosActorImpl::submitTasks(tm);
+ mInjectorsCounters.setSize(mInjectorList.getSize(), ApexMirroredPlace::CPU);
+
+ if (mAsset->getParticleDesc()->Enable == false)
+ {
+ return mInjectTask.getTaskID();
+ }
+
+ const PxTaskID taskID = tm->submitUnnamedTask(mSimulateTask);
+ return taskID;
+}
+
+void ParticleIosActorCPU::setTaskDependencies(PxTaskID taskStartAfterID, PxTaskID taskFinishBeforeID)
+{
+ PxTask* iosTask = NULL;
+ if (mAsset->getParticleDesc()->Enable)
+ {
+ iosTask = &mSimulateTask;
+ }
+ ParticleIosActorImpl::setTaskDependencies(taskStartAfterID, taskFinishBeforeID, iosTask, false);
+}
+
+namespace
+{
+class FieldAccessor
+{
+ const PxVec4* mField;
+public:
+ explicit FieldAccessor(const PxVec4* field)
+ {
+ mField = field;
+ }
+
+ PX_INLINE void operator()(unsigned int srcIdx, PxVec3& velocityDelta)
+ {
+ if (mField != NULL)
+ {
+ velocityDelta += mField[srcIdx].getXYZ();
+ }
+ }
+};
+}
+
+void ParticleIosActorCPU::simulateParticles()
+{
+ float deltaTime = mParticleIosScene->getApexScene().getPhysXSimulateTime();
+ const PxVec3& eyePos = mParticleIosScene->getApexScene().getEyePosition();
+
+ SCOPED_PHYSX_LOCK_WRITE(&mParticleIosScene->getApexScene());
+
+ mTotalElapsedTime += deltaTime;
+
+ uint32_t totalCount = mParticleCount + mInjectedCount;
+ uint32_t activeCount = mLastActiveCount + mInjectedCount;
+
+ mParticleBudget = mMaxParticleCount;
+ if (mParticleBudget > activeCount)
+ {
+ mParticleBudget = activeCount;
+ }
+ uint32_t targetCount = mParticleBudget;
+
+ uint32_t maxStateID = 0; //we could drop state in case targetCount = 0
+
+ for(uint32_t i = 0; i < mInjectorList.getSize(); ++i)
+ {
+ mInjectorsCounters[i] = 0;
+ }
+
+ if (targetCount > 0)
+ {
+ maxStateID = mParticleCount;
+ for (uint32_t i = 0; i < maxStateID; ++i)
+ {
+ mNewIndices[i] = IosBufferDescIntl::NOT_A_PARTICLE;
+ }
+
+ uint32_t boundCount = 0;
+ if (activeCount > targetCount)
+ {
+ boundCount = activeCount - targetCount;
+ }
+
+ float benefitMin = PxMin(mLastBenefitMin, mInjectedBenefitMin);
+ float benefitMax = PxMax(mLastBenefitMax, mInjectedBenefitMax);
+ PX_ASSERT(benefitMin <= benefitMax);
+ benefitMax *= 1.00001f;
+
+ /*
+ boundBin - the highest benefit bin that should be culled
+ boundCount - before computeHistogram it's the total culled particles.
+ - after computeHistogram it's the count of culled particles in boundBin
+ boundIndex - count of culled particles in boundBin (0..boundCount-1)
+ */
+ int32_t boundBin = (int32_t)computeHistogram(totalCount, benefitMin, benefitMax, boundCount);
+ float factor = HISTOGRAM_BIN_COUNT / (benefitMax - benefitMin);
+ for (uint32_t i = 0, boundIndex = 0; i < totalCount; ++i)
+ {
+ float benefit = mBenefit[i];
+ if (benefit > -FLT_MAX)
+ {
+ PX_ASSERT(benefit >= benefitMin && benefit < benefitMax);
+
+ int32_t bin = int32_t((benefit - benefitMin) * factor);
+ if (bin < boundBin)
+ {
+ mBenefit[i] = -FLT_MAX;
+ continue;
+ }
+ if (bin == boundBin && boundIndex < boundCount)
+ {
+ mBenefit[i] = -FLT_MAX;
+ ++boundIndex;
+ }
+ }
+ }
+ }
+
+ if (mParticleCount > 0)
+ {
+ mRemovedParticleList.clear();
+ for (uint32_t i = 0 ; i < mParticleCount; ++i)
+ {
+ if (!(mBenefit[i] > -FLT_MAX))
+ {
+ mRemovedParticleList.pushBack(mInputIdToParticleIndex[i]);
+ mInputIdToParticleIndex[i] = INVALID_PARTICLE_INDEX;
+ }
+ }
+ if (mRemovedParticleList.size())
+ {
+ PxStrideIterator<const uint32_t> indexData( &mRemovedParticleList[0] );
+ ((PxParticleBase*)mParticleActor)->releaseParticles(mRemovedParticleList.size(), indexData);
+ mIndexPool->freeIndices(mRemovedParticleList.size(), indexData);
+ mRemovedParticleList.clear();
+ }
+ }
+
+ mLastActiveCount = 0;
+ mLastBenefitSum = 0.0f;
+ mLastBenefitMin = +FLT_MAX;
+ mLastBenefitMax = -FLT_MAX;
+
+ if (targetCount > 0)
+ {
+ const Px3InjectorParams* injectorParamsList = DYNAMIC_CAST(ParticleIosSceneCPU*)(mParticleIosScene)->mInjectorParamsArray.begin();
+
+ FieldAccessor fieldAccessor(mFieldSamplerQuery ? mField.getPtr() : 0);
+
+ mAddedParticleList.clear();
+ mUpdateIndexBuffer.clear();
+ mUpdateVelocityBuffer.clear();
+ physx::PxParticleReadData* readData = ((PxParticleBase*)mParticleActor)->lockParticleReadData();
+
+ bool isDensityValid = false;
+ if (!mIsParticleSystem)
+ {
+ PxParticleFluidReadData* fluidReadData = static_cast<PxParticleFluidReadData*>(readData);
+ isDensityValid = (fluidReadData->densityBuffer.ptr() != 0);
+ }
+
+ for (uint32_t dstIdx = 0, srcHole = targetCount; dstIdx < targetCount; ++dstIdx)
+ {
+ uint32_t srcIdx = dstIdx;
+ //do we have a hole in dstIdx region?
+ if (!(mBenefit[dstIdx] > -FLT_MAX))
+ {
+ //skip holes in srcIdx region
+ while (!(mBenefit[srcHole] > -FLT_MAX))
+ {
+ ++srcHole;
+ }
+ PX_ASSERT(srcHole < totalCount);
+ srcIdx = srcHole++;
+ }
+ //do we have a new particle?
+ bool isNewParticle = (srcIdx >= mParticleCount);
+
+ uint32_t pxIdx;
+ PxVec3 position;
+ PxVec3 velocity;
+ PxVec3 collisionNormal;
+ uint32_t particleFlags;
+ float density;
+
+ if (isNewParticle)
+ {
+ PxStrideIterator<uint32_t> indexBuffer(&pxIdx);
+ if (mIndexPool->allocateIndices(1, indexBuffer) != 1)
+ {
+ PX_ALWAYS_ASSERT();
+ continue;
+ }
+ mInputIdToParticleIndex[dstIdx] = pxIdx;
+ }
+ else
+ {
+ pxIdx = mInputIdToParticleIndex[srcIdx];
+ PX_ASSERT((readData->flagsBuffer[pxIdx] & PxParticleFlag::eVALID));
+ if (dstIdx != srcIdx)
+ {
+ PX_ASSERT(dstIdx < mParticleCount || !(readData->flagsBuffer[mInputIdToParticleIndex[dstIdx]] & PxParticleFlag::eVALID));
+ mInputIdToParticleIndex[dstIdx] = pxIdx;
+ }
+
+ position = readData->positionBuffer[pxIdx],
+ velocity = readData->velocityBuffer[pxIdx],
+ collisionNormal = readData->collisionNormalBuffer[pxIdx],
+ particleFlags = readData->flagsBuffer[pxIdx],
+ density = isDensityValid ? static_cast<PxParticleFluidReadData*>(readData)->densityBuffer[pxIdx] : 0.0f;
+ }
+
+ unsigned int injIndex;
+ float benefit = simulateParticle(
+ NULL, injectorParamsList,
+ deltaTime, eyePos,
+ isNewParticle, srcIdx, dstIdx,
+ mBufDesc.pmaPositionMass->getPtr(), mBufDesc.pmaVelocityLife->getPtr(),
+ mBufDesc.pmaCollisionNormalFlags->getPtr(), mBufDesc.pmaUserData->getPtr(), mBufDesc.pmaActorIdentifiers->getPtr(),
+ mLifeSpan.getPtr(), mLifeTime.getPtr(), mBufDesc.pmaDensity ? mBufDesc.pmaDensity->getPtr() : NULL, mInjector.getPtr(),
+ fieldAccessor, injIndex,
+ mGridDensityParams,
+ position,
+ velocity,
+ collisionNormal,
+ particleFlags,
+ density
+ );
+
+ if (injIndex < mInjectorsCounters.getSize())
+ {
+ ++mInjectorsCounters[injIndex];
+ }
+
+ if (isNewParticle)
+ {
+ NewParticleData data;
+ data.destIndex = pxIdx;
+ data.position = position;
+ data.velocity = velocity;
+ mAddedParticleList.pushBack(data);
+
+ mBufDesc.pmaInStateToInput->get(maxStateID) = dstIdx | IosBufferDescIntl::NEW_PARTICLE_FLAG;
+ ++maxStateID;
+ }
+ else
+ {
+ mUpdateIndexBuffer.pushBack(pxIdx);
+ mUpdateVelocityBuffer.pushBack(velocity);
+
+ mNewIndices[srcIdx] = dstIdx;
+ }
+
+ mBenefit[dstIdx] = benefit;
+ if (benefit > -FLT_MAX)
+ {
+ mLastBenefitSum += benefit;
+ mLastBenefitMin = PxMin(mLastBenefitMin, benefit);
+ mLastBenefitMax = PxMax(mLastBenefitMax, benefit);
+ ++mLastActiveCount;
+ }
+ }
+
+ if (readData)
+ {
+ readData->unlock();
+ }
+
+ if (mUpdateIndexBuffer.size())
+ {
+ ((PxParticleBase*)mParticleActor)->setVelocities(mUpdateIndexBuffer.size(), PxStrideIterator<const uint32_t>(&mUpdateIndexBuffer[0]), PxStrideIterator<const PxVec3>(&mUpdateVelocityBuffer[0]));
+ }
+
+ if (mAddedParticleList.size())
+ {
+ PxParticleCreationData createData;
+ createData.numParticles = mAddedParticleList.size();
+ createData.positionBuffer = PxStrideIterator<const PxVec3>(&mAddedParticleList[0].position, sizeof(NewParticleData));
+ createData.velocityBuffer = PxStrideIterator<const PxVec3>(&mAddedParticleList[0].velocity, sizeof(NewParticleData));
+ createData.indexBuffer = PxStrideIterator<const uint32_t>(&mAddedParticleList[0].destIndex, sizeof(NewParticleData));
+ bool ok = ((PxParticleBase*)mParticleActor)->createParticles(createData);
+ PX_ASSERT(ok);
+ PX_UNUSED(ok);
+ }
+
+ //update stateToInput
+ for (uint32_t i = 0; i < mParticleCount; ++i)
+ {
+ uint32_t srcIdx = mBufDesc.pmaOutStateToInput->get(i);
+ PX_ASSERT(srcIdx < mParticleCount);
+ mBufDesc.pmaInStateToInput->get(i) = mNewIndices[srcIdx];
+ }
+ }
+ mParticleCount = targetCount;
+
+ /* Oh! Manager of the IOFX! do your thing */
+ mIofxMgr->updateEffectsData(deltaTime, mParticleCount, mParticleCount, maxStateID);
+}
+
+uint32_t ParticleIosActorCPU::computeHistogram(uint32_t dataCount, float dataMin, float dataMax, uint32_t& bound)
+{
+ const float* dataArray = mBenefit.getPtr();
+
+ uint32_t histogram[HISTOGRAM_BIN_COUNT];
+
+ //clear Histogram
+ for (uint32_t i = 0; i < HISTOGRAM_BIN_COUNT; ++i)
+ {
+ histogram[i] = 0;
+ }
+
+ float factor = HISTOGRAM_BIN_COUNT / (dataMax - dataMin);
+ //accum Histogram
+ for (uint32_t i = 0; i < dataCount; ++i)
+ {
+ float data = dataArray[i];
+ if (data >= dataMin && data < dataMax)
+ {
+ int32_t bin = int32_t((data - dataMin) * factor);
+ ++histogram[bin];
+ }
+ }
+ //compute CDF from Histogram
+ uint32_t countSum = 0;
+ for (uint32_t i = 0; i < HISTOGRAM_BIN_COUNT; ++i)
+ {
+ uint32_t count = histogram[i];
+ countSum += count;
+ histogram[i] = countSum;
+ }
+
+ PX_ASSERT(countSum == mLastActiveCount + mInjectedCount);
+
+ //binary search in CDF
+ uint32_t beg = 0;
+ uint32_t end = HISTOGRAM_BIN_COUNT;
+ while (beg < end)
+ {
+ uint32_t mid = beg + ((end - beg) >> 1);
+ if (bound > histogram[mid])
+ {
+ beg = mid + 1;
+ }
+ else
+ {
+ end = mid;
+ }
+ }
+
+ PX_ASSERT(histogram[beg] >= bound);
+ if (beg > 0)
+ {
+ bound -= histogram[beg - 1];
+ }
+
+ return beg;
+}
+
+}
+} // end namespace nvidia
+
+
diff --git a/APEX_1.4/module/pxparticleios/src/ParticleIosActorGPU.cpp b/APEX_1.4/module/pxparticleios/src/ParticleIosActorGPU.cpp
new file mode 100644
index 00000000..407c24b4
--- /dev/null
+++ b/APEX_1.4/module/pxparticleios/src/ParticleIosActorGPU.cpp
@@ -0,0 +1,993 @@
+/*
+ * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
+ *
+ * NVIDIA CORPORATION and its licensors retain all intellectual property
+ * and proprietary rights in and to this software, related documentation
+ * and any modifications thereto. Any use, reproduction, disclosure or
+ * distribution of this software and related documentation without an express
+ * license agreement from NVIDIA CORPORATION is strictly prohibited.
+ */
+
+
+#include "ApexDefs.h"
+#if APEX_CUDA_SUPPORT
+
+#include "Apex.h"
+#include "SceneIntl.h"
+#include "ApexSDKIntl.h"
+#include "ParticleIosActor.h"
+#include "ParticleIosActorGPU.h"
+#include "ParticleIosAssetImpl.h"
+
+#include "iofx/IofxAsset.h"
+#include "iofx/IofxActor.h"
+
+#include "ModuleParticleIosImpl.h"
+#include "ParticleIosScene.h"
+#include "RenderDebugInterface.h"
+#include "AuthorableObjectIntl.h"
+
+#include "PxMath.h"
+
+#define DEBUG_GPU 0
+#define USE_PHYSX_TASK_SYNC 1
+
+//CUDA
+#include "PxGpuTask.h"
+#include "ApexCutil.h"
+
+#define CUDA_OBJ(name) SCENE_CUDA_OBJ(*mParticleIosScene, name)
+
+#include "PxParticleBase.h"
+#include "PxParticleSystem.h"
+#include "PxParticleDeviceExclusive.h"
+
+namespace nvidia
+{
+namespace pxparticleios
+{
+
+using namespace physx;
+
+#pragma warning(disable: 4355) // 'this' : used in base member initializer list
+
+ParticleIosActorGPU::ParticleIosActorGPU(
+ ResourceList& list,
+ ParticleIosAssetImpl& asset,
+ ParticleIosScene& scene,
+ IofxAsset& iofxAsset)
+ : ParticleIosActorImpl(list, asset, scene, iofxAsset, true)
+ , mCopyQueue(*scene.getApexScene().getTaskManager()->getGpuDispatcher())
+ , mHoleScanSum(scene.getApexScene(), PX_ALLOC_INFO("mHoleScanSum", PARTICLES))
+ , mMoveIndices(scene.getApexScene(), PX_ALLOC_INFO("mMoveIndices", PARTICLES))
+ , mTmpReduce(scene.getApexScene(), PX_ALLOC_INFO("mTmpReduce", PARTICLES))
+ , mTmpHistogram(scene.getApexScene(), PX_ALLOC_INFO("mTmpHistogram", PARTICLES))
+ , mTmpScan(scene.getApexScene(), PX_ALLOC_INFO("mTmpScan", PARTICLES))
+ , mTmpScan1(scene.getApexScene(), PX_ALLOC_INFO("mTmpScan1", PARTICLES))
+ , mTmpOutput(scene.getApexScene(), PX_ALLOC_INFO("mTmpOutput", PARTICLES))
+ , mTmpBoundParams(scene.getApexScene(), PX_ALLOC_INFO("mTmpBoundParams", PARTICLES))
+ , mLaunchTask(*this)
+ , mTriggerTask(*this)
+ , mCuSyncEvent(0)
+{
+ initStorageGroups(CUDA_OBJ(simulateStorage));
+
+#if DEBUG_GPU
+ const ApexMirroredPlace::Enum defaultPlace = ApexMirroredPlace::CPU_GPU;
+#else
+ const ApexMirroredPlace::Enum defaultPlace = ApexMirroredPlace::GPU;
+#endif
+
+ mTmpOutput.setSize(4, ApexMirroredPlace::CPU_GPU);
+ mTmpBoundParams.setSize(2, defaultPlace);
+
+ const unsigned int ScanWarpsPerBlock = MAX_WARPS_PER_BLOCK; //CUDA_OBJ(scanKernel).getBlockDim().x / WARP_SIZE;
+
+ mTmpReduce.reserve(MAX_BOUND_BLOCKS * 4, defaultPlace);
+ mTmpHistogram.reserve(MAX_BOUND_BLOCKS * HISTOGRAM_SIMULATE_BIN_COUNT, defaultPlace);
+ mTmpScan.reserve(MAX_BOUND_BLOCKS * ScanWarpsPerBlock, defaultPlace);
+ mTmpScan1.reserve(MAX_BOUND_BLOCKS * ScanWarpsPerBlock, defaultPlace);
+
+ mField.reserve(mMaxParticleCount, defaultPlace);
+ mLifeTime.reserve(mMaxParticleCount, defaultPlace);
+
+ mLifeSpan.reserve(mMaxTotalParticleCount, ApexMirroredPlace::CPU_GPU);
+ mInjector.reserve(mMaxTotalParticleCount, ApexMirroredPlace::CPU_GPU);
+ mBenefit.reserve(mMaxTotalParticleCount, ApexMirroredPlace::CPU_GPU);
+
+ {
+ uint32_t size = mGridDensityParams.GridResolution;
+ if(size > 0)
+ {
+ mGridDensityGrid.setSize(size*size*size,ApexMirroredPlace::GPU);
+ mGridDensityGridLowPass.setSize(size*size*size,ApexMirroredPlace::GPU);
+ }
+ }
+
+ mHoleScanSum.reserve(mMaxTotalParticleCount, defaultPlace);
+ mMoveIndices.reserve(mMaxTotalParticleCount, defaultPlace);
+
+#if USE_PHYSX_TASK_SYNC
+ {
+ PxCudaContextManager* ctxMgr = mParticleIosScene->getApexScene().getTaskManager()->getGpuDispatcher()->getCudaContextManager();
+ PxScopedCudaLock _lock_(*ctxMgr);
+
+ CUT_SAFE_CALL(cuEventCreate(&mCuSyncEvent, CU_EVENT_DISABLE_TIMING));
+ }
+#endif
+}
+
+ParticleIosActorGPU::~ParticleIosActorGPU()
+{
+#if USE_PHYSX_TASK_SYNC
+ {
+ PxCudaContextManager* ctxMgr = mParticleIosScene->getApexScene().getTaskManager()->getGpuDispatcher()->getCudaContextManager();
+ PxScopedCudaLock _lock_(*ctxMgr);
+
+ CUT_SAFE_CALL(cuEventDestroy(mCuSyncEvent));
+ }
+#endif
+}
+
+PxTaskID ParticleIosActorGPU::submitTasks(PxTaskManager* tm)
+{
+ ParticleIosActorImpl::submitTasks(tm);
+ mInjectorsCounters.setSize(mInjectorList.getSize(), ApexMirroredPlace::CPU_GPU);
+
+ if (mAsset->getParticleDesc()->Enable == false)
+ {
+ return mInjectTask.getTaskID();
+ }
+
+ tm->submitUnnamedTask(mTriggerTask);
+ PxTaskID taskID = tm->submitUnnamedTask(mLaunchTask, PxTaskType::TT_GPU);
+
+ SCOPED_PHYSX_LOCK_WRITE(mParticleIosScene->getModulePhysXScene());
+
+ if (!PxParticleDeviceExclusive::isEnabled(*mParticleActor->is<PxParticleBase>()))
+ {
+ PxParticleDeviceExclusive::enable(*mParticleActor->is<PxParticleBase>());
+ }
+ PxParticleDeviceExclusive::setValidParticleRange(*mParticleActor->is<PxParticleBase>(), mParticleCount);
+
+#if USE_PHYSX_TASK_SYNC
+ PxParticleDeviceExclusive::addLaunchTaskDependent(*mParticleActor->is<PxParticleBase>(), mLaunchTask);
+
+ PxBaseTask* physxTask = PxParticleDeviceExclusive::getLaunchTask(*mParticleActor->is<PxParticleBase>());
+ static_cast<ParticleIosSceneGPU*>(mParticleIosScene)->getGpuDispatcher()->addPreLaunchDependent(*physxTask);
+ physxTask->removeReference();
+#endif
+ return taskID;
+}
+
+void ParticleIosActorGPU::setTaskDependencies(PxTaskID taskStartAfterID, PxTaskID taskFinishBeforeID)
+{
+ if (mAsset->getParticleDesc()->Enable == false)
+ {
+ ParticleIosActorImpl::setTaskDependencies(taskStartAfterID, taskFinishBeforeID, NULL, true);
+ return;
+ }
+
+#if USE_PHYSX_TASK_SYNC
+ PX_UNUSED(taskStartAfterID);
+ PX_UNUSED(taskFinishBeforeID);
+ ParticleIosActorImpl::setTaskDependencies(PxTaskID(0xFFFFFFFF), PxTaskID(0xFFFFFFFF), &mLaunchTask, true);
+
+ mTriggerTask.startAfter(mParticleIosScene->getApexScene().getTaskManager()->getNamedTask(AST_PHYSX_SIMULATE));
+ mTriggerTask.finishBefore(mLaunchTask.getTaskID());
+#else
+ ParticleIosActorImpl::setTaskDependencies(taskStartAfterID, taskFinishBeforeID, &mLaunchTask, true);
+#endif
+
+#if 0
+ if (tm->getGpuDispatcher()->getCudaContextManager()->supportsArchSM20())
+ {
+ /* For Fermi devices, it pays to launch all IOS together. This also forces
+ * The IOFX managers to step at the same time.
+ */
+ PxTaskID interlock = tm->getNamedTask("IOS::StepInterlock");
+ mLaunchTask.startAfter(interlock);
+ }
+#endif
+}
+
+void ParticleIosActorGPU::trigger()
+{
+#if USE_PHYSX_TASK_SYNC
+ static_cast<ParticleIosSceneGPU*>(mParticleIosScene)->getGpuDispatcher()->getPreLaunchTask().removeReference();
+#endif
+}
+
+bool ParticleIosActorGPU::launch(CUstream stream, int kernelIndex)
+{
+ float deltaTime = mParticleIosScene->getApexScene().getPhysXSimulateTime();
+
+ uint32_t activeCount = mLastActiveCount + mInjectedCount;
+ mParticleBudget = mMaxParticleCount;
+ if (mParticleBudget > activeCount)
+ {
+ mParticleBudget = activeCount;
+ }
+ uint32_t targetCount = mParticleBudget;
+ if (targetCount == 0)
+ {
+ //reset output
+ float* pTmpOutput = (float*)mTmpOutput.getPtr();
+ mTmpOutput[STATUS_LAST_ACTIVE_COUNT] = 0;
+ pTmpOutput[STATUS_LAST_BENEFIT_SUM] = 0.0f;
+ pTmpOutput[STATUS_LAST_BENEFIT_MIN] = +FLT_MAX;
+ pTmpOutput[STATUS_LAST_BENEFIT_MAX] = -FLT_MAX;
+
+ for(uint32_t i = 0; i < mInjectorsCounters.getSize(); ++i)
+ {
+ mInjectorsCounters[i] = 0;
+ }
+
+ //skip simulation & just call IofxManager
+ mIofxMgr->updateEffectsData(deltaTime, 0, 0, 0, stream);
+ return false;
+ }
+
+ uint32_t lastCount = mParticleCount;
+ uint32_t injectCount = mInjectedCount;
+ uint32_t totalCount = lastCount + injectCount;
+ PX_ASSERT(targetCount <= totalCount);
+
+ uint32_t boundCount = 0;
+ if (activeCount > targetCount)
+ {
+ boundCount = activeCount - targetCount;
+ }
+
+ ParticleIosSceneGPU* sceneGPU = static_cast<ParticleIosSceneGPU*>(mParticleIosScene);
+ bool useSyncKernels = !sceneGPU->getGpuDispatcher()->getCudaContextManager()->supportsArchSM20();
+
+ switch (kernelIndex)
+ {
+ case 0:
+ if (!mFieldSamplerQuery && mOnStartCallback)
+ {
+ (*mOnStartCallback)(stream);
+ }
+
+ // Copy particle data for newly injected particles
+ mCopyQueue.reset(stream, 24);
+ mIofxMgr->outputHostToDevice(mCopyQueue);
+ if (mInjectedCount > 0)
+ {
+ mBufDesc.pmaPositionMass->copyHostToDeviceQ(mCopyQueue, mInjectedCount, mParticleCount);
+ mBufDesc.pmaVelocityLife->copyHostToDeviceQ(mCopyQueue, mInjectedCount, mParticleCount);
+ mBufDesc.pmaActorIdentifiers->copyHostToDeviceQ(mCopyQueue, mInjectedCount, mParticleCount);
+ mLifeSpan.copyHostToDeviceQ(mCopyQueue, mInjectedCount, mParticleCount);
+ mInjector.copyHostToDeviceQ(mCopyQueue, mInjectedCount, mParticleCount);
+ mBenefit.copyHostToDeviceQ(mCopyQueue, mInjectedCount, mParticleCount);
+ mBufDesc.pmaUserData->copyHostToDeviceQ(mCopyQueue,mInjectedCount,mParticleCount);
+ }
+#if DEBUG_GPU
+ mBenefit.copyDeviceToHostQ(mCopyQueue, mParticleCount);
+#endif
+ mCopyQueue.flushEnqueued();
+ return true;
+
+ case 1:
+ if (totalCount > 0)
+ {
+ float benefitMin = PxMin(mLastBenefitMin, mInjectedBenefitMin);
+ float benefitMax = PxMax(mLastBenefitMax, mInjectedBenefitMax);
+ PX_ASSERT(benefitMin <= benefitMax);
+ benefitMax *= 1.00001f;
+
+ if (useSyncKernels)
+ {
+ CUDA_OBJ(histogramSyncKernel)(
+ stream, totalCount,
+ mBenefit.getGpuPtr(), boundCount,
+ benefitMin, benefitMax,
+ mTmpBoundParams.getGpuPtr(),
+ mTmpHistogram.getGpuPtr()
+ );
+ }
+ else
+ {
+ uint32_t histogramGridSize =
+ CUDA_OBJ(histogramKernel)(
+ stream, totalCount,
+ createApexCudaMemRef(mBenefit, ApexCudaMemFlags::IN),
+ boundCount, benefitMin, benefitMax,
+ createApexCudaMemRef(mTmpBoundParams, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpHistogram, ApexCudaMemFlags::OUT),
+ 1, 0
+ );
+
+ //launch just 1 block
+ CUDA_OBJ(histogramKernel)(
+ stream, APEX_CUDA_SINGLE_BLOCK_LAUNCH,
+ createApexCudaMemRef(mBenefit, ApexCudaMemFlags::IN), boundCount,
+ benefitMin, benefitMax,
+ createApexCudaMemRef(mTmpBoundParams, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(mTmpHistogram, ApexCudaMemFlags::IN_OUT),
+ 2, histogramGridSize
+ );
+ }
+ }
+ return true;
+
+ case 2:
+ if (totalCount > 0)
+ {
+ float benefitMin = PxMin(mLastBenefitMin, mInjectedBenefitMin);
+ float benefitMax = PxMax(mLastBenefitMax, mInjectedBenefitMax);
+ PX_ASSERT(benefitMin <= benefitMax);
+ benefitMax *= 1.00001f;
+
+ if (useSyncKernels)
+ {
+ CUDA_OBJ(scanSyncKernel)(
+ stream, totalCount,
+ benefitMin, benefitMax,
+ mHoleScanSum.getGpuPtr(), mBenefit.getGpuPtr(),
+ mTmpBoundParams.getGpuPtr(),
+ mTmpScan.getGpuPtr(), mTmpScan1.getGpuPtr()
+ );
+ }
+ else
+ {
+ uint32_t scanGridSize =
+ CUDA_OBJ(scanKernel)(
+ stream, totalCount,
+ benefitMin, benefitMax,
+ createApexCudaMemRef(mHoleScanSum, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mBenefit, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpBoundParams, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpScan, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(mTmpScan1, ApexCudaMemFlags::OUT),
+ 1, 0
+ );
+
+ //launch just 1 block
+ CUDA_OBJ(scanKernel)(
+ stream, APEX_CUDA_SINGLE_BLOCK_LAUNCH,
+ benefitMin, benefitMax,
+ createApexCudaMemRef(mHoleScanSum, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mBenefit, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpBoundParams, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpScan, ApexCudaMemFlags::IN_OUT),
+ createApexCudaMemRef(mTmpScan1, ApexCudaMemFlags::IN_OUT),
+ 2, scanGridSize
+ );
+
+ CUDA_OBJ(scanKernel)(
+ stream, totalCount,
+ benefitMin, benefitMax,
+ createApexCudaMemRef(mHoleScanSum, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(mBenefit, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpBoundParams, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpScan, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpScan1, ApexCudaMemFlags::IN),
+ 3, 0
+ );
+ }
+ }
+ return true;
+
+ case 3:
+ {
+ if (totalCount > 0)
+ {
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefCompactScanSum, mHoleScanSum);
+ const uint32_t injectorCount = mInjectorList.getSize();
+
+ CUDA_OBJ(compactKernel)(
+ stream,
+ PxMax(totalCount, injectorCount),
+ targetCount,
+ totalCount,
+ injectorCount,
+ createApexCudaMemRef(mMoveIndices, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(mTmpScan, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(mInjectorsCounters, ApexCudaMemFlags::OUT)
+ );
+ }
+ return true;
+ }
+
+ case 4:
+ if (targetCount > 0)
+ {
+ uint32_t histogramGridSize = 0;
+ {
+ PxCudaReadWriteParticleBuffers buffers;
+ memset(&buffers, 0, sizeof(buffers));
+
+ CUstream physxCuStream = 0;
+ {
+ SCOPED_PHYSX_LOCK_READ(&mParticleIosScene->getApexScene());
+
+ PxParticleDeviceExclusive::getReadWriteCudaBuffers(*mParticleActor->is<PxParticleBase>(), buffers);
+ PX_ASSERT( buffers.positions && buffers.velocities && buffers.collisionNormals && buffers.flags);
+
+#if USE_PHYSX_TASK_SYNC
+ physxCuStream = PxParticleDeviceExclusive::getCudaStream(*mParticleActor->is<PxParticleBase>());
+#endif
+ }
+ PX_UNUSED(physxCuStream);
+#if USE_PHYSX_TASK_SYNC
+ //sync physx & apex cuda streams!
+ if (stream != 0 && physxCuStream != 0)
+ {
+ CUT_SAFE_CALL(cuEventRecord(mCuSyncEvent, physxCuStream));
+ CUT_SAFE_CALL(cuStreamWaitEvent(stream, mCuSyncEvent, 0));
+ }
+#endif
+
+ APEX_CUDA_TEXTURE_SCOPE_BIND_SIZE(texRefMoveIndices, mMoveIndices, totalCount);
+
+ APEX_CUDA_TEXTURE_SCOPE_BIND_SIZE(texRefPositionMass, *mBufDesc.pmaPositionMass, totalCount);
+ APEX_CUDA_TEXTURE_SCOPE_BIND_SIZE(texRefVelocityLife, *mBufDesc.pmaVelocityLife, totalCount);
+ APEX_CUDA_TEXTURE_SCOPE_BIND_SIZE(texRefIofxActorIDs, *mBufDesc.pmaActorIdentifiers, totalCount);
+ APEX_CUDA_TEXTURE_SCOPE_BIND_SIZE(texRefLifeSpan, mLifeSpan, totalCount);
+ APEX_CUDA_TEXTURE_SCOPE_BIND_SIZE(texRefLifeTime, mLifeTime, totalCount);
+ APEX_CUDA_TEXTURE_SCOPE_BIND_SIZE(texRefInjector, mInjector, totalCount);
+
+ APEX_CUDA_TEXTURE_SCOPE_BIND_SIZE(texRefUserData,*mBufDesc.pmaUserData, totalCount);
+
+
+ APEX_CUDA_TEXTURE_SCOPE_BIND_PTR(texRefPxPosition, (float4*)buffers.positions, lastCount);
+ APEX_CUDA_TEXTURE_SCOPE_BIND_PTR(texRefPxVelocity, (float4*)buffers.velocities, lastCount);
+ APEX_CUDA_TEXTURE_SCOPE_BIND_PTR(texRefPxCollision, (float4*)buffers.collisionNormals, lastCount);
+ if(buffers.densities)
+ {
+ CUDA_OBJ(texRefPxDensity).bindTo(buffers.densities, lastCount);
+ }
+ APEX_CUDA_TEXTURE_SCOPE_BIND_PTR(texRefNvFlags, (unsigned int*)buffers.flags, lastCount);
+
+ const PxVec3& eyePos = mParticleIosScene->getApexScene().getEyePosition();
+ ParticleIosSceneGPU* sceneGPU = static_cast<ParticleIosSceneGPU*>(mParticleIosScene);
+
+ if (mFieldSamplerQuery != NULL)
+ {
+ APEX_CUDA_TEXTURE_SCOPE_BIND_SIZE(texRefField, mField, totalCount);
+
+ histogramGridSize = CUDA_OBJ(simulateApplyFieldKernel)(stream,
+ targetCount,
+ lastCount,
+ deltaTime,
+ eyePos,
+ sceneGPU->mInjectorConstMemGroup.getStorage().mappedHandle(sceneGPU->mInjectorParamsArrayHandle),
+ mInjectorsCounters.getSize(),
+ createApexCudaMemRef(mHoleScanSum, targetCount, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mInputIdToParticleIndex, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpScan, 1, ApexCudaMemFlags::IN), //g_moveCount
+ createApexCudaMemRef(mTmpHistogram, targetCount, ApexCudaMemFlags::OUT), //targetCount ????
+ createApexCudaMemRef(mInjectorsCounters, mInjectorsCounters.getSize(), ApexCudaMemFlags::OUT),
+ createApexCudaMemRef((float4*)mBufDesc.pmaPositionMass->getGpuPtr(), targetCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef((float4*)mBufDesc.pmaVelocityLife->getGpuPtr(), targetCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef((float4*)mBufDesc.pmaCollisionNormalFlags->getGpuPtr(), targetCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef((unsigned int*)mBufDesc.pmaUserData->getGpuPtr(), targetCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(mLifeSpan, targetCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(mLifeTime, targetCount, ApexCudaMemFlags::OUT),
+ mBufDesc.pmaDensity != NULL ? createApexCudaMemRef((float*)mBufDesc.pmaDensity->getGpuPtr(), targetCount, ApexCudaMemFlags::OUT) : ApexCudaMemRef<float>(NULL, 0),
+ createApexCudaMemRef(mInjector, targetCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(*(mBufDesc.pmaActorIdentifiers), targetCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(mBenefit, targetCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef((float4*)buffers.positions, targetCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef((float4*)buffers.velocities, targetCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef((float4*)buffers.collisionNormals, targetCount, ApexCudaMemFlags::IN),
+ buffers.densities != NULL ? createApexCudaMemRef((float*)buffers.densities, targetCount, ApexCudaMemFlags::OUT) : ApexCudaMemRef<float>(NULL, 0),
+ createApexCudaMemRef((unsigned int*)buffers.flags, targetCount, ApexCudaMemFlags::OUT),
+ mGridDensityParams
+ );
+ }
+ else
+ {
+ histogramGridSize = CUDA_OBJ(simulateKernel)(stream,
+ targetCount,
+ lastCount,
+ deltaTime,
+ eyePos,
+ sceneGPU->mInjectorConstMemGroup.getStorage().mappedHandle(sceneGPU->mInjectorParamsArrayHandle),
+ mInjectorsCounters.getSize(),
+ mHoleScanSum.getGpuPtr(),
+ mInputIdToParticleIndex.getGpuPtr(),
+ mTmpScan.getGpuPtr(),
+ mTmpHistogram.getGpuPtr(),
+ mInjectorsCounters.getGpuPtr(),
+ (float4*)mBufDesc.pmaPositionMass->getGpuPtr(),
+ (float4*)mBufDesc.pmaVelocityLife->getGpuPtr(),
+ (float4*)mBufDesc.pmaCollisionNormalFlags->getGpuPtr(),
+ (unsigned int*)mBufDesc.pmaUserData->getGpuPtr(),
+ mLifeSpan.getGpuPtr(),
+ mLifeTime.getGpuPtr(),
+ mBufDesc.pmaDensity != NULL ? (float*)mBufDesc.pmaDensity->getGpuPtr() : NULL,
+ mInjector.getGpuPtr(),
+ mBufDesc.pmaActorIdentifiers->getGpuPtr(),
+ mBenefit.getGpuPtr(),
+ (float4*)buffers.positions,
+ (float4*)buffers.velocities,
+ (float4*)buffers.collisionNormals,
+ buffers.densities != NULL ? (float*)buffers.densities : NULL,
+ (unsigned int*) buffers.flags,
+ mGridDensityParams
+ );
+ }
+ if(buffers.densities)
+ {
+ CUDA_OBJ(texRefPxDensity).unbind();
+ }
+ }
+ //new kernel invocation - to merge temp histograms
+ {
+ if(mInjectorsCounters.getSize() <= HISTOGRAM_SIMULATE_BIN_COUNT)
+ {
+ CUDA_OBJ(mergeHistogramKernel)(stream, APEX_CUDA_SINGLE_BLOCK_LAUNCH,
+ mInjectorsCounters.getGpuPtr(),
+ mTmpHistogram.getGpuPtr(),
+ histogramGridSize,
+ mInjectorsCounters.getSize()
+ );
+ }
+
+ }
+ // calculate grid grid density
+ if (mGridDensityParams.Enabled)
+ {
+ mGridDensityParams.DensityOrigin = mDensityOrigin;
+ const unsigned int dim = mGridDensityParams.GridResolution;
+ // refreshed non-shared params
+ {
+ ParticleIosAssetParam* params = (ParticleIosAssetParam*)(mAsset->getAssetNvParameterized());
+ const SimpleParticleSystemParams* gridParams = static_cast<SimpleParticleSystemParams*>(params->particleType);
+ mGridDensityParams.GridSize = gridParams->GridDensity.GridSize;
+ mGridDensityParams.GridMaxCellCount = gridParams->GridDensity.MaxCellCount;
+ }
+ // extract frustum
+ if(mParticleIosScene->getApexScene().getNumProjMatrices() > 0)
+ {
+ PxMat44 matDen = PxMat44(PxIdentity);
+ GridDensityFrustumParams frustum;
+ PxMat44 matModel = mParticleIosScene->getApexScene().getViewMatrix();
+ PxMat44 matProj = mParticleIosScene->getApexScene().getProjMatrix();
+ PxMat44 mat = matProj*matModel;
+ PxMat44 matInv = inverse(mat);
+ const float targetDepth = mGridDensityParams.GridSize;
+ // for debug vis
+ mDensityDebugMatInv = matInv;
+ // to calculate w transform
+ float nearDimX = distance(matInv.transform(PxVec4(-1.f,0.f,0.f,1.f)),matInv.transform(PxVec4(1.f,0.f,0.f,1.f)));
+ float farDimX = distance(matInv.transform(PxVec4(-1.f,0.f,1.f,1.f)),matInv.transform(PxVec4(1.f,0.f,1.f,1.f)));
+ float nearDimY = distance(matInv.transform(PxVec4(0.f,-1.f,0.f,1.f)),matInv.transform(PxVec4(0.f,1.f,0.f,1.f)));
+ float farDimY = distance(matInv.transform(PxVec4(0.f,-1.f,1.f,1.f)),matInv.transform(PxVec4(0.f,1.f,1.f,1.f)));
+ float dimZ = distance(matInv.transform(PxVec4(0.f, 0.f,0.f,1.f)),matInv.transform(PxVec4(0.f,0.f,1.f,1.f)));
+ float myFarDimX = nearDimX*(1.f-targetDepth/dimZ) + farDimX*(targetDepth/dimZ);
+ float myFarDimY = nearDimY*(1.f-targetDepth/dimZ) + farDimY*(targetDepth/dimZ);
+ // grab necessary frustum coordinates
+ PxVec4 origin4 = matInv.transform(PxVec4(-1.f, 1.f,0.f,1.f));
+ PxVec4 basisX4 = matInv.transform(PxVec4( 1.f, 1.f,0.f,1.f));
+ PxVec4 basisY4 = matInv.transform(PxVec4(-1.f,-1.f,0.f,1.f));
+ PxVec4 zDepth4 = matInv.transform(PxVec4(-1.f, 1.f,1.f,1.f));
+ // create vec3 versions
+ PxVec3 origin3(origin4.x/origin4.w,origin4.y/origin4.w,origin4.z/origin4.w);
+ PxVec3 basisX3(basisX4.x/basisX4.w,basisX4.y/basisX4.w,basisX4.z/basisX4.w);
+ PxVec3 basisY3(basisY4.x/basisY4.w,basisY4.y/basisY4.w,basisY4.z/basisY4.w);
+ PxVec3 zDepth3(zDepth4.x/zDepth4.w,zDepth4.y/zDepth4.w,zDepth4.z/zDepth4.w);
+ // make everthing relative to origin
+ basisX3 -= origin3;
+ basisY3 -= origin3;
+ zDepth3 -= origin3;
+ // find third basis
+ PxVec3 basisZ3(basisX3.cross(basisY3));
+ basisZ3.normalize();
+ basisZ3*= targetDepth;
+ // build scale,rotation,translation matrix
+ PxMat44 mat1Inv = PxMat44(PxIdentity);
+ mat1Inv.column0 = PxVec4(basisX3,0.f);
+ mat1Inv.column1 = PxVec4(basisY3,0.f);
+ mat1Inv.column2 = PxVec4(basisZ3,0.f);
+ mat1Inv.column3 = PxVec4(origin3,1.f);
+ PxMat44 mat1 = inverse(mat1Inv);
+ // do perspective transform
+ PxMat44 mat2 = PxMat44(PxIdentity);
+ {
+ float left = -3.0f;
+ float right = 1.0f;
+ float top = 1.0f;
+ float bottom = -3.0f;
+ float nearVal = nearDimX/(0.5f*(myFarDimX-nearDimX));
+ //float farVal = nearVal + 1.f;
+ // build matrix
+ mat2.column0.x = -2.f*nearVal/(right-left);
+ mat2.column1.y = -2.f*nearVal/(top-bottom);
+ mat2.column2.x = (right+left)/(right-left);
+ mat2.column2.y = (top+bottom)/(top-bottom);
+ //mat2.column2.z = -(farVal+nearVal)/(farVal-nearVal);
+ mat2.column2.w = -1.f;
+ //mat2.column3.z = -(2.f*farVal*nearVal)/(farVal-nearVal);
+ mat2.column3.w = 0.f;
+ }
+ // shrink to calculate density just outside of frustum
+ PxMat44 mat3 = PxMat44(PxIdentity);
+ float factor = (float)(mGridDensityParams.GridResolution-4) / (mGridDensityParams.GridResolution);
+ {
+ mat3.column0.x = factor;
+ mat3.column1.y = factor;
+ mat3.column2.z = factor;
+ mat3.column3.x = (1.0f-factor)/2.0f;
+ mat3.column3.y = (1.0f-factor)/2.0f;
+ mat3.column3.z = (1.0f-factor)/2.0f;
+ }
+ // create final matrix
+ matDen = mat3*mat2*mat1;
+ // create frustum info
+ frustum.nearDimX = factor*nearDimX;
+ frustum.farDimX = factor*myFarDimX;
+ frustum.nearDimY = factor*nearDimY;
+ frustum.farDimY = factor*myFarDimY;
+ frustum.dimZ = factor*targetDepth;
+ // launch frustum kernels
+ CUDA_OBJ(gridDensityGridClearKernel)(stream, dim*dim*dim,
+ mGridDensityGrid.getGpuPtr(),
+ mGridDensityParams
+ );
+ CUDA_OBJ(gridDensityGridFillFrustumKernel)(stream, targetCount,
+ (float4*)mBufDesc.pmaPositionMass->getGpuPtr(),
+ mGridDensityGrid.getGpuPtr(),
+ mGridDensityParams,
+ matDen,
+ frustum
+ );
+ CUDA_OBJ(gridDensityGridLowPassKernel)(stream, dim*dim*dim,
+ mGridDensityGrid.getGpuPtr(),
+ mGridDensityGridLowPass.getGpuPtr(),
+ mGridDensityParams
+ );
+ CUDA_OBJ(gridDensityGridApplyFrustumKernel)(stream, targetCount,
+ mBufDesc.pmaDensity != NULL ? (float*)mBufDesc.pmaDensity->getGpuPtr() : NULL,
+ (float4*)mBufDesc.pmaPositionMass->getGpuPtr(),
+ mGridDensityGridLowPass.getGpuPtr(),
+ mGridDensityParams,
+ matDen,
+ frustum
+ );
+ }
+ }
+ }
+ return true;
+
+ case 5:
+ if (targetCount > 0)
+ {
+ if (useSyncKernels)
+ {
+ CUDA_OBJ(reduceSyncKernel)(
+ stream, targetCount,
+ mBenefit.getGpuPtr(), (float4*)mTmpOutput.getGpuPtr(), mTmpReduce.getGpuPtr()
+ );
+ }
+ else
+ {
+ uint32_t reduceGridSize =
+ CUDA_OBJ(reduceKernel)(
+ stream, targetCount,
+ createApexCudaMemRef(mBenefit, ApexCudaMemFlags::IN),
+ createApexCudaMemRef((float4*)mTmpOutput.getGpuPtr(), 1, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpReduce, ApexCudaMemFlags::OUT),
+ 1, 0
+ );
+
+ //launch just 1 block
+ CUDA_OBJ(reduceKernel)(
+ stream, APEX_CUDA_SINGLE_BLOCK_LAUNCH,
+ createApexCudaMemRef(mBenefit, ApexCudaMemFlags::IN),
+ createApexCudaMemRef((float4*)mTmpOutput.getGpuPtr(), 1, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(mTmpReduce, ApexCudaMemFlags::IN),
+ 2, reduceGridSize
+ );
+ }
+ }
+ return true;
+
+ case 6:
+ if (totalCount > 0)
+ {
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefHoleScanSum, mHoleScanSum);
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefMoveIndices, mMoveIndices);
+
+ CUDA_OBJ(stateKernel)(stream, totalCount,
+ lastCount, targetCount,
+ createApexCudaMemRef(mTmpScan, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(*mBufDesc.pmaInStateToInput, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(*mBufDesc.pmaOutStateToInput, ApexCudaMemFlags::IN)
+ );
+ }
+ return true;
+
+ case 7:
+ mTmpOutput.copyDeviceToHostQ(mCopyQueue);
+ mInjectorsCounters.copyDeviceToHostQ(mCopyQueue);
+#if DEBUG_GPU
+ mHoleScanSum.copyDeviceToHostQ(mCopyQueue, totalCount);
+ mMoveIndices.copyDeviceToHostQ(mCopyQueue, totalCount);
+ mTmpScan.copyDeviceToHostQ(mCopyQueue, 1);
+ mTmpBoundParams.copyDeviceToHostQ(mCopyQueue, 2);
+ //mTmpHistogram.copyDeviceToHostQ(mCopyQueue, HISTOGRAM_BIN_COUNT);
+ mBufDesc.pmaInStateToInput->copyDeviceToHostQ(mCopyQueue, totalCount);
+#endif
+ mCopyQueue.flushEnqueued();
+
+ /* Oh! Manager of the IOFX! do your thing */
+ mIofxMgr->updateEffectsData(deltaTime, targetCount, targetCount, totalCount, stream);
+ return false;
+ }
+ return false;
+}
+
+
+#if DEBUG_GPU
+template<typename T, typename F>
+void dumpArray(const char* name, ApexMirroredArray<T>& inpArray, uint32_t size, F func)
+{
+ char buf[256 * 1024];
+ char* str = buf;
+ str += sprintf(str, "%s[%d]=", name, size);
+ for (uint32_t i = 0; i < PxMin<uint32_t>(size, 1024); ++i)
+ {
+ str += func(str, inpArray.get(i));
+ }
+ APEX_DEBUG_INFO(buf);
+}
+#endif
+
+void ParticleIosActorGPU::fetchResults()
+{
+ ParticleIosActorImpl::fetchResults();
+ if (mAsset->getParticleDesc()->Enable == false)
+ {
+ return;
+ }
+#if DEBUG_GPU
+ if (mParticleBudget > 0)
+ {
+ uint32_t targetCount = mParticleBudget;
+ uint32_t lastCount = mParticleCount;
+ uint32_t totalCount = lastCount + mInjectedCount;
+ uint32_t activeCount = mLastActiveCount + mInjectedCount;
+ uint32_t boundCount = (activeCount > targetCount) ? (activeCount - targetCount) : 0;
+
+ uint32_t lastActiveCount = 0;
+ for (uint32_t i = 0; i < lastCount; ++i)
+ {
+ float benefit = mBenefit[i];
+ if (benefit > -FLT_MAX)
+ {
+ ++lastActiveCount;
+ }
+ }
+ if (lastActiveCount != mLastActiveCount)
+ {
+ APEX_DEBUG_INFO("lastCount=%d, totalCount=%d, targetCount=%d", lastCount, totalCount, targetCount);
+ struct FBenefit { PX_INLINE uint32_t operator () (char* str, float x) { return sprintf(str, "%f,", x); } };
+ dumpArray("mBenefit", mBenefit, lastCount, FBenefit() );
+ APEX_INTERNAL_ERROR("lastActiveCount(%d) != mLastActiveCount(%d)", lastActiveCount, mLastActiveCount);
+ }
+ PX_ASSERT(lastActiveCount == mLastActiveCount);
+
+ //Test src hole count
+ uint32_t moveCount = mTmpScan[0];
+
+ uint32_t holeCount = 0;
+ for (uint32_t i = 0; i < totalCount; ++i)
+ {
+ uint32_t holeScanSum = mHoleScanSum[i];
+ if (holeScanSum & HOLE_SCAN_FLAG)
+ {
+ ++holeCount;
+ }
+ PX_ASSERT(holeCount == (holeScanSum & ~HOLE_SCAN_FLAG));
+ }
+ if (totalCount != targetCount + holeCount)
+ {
+ APEX_DEBUG_INFO("lastCount=%d, lastActiveCount=%d, injectCount=%d, totalCount=%d, targetCount=%d, moveCount=%d, holeCount=%d", lastCount, mLastActiveCount, mInjectedCount, totalCount, targetCount, moveCount, holeCount);
+ APEX_DEBUG_INFO("boundCount=%d, mTmpBoundParams[0]=%d, mTmpBoundParams[1]=%d", boundCount, mTmpBoundParams[0], mTmpBoundParams[1]);
+ struct FBenefit { PX_INLINE uint32_t operator () (char* str, float x) { return sprintf(str, "%f,", x); } };
+ dumpArray("mBenefit", mBenefit, totalCount, FBenefit() );
+ struct FHoleScanSum { PX_INLINE uint32_t operator () (char* str, uint32_t x) { return sprintf(str, "%x,", x); } };
+ dumpArray("mHoleScanSum", mHoleScanSum, totalCount, FHoleScanSum() );
+ //struct FHistogram { PX_INLINE uint32_t operator () (char* str, uint32_t x) { return sprintf(str, "%d,", x); } };
+ //dumpArray("mTmpHistogram", mTmpHistogram, HISTOGRAM_BIN_COUNT, FHistogram() );
+ APEX_INTERNAL_ERROR("totalCount (%d) != targetCount + holeCount (%d)", totalCount, targetCount + holeCount);
+ }
+ PX_ASSERT(totalCount == targetCount + holeCount);
+
+ PX_ASSERT(moveCount <= holeCount);
+ for (uint32_t i = 0; i < moveCount; ++i)
+ {
+ uint32_t holeIndex = mMoveIndices[i];
+ PX_ASSERT(holeIndex < targetCount);
+
+ uint32_t holeScanSum = mHoleScanSum[holeIndex];
+ PX_ASSERT((holeScanSum & HOLE_SCAN_FLAG) != 0);
+ PX_ASSERT( i + 1 == (holeScanSum & HOLE_SCAN_MASK) );
+ }
+ for (uint32_t i = moveCount; i < moveCount*2; ++i)
+ {
+ uint32_t nonHoleIndex = mMoveIndices[i];
+ PX_ASSERT(nonHoleIndex >= targetCount);
+ PX_ASSERT(nonHoleIndex < totalCount);
+
+ uint32_t nonHoleScanSum = mHoleScanSum[nonHoleIndex];
+ PX_ASSERT((nonHoleScanSum & HOLE_SCAN_FLAG) == 0);
+ PX_ASSERT( i + 1 == moveCount + (((nonHoleIndex + 1) - nonHoleScanSum) - (targetCount - moveCount)) );
+ }
+
+ uint32_t validInputCount = 0;
+ for (uint32_t i = 0; i < totalCount; ++i)
+ {
+ uint32_t inputId = mBufDesc.pmaInStateToInput->get(i);
+ if (inputId != IosBufferDescIntl::NOT_A_PARTICLE)
+ {
+ inputId &= ~IosBufferDescIntl::NEW_PARTICLE_FLAG;
+ PX_ASSERT(inputId < targetCount);
+
+ validInputCount++;
+ }
+ }
+ PX_ASSERT(validInputCount == targetCount);
+ }
+#endif
+
+ mParticleCount = mParticleBudget;
+
+ float* pTmpOutput = (float*)mTmpOutput.getPtr();
+ mLastActiveCount = mTmpOutput[STATUS_LAST_ACTIVE_COUNT];
+ mLastBenefitSum = pTmpOutput[STATUS_LAST_BENEFIT_SUM];
+ mLastBenefitMin = pTmpOutput[STATUS_LAST_BENEFIT_MIN];
+ mLastBenefitMax = pTmpOutput[STATUS_LAST_BENEFIT_MAX];
+}
+
+
+PxMat44 ParticleIosActorGPU::inverse(const PxMat44& in)
+{
+ PxMat44 ret;
+ float inv[16];
+ float* invOut = &ret.column0.x;
+ const float* m = &in.column0.x;
+ int i;
+
+ inv[0] = m[5] * m[10] * m[15] -
+ m[5] * m[11] * m[14] -
+ m[9] * m[6] * m[15] +
+ m[9] * m[7] * m[14] +
+ m[13] * m[6] * m[11] -
+ m[13] * m[7] * m[10];
+
+ inv[4] = -m[4] * m[10] * m[15] +
+ m[4] * m[11] * m[14] +
+ m[8] * m[6] * m[15] -
+ m[8] * m[7] * m[14] -
+ m[12] * m[6] * m[11] +
+ m[12] * m[7] * m[10];
+
+ inv[8] = m[4] * m[9] * m[15] -
+ m[4] * m[11] * m[13] -
+ m[8] * m[5] * m[15] +
+ m[8] * m[7] * m[13] +
+ m[12] * m[5] * m[11] -
+ m[12] * m[7] * m[9];
+
+ inv[12] = -m[4] * m[9] * m[14] +
+ m[4] * m[10] * m[13] +
+ m[8] * m[5] * m[14] -
+ m[8] * m[6] * m[13] -
+ m[12] * m[5] * m[10] +
+ m[12] * m[6] * m[9];
+
+ inv[1] = -m[1] * m[10] * m[15] +
+ m[1] * m[11] * m[14] +
+ m[9] * m[2] * m[15] -
+ m[9] * m[3] * m[14] -
+ m[13] * m[2] * m[11] +
+ m[13] * m[3] * m[10];
+
+ inv[5] = m[0] * m[10] * m[15] -
+ m[0] * m[11] * m[14] -
+ m[8] * m[2] * m[15] +
+ m[8] * m[3] * m[14] +
+ m[12] * m[2] * m[11] -
+ m[12] * m[3] * m[10];
+
+ inv[9] = -m[0] * m[9] * m[15] +
+ m[0] * m[11] * m[13] +
+ m[8] * m[1] * m[15] -
+ m[8] * m[3] * m[13] -
+ m[12] * m[1] * m[11] +
+ m[12] * m[3] * m[9];
+
+ inv[13] = m[0] * m[9] * m[14] -
+ m[0] * m[10] * m[13] -
+ m[8] * m[1] * m[14] +
+ m[8] * m[2] * m[13] +
+ m[12] * m[1] * m[10] -
+ m[12] * m[2] * m[9];
+
+ inv[2] = m[1] * m[6] * m[15] -
+ m[1] * m[7] * m[14] -
+ m[5] * m[2] * m[15] +
+ m[5] * m[3] * m[14] +
+ m[13] * m[2] * m[7] -
+ m[13] * m[3] * m[6];
+
+ inv[6] = -m[0] * m[6] * m[15] +
+ m[0] * m[7] * m[14] +
+ m[4] * m[2] * m[15] -
+ m[4] * m[3] * m[14] -
+ m[12] * m[2] * m[7] +
+ m[12] * m[3] * m[6];
+
+ inv[10] = m[0] * m[5] * m[15] -
+ m[0] * m[7] * m[13] -
+ m[4] * m[1] * m[15] +
+ m[4] * m[3] * m[13] +
+ m[12] * m[1] * m[7] -
+ m[12] * m[3] * m[5];
+
+ inv[14] = -m[0] * m[5] * m[14] +
+ m[0] * m[6] * m[13] +
+ m[4] * m[1] * m[14] -
+ m[4] * m[2] * m[13] -
+ m[12] * m[1] * m[6] +
+ m[12] * m[2] * m[5];
+
+ inv[3] = -m[1] * m[6] * m[11] +
+ m[1] * m[7] * m[10] +
+ m[5] * m[2] * m[11] -
+ m[5] * m[3] * m[10] -
+ m[9] * m[2] * m[7] +
+ m[9] * m[3] * m[6];
+
+ inv[7] = m[0] * m[6] * m[11] -
+ m[0] * m[7] * m[10] -
+ m[4] * m[2] * m[11] +
+ m[4] * m[3] * m[10] +
+ m[8] * m[2] * m[7] -
+ m[8] * m[3] * m[6];
+
+ inv[11] = -m[0] * m[5] * m[11] +
+ m[0] * m[7] * m[9] +
+ m[4] * m[1] * m[11] -
+ m[4] * m[3] * m[9] -
+ m[8] * m[1] * m[7] +
+ m[8] * m[3] * m[5];
+
+ inv[15] = m[0] * m[5] * m[10] -
+ m[0] * m[6] * m[9] -
+ m[4] * m[1] * m[10] +
+ m[4] * m[2] * m[9] +
+ m[8] * m[1] * m[6] -
+ m[8] * m[2] * m[5];
+
+ float det = m[0] * inv[0] + m[1] * inv[4] + m[2] * inv[8] + m[3] * inv[12];
+
+ if (det == 0)
+ return PxMat44(PxIdentity);
+
+ det = 1.0f / det;
+
+ for (i = 0; i < 16; i++)
+ invOut[i] = inv[i] * det;
+
+ return ret;
+}
+
+float ParticleIosActorGPU::distance(PxVec4 a, PxVec4 b)
+{
+ PxVec3 a3(a.x/a.w,a.y/a.w,a.z/a.w);
+ PxVec3 b3(b.x/b.w,b.y/b.w,b.z/b.w);
+ PxVec3 diff(b3-a3);
+ return diff.magnitude();
+}
+
+}
+} // namespace nvidia
+
+#endif //APEX_CUDA_SUPPORT
+
diff --git a/APEX_1.4/module/pxparticleios/src/ParticleIosActorImpl.cpp b/APEX_1.4/module/pxparticleios/src/ParticleIosActorImpl.cpp
new file mode 100644
index 00000000..0274520a
--- /dev/null
+++ b/APEX_1.4/module/pxparticleios/src/ParticleIosActorImpl.cpp
@@ -0,0 +1,818 @@
+/*
+ * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
+ *
+ * NVIDIA CORPORATION and its licensors retain all intellectual property
+ * and proprietary rights in and to this software, related documentation
+ * and any modifications thereto. Any use, reproduction, disclosure or
+ * distribution of this software and related documentation without an express
+ * license agreement from NVIDIA CORPORATION is strictly prohibited.
+ */
+
+
+#include "ApexDefs.h"
+#include "Apex.h"
+#include "SceneIntl.h"
+#include "ApexSDKIntl.h"
+#include "ParticleIosActor.h"
+#include "ParticleIosActorImpl.h"
+#include "ParticleIosAssetImpl.h"
+
+#include "iofx/IofxAsset.h"
+#include "iofx/IofxActor.h"
+
+#include "ModuleParticleIosImpl.h"
+#include "ParticleIosScene.h"
+#include "RenderDebugInterface.h"
+#include "AuthorableObjectIntl.h"
+#include "ModuleIofxIntl.h"
+#include "FieldSamplerManagerIntl.h"
+#include "FieldSamplerQueryIntl.h"
+#include "FieldSamplerSceneIntl.h"
+#include "ApexResourceHelper.h"
+#include "ApexMirroredArray.h"
+
+#include <PxPhysics.h>
+#include <PsAsciiConversion.h>
+#include "ReadCheck.h"
+#include "WriteCheck.h"
+
+#include "PsMathUtils.h"
+
+namespace nvidia
+{
+namespace pxparticleios
+{
+
+using namespace physx;
+
+void ParticleIosActorImpl::initStorageGroups(InplaceStorage& storage)
+{
+ mSimulationStorageGroup.init(storage);
+}
+
+#pragma warning(disable: 4355) // 'this' : used in base member initializer list
+
+ParticleIosActorImpl::ParticleIosActorImpl(
+ ResourceList& list,
+ ParticleIosAssetImpl& asset,
+ ParticleIosScene& scene,
+ IofxAsset& iofxAsset,
+ bool isDataOnDevice)
+ : mAsset(&asset)
+ , mParticleIosScene(&scene)
+ , mIsParticleSystem(false)
+ , mParticleActor(NULL)
+ , mIofxMgr(NULL)
+ , mTotalElapsedTime(0.0f)
+ , mParticleCount(0)
+ , mParticleBudget(0)
+ , mInjectedCount(0)
+ , mLastActiveCount(0)
+ , mLastBenefitSum(0)
+ , mLastBenefitMin(+FLT_MAX)
+ , mLastBenefitMax(-FLT_MAX)
+ , mLifeSpan(scene.getApexScene(), PX_ALLOC_INFO("mLifeSpan", PARTICLES))
+ , mLifeTime(scene.getApexScene(), PX_ALLOC_INFO("mLifeTime", PARTICLES))
+ , mInjector(scene.getApexScene(), PX_ALLOC_INFO("mInjector", PARTICLES))
+ , mBenefit(scene.getApexScene(), PX_ALLOC_INFO("mBenefit", PARTICLES))
+ , mInjectorsCounters(scene.getApexScene(), PX_ALLOC_INFO("mInjectorsCounters", PARTICLES))
+ , mInputIdToParticleIndex(scene.getApexScene(), PX_ALLOC_INFO("mInputIdToParticleIndex", PARTICLES))
+ , mGridDensityGrid(scene.getApexScene(), PX_ALLOC_INFO("mGridDensityGrid", PARTICLES))
+ , mGridDensityGridLowPass(scene.getApexScene(), PX_ALLOC_INFO("mGridDensityGridLowPass", PARTICLES))
+ , mFieldSamplerQuery(NULL)
+ , mField(scene.getApexScene(), PX_ALLOC_INFO("mField", PARTICLES))
+ , mInjectTask(*this)
+ , mDensityOrigin(0.f,0.f,0.f)
+ , mOnStartCallback(NULL)
+ , mOnFinishCallback(NULL)
+{
+ list.add(*this);
+
+ if (mAsset->getParticleDesc()->Enable == false)
+ {
+ APEX_DEBUG_WARNING("ParticleIos Asset '%s' has Enable=false, particle simulation is disabled.", mAsset->getName());
+ }
+
+ mMaxParticleCount = mAsset->mParams->maxParticleCount;
+ float maxInjectCount = mAsset->mParams->maxInjectedParticleCount;
+ mMaxTotalParticleCount = mMaxParticleCount + uint32_t(maxInjectCount <= 1.0f ? mMaxParticleCount * maxInjectCount : maxInjectCount);
+
+ IofxManagerDescIntl desc;
+ desc.iosAssetName = mAsset->getName();
+ desc.iosSupportsDensity = mAsset->getSupportsDensity();
+ desc.iosSupportsCollision = true;
+ desc.iosSupportsUserData = true;
+ desc.iosOutputsOnDevice = isDataOnDevice;
+ desc.maxObjectCount = mMaxParticleCount;
+ desc.maxInputCount = mMaxTotalParticleCount;
+ desc.maxInStateCount = mMaxTotalParticleCount;
+
+ ModuleIofxIntl* moduleIofx = mAsset->mModule->getInternalModuleIofx();
+ if (moduleIofx)
+ {
+ mIofxMgr = moduleIofx->createActorManager(*mParticleIosScene->mApexScene, iofxAsset, desc);
+ mIofxMgr->createSimulationBuffers(mBufDesc);
+
+ for (uint32_t i = 0 ; i < mMaxParticleCount ; i++)
+ {
+ mBufDesc.pmaInStateToInput->get(i) = IosBufferDescIntl::NOT_A_PARTICLE;
+ }
+ }
+
+ FieldSamplerManagerIntl* fieldSamplerManager = mParticleIosScene->getInternalFieldSamplerManager();
+ if (fieldSamplerManager)
+ {
+ FieldSamplerQueryDescIntl queryDesc;
+ queryDesc.maxCount = mMaxParticleCount;
+ queryDesc.samplerFilterData = ApexResourceHelper::resolveCollisionGroup128(mAsset->mParams->fieldSamplerFilterData);
+
+ mFieldSamplerQuery = fieldSamplerManager->createFieldSamplerQuery(queryDesc);
+ }
+
+ addSelfToContext(*scene.mApexScene->getApexContext()); // add self to Scene
+ addSelfToContext(*DYNAMIC_CAST(ApexContext*)(&scene)); // add self to ParticleIosScene
+
+ // Pull Grid Density Parameters
+ {
+ if(mIsParticleSystem && mBufDesc.pmaDensity)
+ {
+ ParticleIosAssetParam* params = (ParticleIosAssetParam*)(mAsset->getAssetNvParameterized());
+ const SimpleParticleSystemParams* gridParams = static_cast<SimpleParticleSystemParams*>(params->particleType);
+ mGridDensityParams.Enabled = gridParams->GridDensity.Enabled;
+ mGridDensityParams.GridSize = gridParams->GridDensity.GridSize;
+ mGridDensityParams.GridMaxCellCount = gridParams->GridDensity.MaxCellCount;
+ mGridDensityParams.GridResolution = general_string_parsing2::PxAsc::strToU32(&gridParams->GridDensity.Resolution[4],NULL);
+ mGridDensityParams.DensityOrigin = mDensityOrigin;
+ }
+ else
+ {
+ mGridDensityParams.Enabled = false;
+ mGridDensityParams.GridSize = 1.f;
+ mGridDensityParams.GridMaxCellCount = 1u;
+ mGridDensityParams.GridResolution = 8;
+ mGridDensityParams.DensityOrigin = mDensityOrigin;
+ }
+ }
+}
+
+ParticleIosActorImpl::~ParticleIosActorImpl()
+{
+}
+
+void ParticleIosActorImpl::release()
+{
+ if (mInRelease)
+ {
+ return;
+ }
+ mInRelease = true;
+ mAsset->releaseIosActor(*this);
+}
+
+void ParticleIosActorImpl::destroy()
+{
+ ApexActor::destroy();
+
+ setPhysXScene(NULL);
+
+ // remove ourself from our asset's resource list, in case releasing our emitters
+ // causes our asset's resource count to reach zero and for it to be released.
+ ApexResource::removeSelf();
+
+ // Release all injectors, releasing all emitters and their IOFX asset references
+ while (mInjectorList.getSize())
+ {
+ ParticleParticleInjector* inj = DYNAMIC_CAST(ParticleParticleInjector*)(mInjectorList.getResource(mInjectorList.getSize() - 1));
+ inj->release();
+ }
+
+ if (mIofxMgr)
+ {
+ mIofxMgr->release();
+ }
+ if (mFieldSamplerQuery)
+ {
+ mFieldSamplerQuery->release();
+ }
+
+ delete this;
+}
+
+void ParticleIosActorImpl::setPhysXScene(PxScene* scene)
+{
+ if (scene)
+ {
+ putInScene(scene);
+ }
+ else
+ {
+ removeFromScene();
+ }
+}
+
+PxScene* ParticleIosActorImpl::getPhysXScene() const
+{
+ if (mParticleActor)
+ {
+ return mParticleActor->getScene();
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+void ParticleIosActorImpl::putInScene(PxScene* scene)
+{
+ SCOPED_PHYSX_LOCK_WRITE(scene);
+ mUp = scene->getGravity();
+
+ // apply asset's scene gravity scale and external acceleration
+ // mUp *= mAsset->getSceneGravityScale();
+ // mUp += mAsset->getExternalAcceleration();
+
+ mGravity = mUp.magnitude();
+ if (!PxIsFinite(mGravity))
+ {
+ // and they could set both to 0,0,0
+ mUp = PxVec3(0.0f, -1.0f, 0.0f);
+ mGravity = 1.0f;
+ }
+ mUp *= -1.0f;
+
+ const ParticleIosAssetParam* desc = mAsset->getParticleDesc();
+
+ if (!isParticleDescValid(desc))
+ {
+ PX_ASSERT(0);
+ return;
+ }
+
+ uint32_t maxParticles = mMaxParticleCount;
+ PxParticleBase* particle = NULL;
+ PxParticleFluid* fluid = NULL;
+
+ ApexSimpleString className(mAsset->getParticleTypeClassName());
+ if (className == SimpleParticleSystemParams::staticClassName())
+ {
+ mIsParticleSystem = true;
+ particle = scene->getPhysics().createParticleSystem(maxParticles, desc->PerParticleRestOffset);
+ }
+ else
+ {
+ mIsParticleSystem = false;
+ fluid = scene->getPhysics().createParticleFluid(maxParticles, desc->PerParticleRestOffset);
+ particle = fluid;
+ }
+
+ if (particle)
+ {
+ particle->setMaxMotionDistance(desc->maxMotionDistance);
+ particle->setContactOffset(desc->contactOffset);
+ particle->setRestOffset(desc->restOffset);
+ particle->setGridSize(desc->gridSize);
+ particle->setDamping(desc->damping);
+ particle->setExternalAcceleration(desc->externalAcceleration);
+ particle->setProjectionPlane(desc->projectionPlaneNormal, desc->projectionPlaneDistance);
+ particle->setParticleMass(desc->particleMass);
+ particle->setRestitution(desc->restitution);
+ particle->setDynamicFriction(desc->dynamicFriction);
+ particle->setStaticFriction(desc->staticFriction);
+ if (desc->fieldSamplerFilterData && desc->fieldSamplerFilterData[0])
+ {
+ ResourceProviderIntl* nrp = mAsset->mModule->mSdk->getInternalResourceProvider();
+
+ ResID cgmns = mAsset->mModule->mSdk->getCollisionGroup128NameSpace();
+ ResID cgmresid = nrp->createResource(cgmns, desc->fieldSamplerFilterData);
+ void* tmpCGM = nrp->getResource(cgmresid);
+ if (tmpCGM)
+ {
+ particle->setSimulationFilterData(*(static_cast<PxFilterData*>(tmpCGM)));
+ }
+ //nrp->releaseResource( cgresid );
+ }
+ particle->setParticleBaseFlag(PxParticleBaseFlag::eCOLLISION_TWOWAY, desc->CollisionTwoway);
+ particle->setParticleBaseFlag(PxParticleBaseFlag::eCOLLISION_WITH_DYNAMIC_ACTORS, desc->CollisionWithDynamicActors);
+ particle->setParticleBaseFlag(PxParticleBaseFlag::eENABLED, desc->Enable);
+ particle->setParticleBaseFlag(PxParticleBaseFlag::ePROJECT_TO_PLANE, desc->ProjectToPlane);
+ // PxParticleBaseFlag::ePER_PARTICLE_REST_OFFSET is set in create() function
+ particle->setParticleBaseFlag(PxParticleBaseFlag::ePER_PARTICLE_COLLISION_CACHE_HINT, desc->PerParticleCollisionCacheHint);
+ // set hardware flag only if hardware is available
+ particle->setParticleBaseFlag(PxParticleBaseFlag::eGPU, NULL != scene->getTaskManager()->getGpuDispatcher());
+
+ particle->setParticleReadDataFlag(PxParticleReadDataFlag::ePOSITION_BUFFER, true);
+ particle->setParticleReadDataFlag(PxParticleReadDataFlag::eVELOCITY_BUFFER, true);
+ particle->setParticleReadDataFlag(PxParticleReadDataFlag::eREST_OFFSET_BUFFER, desc->PerParticleRestOffset);
+ particle->setParticleReadDataFlag(PxParticleReadDataFlag::eFLAGS_BUFFER, true);
+ particle->setParticleReadDataFlag(PxParticleReadDataFlag::eCOLLISION_NORMAL_BUFFER, true);
+ if (fluid)
+ {
+ particle->setParticleReadDataFlag(PxParticleReadDataFlag::eDENSITY_BUFFER, desc->DensityBuffer);
+
+ const FluidParticleSystemParams* fluidDesc = (FluidParticleSystemParams*)desc->particleType;
+ fluid->setRestParticleDistance(fluidDesc->restParticleDistance);
+ fluid->setStiffness(fluidDesc->stiffness);
+ fluid->setViscosity(fluidDesc->viscosity);
+ }
+ }
+ mParticleActor = particle;
+
+ PX_ASSERT(mParticleActor);
+
+ scene->addActor(*mParticleActor);
+ if (mParticleIosScene->getInternalFieldSamplerManager())
+ {
+ mParticleIosScene->getInternalFieldSamplerManager()->registerUnhandledParticleSystem(mParticleActor);
+ }
+ PX_ASSERT(mParticleActor->getScene());
+
+ mIofxMgr->setSimulationParameters(desc->restOffset, mUp, mGravity, 1 / desc->restOffset);
+}
+
+void ParticleIosActorImpl::removeFromScene()
+{
+ if (mParticleActor)
+ {
+ if (mParticleIosScene->getInternalFieldSamplerManager())
+ {
+ mParticleIosScene->getInternalFieldSamplerManager()->unregisterUnhandledParticleSystem(mParticleActor);
+ }
+ SCOPED_PHYSX_LOCK_WRITE(mParticleActor->getScene());
+ mParticleActor->getScene()->removeActor(*mParticleActor);
+ mParticleActor->release();
+ }
+ mParticleActor = NULL;
+ mParticleCount = 0;
+}
+
+
+
+void ParticleIosActorImpl::getLodRange(float& min, float& max, bool& intOnly) const
+{
+ READ_ZONE();
+ PX_UNUSED(min);
+ PX_UNUSED(max);
+ PX_UNUSED(intOnly);
+ APEX_INVALID_OPERATION("not implemented");
+}
+
+
+float ParticleIosActorImpl::getActiveLod() const
+{
+ READ_ZONE();
+ APEX_INVALID_OPERATION("ParticleIosActor does not support this operation");
+ return -1.0f;
+}
+
+
+void ParticleIosActorImpl::forceLod(float lod)
+{
+ WRITE_ZONE();
+ PX_UNUSED(lod);
+ APEX_INVALID_OPERATION("not implemented");
+}
+
+
+
+const PxVec3* ParticleIosActorImpl::getRecentPositions(uint32_t& count, uint32_t& stride) const
+{
+ count = mParticleCount;
+ stride = sizeof(PxVec4);
+ return (const PxVec3*) mBufDesc.pmaPositionMass->getPtr();
+}
+
+IosInjectorIntl* ParticleIosActorImpl::allocateInjector(IofxAsset* iofxAsset)
+{
+ ParticleParticleInjector* inj = 0;
+ //createInjector
+ {
+ uint32_t injectorID = mParticleIosScene->getInjectorAllocator().allocateInjectorID();
+ if (injectorID != ParticleIosInjectorAllocator::NULL_INJECTOR_INDEX)
+ {
+ inj = PX_NEW(ParticleParticleInjector)(mInjectorList, *this, injectorID);
+ }
+ }
+ if (inj == 0)
+ {
+ APEX_INTERNAL_ERROR("Failed to create new ParticleIos injector.");
+ return NULL;
+ }
+
+ inj->init(iofxAsset);
+ return inj;
+}
+
+void ParticleIosActorImpl::releaseInjector(IosInjectorIntl& injector)
+{
+ ParticleParticleInjector* inj = DYNAMIC_CAST(ParticleParticleInjector*)(&injector);
+ //destroyInjector
+ {
+ //set mLODBias to FLT_MAX to mark released injector
+ //all particles from released injectors will be removed in simulation
+ Px3InjectorParams injParams;
+ mParticleIosScene->fetchInjectorParams(inj->mInjectorID, injParams);
+ injParams.mLODBias = FLT_MAX;
+ mParticleIosScene->updateInjectorParams(inj->mInjectorID, injParams);
+
+ mParticleIosScene->getInjectorAllocator().releaseInjectorID(inj->mInjectorID);
+ inj->destroy();
+ }
+
+ if(mInjectorList.getSize() == 0)
+ {
+ //if we have no injectors - release self
+ release();
+ }
+}
+
+void ParticleIosActorImpl::visualize()
+{
+#ifndef WITHOUT_DEBUG_VISUALIZE
+ if ( !mEnableDebugVisualization ) return;
+ RenderDebugInterface* renderer = mParticleIosScene->mRenderDebug;
+ const physx::PxMat44& savedPose = *RENDER_DEBUG_IFACE(renderer)->getPoseTyped();
+ RENDER_DEBUG_IFACE(renderer)->setIdentityPose();
+ if(mParticleIosScene->mParticleIosDebugRenderParams->VISUALIZE_PARTICLE_IOS_GRID_DENSITY)
+ {
+ if(mGridDensityParams.Enabled)
+ {
+ RENDER_DEBUG_IFACE(renderer)->setCurrentColor(0x0000ff);
+ uint32_t onScreenRes = mGridDensityParams.GridResolution - 4;
+ for (uint32_t i = 0 ; i <= onScreenRes; i++)
+ {
+ float u = 2.f*((float)i/(onScreenRes))-1.f;
+ PxVec4 a = mDensityDebugMatInv.transform(PxVec4(u,-1.f,0.1f,1.f));
+ PxVec4 b = mDensityDebugMatInv.transform(PxVec4(u, 1.f,0.1f,1.f));
+ PxVec4 c = mDensityDebugMatInv.transform(PxVec4(-1.f,u,0.1f,1.f));
+ PxVec4 d = mDensityDebugMatInv.transform(PxVec4( 1.f,u,0.1f,1.f));
+ RENDER_DEBUG_IFACE(renderer)->debugLine(PxVec3(a.getXYZ()/a.w),PxVec3(b.getXYZ()/b.w));
+ RENDER_DEBUG_IFACE(renderer)->debugLine(PxVec3(c.getXYZ()/c.w),PxVec3(d.getXYZ()/d.w));
+ }
+ }
+ }
+ RENDER_DEBUG_IFACE(renderer)->setPose(savedPose);
+#endif
+}
+
+
+PxTaskID ParticleIosActorImpl::submitTasks(PxTaskManager* tm)
+{
+ return tm->submitUnnamedTask(mInjectTask);
+}
+
+void ParticleIosActorImpl::setTaskDependencies(PxTaskID taskStartAfterID, PxTaskID taskFinishBeforeID, PxTask* iosTask, bool isDataOnDevice)
+{
+ PxTaskManager* tm = mParticleIosScene->getApexScene().getTaskManager();
+
+ PxTaskID simTaskID = tm->getNamedTask(AST_PHYSX_SIMULATE);
+ mInjectTask.finishBefore(simTaskID);
+ if (iosTask == 0)
+ {
+ return;
+ }
+ iosTask->startAfter(mInjectTask.getTaskID());
+
+ if (taskStartAfterID != (PxTaskID)0xFFFFFFFF)
+ {
+ iosTask->startAfter(taskStartAfterID);
+ }
+ if (taskFinishBeforeID != (PxTaskID)0xFFFFFFFF)
+ {
+ iosTask->finishBefore(taskFinishBeforeID);
+ }
+
+ if (mFieldSamplerQuery != NULL)
+ {
+ float deltaTime = mParticleIosScene->getApexScene().getPhysXSimulateTime();
+
+ FieldSamplerQueryDataIntl queryData;
+ queryData.timeStep = deltaTime;
+ queryData.count = mParticleCount;
+ queryData.isDataOnDevice = isDataOnDevice;
+ queryData.positionStrideBytes = sizeof(PxVec4);
+ queryData.velocityStrideBytes = sizeof(PxVec4);
+ queryData.massStrideBytes = sizeof(PxVec4);
+ queryData.pmaInIndices = 0;
+ if (isDataOnDevice)
+ {
+#if APEX_CUDA_SUPPORT
+ queryData.pmaInPosition = (float*)mBufDesc.pmaPositionMass->getGpuPtr();
+ queryData.pmaInVelocity = (float*)mBufDesc.pmaVelocityLife->getGpuPtr();
+ queryData.pmaInMass = &mBufDesc.pmaPositionMass->getGpuPtr()->w;
+ queryData.pmaOutField = mField.getGpuPtr();
+#endif
+ }
+ else
+ {
+ queryData.pmaInPosition = (float*)mBufDesc.pmaPositionMass->getPtr();
+ queryData.pmaInVelocity = (float*)mBufDesc.pmaVelocityLife->getPtr();
+ queryData.pmaInMass = &mBufDesc.pmaPositionMass->getPtr()->w;
+ queryData.pmaOutField = mField.getPtr();
+ }
+
+ mFieldSamplerQuery->submitFieldSamplerQuery(queryData, iosTask->getTaskID());
+ }
+
+ const PxTaskID postIofxTaskID = tm->getNamedTask(AST_PHYSX_FETCH_RESULTS);
+ PxTaskID iofxTaskID = mIofxMgr->getUpdateEffectsTaskID(postIofxTaskID);
+ if (iofxTaskID == (PxTaskID)0xFFFFFFFF)
+ {
+ iofxTaskID = postIofxTaskID;
+ }
+ iosTask->finishBefore(iofxTaskID);
+}
+
+void ParticleIosActorImpl::fetchResults()
+{
+ for(uint32_t i = 0; i < mInjectorList.getSize(); ++i)
+ {
+ ParticleParticleInjector* inj = DYNAMIC_CAST(ParticleParticleInjector*)(mInjectorList.getResource(i));
+ inj->assignSimParticlesCount(mInjectorsCounters.get(i));
+ }
+}
+
+void ParticleIosActorImpl::injectNewParticles()
+{
+ mInjectedBenefitSum = 0;
+ mInjectedBenefitMin = +FLT_MAX;
+ mInjectedBenefitMax = -FLT_MAX;
+
+ uint32_t maxInjectCount = (mMaxTotalParticleCount - mParticleCount);
+
+ uint32_t injectCount = 0;
+ uint32_t lastInjectCount = 0;
+ do
+ {
+ lastInjectCount = injectCount;
+ for (uint32_t i = 0; i < mInjectorList.getSize(); i++)
+ {
+ ParticleParticleInjector* inj = DYNAMIC_CAST(ParticleParticleInjector*)(mInjectorList.getResource(i));
+ if (inj->mInjectedParticles.size() == 0)
+ {
+ continue;
+ }
+
+ if (injectCount < maxInjectCount)
+ {
+ IosNewObject obj;
+ if (inj->mInjectedParticles.popFront(obj))
+ {
+ PX_ASSERT(obj.lifetime > 0.0f);
+ PX_ASSERT(PxIsFinite(obj.lodBenefit));
+
+ uint32_t injectIndex = mParticleCount + injectCount;
+
+ float particleMass = mAsset->getParticleMass();
+ mBufDesc.pmaPositionMass->get(injectIndex) = PxVec4(obj.initialPosition.x, obj.initialPosition.y, obj.initialPosition.z, particleMass);
+ mBufDesc.pmaVelocityLife->get(injectIndex) = PxVec4(obj.initialVelocity.x, obj.initialVelocity.y, obj.initialVelocity.z, 1.0f);
+ mBufDesc.pmaCollisionNormalFlags->get(injectIndex).setZero();
+ mBufDesc.pmaActorIdentifiers->get(injectIndex) = obj.iofxActorID;
+
+ mBufDesc.pmaUserData->get(injectIndex) = obj.userData;
+
+ mLifeSpan[injectIndex] = obj.lifetime;
+ mInjector[injectIndex] = inj->mInjectorID;
+ mBenefit[injectIndex] = obj.lodBenefit;
+
+ mInjectedBenefitSum += obj.lodBenefit;
+ mInjectedBenefitMin = PxMin(mInjectedBenefitMin, obj.lodBenefit);
+ mInjectedBenefitMax = PxMax(mInjectedBenefitMax, obj.lodBenefit);
+
+ ++injectCount;
+ }
+ }
+ }
+ }
+ while (injectCount > lastInjectCount);
+
+ mInjectedCount = injectCount;
+
+ //clear injectors FIFO
+ for (uint32_t i = 0; i < mInjectorList.getSize(); i++)
+ {
+ ParticleParticleInjector* inj = DYNAMIC_CAST(ParticleParticleInjector*)(mInjectorList.getResource(i));
+
+ IosNewObject obj;
+ while (inj->mInjectedParticles.popFront(obj))
+ {
+ ;
+ }
+ }
+}
+
+bool ParticleIosActorImpl::isParticleDescValid( const ParticleIosAssetParam* desc) const
+{
+ if (desc->gridSize <= 0.0f) return false;
+ if (desc->maxMotionDistance <= 0.0f) return false;
+ if (desc->maxMotionDistance + desc->contactOffset > desc->gridSize) return false;
+ if (desc->contactOffset < 0.0f) return false;
+ if (desc->contactOffset < desc->restOffset) return false;
+ if (desc->particleMass < 0.0f) return false;
+ if (desc->damping < 0.0f) return false;
+ if (desc->projectionPlaneNormal.isZero()) return false;
+ if (desc->restitution < 0.0f || desc->restitution > 1.0f) return false;
+ if (desc->dynamicFriction < 0.0f || desc->dynamicFriction > 1.0f) return false;
+ if (desc->staticFriction < 0.0f) return false;
+ if (desc->maxParticleCount < 1) return false;
+
+ ApexSimpleString className(mAsset->getParticleTypeClassName());
+ if (className == SimpleParticleSystemParams::staticClassName())
+ {
+ return true;
+ }
+ else
+ if (className == FluidParticleSystemParams::staticClassName())
+ {
+ const FluidParticleSystemParams* fluidDesc = (FluidParticleSystemParams*)desc->particleType;
+ if (fluidDesc->restParticleDistance <= 0.0f) return false;
+
+ if (fluidDesc->stiffness <= 0.0f) return false;
+ if (fluidDesc->viscosity <= 0.0f) return false;
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+////////////////////////////////////////////////////////////////////////////////
+
+ParticleParticleInjector::ParticleParticleInjector(ResourceList& list, ParticleIosActorImpl& actor, uint32_t injectorID)
+ : mIosActor(&actor)
+ , mIofxClient(NULL)
+ , mVolume(NULL)
+ , mLastRandomID(0)
+ , mVolumeID(IofxActorIDIntl::NO_VOLUME)
+ , mInjectorID(injectorID)
+ , mSimulatedParticlesCount(0)
+{
+ list.add(*this);
+
+ setLODWeights(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f);
+
+ mInjectedParticles.reserve(actor.mMaxTotalParticleCount);
+}
+
+void ParticleParticleInjector::setListIndex(ResourceList& list, uint32_t index)
+{
+ m_listIndex = index;
+ m_list = &list;
+
+ Px3InjectorParams injParams;
+ mIosActor->mParticleIosScene->fetchInjectorParams(mInjectorID, injParams);
+ injParams.mLocalIndex = index;
+ mIosActor->mParticleIosScene->updateInjectorParams(mInjectorID, injParams);
+}
+
+/* Emitter calls this function to adjust their particle weights with respect to other emitters */
+void ParticleParticleInjector::setLODWeights(float maxDistance, float distanceWeight, float speedWeight, float lifeWeight, float separationWeight, float bias)
+{
+ PX_UNUSED(separationWeight);
+
+ Px3InjectorParams injParams;
+ mIosActor->mParticleIosScene->fetchInjectorParams(mInjectorID, injParams);
+
+ injParams.mLODMaxDistance = maxDistance;
+ injParams.mLODDistanceWeight = distanceWeight;
+ injParams.mLODSpeedWeight = speedWeight;
+ injParams.mLODLifeWeight = lifeWeight;
+ injParams.mLODBias = bias;
+
+ mIosActor->mParticleIosScene->updateInjectorParams(mInjectorID, injParams);
+}
+
+PxTaskID ParticleParticleInjector::getCompletionTaskID() const
+{
+ return mIosActor->mInjectTask.getTaskID();
+}
+
+void ParticleParticleInjector::setObjectScale(float objectScale)
+{
+ PX_ASSERT(mIofxClient);
+ IofxManagerClientIntl::Params params;
+ mIofxClient->getParams(params);
+ params.objectScale = objectScale;
+ mIofxClient->setParams(params);
+}
+
+void ParticleParticleInjector::init(IofxAsset* iofxAsset)
+{
+ mIofxClient = mIosActor->mIofxMgr->createClient(iofxAsset, IofxManagerClientIntl::Params());
+
+ /* add this injector to the IOFX asset's context (so when the IOFX goes away our ::release() is called) */
+ iofxAsset->addDependentActor(this);
+
+ mRandomActorClassIDs.clear();
+ if (iofxAsset->getMeshAssetCount() < 2)
+ {
+ mRandomActorClassIDs.pushBack(mIosActor->mIofxMgr->getActorClassID(mIofxClient, 0));
+ return;
+ }
+
+ /* Cache actorClassIDs for this asset */
+ physx::Array<uint16_t> temp;
+ for (uint32_t i = 0 ; i < iofxAsset->getMeshAssetCount() ; i++)
+ {
+ uint32_t w = iofxAsset->getMeshAssetWeight(i);
+ uint16_t acid = mIosActor->mIofxMgr->getActorClassID(mIofxClient, (uint16_t) i);
+ for (uint32_t j = 0 ; j < w ; j++)
+ {
+ temp.pushBack(acid);
+ }
+ }
+
+ mRandomActorClassIDs.reserve(temp.size());
+ while (temp.size())
+ {
+ uint32_t index = (uint32_t)physx::shdfnd::rand(0, (int32_t)temp.size() - 1);
+ mRandomActorClassIDs.pushBack(temp[ index ]);
+ temp.replaceWithLast(index);
+ }
+}
+
+
+void ParticleParticleInjector::release()
+{
+ if (mInRelease)
+ {
+ return;
+ }
+ mInRelease = true;
+ mIosActor->releaseInjector(*this);
+}
+
+void ParticleParticleInjector::destroy()
+{
+ ApexActor::destroy();
+
+ mIosActor->mIofxMgr->releaseClient(mIofxClient);
+
+ delete this;
+}
+
+void ParticleParticleInjector::setPreferredRenderVolume(RenderVolume* volume)
+{
+ mVolume = volume;
+ mVolumeID = mVolume ? mIosActor->mIofxMgr->getVolumeID(mVolume) : IofxActorIDIntl::NO_VOLUME;
+}
+
+/* Emitter calls this virtual injector API to insert new particles. It is safe for an emitter to
+ * call this function at any time except for during the IOS::fetchResults(). Since
+ * ParticleScene::fetchResults() is single threaded, it should be safe to call from
+ * emitter::fetchResults() (destruction may want to do this because of contact reporting)
+ */
+void ParticleParticleInjector::createObjects(uint32_t count, const IosNewObject* createList)
+{
+ PX_PROFILE_ZONE("ParticleIosCreateObjects", GetInternalApexSDK()->getContextId());
+
+ if (mRandomActorClassIDs.size() == 0)
+ {
+ return;
+ }
+
+ const PxVec3& eyePos = mIosActor->mParticleIosScene->getApexScene().getEyePosition();
+ Px3InjectorParams injParams;
+ mIosActor->mParticleIosScene->fetchInjectorParams(mInjectorID, injParams);
+
+ // Append new objects to our FIFO. We do copies because we must perform buffering for the
+ // emitters. We have to hold these new objects until there is room in the TurbulenceFS and the
+ // injector's virtID range to emit them.
+ for (uint32_t i = 0 ; i < count ; i++)
+ {
+ if (mInjectedParticles.size() == mInjectedParticles.capacity())
+ {
+ break;
+ }
+
+ IosNewObject obj = *createList++;
+
+ obj.lodBenefit = calcParticleBenefit(injParams, eyePos, obj.initialPosition, obj.initialVelocity, 1.0f);
+ obj.iofxActorID.set(mVolumeID, mRandomActorClassIDs[ mLastRandomID++ ]);
+ mLastRandomID = mLastRandomID == mRandomActorClassIDs.size() ? 0 : mLastRandomID;
+ //mInjectedParticleBenefit += obj.lodBenefit;
+ mInjectedParticles.pushBack(obj);
+ }
+}
+
+#if APEX_CUDA_SUPPORT
+void ParticleParticleInjector::createObjects(ApexMirroredArray<const IosNewObject>& createArray)
+{
+ PX_UNUSED(createArray);
+
+ // An emitter will call this API when it has filled a host or device buffer. The injector
+ // should trigger a copy to the location it would like to see the resulting data when the
+ // IOS is finally ticked.
+
+ PX_ALWAYS_ASSERT(); /* Not yet supported */
+}
+#endif
+
+uint32_t ParticleParticleInjector::getActivePaticleCount() const
+{
+ return mSimulatedParticlesCount;
+}
+
+}
+} // end namespace nvidia
+
diff --git a/APEX_1.4/module/pxparticleios/src/ParticleIosAssetImpl.cpp b/APEX_1.4/module/pxparticleios/src/ParticleIosAssetImpl.cpp
new file mode 100644
index 00000000..b7b072f1
--- /dev/null
+++ b/APEX_1.4/module/pxparticleios/src/ParticleIosAssetImpl.cpp
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
+ *
+ * NVIDIA CORPORATION and its licensors retain all intellectual property
+ * and proprietary rights in and to this software, related documentation
+ * and any modifications thereto. Any use, reproduction, disclosure or
+ * distribution of this software and related documentation without an express
+ * license agreement from NVIDIA CORPORATION is strictly prohibited.
+ */
+
+
+#include "ApexDefs.h"
+#include "ParticleIosAssetImpl.h"
+#include "ParticleIosActorImpl.h"
+#include "ModuleParticleIosImpl.h"
+#include "ApexUsingNamespace.h"
+#include "FluidParticleSystemParams.h"
+
+#if APEX_CUDA_SUPPORT
+#include "ParticleIosActorGPU.h"
+#endif
+
+namespace nvidia
+{
+namespace pxparticleios
+{
+
+ParticleIosAssetImpl::ParticleIosAssetImpl(ModuleParticleIosImpl* module, ResourceList& list, NvParameterized::Interface* params, const char* name) :
+ mModule(module),
+ mName(name),
+ mParams((ParticleIosAssetParam*)params)
+{
+ list.add(*this);
+}
+
+ParticleIosAssetImpl::ParticleIosAssetImpl(ModuleParticleIosImpl* module, ResourceList& list, const char* name):
+ mModule(module),
+ mName(name),
+ mParams(0)
+{
+ NvParameterized::Traits* traits = GetInternalApexSDK()->getParameterizedTraits();
+ mParams = (ParticleIosAssetParam*)traits->createNvParameterized(ParticleIosAssetParam::staticClassName());
+
+ list.add(*this);
+}
+
+void ParticleIosAssetImpl::release()
+{
+ mModule->mSdk->releaseAsset(*this);
+}
+
+void ParticleIosAssetImpl::destroy()
+{
+ if (mParams)
+ {
+ mParams->destroy();
+ mParams = NULL;
+ }
+
+ delete this;
+}
+
+ParticleIosAssetImpl::~ParticleIosAssetImpl()
+{
+}
+
+ParticleIosActorImpl* ParticleIosAssetImpl::getIosActorInScene(Scene& scene, bool mesh) const
+{
+ ParticleIosScene* iosScene = mModule->getParticleIosScene(scene);
+ if (iosScene != 0)
+ {
+ for (uint32_t i = 0 ; i < mIosActorList.getSize() ; i++)
+ {
+ ParticleIosActorImpl* iosActor = DYNAMIC_CAST(ParticleIosActorImpl*)(mIosActorList.getResource(i));
+ if (iosActor->mParticleIosScene == iosScene && iosActor->mIsMesh == mesh)
+ {
+ return iosActor;
+ }
+ }
+ }
+ return NULL;
+}
+
+Actor* ParticleIosAssetImpl::createIosActor(Scene& scene, IofxAsset* iofxAsset)
+{
+ WRITE_ZONE();
+ ParticleIosActorImpl* iosActor = getIosActorInScene(scene, iofxAsset->getMeshAssetCount() > 0);
+ if (iosActor == 0)
+ {
+ ParticleIosScene* iosScene = mModule->getParticleIosScene(scene);
+ if (iosScene != 0)
+ {
+ iosActor = iosScene->createIosActor(mIosActorList, *this, *iofxAsset);
+ iosActor->mIsMesh = iofxAsset->getMeshAssetCount() > 0;
+ }
+ }
+ PX_ASSERT(iosActor);
+ return iosActor;
+}
+
+void ParticleIosAssetImpl::releaseIosActor(Actor& actor)
+{
+ WRITE_ZONE();
+ ParticleIosActorImpl* iosActor = DYNAMIC_CAST(ParticleIosActorImpl*)(&actor);
+ iosActor->destroy();
+}
+
+uint32_t ParticleIosAssetImpl::forceLoadAssets()
+{
+ WRITE_ZONE();
+ return 0;
+}
+
+
+#ifndef WITHOUT_APEX_AUTHORING
+/******************* ParticleIosAssetAuthoringImpl *******************/
+ParticleIosAssetAuthoringImpl::ParticleIosAssetAuthoringImpl(ModuleParticleIosImpl* module, ResourceList& list):
+ ParticleIosAssetImpl(module, list, "Authoring")
+{
+}
+ParticleIosAssetAuthoringImpl::ParticleIosAssetAuthoringImpl(ModuleParticleIosImpl* module, ResourceList& list, const char* name):
+ ParticleIosAssetImpl(module, list, name)
+{
+}
+
+ParticleIosAssetAuthoringImpl::ParticleIosAssetAuthoringImpl(ModuleParticleIosImpl* module, ResourceList& list, NvParameterized::Interface* params, const char* name) :
+ ParticleIosAssetImpl(module, list, params, name)
+{
+}
+
+void ParticleIosAssetAuthoringImpl::release()
+{
+ delete this;
+}
+
+void ParticleIosAssetAuthoringImpl::setCollisionGroupName(const char* collisionGroupName)
+{
+ NvParameterized::Handle h(*mParams, "collisionGroupName");
+ h.setParamString(collisionGroupName);
+}
+
+void ParticleIosAssetAuthoringImpl::setCollisionGroupMaskName(const char* collisionGroupMaskName)
+{
+ NvParameterized::Handle h(*mParams, "collisionGroupMaskName");
+ h.setParamString(collisionGroupMaskName);
+}
+#endif // !WITHOUT_APEX_AUTHORING
+
+}
+} // namespace nvidia
+
+
diff --git a/APEX_1.4/module/pxparticleios/src/ParticleIosScene.cpp b/APEX_1.4/module/pxparticleios/src/ParticleIosScene.cpp
new file mode 100644
index 00000000..03731cc2
--- /dev/null
+++ b/APEX_1.4/module/pxparticleios/src/ParticleIosScene.cpp
@@ -0,0 +1,459 @@
+/*
+ * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
+ *
+ * NVIDIA CORPORATION and its licensors retain all intellectual property
+ * and proprietary rights in and to this software, related documentation
+ * and any modifications thereto. Any use, reproduction, disclosure or
+ * distribution of this software and related documentation without an express
+ * license agreement from NVIDIA CORPORATION is strictly prohibited.
+ */
+
+
+#include "ApexDefs.h"
+#include "Apex.h"
+#include "ParticleIosScene.h"
+#include "ModuleParticleIosImpl.h"
+#include "ParticleIosActorImpl.h"
+#include "ParticleIosActorCPU.h"
+#include "SceneIntl.h"
+#include "ModuleFieldSamplerIntl.h"
+#include "ModulePerfScope.h"
+#include "ApexUsingNamespace.h"
+#include "RenderDebugInterface.h"
+
+
+#if APEX_CUDA_SUPPORT
+#include <cuda.h>
+#include "ApexCutil.h"
+#include "ParticleIosActorGPU.h"
+#include "ApexCudaSource.h"
+#endif
+
+#include "Lock.h"
+
+#define CUDA_OBJ(name) SCENE_CUDA_OBJ(*this, name)
+
+namespace nvidia
+{
+namespace pxparticleios
+{
+
+
+#pragma warning(push)
+#pragma warning(disable:4355)
+
+ParticleIosScene::ParticleIosScene(ModuleParticleIosImpl& _module, SceneIntl& scene, RenderDebugInterface* renderDebug, ResourceList& list)
+ : mPhysXScene(NULL)
+ , mModule(&_module)
+ , mApexScene(&scene)
+ , mRenderDebug(renderDebug)
+ , mSumBenefit(0.0f)
+ , mFieldSamplerManager(NULL)
+ , mInjectorAllocator(this)
+{
+ list.add(*this);
+
+ /* Initialize reference to ParticleIosDebugRenderParams */
+ mDebugRenderParams = DYNAMIC_CAST(DebugRenderParams*)(mApexScene->getDebugRenderParams());
+ PX_ASSERT(mDebugRenderParams);
+ NvParameterized::Handle handle(*mDebugRenderParams), memberHandle(*mDebugRenderParams);
+ int size;
+
+ if (mDebugRenderParams->getParameterHandle("moduleName", handle) == NvParameterized::ERROR_NONE)
+ {
+ handle.getArraySize(size, 0);
+ handle.resizeArray(size + 1);
+ if (handle.getChildHandle(size, memberHandle) == NvParameterized::ERROR_NONE)
+ {
+ memberHandle.initParamRef(ParticleIosDebugRenderParams::staticClassName(), true);
+ }
+ }
+
+ /* Load reference to ParticleIosDebugRenderParams */
+ NvParameterized::Interface* refPtr = NULL;
+ memberHandle.getParamRef(refPtr);
+ mParticleIosDebugRenderParams = DYNAMIC_CAST(ParticleIosDebugRenderParams*)(refPtr);
+ PX_ASSERT(mParticleIosDebugRenderParams);
+}
+#pragma warning(pop)
+
+ParticleIosScene::~ParticleIosScene()
+{
+}
+
+void ParticleIosScene::destroy()
+{
+ removeAllActors();
+ mApexScene->moduleReleased(*this);
+ delete this;
+}
+
+void ParticleIosScene::setModulePhysXScene(PxScene* s)
+{
+ if (mPhysXScene == s)
+ {
+ return;
+ }
+
+ mPhysXScene = s;
+ for (uint32_t i = 0; i < mActorArray.size(); ++i)
+ {
+ ParticleIosActorImpl* actor = DYNAMIC_CAST(ParticleIosActorImpl*)(mActorArray[i]);
+ actor->setPhysXScene(mPhysXScene);
+ }
+}
+
+void ParticleIosScene::visualize()
+{
+#ifndef WITHOUT_DEBUG_VISUALIZE
+ if (!mParticleIosDebugRenderParams->VISUALIZE_PARTICLE_IOS_ACTOR)
+ {
+ return;
+ }
+
+ RENDER_DEBUG_IFACE(mRenderDebug)->pushRenderState();
+ for (uint32_t i = 0 ; i < mActorArray.size() ; i++)
+ {
+ ParticleIosActorImpl* testActor = DYNAMIC_CAST(ParticleIosActorImpl*)(mActorArray[ i ]);
+ testActor->visualize();
+ }
+ RENDER_DEBUG_IFACE(mRenderDebug)->popRenderState();
+#endif
+}
+
+void ParticleIosScene::submitTasks(float /*elapsedTime*/, float /*substepSize*/, uint32_t /*numSubSteps*/)
+{
+ PxTaskManager* tm;
+ {
+ READ_LOCK(*mApexScene);
+ tm = mApexScene->getTaskManager();
+ }
+
+ for (uint32_t i = 0; i < mActorArray.size(); ++i)
+ {
+ ParticleIosActorImpl* actor = DYNAMIC_CAST(ParticleIosActorImpl*)(mActorArray[i]);
+ actor->submitTasks(tm);
+ }
+}
+
+void ParticleIosScene::setTaskDependencies()
+{
+ PxTaskManager* tm;
+ {
+ READ_LOCK(*mApexScene);
+ tm = mApexScene->getTaskManager();
+ }
+#if 0
+ //run IOS after PhysX
+ PxTaskID taskStartAfterID = tm->getNamedTask(AST_PHYSX_CHECK_RESULTS);
+ PxTaskID taskFinishBeforeID = (PxTaskID)0xFFFFFFFF;
+#else
+ //run IOS before PhysX
+ PxTaskID taskStartAfterID = (PxTaskID)0xFFFFFFFF;
+ PxTaskID taskFinishBeforeID = tm->getNamedTask(AST_PHYSX_SIMULATE);
+#endif
+
+ for (uint32_t i = 0; i < mActorArray.size(); ++i)
+ {
+ ParticleIosActorImpl* actor = DYNAMIC_CAST(ParticleIosActorImpl*)(mActorArray[i]);
+ actor->setTaskDependencies(taskStartAfterID, taskFinishBeforeID);
+ }
+
+ onSimulationStart();
+}
+
+void ParticleIosScene::fetchResults()
+{
+ onSimulationFinish();
+
+ for (uint32_t i = 0; i < mActorArray.size(); ++i)
+ {
+ ParticleIosActorImpl* actor = DYNAMIC_CAST(ParticleIosActorImpl*)(mActorArray[i]);
+ actor->fetchResults();
+ }
+}
+
+FieldSamplerManagerIntl* ParticleIosScene::getInternalFieldSamplerManager()
+{
+ if (mFieldSamplerManager == NULL)
+ {
+ ModuleFieldSamplerIntl* moduleFieldSampler = mModule->getInternalModuleFieldSampler();
+ if (moduleFieldSampler != NULL)
+ {
+ mFieldSamplerManager = moduleFieldSampler->getInternalFieldSamplerManager(*mApexScene);
+ PX_ASSERT(mFieldSamplerManager != NULL);
+ }
+ }
+ return mFieldSamplerManager;
+}
+
+/******************************** CPU Version ********************************/
+
+void ParticleIosSceneCPU::TimerCallback::operator()(void* stream)
+{
+ PX_UNUSED(stream);
+
+ float elapsed = (float)mTimer.peekElapsedSeconds();
+ mMinTime = PxMin(elapsed, mMinTime);
+ mMaxTime = PxMax(elapsed, mMaxTime);
+}
+
+void ParticleIosSceneCPU::TimerCallback::reset()
+{
+ mTimer.getElapsedSeconds();
+ mMinTime = 1e20;
+ mMaxTime = 0.f;
+}
+
+float ParticleIosSceneCPU::TimerCallback::getElapsedTime() const
+{
+ return (mMaxTime - mMinTime) * 1000.f;
+}
+
+ParticleIosSceneCPU::ParticleIosSceneCPU(ModuleParticleIosImpl& module, SceneIntl& scene, RenderDebugInterface* debugRender, ResourceList& list) :
+ ParticleIosScene(module, scene, debugRender, list)
+{
+}
+
+ParticleIosSceneCPU::~ParticleIosSceneCPU()
+{
+}
+
+ParticleIosActorImpl* ParticleIosSceneCPU::createIosActor(ResourceList& list, ParticleIosAssetImpl& asset, IofxAsset& iofxAsset)
+{
+ ParticleIosActorCPU* actor = PX_NEW(ParticleIosActorCPU)(list, asset, *this, iofxAsset);
+
+ actor->setOnStartFSCallback(&mTimerCallback);
+ actor->setOnFinishIOFXCallback(&mTimerCallback);
+ return actor;
+}
+
+void ParticleIosSceneCPU::fetchResults()
+{
+ ParticleIosScene::fetchResults();
+
+ nvidia::apex::StatValue val;
+ val.Float = mTimerCallback.getElapsedTime();
+ mTimerCallback.reset();
+ if (val.Float > 0.f)
+ {
+ mApexScene->setApexStatValue(SceneIntl::ParticleSimulationTime, val);
+ }
+}
+
+/******************************** GPU Version ********************************/
+
+#if APEX_CUDA_SUPPORT
+
+ParticleIosSceneGPU::EventCallback::EventCallback() : mIsCalled(false), mEvent(NULL)
+{
+}
+void ParticleIosSceneGPU::EventCallback::init()
+{
+ if (mEvent == NULL)
+ {
+ CUT_SAFE_CALL(cuEventCreate((CUevent*)(&mEvent), CU_EVENT_DEFAULT));
+ }
+}
+
+ParticleIosSceneGPU::EventCallback::~EventCallback()
+{
+ if (mEvent != NULL)
+ {
+ CUT_SAFE_CALL(cuEventDestroy((CUevent)mEvent));
+ }
+}
+
+void ParticleIosSceneGPU::EventCallback::operator()(void* stream)
+{
+ if (mEvent != NULL)
+ {
+ CUT_SAFE_CALL(cuEventRecord((CUevent)mEvent, (CUstream)stream));
+ mIsCalled = true;
+ }
+}
+
+ParticleIosSceneGPU::ParticleIosSceneGPU(ModuleParticleIosImpl& module, SceneIntl& scene, RenderDebugInterface* debugRender, ResourceList& list)
+ : ParticleIosScene(module, scene, debugRender, list)
+ , CudaModuleScene(scene, *mModule, APEX_CUDA_TO_STR(APEX_CUDA_MODULE_PREFIX))
+ , mInjectorConstMemGroup(APEX_CUDA_OBJ_NAME(simulateStorage))
+{
+ {
+ PxGpuDispatcher* gd = mApexScene->getTaskManager()->getGpuDispatcher();
+ PX_ASSERT(gd != NULL);
+ PxScopedCudaLock _lock_(*gd->getCudaContextManager());
+
+ mOnSimulationStart.init();
+//CUDA module objects
+#include "../cuda/include/moduleList.h"
+ }
+
+ {
+ mInjectorConstMemGroup.begin();
+ mInjectorParamsArrayHandle.alloc(mInjectorConstMemGroup.getStorage());
+ //injectorParamsArray.resize( mInjectorConstMemGroup.getStorage(), MAX_INJECTOR_COUNT );
+ mInjectorConstMemGroup.end();
+ }
+
+}
+
+ParticleIosSceneGPU::~ParticleIosSceneGPU()
+{
+ for (uint32_t i = 0; i < mOnStartCallbacks.size(); i++)
+ {
+ PX_DELETE(mOnStartCallbacks[i]);
+ }
+ for (uint32_t i = 0; i < mOnFinishCallbacks.size(); i++)
+ {
+ PX_DELETE(mOnFinishCallbacks[i]);
+ }
+ CudaModuleScene::destroy(*mApexScene);
+}
+
+ParticleIosActorImpl* ParticleIosSceneGPU::createIosActor(ResourceList& list, ParticleIosAssetImpl& asset, IofxAsset& iofxAsset)
+{
+ ParticleIosActorGPU* actor = PX_NEW(ParticleIosActorGPU)(list, asset, *this, iofxAsset);
+ mOnStartCallbacks.pushBack(PX_NEW(EventCallback)());
+ mOnFinishCallbacks.pushBack(PX_NEW(EventCallback)());
+ {
+ PxGpuDispatcher* gd = mApexScene->getTaskManager()->getGpuDispatcher();
+ PX_ASSERT(gd != NULL);
+ PxScopedCudaLock _lock_(*gd->getCudaContextManager());
+
+ mOnStartCallbacks.back()->init();
+ mOnFinishCallbacks.back()->init();
+ }
+ actor->setOnStartFSCallback(mOnStartCallbacks.back());
+ actor->setOnFinishIOFXCallback(mOnFinishCallbacks.back());
+ return actor;
+}
+
+void ParticleIosSceneGPU::fetchInjectorParams(uint32_t injectorID, Px3InjectorParams& injParams)
+{
+ APEX_CUDA_CONST_MEM_GROUP_SCOPE(mInjectorConstMemGroup);
+
+ InjectorParamsArray injectorParamsArray;
+ mInjectorParamsArrayHandle.fetch(_storage_, injectorParamsArray);
+ PX_ASSERT(injectorID < injectorParamsArray.getSize());
+ injectorParamsArray.fetchElem(_storage_, injParams, injectorID);
+}
+void ParticleIosSceneGPU::updateInjectorParams(uint32_t injectorID, const Px3InjectorParams& injParams)
+{
+ APEX_CUDA_CONST_MEM_GROUP_SCOPE(mInjectorConstMemGroup);
+
+ InjectorParamsArray injectorParamsArray;
+ mInjectorParamsArrayHandle.fetch(_storage_, injectorParamsArray);
+ PX_ASSERT(injectorID < injectorParamsArray.getSize());
+ injectorParamsArray.updateElem(_storage_, injParams, injectorID);
+}
+
+void ParticleIosSceneGPU::fetchResults()
+{
+ ParticleIosScene::fetchResults();
+
+ nvidia::apex::StatValue val;
+ val.Float = 0.f;
+ float minTime = 1e30;
+
+ for (uint32_t i = 0 ; i < this->mOnStartCallbacks.size(); i++)
+ {
+ if (mOnStartCallbacks[i]->mIsCalled && mOnFinishCallbacks[i]->mIsCalled)
+ {
+ mOnStartCallbacks[i]->mIsCalled = false;
+ mOnFinishCallbacks[i]->mIsCalled = false;
+ CUT_SAFE_CALL(cuEventSynchronize((CUevent)mOnStartCallbacks[i]->getEvent()));
+ CUT_SAFE_CALL(cuEventSynchronize((CUevent)mOnFinishCallbacks[i]->getEvent()));
+ float tmp;
+ CUT_SAFE_CALL(cuEventElapsedTime(&tmp, (CUevent)mOnSimulationStart.getEvent(), (CUevent)mOnStartCallbacks[i]->getEvent()));
+ minTime = PxMin(tmp, minTime);
+ CUT_SAFE_CALL(cuEventElapsedTime(&tmp, (CUevent)mOnSimulationStart.getEvent(), (CUevent)mOnFinishCallbacks[i]->getEvent()));
+ val.Float = PxMax(tmp, val.Float);
+ }
+ }
+ val.Float -= PxMin(minTime, val.Float);
+
+ if (val.Float > 0.f)
+ {
+ mApexScene->setApexStatValue(SceneIntl::ParticleSimulationTime, val);
+ }
+}
+
+bool ParticleIosSceneGPU::growInjectorStorage(uint32_t newSize)
+{
+ APEX_CUDA_CONST_MEM_GROUP_SCOPE(mInjectorConstMemGroup);
+
+ InjectorParamsArray injectorParamsArray;
+ mInjectorParamsArrayHandle.fetch(_storage_, injectorParamsArray);
+ if (injectorParamsArray.resize(_storage_, newSize))
+ {
+ mInjectorParamsArrayHandle.update(_storage_, injectorParamsArray);
+ return true;
+ }
+ return false;
+}
+
+
+void ParticleIosSceneGPU::onSimulationStart()
+{
+ ParticleIosScene::onSimulationStart();
+
+ PxGpuDispatcher* gd = mApexScene->getTaskManager()->getGpuDispatcher();
+ PX_ASSERT(gd != NULL);
+ PxScopedCudaLock _lock_(*gd->getCudaContextManager());
+
+ //we pass default 0 stream so that this copy happens before any kernel launches
+ APEX_CUDA_OBJ_NAME(simulateStorage).copyToDevice(gd->getCudaContextManager(), 0);
+
+ mOnSimulationStart(NULL);
+}
+
+#endif
+
+// ParticleIosInjectorAllocator
+uint32_t ParticleIosInjectorAllocator::allocateInjectorID()
+{
+ if (mFreeInjectorListStart == NULL_INJECTOR_INDEX)
+ {
+ //try to get new injectors
+ uint32_t size = mInjectorList.size();
+ if (mStorage->growInjectorStorage(size + 1) == false)
+ {
+ return NULL_INJECTOR_INDEX;
+ }
+
+ mFreeInjectorListStart = size;
+ mInjectorList.resize(size + 1);
+ mInjectorList.back() = NULL_INJECTOR_INDEX;
+ }
+ uint32_t injectorID = mFreeInjectorListStart;
+ mFreeInjectorListStart = mInjectorList[injectorID];
+ mInjectorList[injectorID] = USED_INJECTOR_INDEX;
+ return injectorID;
+}
+
+void ParticleIosInjectorAllocator::releaseInjectorID(uint32_t injectorID)
+{
+ //add to released injector list
+ PX_ASSERT(mInjectorList[injectorID] == USED_INJECTOR_INDEX);
+ mInjectorList[injectorID] = mReleasedInjectorListStart;
+ mReleasedInjectorListStart = injectorID;
+}
+
+void ParticleIosInjectorAllocator::flushReleased()
+{
+ //add all released injectors to free injector list
+ while (mReleasedInjectorListStart != NULL_INJECTOR_INDEX)
+ {
+ uint32_t injectorID = mInjectorList[mReleasedInjectorListStart];
+
+ //add to free injector list
+ mInjectorList[mReleasedInjectorListStart] = mFreeInjectorListStart;
+ mFreeInjectorListStart = mReleasedInjectorListStart;
+
+ mReleasedInjectorListStart = injectorID;
+ }
+}
+
+}
+} // namespace nvidia
+
diff --git a/APEX_1.4/module/pxparticleios/src/autogen/FluidParticleSystemParams.cpp b/APEX_1.4/module/pxparticleios/src/autogen/FluidParticleSystemParams.cpp
new file mode 100644
index 00000000..cd1b55a4
--- /dev/null
+++ b/APEX_1.4/module/pxparticleios/src/autogen/FluidParticleSystemParams.cpp
@@ -0,0 +1,361 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#include "FluidParticleSystemParams.h"
+#include <string.h>
+#include <stdlib.h>
+
+using namespace NvParameterized;
+
+namespace nvidia
+{
+namespace pxparticleios
+{
+
+using namespace FluidParticleSystemParamsNS;
+
+const char* const FluidParticleSystemParamsFactory::vptr =
+ NvParameterized::getVptr<FluidParticleSystemParams, FluidParticleSystemParams::ClassAlignment>();
+
+const uint32_t NumParamDefs = 4;
+static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs];
+
+
+static const size_t ParamLookupChildrenTable[] =
+{
+ 1, 2, 3,
+};
+
+#define TENUM(type) nvidia::##type
+#define CHILDREN(index) &ParamLookupChildrenTable[index]
+static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] =
+{
+ { TYPE_STRUCT, false, 0, CHILDREN(0), 3 },
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->restParticleDistance), NULL, 0 }, // restParticleDistance
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->stiffness), NULL, 0 }, // stiffness
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->viscosity), NULL, 0 }, // viscosity
+};
+
+
+bool FluidParticleSystemParams::mBuiltFlag = false;
+NvParameterized::MutexType FluidParticleSystemParams::mBuiltFlagMutex;
+
+FluidParticleSystemParams::FluidParticleSystemParams(NvParameterized::Traits* traits, void* buf, int32_t* refCount) :
+ NvParameters(traits, buf, refCount)
+{
+ //mParameterizedTraits->registerFactory(className(), &FluidParticleSystemParamsFactoryInst);
+
+ if (!buf) //Do not init data if it is inplace-deserialized
+ {
+ initDynamicArrays();
+ initStrings();
+ initReferences();
+ initDefaults();
+ }
+}
+
+FluidParticleSystemParams::~FluidParticleSystemParams()
+{
+ freeStrings();
+ freeReferences();
+ freeDynamicArrays();
+}
+
+void FluidParticleSystemParams::destroy()
+{
+ // We cache these fields here to avoid overwrite in destructor
+ bool doDeallocateSelf = mDoDeallocateSelf;
+ NvParameterized::Traits* traits = mParameterizedTraits;
+ int32_t* refCount = mRefCount;
+ void* buf = mBuffer;
+
+ this->~FluidParticleSystemParams();
+
+ NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf);
+}
+
+const NvParameterized::DefinitionImpl* FluidParticleSystemParams::getParameterDefinitionTree(void)
+{
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+ if (!mBuiltFlag)
+ {
+ buildTree();
+ }
+ }
+
+ return(&ParamDefTable[0]);
+}
+
+const NvParameterized::DefinitionImpl* FluidParticleSystemParams::getParameterDefinitionTree(void) const
+{
+ FluidParticleSystemParams* tmpParam = const_cast<FluidParticleSystemParams*>(this);
+
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+ if (!mBuiltFlag)
+ {
+ tmpParam->buildTree();
+ }
+ }
+
+ return(&ParamDefTable[0]);
+}
+
+NvParameterized::ErrorType FluidParticleSystemParams::getParameterHandle(const char* long_name, Handle& handle) const
+{
+ ErrorType Ret = NvParameters::getParameterHandle(long_name, handle);
+ if (Ret != ERROR_NONE)
+ {
+ return(Ret);
+ }
+
+ size_t offset;
+ void* ptr;
+
+ getVarPtr(handle, ptr, offset);
+
+ if (ptr == NULL)
+ {
+ return(ERROR_INDEX_OUT_OF_RANGE);
+ }
+
+ return(ERROR_NONE);
+}
+
+NvParameterized::ErrorType FluidParticleSystemParams::getParameterHandle(const char* long_name, Handle& handle)
+{
+ ErrorType Ret = NvParameters::getParameterHandle(long_name, handle);
+ if (Ret != ERROR_NONE)
+ {
+ return(Ret);
+ }
+
+ size_t offset;
+ void* ptr;
+
+ getVarPtr(handle, ptr, offset);
+
+ if (ptr == NULL)
+ {
+ return(ERROR_INDEX_OUT_OF_RANGE);
+ }
+
+ return(ERROR_NONE);
+}
+
+void FluidParticleSystemParams::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const
+{
+ ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<FluidParticleSystemParams::ParametersStruct*>(&parameters()), handle, offset);
+}
+
+
+/* Dynamic Handle Indices */
+
+void FluidParticleSystemParams::freeParameterDefinitionTable(NvParameterized::Traits* traits)
+{
+ if (!traits)
+ {
+ return;
+ }
+
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ return;
+ }
+
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+
+ if (!mBuiltFlag)
+ {
+ return;
+ }
+
+ for (uint32_t i = 0; i < NumParamDefs; ++i)
+ {
+ ParamDefTable[i].~DefinitionImpl();
+ }
+
+ traits->free(ParamDefTable);
+
+ mBuiltFlag = false;
+}
+
+#define PDEF_PTR(index) (&ParamDefTable[index])
+
+void FluidParticleSystemParams::buildTree(void)
+{
+
+ uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs;
+ ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize));
+ memset(ParamDefTable, 0, allocSize);
+
+ for (uint32_t i = 0; i < NumParamDefs; ++i)
+ {
+ NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits);
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=0, longName=""
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0];
+ ParamDef->init("", TYPE_STRUCT, "STRUCT", true);
+
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=1, longName="restParticleDistance"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1];
+ ParamDef->init("restParticleDistance", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("longDescription", "The typical particle distance of particles in the rest state (relaxed).\nDefines the particle resolution of the fluid. \n \nThis property can't be changed after the particle fluid has been created.\nMust be positive.\n", true);
+ HintTable[1].init("shortDescription", "Rest distance of particles", true);
+ ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=2, longName="stiffness"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2];
+ ParamDef->init("stiffness", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("longDescription", "This factor linearly scales the force which acts on particles which are closer to each other than \nthe rest spacing.\n\nSetting this parameter appropriately is crucial for the simulation. The right value depends on many factors\nsuch as viscosity and damping. Values which are too high will result in an\nunstable simulation, whereas too low values will make the fluid appear \"springy\" (the fluid\nacts more compressible).\n\nMust be positive.\n", true);
+ HintTable[1].init("shortDescription", "The stiffness of the particle interaction related to the pressure", true);
+ ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=3, longName="viscosity"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3];
+ ParamDef->init("viscosity", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("longDescription", "Higher values will result in a honey-like behavior. Viscosity is an effect which depends on the \nrelative velocity of neighboring particles; it reduces the magnitude of the relative velocity.\n\nMust be positive.\n", true);
+ HintTable[1].init("shortDescription", "The viscosity of the fluid defines its viscous behavior", true);
+ ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // SetChildren for: nodeIndex=0, longName=""
+ {
+ static Definition* Children[3];
+ Children[0] = PDEF_PTR(1);
+ Children[1] = PDEF_PTR(2);
+ Children[2] = PDEF_PTR(3);
+
+ ParamDefTable[0].setChildren(Children, 3);
+ }
+
+ mBuiltFlag = true;
+
+}
+void FluidParticleSystemParams::initStrings(void)
+{
+}
+
+void FluidParticleSystemParams::initDynamicArrays(void)
+{
+}
+
+void FluidParticleSystemParams::initDefaults(void)
+{
+
+ freeStrings();
+ freeReferences();
+ freeDynamicArrays();
+ restParticleDistance = float(0.02);
+ stiffness = float(20);
+ viscosity = float(6);
+
+ initDynamicArrays();
+ initStrings();
+ initReferences();
+}
+
+void FluidParticleSystemParams::initReferences(void)
+{
+}
+
+void FluidParticleSystemParams::freeDynamicArrays(void)
+{
+}
+
+void FluidParticleSystemParams::freeStrings(void)
+{
+}
+
+void FluidParticleSystemParams::freeReferences(void)
+{
+}
+
+} // namespace pxparticleios
+} // namespace nvidia
diff --git a/APEX_1.4/module/pxparticleios/src/autogen/ParticleIosAssetParam.cpp b/APEX_1.4/module/pxparticleios/src/autogen/ParticleIosAssetParam.cpp
new file mode 100644
index 00000000..9a0f95a6
--- /dev/null
+++ b/APEX_1.4/module/pxparticleios/src/autogen/ParticleIosAssetParam.cpp
@@ -0,0 +1,1339 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#include "ParticleIosAssetParam.h"
+#include <string.h>
+#include <stdlib.h>
+
+using namespace NvParameterized;
+
+namespace nvidia
+{
+namespace pxparticleios
+{
+
+using namespace ParticleIosAssetParamNS;
+
+const char* const ParticleIosAssetParamFactory::vptr =
+ NvParameterized::getVptr<ParticleIosAssetParam, ParticleIosAssetParam::ClassAlignment>();
+
+const uint32_t NumParamDefs = 36;
+static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs];
+
+
+static const size_t ParamLookupChildrenTable[] =
+{
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 32, 29, 30, 31, 33, 34, 35,
+};
+
+#define TENUM(type) nvidia::##type
+#define CHILDREN(index) &ParamLookupChildrenTable[index]
+static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] =
+{
+ { TYPE_STRUCT, false, 0, CHILDREN(0), 29 },
+ { TYPE_REF, false, (size_t)(&((ParametersStruct*)0)->particleType), NULL, 0 }, // particleType
+ { TYPE_U32, false, (size_t)(&((ParametersStruct*)0)->maxParticleCount), NULL, 0 }, // maxParticleCount
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->particleRadius), NULL, 0 }, // particleRadius
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->maxInjectedParticleCount), NULL, 0 }, // maxInjectedParticleCount
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->maxMotionDistance), NULL, 0 }, // maxMotionDistance
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->contactOffset), NULL, 0 }, // contactOffset
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->restOffset), NULL, 0 }, // restOffset
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->gridSize), NULL, 0 }, // gridSize
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->damping), NULL, 0 }, // damping
+ { TYPE_VEC3, false, (size_t)(&((ParametersStruct*)0)->externalAcceleration), NULL, 0 }, // externalAcceleration
+ { TYPE_VEC3, false, (size_t)(&((ParametersStruct*)0)->projectionPlaneNormal), NULL, 0 }, // projectionPlaneNormal
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->projectionPlaneDistance), NULL, 0 }, // projectionPlaneDistance
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->particleMass), NULL, 0 }, // particleMass
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->restitution), NULL, 0 }, // restitution
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->dynamicFriction), NULL, 0 }, // dynamicFriction
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->staticFriction), NULL, 0 }, // staticFriction
+ { TYPE_STRING, false, (size_t)(&((ParametersStruct*)0)->simulationFilterData), NULL, 0 }, // simulationFilterData
+ { TYPE_STRING, false, (size_t)(&((ParametersStruct*)0)->fieldSamplerFilterData), NULL, 0 }, // fieldSamplerFilterData
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->CollisionTwoway), NULL, 0 }, // CollisionTwoway
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->CollisionWithDynamicActors), NULL, 0 }, // CollisionWithDynamicActors
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->Enable), NULL, 0 }, // Enable
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->ProjectToPlane), NULL, 0 }, // ProjectToPlane
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->PerParticleRestOffset), NULL, 0 }, // PerParticleRestOffset
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->PerParticleCollisionCacheHint), NULL, 0 }, // PerParticleCollisionCacheHint
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->DensityBuffer), NULL, 0 }, // DensityBuffer
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->enableTemperatureBuffer), NULL, 0 }, // enableTemperatureBuffer
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->enableCouplingOverride), NULL, 0 }, // enableCouplingOverride
+ { TYPE_STRUCT, false, (size_t)(&((ParametersStruct*)0)->particleToGridCoupling), CHILDREN(29), 3 }, // particleToGridCoupling
+ { TYPE_F32, false, (size_t)(&((ParticleToGridCouplingParams_Type*)0)->accelTimeConstant), NULL, 0 }, // particleToGridCoupling.accelTimeConstant
+ { TYPE_F32, false, (size_t)(&((ParticleToGridCouplingParams_Type*)0)->decelTimeConstant), NULL, 0 }, // particleToGridCoupling.decelTimeConstant
+ { TYPE_F32, false, (size_t)(&((ParticleToGridCouplingParams_Type*)0)->thresholdMultiplier), NULL, 0 }, // particleToGridCoupling.thresholdMultiplier
+ { TYPE_STRUCT, false, (size_t)(&((ParametersStruct*)0)->gridToParticleCoupling), CHILDREN(32), 3 }, // gridToParticleCoupling
+ { TYPE_F32, false, (size_t)(&((GridToParticleCouplingParams_Type*)0)->accelTimeConstant), NULL, 0 }, // gridToParticleCoupling.accelTimeConstant
+ { TYPE_F32, false, (size_t)(&((GridToParticleCouplingParams_Type*)0)->decelTimeConstant), NULL, 0 }, // gridToParticleCoupling.decelTimeConstant
+ { TYPE_F32, false, (size_t)(&((GridToParticleCouplingParams_Type*)0)->thresholdMultiplier), NULL, 0 }, // gridToParticleCoupling.thresholdMultiplier
+};
+
+
+bool ParticleIosAssetParam::mBuiltFlag = false;
+NvParameterized::MutexType ParticleIosAssetParam::mBuiltFlagMutex;
+
+ParticleIosAssetParam::ParticleIosAssetParam(NvParameterized::Traits* traits, void* buf, int32_t* refCount) :
+ NvParameters(traits, buf, refCount)
+{
+ //mParameterizedTraits->registerFactory(className(), &ParticleIosAssetParamFactoryInst);
+
+ if (!buf) //Do not init data if it is inplace-deserialized
+ {
+ initDynamicArrays();
+ initStrings();
+ initReferences();
+ initDefaults();
+ }
+}
+
+ParticleIosAssetParam::~ParticleIosAssetParam()
+{
+ freeStrings();
+ freeReferences();
+ freeDynamicArrays();
+}
+
+void ParticleIosAssetParam::destroy()
+{
+ // We cache these fields here to avoid overwrite in destructor
+ bool doDeallocateSelf = mDoDeallocateSelf;
+ NvParameterized::Traits* traits = mParameterizedTraits;
+ int32_t* refCount = mRefCount;
+ void* buf = mBuffer;
+
+ this->~ParticleIosAssetParam();
+
+ NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf);
+}
+
+const NvParameterized::DefinitionImpl* ParticleIosAssetParam::getParameterDefinitionTree(void)
+{
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+ if (!mBuiltFlag)
+ {
+ buildTree();
+ }
+ }
+
+ return(&ParamDefTable[0]);
+}
+
+const NvParameterized::DefinitionImpl* ParticleIosAssetParam::getParameterDefinitionTree(void) const
+{
+ ParticleIosAssetParam* tmpParam = const_cast<ParticleIosAssetParam*>(this);
+
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+ if (!mBuiltFlag)
+ {
+ tmpParam->buildTree();
+ }
+ }
+
+ return(&ParamDefTable[0]);
+}
+
+NvParameterized::ErrorType ParticleIosAssetParam::getParameterHandle(const char* long_name, Handle& handle) const
+{
+ ErrorType Ret = NvParameters::getParameterHandle(long_name, handle);
+ if (Ret != ERROR_NONE)
+ {
+ return(Ret);
+ }
+
+ size_t offset;
+ void* ptr;
+
+ getVarPtr(handle, ptr, offset);
+
+ if (ptr == NULL)
+ {
+ return(ERROR_INDEX_OUT_OF_RANGE);
+ }
+
+ return(ERROR_NONE);
+}
+
+NvParameterized::ErrorType ParticleIosAssetParam::getParameterHandle(const char* long_name, Handle& handle)
+{
+ ErrorType Ret = NvParameters::getParameterHandle(long_name, handle);
+ if (Ret != ERROR_NONE)
+ {
+ return(Ret);
+ }
+
+ size_t offset;
+ void* ptr;
+
+ getVarPtr(handle, ptr, offset);
+
+ if (ptr == NULL)
+ {
+ return(ERROR_INDEX_OUT_OF_RANGE);
+ }
+
+ return(ERROR_NONE);
+}
+
+void ParticleIosAssetParam::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const
+{
+ ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<ParticleIosAssetParam::ParametersStruct*>(&parameters()), handle, offset);
+}
+
+
+/* Dynamic Handle Indices */
+
+void ParticleIosAssetParam::freeParameterDefinitionTable(NvParameterized::Traits* traits)
+{
+ if (!traits)
+ {
+ return;
+ }
+
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ return;
+ }
+
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+
+ if (!mBuiltFlag)
+ {
+ return;
+ }
+
+ for (uint32_t i = 0; i < NumParamDefs; ++i)
+ {
+ ParamDefTable[i].~DefinitionImpl();
+ }
+
+ traits->free(ParamDefTable);
+
+ mBuiltFlag = false;
+}
+
+#define PDEF_PTR(index) (&ParamDefTable[index])
+
+void ParticleIosAssetParam::buildTree(void)
+{
+
+ uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs;
+ ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize));
+ memset(ParamDefTable, 0, allocSize);
+
+ for (uint32_t i = 0; i < NumParamDefs; ++i)
+ {
+ NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits);
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=0, longName=""
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0];
+ ParamDef->init("", TYPE_STRUCT, "STRUCT", true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "Contains the asset properties for an IOS", true);
+ ParamDefTable[0].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=1, longName="particleType"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1];
+ ParamDef->init("particleType", TYPE_REF, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("INCLUDED", uint64_t(1), true);
+ ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#else
+
+ static HintImpl HintTable[3];
+ static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], };
+ HintTable[0].init("INCLUDED", uint64_t(1), true);
+ HintTable[1].init("longDescription", "ParticleSystem: generic particle system; ParticleFluid: SPH fluid particle system.\n\nThe generic particle system provides basic particle motion and collision with rigid actors.\nIt can be used for objects that require collisions against the environment but for whom inter-object\ninteration may be neglected. Examples might include items of small debris, sparks or leaves.\n\nThe SPH fluid particle system can be used for fluid effects that require approximate incompressibility\n and flowing behavior, such as liquids or fog and smoke filling up a volume\n", true);
+ HintTable[2].init("shortDescription", "Particle system types", true);
+ ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 3);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+ static const char* const RefVariantVals[] = { "SimpleParticleSystemParams", "FluidParticleSystemParams" };
+ ParamDefTable[1].setRefVariantVals((const char**)RefVariantVals, 2);
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=2, longName="maxParticleCount"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2];
+ ParamDef->init("maxParticleCount", TYPE_U32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("min", uint64_t(0), true);
+ ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("min", uint64_t(0), true);
+ HintTable[1].init("shortDescription", "Maximum particle count", true);
+ ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=3, longName="particleRadius"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3];
+ ParamDef->init("particleRadius", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("gameScale", "true", true);
+ HintTable[1].init("min", uint64_t(0), true);
+ ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#else
+
+ static HintImpl HintTable[4];
+ static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], };
+ HintTable[0].init("gameScale", "true", true);
+ HintTable[1].init("longDescription", "Query the authored radius of the instanced objects simulated by this IOS. Emitters need this\nvalue for volume fill effects and an IOFX may need it for rendering purposes\n", true);
+ HintTable[2].init("min", uint64_t(0), true);
+ HintTable[3].init("shortDescription", "Particle radius", true);
+ ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 4);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=4, longName="maxInjectedParticleCount"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[4];
+ ParamDef->init("maxInjectedParticleCount", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("min", uint64_t(0), true);
+ ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#else
+
+ static HintImpl HintTable[3];
+ static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], };
+ HintTable[0].init("longDescription", "The maximum number of new particles to be spawned on each frame. Use values >1 to provide the absolute value,\nor 0 <= x <= 1 to provide the percentage rate to overall number of particles. \n", true);
+ HintTable[1].init("min", uint64_t(0), true);
+ HintTable[2].init("shortDescription", "Maximum number of newly created particles on each frame", true);
+ ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 3);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=5, longName="maxMotionDistance"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[5];
+ ParamDef->init("maxMotionDistance", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("uimax", double(0.5), true);
+ HintTable[1].init("uimin", double(0.001), true);
+ ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#else
+
+ static HintImpl HintTable[4];
+ static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], };
+ HintTable[0].init("longDescription", "Max distance a particle can travel in a single simulation step\n", true);
+ HintTable[1].init("shortDescription", "Max motion distance", true);
+ HintTable[2].init("uimax", double(0.5), true);
+ HintTable[3].init("uimin", double(0.001), true);
+ ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 4);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=6, longName="contactOffset"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[6];
+ ParamDef->init("contactOffset", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("uimax", double(0.5), true);
+ HintTable[1].init("uimin", double(0.002), true);
+ ParamDefTable[6].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#else
+
+ static HintImpl HintTable[4];
+ static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], };
+ HintTable[0].init("longDescription", "Specifies a skin around the particles within which contacts will be generated\n\nObjects that come within contactOffset distance of the particles will count as being in contact (the contactOffset\nof the other object has no influence). The contactOffset has to be greater than zero and also be greater than the\nparticle systems restOffset. Having a contactOffset bigger than the restOffset is important to avoid jittering and sticking.\nThe contactOffset needs to be positive and the sum maxMotionDistance + contactOffset must not be higher than gridSize.\n\n", true);
+ HintTable[1].init("shortDescription", "Contact offset", true);
+ HintTable[2].init("uimax", double(0.5), true);
+ HintTable[3].init("uimin", double(0.002), true);
+ ParamDefTable[6].setHints((const NvParameterized::Hint**)HintPtrTable, 4);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=7, longName="restOffset"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[7];
+ ParamDef->init("restOffset", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("uimax", double(0.4), true);
+ HintTable[1].init("uimin", double(0.001), true);
+ ParamDefTable[7].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#else
+
+ static HintImpl HintTable[4];
+ static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], };
+ HintTable[0].init("longDescription", "Specifies an offset at which particles will come to rest relative to an objects surface\n\nParticles will maintain a distance equal to the restOffset to rigid bodies (the restOffset of the rigid body has no influence).\nIf the restOffset is zero the particles should rest exactly on the object surface.\n\nThe restOffset can alternatively be specified per particle. However the per particle restOffset needs to be smaller or equal\nto the PxParticleBaseDesc.restOffset.\n", true);
+ HintTable[1].init("shortDescription", "Rest offset", true);
+ HintTable[2].init("uimax", double(0.4), true);
+ HintTable[3].init("uimin", double(0.001), true);
+ ParamDefTable[7].setHints((const NvParameterized::Hint**)HintPtrTable, 4);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=8, longName="gridSize"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[8];
+ ParamDef->init("gridSize", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("uimax", uint64_t(50), true);
+ HintTable[1].init("uimin", uint64_t(1), true);
+ ParamDefTable[8].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#else
+
+ static HintImpl HintTable[4];
+ static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], };
+ HintTable[0].init("longDescription", "This parameter controls the parallelization of the particle system.\n\nThe spatial domain is divided into equal sized cubes, aligned in a grid.\n\nThe parameter given defines the scale of the grid. The sdk may internally choose\na different, larger value which can be queried with PxParticleBase.getGridSize(). Therefore the parameter\nhas to be considered as a hint only.\n\nLarge values will have a negative effect on performance, while too small values are problematic\ndue to spatial data structure buffer limits. Balancing this value is important to achieve a good effect\nwhile maintaining good performance.\n", true);
+ HintTable[1].init("shortDescription", "Grid size", true);
+ HintTable[2].init("uimax", uint64_t(50), true);
+ HintTable[3].init("uimin", uint64_t(1), true);
+ ParamDefTable[8].setHints((const NvParameterized::Hint**)HintPtrTable, 4);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=9, longName="damping"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[9];
+ ParamDef->init("damping", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("uimax", uint64_t(100), true);
+ HintTable[1].init("uimin", uint64_t(0), true);
+ ParamDefTable[9].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#else
+
+ static HintImpl HintTable[4];
+ static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], };
+ HintTable[0].init("longDescription", "It generally reduces the velocity of the particles. Setting the damping to 0 will leave the\nparticles unaffected.\n", true);
+ HintTable[1].init("shortDescription", "Velocity damping constant", true);
+ HintTable[2].init("uimax", uint64_t(100), true);
+ HintTable[3].init("uimin", uint64_t(0), true);
+ ParamDefTable[9].setHints((const NvParameterized::Hint**)HintPtrTable, 4);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=10, longName="externalAcceleration"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[10];
+ ParamDef->init("externalAcceleration", TYPE_VEC3, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("longDescription", "Acceleration (m/s^2) applied to all particles at all time steps.\n\nUseful to simulate smoke or fire.\nThis acceleration is additive to the scene gravity. The scene gravity can be turned off\nfor the particle system, using the flag PxActorFlag::eDISABLE_GRAVITY.\n", true);
+ HintTable[1].init("shortDescription", "External acceleration", true);
+ ParamDefTable[10].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=11, longName="projectionPlaneNormal"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[11];
+ ParamDef->init("projectionPlaneNormal", TYPE_VEC3, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("longDescription", "This parameter is only used if\nPxParticleBaseFlag::ePROJECT_TO_PLANE is set.\n\nTogether with the parameter #projectionPlaneDistance a plane is formed. For each point p on the\nplane the following equation has to hold:\n (projectionPlaneNormal.x * p.x) + (projectionPlaneNormal.y * p.y) + (projectionPlaneNormal.z * p.z) + projectionPlaneDistance = 0\n", true);
+ HintTable[1].init("shortDescription", "The normal of the plane the particles are projected to", true);
+ ParamDefTable[11].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=12, longName="projectionPlaneDistance"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[12];
+ ParamDef->init("projectionPlaneDistance", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("longDescription", "This parameter is only used if\nPxParticleBaseFlag::ePROJECT_TO_PLANE is set.\n\nTogether with the parameter #projectionPlaneNormal a plane is formed. For each point p on the\nplane the following equation has to hold:\n (projectionPlaneNormal.x * p.x) + (projectionPlaneNormal.y * p.y) + (projectionPlaneNormal.z * p.z) + projectionPlaneDistance = 0\n", true);
+ HintTable[1].init("shortDescription", "Constant term of the plane the particles are projected to", true);
+ ParamDefTable[12].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=13, longName="particleMass"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[13];
+ ParamDef->init("particleMass", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("uimax", uint64_t(1), true);
+ HintTable[1].init("uimin", double(0.001), true);
+ ParamDefTable[13].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#else
+
+ static HintImpl HintTable[4];
+ static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], };
+ HintTable[0].init("longDescription", "The mass is used to translate force or impulses to velocities for collisions\n(in case PxParticleBaseFlag::eCOLLISION_TWOWAY is set) or for particle updates.\n", true);
+ HintTable[1].init("shortDescription", "Mass of a particle", true);
+ HintTable[2].init("uimax", uint64_t(1), true);
+ HintTable[3].init("uimin", double(0.001), true);
+ ParamDefTable[13].setHints((const NvParameterized::Hint**)HintPtrTable, 4);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=14, longName="restitution"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[14];
+ ParamDef->init("restitution", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("max", uint64_t(1), true);
+ HintTable[1].init("min", uint64_t(0), true);
+ ParamDefTable[14].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#else
+
+ static HintImpl HintTable[4];
+ static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], };
+ HintTable[0].init("longDescription", "A value of 0 causes the colliding particle to get a zero velocity component in the\ndirection of the surface normal of the shape at the collision location; i.e.\nit will not bounce.\n\nA value of 1 causes a particle's velocity component in the direction of the surface normal to invert;\ni.e. the particle bounces off the surface with the same velocity magnitude as it had before collision.\n(Caution: values near 1 may have a negative impact on stability)\n", true);
+ HintTable[1].init("max", uint64_t(1), true);
+ HintTable[2].init("min", uint64_t(0), true);
+ HintTable[3].init("shortDescription", "Restitution coefficient", true);
+ ParamDefTable[14].setHints((const NvParameterized::Hint**)HintPtrTable, 4);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=15, longName="dynamicFriction"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[15];
+ ParamDef->init("dynamicFriction", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("max", uint64_t(1), true);
+ HintTable[1].init("min", uint64_t(0), true);
+ ParamDefTable[15].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#else
+
+ static HintImpl HintTable[4];
+ static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], };
+ HintTable[0].init("longDescription", "A value of 1 will cause the particle to lose its velocity tangential to\nthe surface normal of the shape at the collision location; i.e. it will not slide\nalong the surface.\n\nA value of 0 will preserve the particle's velocity in the tangential surface\ndirection; i.e. it will slide without resistance on the surface.\n", true);
+ HintTable[1].init("max", uint64_t(1), true);
+ HintTable[2].init("min", uint64_t(0), true);
+ HintTable[3].init("shortDescription", "Dynamic friction", true);
+ ParamDefTable[15].setHints((const NvParameterized::Hint**)HintPtrTable, 4);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=16, longName="staticFriction"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[16];
+ ParamDef->init("staticFriction", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("uimax", uint64_t(100), true);
+ HintTable[1].init("uimin", uint64_t(0), true);
+ ParamDefTable[16].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#else
+
+ static HintImpl HintTable[4];
+ static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], };
+ HintTable[0].init("longDescription", "The value defines a limit at which a particle starts to slide along a surface depending on\nrelative tangential and normal velocity components of the particle.\n\nA value of 0 will turn off static friction.\n", true);
+ HintTable[1].init("shortDescription", "Static friction", true);
+ HintTable[2].init("uimax", uint64_t(100), true);
+ HintTable[3].init("uimin", uint64_t(0), true);
+ ParamDefTable[16].setHints((const NvParameterized::Hint**)HintPtrTable, 4);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=17, longName="simulationFilterData"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[17];
+ ParamDef->init("simulationFilterData", TYPE_STRING, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("HIDDEN", uint64_t(1), true);
+ ParamDefTable[17].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#else
+
+ static HintImpl HintTable[3];
+ static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], };
+ HintTable[0].init("HIDDEN", uint64_t(1), true);
+ HintTable[1].init("longDescription", "The namespace is NSCollisionGroup128, the type returned should be physx::PxFilterData.", true);
+ HintTable[2].init("shortDescription", "The name for the collision filtering data for PhysX object interaction.", true);
+ ParamDefTable[17].setHints((const NvParameterized::Hint**)HintPtrTable, 3);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=18, longName="fieldSamplerFilterData"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[18];
+ ParamDef->init("fieldSamplerFilterData", TYPE_STRING, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("longDescription", "The namespace is NSCollisionGroup64, the type returned should be GroupsMask64.", true);
+ HintTable[1].init("shortDescription", "The name for collision filtering data for APEX FieldSampler interaction.", true);
+ ParamDefTable[18].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=19, longName="CollisionTwoway"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[19];
+ ParamDef->init("CollisionTwoway", TYPE_BOOL, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("longDescription", "In either case, particles are influenced by colliding rigid bodies.\nIf eCOLLISION_TWOWAY is not set, rigid bodies are not influenced by \ncolliding particles. Use PxParticleBaseDesc.particleMass to\ncontrol the strength of the feedback force on rigid bodies.\n \nSwitching this flag while the particle system is part of a scene will fail.\n", true);
+ HintTable[1].init("shortDescription", "Enable/disable two way collision of particles with the rigid body scene", true);
+ ParamDefTable[19].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=20, longName="CollisionWithDynamicActors"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[20];
+ ParamDef->init("CollisionWithDynamicActors", TYPE_BOOL, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("longDescription", "The flag can be turned off as a hint to the sdk to save memory space and \nexecution time. In principle any collisions can be turned off using filters\nbut without or reduced memory and performance benefits.\n\nSwitching this flag while the particle system is part of a scene might have a negative impact on performance.\n", true);
+ HintTable[1].init("shortDescription", "Enable/disable collision of particles with dynamic actors", true);
+ ParamDefTable[20].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=21, longName="Enable"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[21];
+ ParamDef->init("Enable", TYPE_BOOL, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "Enables collision with static shapes", true);
+ ParamDefTable[21].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=22, longName="ProjectToPlane"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[22];
+ ParamDef->init("ProjectToPlane", TYPE_BOOL, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("longDescription", "This can be used to build 2D applications, for instance. The projection\nplane is defined by the parameter PxParticleBaseDesc.projectionPlaneNormal and PxParticleBaseDesc.projectionPlaneDistance.\n", true);
+ HintTable[1].init("shortDescription", "Whether the particles of this particle system should be projected to a plane", true);
+ ParamDefTable[22].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=23, longName="PerParticleRestOffset"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[23];
+ ParamDef->init("PerParticleRestOffset", TYPE_BOOL, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("longDescription", "Per particle rest offsets can be used to support particles having different sizes with \nrespect to collision.\n \nThis configuration cannot be changed after the particle system was created.\n", true);
+ HintTable[1].init("shortDescription", "Enable/disable per particle rest offsets", true);
+ ParamDefTable[23].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=24, longName="PerParticleCollisionCacheHint"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[24];
+ ParamDef->init("PerParticleCollisionCacheHint", TYPE_BOOL, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("longDescription", "Per particle collision caches improve collision detection performance at the cost of increased memory usage.\n\nSwitching this flag while the particle system is part of a scene might have a negative impact on performance.\n", true);
+ HintTable[1].init("shortDescription", "Ename/disable per particle collision caches", true);
+ ParamDefTable[24].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=25, longName="DensityBuffer"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[25];
+ ParamDef->init("DensityBuffer", TYPE_BOOL, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "Enables reading particle densities from the SDK. (PxParticleFluid only)", true);
+ ParamDefTable[25].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=26, longName="enableTemperatureBuffer"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[26];
+ ParamDef->init("enableTemperatureBuffer", TYPE_BOOL, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("defaultValue", uint64_t(0), true);
+ ParamDefTable[26].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("defaultValue", uint64_t(0), true);
+ HintTable[1].init("shortDescription", "Enables temperature buffer.", true);
+ ParamDefTable[26].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=27, longName="enableCouplingOverride"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[27];
+ ParamDef->init("enableCouplingOverride", TYPE_BOOL, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("defaultValue", uint64_t(0), true);
+ ParamDefTable[27].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("defaultValue", uint64_t(0), true);
+ HintTable[1].init("shortDescription", "If true, IOS coupling settings are used. If false, dynamic grid coupling settings are used.", true);
+ ParamDefTable[27].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=28, longName="particleToGridCoupling"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[28];
+ ParamDef->init("particleToGridCoupling", TYPE_STRUCT, "ParticleToGridCouplingParams", true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "Settings for particle to grid coupling", true);
+ ParamDefTable[28].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=29, longName="particleToGridCoupling.accelTimeConstant"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[29];
+ ParamDef->init("accelTimeConstant", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "Controls rate at which the grid accepts influence from particles. A value of 0 means instant coupling.", true);
+ ParamDefTable[29].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=30, longName="particleToGridCoupling.decelTimeConstant"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[30];
+ ParamDef->init("decelTimeConstant", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "Controls rate at which the grid accepts influence from particles. A value of 0 means instant coupling.", true);
+ ParamDefTable[30].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=31, longName="particleToGridCoupling.thresholdMultiplier"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[31];
+ ParamDef->init("thresholdMultiplier", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "A value greater than 1 creates a deadzone, where no particle to grid coupling occurs.", true);
+ ParamDefTable[31].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=32, longName="gridToParticleCoupling"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[32];
+ ParamDef->init("gridToParticleCoupling", TYPE_STRUCT, "GridToParticleCouplingParams", true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "Settings for grid to particle coupling", true);
+ ParamDefTable[32].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=33, longName="gridToParticleCoupling.accelTimeConstant"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[33];
+ ParamDef->init("accelTimeConstant", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "Controls rate at which particles accept influence from the grid. A value of 0 means instant coupling.", true);
+ ParamDefTable[33].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=34, longName="gridToParticleCoupling.decelTimeConstant"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[34];
+ ParamDef->init("decelTimeConstant", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "Controls rate at which particles accept influence from the grid. A value of 0 means instant coupling.", true);
+ ParamDefTable[34].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=35, longName="gridToParticleCoupling.thresholdMultiplier"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[35];
+ ParamDef->init("thresholdMultiplier", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "A value greater than 1 creates a deadzone, where no grid to particle coupling occurs.", true);
+ ParamDefTable[35].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // SetChildren for: nodeIndex=0, longName=""
+ {
+ static Definition* Children[29];
+ Children[0] = PDEF_PTR(1);
+ Children[1] = PDEF_PTR(2);
+ Children[2] = PDEF_PTR(3);
+ Children[3] = PDEF_PTR(4);
+ Children[4] = PDEF_PTR(5);
+ Children[5] = PDEF_PTR(6);
+ Children[6] = PDEF_PTR(7);
+ Children[7] = PDEF_PTR(8);
+ Children[8] = PDEF_PTR(9);
+ Children[9] = PDEF_PTR(10);
+ Children[10] = PDEF_PTR(11);
+ Children[11] = PDEF_PTR(12);
+ Children[12] = PDEF_PTR(13);
+ Children[13] = PDEF_PTR(14);
+ Children[14] = PDEF_PTR(15);
+ Children[15] = PDEF_PTR(16);
+ Children[16] = PDEF_PTR(17);
+ Children[17] = PDEF_PTR(18);
+ Children[18] = PDEF_PTR(19);
+ Children[19] = PDEF_PTR(20);
+ Children[20] = PDEF_PTR(21);
+ Children[21] = PDEF_PTR(22);
+ Children[22] = PDEF_PTR(23);
+ Children[23] = PDEF_PTR(24);
+ Children[24] = PDEF_PTR(25);
+ Children[25] = PDEF_PTR(26);
+ Children[26] = PDEF_PTR(27);
+ Children[27] = PDEF_PTR(28);
+ Children[28] = PDEF_PTR(32);
+
+ ParamDefTable[0].setChildren(Children, 29);
+ }
+
+ // SetChildren for: nodeIndex=28, longName="particleToGridCoupling"
+ {
+ static Definition* Children[3];
+ Children[0] = PDEF_PTR(29);
+ Children[1] = PDEF_PTR(30);
+ Children[2] = PDEF_PTR(31);
+
+ ParamDefTable[28].setChildren(Children, 3);
+ }
+
+ // SetChildren for: nodeIndex=32, longName="gridToParticleCoupling"
+ {
+ static Definition* Children[3];
+ Children[0] = PDEF_PTR(33);
+ Children[1] = PDEF_PTR(34);
+ Children[2] = PDEF_PTR(35);
+
+ ParamDefTable[32].setChildren(Children, 3);
+ }
+
+ mBuiltFlag = true;
+
+}
+void ParticleIosAssetParam::initStrings(void)
+{
+ simulationFilterData.isAllocated = true;
+ simulationFilterData.buf = NULL;
+ fieldSamplerFilterData.isAllocated = true;
+ fieldSamplerFilterData.buf = NULL;
+}
+
+void ParticleIosAssetParam::initDynamicArrays(void)
+{
+}
+
+void ParticleIosAssetParam::initDefaults(void)
+{
+
+ freeStrings();
+ freeReferences();
+ freeDynamicArrays();
+ maxParticleCount = uint32_t(32767);
+ particleRadius = float(1.0f);
+ maxInjectedParticleCount = float(0.1);
+ maxMotionDistance = float(0.2);
+ contactOffset = float(0.008);
+ restOffset = float(0.004);
+ gridSize = float(1.5);
+ damping = float(0);
+ externalAcceleration = physx::PxVec3(init(0, 0, 0));
+ projectionPlaneNormal = physx::PxVec3(init(0, 0, 1));
+ projectionPlaneDistance = float(0);
+ particleMass = float(0.001);
+ restitution = float(0.5);
+ dynamicFriction = float(0.05);
+ staticFriction = float(0);
+ CollisionTwoway = bool(0);
+ CollisionWithDynamicActors = bool(1);
+ Enable = bool(1);
+ ProjectToPlane = bool(0);
+ PerParticleRestOffset = bool(0);
+ PerParticleCollisionCacheHint = bool(1);
+ DensityBuffer = bool(0);
+ enableTemperatureBuffer = bool(0);
+ enableCouplingOverride = bool(0);
+ particleToGridCoupling.accelTimeConstant = float(0.01);
+ particleToGridCoupling.decelTimeConstant = float(10);
+ particleToGridCoupling.thresholdMultiplier = float(2);
+ gridToParticleCoupling.accelTimeConstant = float(0.01);
+ gridToParticleCoupling.decelTimeConstant = float(0.01);
+ gridToParticleCoupling.thresholdMultiplier = float(1);
+
+ initDynamicArrays();
+ initStrings();
+ initReferences();
+}
+
+void ParticleIosAssetParam::initReferences(void)
+{
+ particleType = NULL;
+
+}
+
+void ParticleIosAssetParam::freeDynamicArrays(void)
+{
+}
+
+void ParticleIosAssetParam::freeStrings(void)
+{
+
+ if (simulationFilterData.isAllocated && simulationFilterData.buf)
+ {
+ mParameterizedTraits->strfree((char*)simulationFilterData.buf);
+ }
+
+ if (fieldSamplerFilterData.isAllocated && fieldSamplerFilterData.buf)
+ {
+ mParameterizedTraits->strfree((char*)fieldSamplerFilterData.buf);
+ }
+}
+
+void ParticleIosAssetParam::freeReferences(void)
+{
+ if (particleType)
+ {
+ particleType->destroy();
+ }
+
+}
+
+} // namespace pxparticleios
+} // namespace nvidia
diff --git a/APEX_1.4/module/pxparticleios/src/autogen/ParticleIosDebugRenderParams.cpp b/APEX_1.4/module/pxparticleios/src/autogen/ParticleIosDebugRenderParams.cpp
new file mode 100644
index 00000000..ee0c9834
--- /dev/null
+++ b/APEX_1.4/module/pxparticleios/src/autogen/ParticleIosDebugRenderParams.cpp
@@ -0,0 +1,333 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#include "ParticleIosDebugRenderParams.h"
+#include <string.h>
+#include <stdlib.h>
+
+using namespace NvParameterized;
+
+namespace nvidia
+{
+namespace pxparticleios
+{
+
+using namespace ParticleIosDebugRenderParamsNS;
+
+const char* const ParticleIosDebugRenderParamsFactory::vptr =
+ NvParameterized::getVptr<ParticleIosDebugRenderParams, ParticleIosDebugRenderParams::ClassAlignment>();
+
+const uint32_t NumParamDefs = 3;
+static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs];
+
+
+static const size_t ParamLookupChildrenTable[] =
+{
+ 1, 2,
+};
+
+#define TENUM(type) nvidia::##type
+#define CHILDREN(index) &ParamLookupChildrenTable[index]
+static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] =
+{
+ { TYPE_STRUCT, false, 0, CHILDREN(0), 2 },
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->VISUALIZE_PARTICLE_IOS_ACTOR), NULL, 0 }, // VISUALIZE_PARTICLE_IOS_ACTOR
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->VISUALIZE_PARTICLE_IOS_GRID_DENSITY), NULL, 0 }, // VISUALIZE_PARTICLE_IOS_GRID_DENSITY
+};
+
+
+bool ParticleIosDebugRenderParams::mBuiltFlag = false;
+NvParameterized::MutexType ParticleIosDebugRenderParams::mBuiltFlagMutex;
+
+ParticleIosDebugRenderParams::ParticleIosDebugRenderParams(NvParameterized::Traits* traits, void* buf, int32_t* refCount) :
+ NvParameters(traits, buf, refCount)
+{
+ //mParameterizedTraits->registerFactory(className(), &ParticleIosDebugRenderParamsFactoryInst);
+
+ if (!buf) //Do not init data if it is inplace-deserialized
+ {
+ initDynamicArrays();
+ initStrings();
+ initReferences();
+ initDefaults();
+ }
+}
+
+ParticleIosDebugRenderParams::~ParticleIosDebugRenderParams()
+{
+ freeStrings();
+ freeReferences();
+ freeDynamicArrays();
+}
+
+void ParticleIosDebugRenderParams::destroy()
+{
+ // We cache these fields here to avoid overwrite in destructor
+ bool doDeallocateSelf = mDoDeallocateSelf;
+ NvParameterized::Traits* traits = mParameterizedTraits;
+ int32_t* refCount = mRefCount;
+ void* buf = mBuffer;
+
+ this->~ParticleIosDebugRenderParams();
+
+ NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf);
+}
+
+const NvParameterized::DefinitionImpl* ParticleIosDebugRenderParams::getParameterDefinitionTree(void)
+{
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+ if (!mBuiltFlag)
+ {
+ buildTree();
+ }
+ }
+
+ return(&ParamDefTable[0]);
+}
+
+const NvParameterized::DefinitionImpl* ParticleIosDebugRenderParams::getParameterDefinitionTree(void) const
+{
+ ParticleIosDebugRenderParams* tmpParam = const_cast<ParticleIosDebugRenderParams*>(this);
+
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+ if (!mBuiltFlag)
+ {
+ tmpParam->buildTree();
+ }
+ }
+
+ return(&ParamDefTable[0]);
+}
+
+NvParameterized::ErrorType ParticleIosDebugRenderParams::getParameterHandle(const char* long_name, Handle& handle) const
+{
+ ErrorType Ret = NvParameters::getParameterHandle(long_name, handle);
+ if (Ret != ERROR_NONE)
+ {
+ return(Ret);
+ }
+
+ size_t offset;
+ void* ptr;
+
+ getVarPtr(handle, ptr, offset);
+
+ if (ptr == NULL)
+ {
+ return(ERROR_INDEX_OUT_OF_RANGE);
+ }
+
+ return(ERROR_NONE);
+}
+
+NvParameterized::ErrorType ParticleIosDebugRenderParams::getParameterHandle(const char* long_name, Handle& handle)
+{
+ ErrorType Ret = NvParameters::getParameterHandle(long_name, handle);
+ if (Ret != ERROR_NONE)
+ {
+ return(Ret);
+ }
+
+ size_t offset;
+ void* ptr;
+
+ getVarPtr(handle, ptr, offset);
+
+ if (ptr == NULL)
+ {
+ return(ERROR_INDEX_OUT_OF_RANGE);
+ }
+
+ return(ERROR_NONE);
+}
+
+void ParticleIosDebugRenderParams::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const
+{
+ ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<ParticleIosDebugRenderParams::ParametersStruct*>(&parameters()), handle, offset);
+}
+
+
+/* Dynamic Handle Indices */
+
+void ParticleIosDebugRenderParams::freeParameterDefinitionTable(NvParameterized::Traits* traits)
+{
+ if (!traits)
+ {
+ return;
+ }
+
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ return;
+ }
+
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+
+ if (!mBuiltFlag)
+ {
+ return;
+ }
+
+ for (uint32_t i = 0; i < NumParamDefs; ++i)
+ {
+ ParamDefTable[i].~DefinitionImpl();
+ }
+
+ traits->free(ParamDefTable);
+
+ mBuiltFlag = false;
+}
+
+#define PDEF_PTR(index) (&ParamDefTable[index])
+
+void ParticleIosDebugRenderParams::buildTree(void)
+{
+
+ uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs;
+ ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize));
+ memset(ParamDefTable, 0, allocSize);
+
+ for (uint32_t i = 0; i < NumParamDefs; ++i)
+ {
+ NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits);
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=0, longName=""
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0];
+ ParamDef->init("", TYPE_STRUCT, "STRUCT", true);
+
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=1, longName="VISUALIZE_PARTICLE_IOS_ACTOR"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1];
+ ParamDef->init("VISUALIZE_PARTICLE_IOS_ACTOR", TYPE_BOOL, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "Render IOS actor in view window", true);
+ ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=2, longName="VISUALIZE_PARTICLE_IOS_GRID_DENSITY"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2];
+ ParamDef->init("VISUALIZE_PARTICLE_IOS_GRID_DENSITY", TYPE_BOOL, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "Reder IOS Grid density in view window", true);
+ ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // SetChildren for: nodeIndex=0, longName=""
+ {
+ static Definition* Children[2];
+ Children[0] = PDEF_PTR(1);
+ Children[1] = PDEF_PTR(2);
+
+ ParamDefTable[0].setChildren(Children, 2);
+ }
+
+ mBuiltFlag = true;
+
+}
+void ParticleIosDebugRenderParams::initStrings(void)
+{
+}
+
+void ParticleIosDebugRenderParams::initDynamicArrays(void)
+{
+}
+
+void ParticleIosDebugRenderParams::initDefaults(void)
+{
+
+ freeStrings();
+ freeReferences();
+ freeDynamicArrays();
+ VISUALIZE_PARTICLE_IOS_ACTOR = bool(false);
+ VISUALIZE_PARTICLE_IOS_GRID_DENSITY = bool(false);
+
+ initDynamicArrays();
+ initStrings();
+ initReferences();
+}
+
+void ParticleIosDebugRenderParams::initReferences(void)
+{
+}
+
+void ParticleIosDebugRenderParams::freeDynamicArrays(void)
+{
+}
+
+void ParticleIosDebugRenderParams::freeStrings(void)
+{
+}
+
+void ParticleIosDebugRenderParams::freeReferences(void)
+{
+}
+
+} // namespace pxparticleios
+} // namespace nvidia
diff --git a/APEX_1.4/module/pxparticleios/src/autogen/ParticleIosModuleParameters.cpp b/APEX_1.4/module/pxparticleios/src/autogen/ParticleIosModuleParameters.cpp
new file mode 100644
index 00000000..c6e57735
--- /dev/null
+++ b/APEX_1.4/module/pxparticleios/src/autogen/ParticleIosModuleParameters.cpp
@@ -0,0 +1,318 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#include "ParticleIosModuleParameters.h"
+#include <string.h>
+#include <stdlib.h>
+
+using namespace NvParameterized;
+
+namespace nvidia
+{
+namespace pxparticleios
+{
+
+using namespace ParticleIosModuleParametersNS;
+
+const char* const ParticleIosModuleParametersFactory::vptr =
+ NvParameterized::getVptr<ParticleIosModuleParameters, ParticleIosModuleParameters::ClassAlignment>();
+
+const uint32_t NumParamDefs = 2;
+static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs];
+
+
+static const size_t ParamLookupChildrenTable[] =
+{
+ 1,
+};
+
+#define TENUM(type) nvidia::##type
+#define CHILDREN(index) &ParamLookupChildrenTable[index]
+static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] =
+{
+ { TYPE_STRUCT, false, 0, CHILDREN(0), 1 },
+ { TYPE_U32, false, (size_t)(&((ParametersStruct*)0)->unused), NULL, 0 }, // unused
+};
+
+
+bool ParticleIosModuleParameters::mBuiltFlag = false;
+NvParameterized::MutexType ParticleIosModuleParameters::mBuiltFlagMutex;
+
+ParticleIosModuleParameters::ParticleIosModuleParameters(NvParameterized::Traits* traits, void* buf, int32_t* refCount) :
+ NvParameters(traits, buf, refCount)
+{
+ //mParameterizedTraits->registerFactory(className(), &ParticleIosModuleParametersFactoryInst);
+
+ if (!buf) //Do not init data if it is inplace-deserialized
+ {
+ initDynamicArrays();
+ initStrings();
+ initReferences();
+ initDefaults();
+ }
+}
+
+ParticleIosModuleParameters::~ParticleIosModuleParameters()
+{
+ freeStrings();
+ freeReferences();
+ freeDynamicArrays();
+}
+
+void ParticleIosModuleParameters::destroy()
+{
+ // We cache these fields here to avoid overwrite in destructor
+ bool doDeallocateSelf = mDoDeallocateSelf;
+ NvParameterized::Traits* traits = mParameterizedTraits;
+ int32_t* refCount = mRefCount;
+ void* buf = mBuffer;
+
+ this->~ParticleIosModuleParameters();
+
+ NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf);
+}
+
+const NvParameterized::DefinitionImpl* ParticleIosModuleParameters::getParameterDefinitionTree(void)
+{
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+ if (!mBuiltFlag)
+ {
+ buildTree();
+ }
+ }
+
+ return(&ParamDefTable[0]);
+}
+
+const NvParameterized::DefinitionImpl* ParticleIosModuleParameters::getParameterDefinitionTree(void) const
+{
+ ParticleIosModuleParameters* tmpParam = const_cast<ParticleIosModuleParameters*>(this);
+
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+ if (!mBuiltFlag)
+ {
+ tmpParam->buildTree();
+ }
+ }
+
+ return(&ParamDefTable[0]);
+}
+
+NvParameterized::ErrorType ParticleIosModuleParameters::getParameterHandle(const char* long_name, Handle& handle) const
+{
+ ErrorType Ret = NvParameters::getParameterHandle(long_name, handle);
+ if (Ret != ERROR_NONE)
+ {
+ return(Ret);
+ }
+
+ size_t offset;
+ void* ptr;
+
+ getVarPtr(handle, ptr, offset);
+
+ if (ptr == NULL)
+ {
+ return(ERROR_INDEX_OUT_OF_RANGE);
+ }
+
+ return(ERROR_NONE);
+}
+
+NvParameterized::ErrorType ParticleIosModuleParameters::getParameterHandle(const char* long_name, Handle& handle)
+{
+ ErrorType Ret = NvParameters::getParameterHandle(long_name, handle);
+ if (Ret != ERROR_NONE)
+ {
+ return(Ret);
+ }
+
+ size_t offset;
+ void* ptr;
+
+ getVarPtr(handle, ptr, offset);
+
+ if (ptr == NULL)
+ {
+ return(ERROR_INDEX_OUT_OF_RANGE);
+ }
+
+ return(ERROR_NONE);
+}
+
+void ParticleIosModuleParameters::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const
+{
+ ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<ParticleIosModuleParameters::ParametersStruct*>(&parameters()), handle, offset);
+}
+
+
+/* Dynamic Handle Indices */
+
+void ParticleIosModuleParameters::freeParameterDefinitionTable(NvParameterized::Traits* traits)
+{
+ if (!traits)
+ {
+ return;
+ }
+
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ return;
+ }
+
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+
+ if (!mBuiltFlag)
+ {
+ return;
+ }
+
+ for (uint32_t i = 0; i < NumParamDefs; ++i)
+ {
+ ParamDefTable[i].~DefinitionImpl();
+ }
+
+ traits->free(ParamDefTable);
+
+ mBuiltFlag = false;
+}
+
+#define PDEF_PTR(index) (&ParamDefTable[index])
+
+void ParticleIosModuleParameters::buildTree(void)
+{
+
+ uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs;
+ ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize));
+ memset(ParamDefTable, 0, allocSize);
+
+ for (uint32_t i = 0; i < NumParamDefs; ++i)
+ {
+ NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits);
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=0, longName=""
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0];
+ ParamDef->init("", TYPE_STRUCT, "STRUCT", true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "This class is used for initializing the ModuleParticleIos.", true);
+ ParamDefTable[0].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=1, longName="unused"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1];
+ ParamDef->init("unused", TYPE_U32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "No parameters necessary", true);
+ ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // SetChildren for: nodeIndex=0, longName=""
+ {
+ static Definition* Children[1];
+ Children[0] = PDEF_PTR(1);
+
+ ParamDefTable[0].setChildren(Children, 1);
+ }
+
+ mBuiltFlag = true;
+
+}
+void ParticleIosModuleParameters::initStrings(void)
+{
+}
+
+void ParticleIosModuleParameters::initDynamicArrays(void)
+{
+}
+
+void ParticleIosModuleParameters::initDefaults(void)
+{
+
+ freeStrings();
+ freeReferences();
+ freeDynamicArrays();
+ unused = uint32_t(0);
+
+ initDynamicArrays();
+ initStrings();
+ initReferences();
+}
+
+void ParticleIosModuleParameters::initReferences(void)
+{
+}
+
+void ParticleIosModuleParameters::freeDynamicArrays(void)
+{
+}
+
+void ParticleIosModuleParameters::freeStrings(void)
+{
+}
+
+void ParticleIosModuleParameters::freeReferences(void)
+{
+}
+
+} // namespace pxparticleios
+} // namespace nvidia
diff --git a/APEX_1.4/module/pxparticleios/src/autogen/SimpleParticleSystemParams.cpp b/APEX_1.4/module/pxparticleios/src/autogen/SimpleParticleSystemParams.cpp
new file mode 100644
index 00000000..03efd112
--- /dev/null
+++ b/APEX_1.4/module/pxparticleios/src/autogen/SimpleParticleSystemParams.cpp
@@ -0,0 +1,435 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2015 NVIDIA Corporation. All rights reserved.
+
+// This file was generated by NvParameterized/scripts/GenParameterized.pl
+
+
+#include "SimpleParticleSystemParams.h"
+#include <string.h>
+#include <stdlib.h>
+
+using namespace NvParameterized;
+
+namespace nvidia
+{
+namespace pxparticleios
+{
+
+using namespace SimpleParticleSystemParamsNS;
+
+const char* const SimpleParticleSystemParamsFactory::vptr =
+ NvParameterized::getVptr<SimpleParticleSystemParams, SimpleParticleSystemParams::ClassAlignment>();
+
+const uint32_t NumParamDefs = 6;
+static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs];
+
+
+static const size_t ParamLookupChildrenTable[] =
+{
+ 1, 2, 3, 4, 5,
+};
+
+#define TENUM(type) nvidia::##type
+#define CHILDREN(index) &ParamLookupChildrenTable[index]
+static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] =
+{
+ { TYPE_STRUCT, false, 0, CHILDREN(0), 1 },
+ { TYPE_STRUCT, false, (size_t)(&((ParametersStruct*)0)->GridDensity), CHILDREN(1), 4 }, // GridDensity
+ { TYPE_BOOL, false, (size_t)(&((GridDensityParams_Type*)0)->Enabled), NULL, 0 }, // GridDensity.Enabled
+ { TYPE_ENUM, false, (size_t)(&((GridDensityParams_Type*)0)->Resolution), NULL, 0 }, // GridDensity.Resolution
+ { TYPE_F32, false, (size_t)(&((GridDensityParams_Type*)0)->GridSize), NULL, 0 }, // GridDensity.GridSize
+ { TYPE_U32, false, (size_t)(&((GridDensityParams_Type*)0)->MaxCellCount), NULL, 0 }, // GridDensity.MaxCellCount
+};
+
+
+bool SimpleParticleSystemParams::mBuiltFlag = false;
+NvParameterized::MutexType SimpleParticleSystemParams::mBuiltFlagMutex;
+
+SimpleParticleSystemParams::SimpleParticleSystemParams(NvParameterized::Traits* traits, void* buf, int32_t* refCount) :
+ NvParameters(traits, buf, refCount)
+{
+ //mParameterizedTraits->registerFactory(className(), &SimpleParticleSystemParamsFactoryInst);
+
+ if (!buf) //Do not init data if it is inplace-deserialized
+ {
+ initDynamicArrays();
+ initStrings();
+ initReferences();
+ initDefaults();
+ }
+}
+
+SimpleParticleSystemParams::~SimpleParticleSystemParams()
+{
+ freeStrings();
+ freeReferences();
+ freeDynamicArrays();
+}
+
+void SimpleParticleSystemParams::destroy()
+{
+ // We cache these fields here to avoid overwrite in destructor
+ bool doDeallocateSelf = mDoDeallocateSelf;
+ NvParameterized::Traits* traits = mParameterizedTraits;
+ int32_t* refCount = mRefCount;
+ void* buf = mBuffer;
+
+ this->~SimpleParticleSystemParams();
+
+ NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf);
+}
+
+const NvParameterized::DefinitionImpl* SimpleParticleSystemParams::getParameterDefinitionTree(void)
+{
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+ if (!mBuiltFlag)
+ {
+ buildTree();
+ }
+ }
+
+ return(&ParamDefTable[0]);
+}
+
+const NvParameterized::DefinitionImpl* SimpleParticleSystemParams::getParameterDefinitionTree(void) const
+{
+ SimpleParticleSystemParams* tmpParam = const_cast<SimpleParticleSystemParams*>(this);
+
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+ if (!mBuiltFlag)
+ {
+ tmpParam->buildTree();
+ }
+ }
+
+ return(&ParamDefTable[0]);
+}
+
+NvParameterized::ErrorType SimpleParticleSystemParams::getParameterHandle(const char* long_name, Handle& handle) const
+{
+ ErrorType Ret = NvParameters::getParameterHandle(long_name, handle);
+ if (Ret != ERROR_NONE)
+ {
+ return(Ret);
+ }
+
+ size_t offset;
+ void* ptr;
+
+ getVarPtr(handle, ptr, offset);
+
+ if (ptr == NULL)
+ {
+ return(ERROR_INDEX_OUT_OF_RANGE);
+ }
+
+ return(ERROR_NONE);
+}
+
+NvParameterized::ErrorType SimpleParticleSystemParams::getParameterHandle(const char* long_name, Handle& handle)
+{
+ ErrorType Ret = NvParameters::getParameterHandle(long_name, handle);
+ if (Ret != ERROR_NONE)
+ {
+ return(Ret);
+ }
+
+ size_t offset;
+ void* ptr;
+
+ getVarPtr(handle, ptr, offset);
+
+ if (ptr == NULL)
+ {
+ return(ERROR_INDEX_OUT_OF_RANGE);
+ }
+
+ return(ERROR_NONE);
+}
+
+void SimpleParticleSystemParams::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const
+{
+ ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<SimpleParticleSystemParams::ParametersStruct*>(&parameters()), handle, offset);
+}
+
+
+/* Dynamic Handle Indices */
+
+void SimpleParticleSystemParams::freeParameterDefinitionTable(NvParameterized::Traits* traits)
+{
+ if (!traits)
+ {
+ return;
+ }
+
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ return;
+ }
+
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+
+ if (!mBuiltFlag)
+ {
+ return;
+ }
+
+ for (uint32_t i = 0; i < NumParamDefs; ++i)
+ {
+ ParamDefTable[i].~DefinitionImpl();
+ }
+
+ traits->free(ParamDefTable);
+
+ mBuiltFlag = false;
+}
+
+#define PDEF_PTR(index) (&ParamDefTable[index])
+
+void SimpleParticleSystemParams::buildTree(void)
+{
+
+ uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs;
+ ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize));
+ memset(ParamDefTable, 0, allocSize);
+
+ for (uint32_t i = 0; i < NumParamDefs; ++i)
+ {
+ NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits);
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=0, longName=""
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0];
+ ParamDef->init("", TYPE_STRUCT, "STRUCT", true);
+
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=1, longName="GridDensity"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1];
+ ParamDef->init("GridDensity", TYPE_STRUCT, "GridDensityParams", true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("longDescription", "Settings for Density Grid\n", true);
+ HintTable[1].init("shortDescription", "Settings for Density Grid", true);
+ ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=2, longName="GridDensity.Enabled"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2];
+ ParamDef->init("Enabled", TYPE_BOOL, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("longDescription", "If this option is true; a density will be computed based on the grouping of particles in a 3d grid\n", true);
+ HintTable[1].init("shortDescription", "Compute a Density Using a Grid", true);
+ ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=3, longName="GridDensity.Resolution"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3];
+ ParamDef->init("Resolution", TYPE_ENUM, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("longDescription", "This enumeration defines the 3d resolution of the grid.\n", true);
+ HintTable[1].init("shortDescription", "Number of cells in a 3D grid, used to calculate particles positions. Higher values divide the grid into more cells.", true);
+ ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+ static const char* const EnumVals[] = { "GDG_8", "GDG_16", "GDG_32", "GDG_64", "GDG_128", "GDG_256" };
+ ParamDefTable[3].setEnumVals((const char**)EnumVals, 6);
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=4, longName="GridDensity.GridSize"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[4];
+ ParamDef->init("GridSize", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("DISPLAY_NAME", "Grid Depth", true);
+ HintTable[1].init("min", uint64_t(0), true);
+ ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#else
+
+ static HintImpl HintTable[4];
+ static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], };
+ HintTable[0].init("DISPLAY_NAME", "Grid Depth", true);
+ HintTable[1].init("longDescription", "The default value is 10 units\nMust be positive.\n", true);
+ HintTable[2].init("min", uint64_t(0), true);
+ HintTable[3].init("shortDescription", "Depth of grid", true);
+ ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 4);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=5, longName="GridDensity.MaxCellCount"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[5];
+ ParamDef->init("MaxCellCount", TYPE_U32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("min", uint64_t(0), true);
+ ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#else
+
+ static HintImpl HintTable[3];
+ static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], };
+ HintTable[0].init("longDescription", "This is the integer count representing how many particles reside in a single grid cell before the density is considered 1.\nIt is valid for the density to be greater than one. For example, if there were 32 particles in a grid cell with a max-cell count of\n16, then the density would be equal to 2.\n", true);
+ HintTable[1].init("min", uint64_t(0), true);
+ HintTable[2].init("shortDescription", "This is the number of particles within a grid cell for a density of 1", true);
+ ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 3);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // SetChildren for: nodeIndex=0, longName=""
+ {
+ static Definition* Children[1];
+ Children[0] = PDEF_PTR(1);
+
+ ParamDefTable[0].setChildren(Children, 1);
+ }
+
+ // SetChildren for: nodeIndex=1, longName="GridDensity"
+ {
+ static Definition* Children[4];
+ Children[0] = PDEF_PTR(2);
+ Children[1] = PDEF_PTR(3);
+ Children[2] = PDEF_PTR(4);
+ Children[3] = PDEF_PTR(5);
+
+ ParamDefTable[1].setChildren(Children, 4);
+ }
+
+ mBuiltFlag = true;
+
+}
+void SimpleParticleSystemParams::initStrings(void)
+{
+}
+
+void SimpleParticleSystemParams::initDynamicArrays(void)
+{
+}
+
+void SimpleParticleSystemParams::initDefaults(void)
+{
+
+ freeStrings();
+ freeReferences();
+ freeDynamicArrays();
+ GridDensity.Enabled = bool(0);
+ GridDensity.Resolution = (const char*)"GDG_16";
+ GridDensity.GridSize = float(10);
+ GridDensity.MaxCellCount = uint32_t(16);
+
+ initDynamicArrays();
+ initStrings();
+ initReferences();
+}
+
+void SimpleParticleSystemParams::initReferences(void)
+{
+}
+
+void SimpleParticleSystemParams::freeDynamicArrays(void)
+{
+}
+
+void SimpleParticleSystemParams::freeStrings(void)
+{
+}
+
+void SimpleParticleSystemParams::freeReferences(void)
+{
+}
+
+} // namespace pxparticleios
+} // namespace nvidia