diff options
| author | git perforce import user <a@b> | 2016-10-25 12:29:14 -0600 |
|---|---|---|
| committer | Sheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees> | 2016-10-25 18:56:37 -0500 |
| commit | 3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch) | |
| tree | fa6485c169e50d7415a651bf838f5bcd0fd3bfbd /APEX_1.4/module/pxparticleios | |
| download | physx-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')
34 files changed, 9353 insertions, 0 deletions
diff --git a/APEX_1.4/module/pxparticleios/cuda/include/common.h b/APEX_1.4/module/pxparticleios/cuda/include/common.h new file mode 100644 index 00000000..6f084e4a --- /dev/null +++ b/APEX_1.4/module/pxparticleios/cuda/include/common.h @@ -0,0 +1,63 @@ +/* + * 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. + */ + + +#ifndef __COMMON_H__ +#define __COMMON_H__ + +#define APEX_CUDA_MODULE_PREFIX ParticleIOS_ + +#include "ApexCuda.h" +#include "InplaceTypes.h" +#include "IofxManagerIntl.h" +#include <float.h> + +#if PX_WINDOWS_FAMILY +#pragma warning(push) +#pragma warning(disable:4201) +#pragma warning(disable:4408) +#endif + +#include <vector_types.h> + +#if PX_WINDOWS_FAMILY +#pragma warning(pop) +#endif + +const unsigned int HISTOGRAM_BIN_COUNT = 256; +const unsigned int HISTOGRAM_SIMULATE_BIN_COUNT = 512; + + +#define COMPACT_KERNEL_CONFIG (0, WARP_SIZE * 3) +#define HISTOGRAM_KERNEL_CONFIG (0, HISTOGRAM_BIN_COUNT) +#define REDUCE_KERNEL_CONFIG (0, WARP_SIZE * 4) +#define SCAN_KERNEL_CONFIG (0, WARP_SIZE * 4) +#define SIMULATE_KERNEL_CONFIG (0, HISTOGRAM_SIMULATE_BIN_COUNT) + + +const unsigned int HOLE_SCAN_FLAG_BIT = 31; +const unsigned int HOLE_SCAN_FLAG = (1U << HOLE_SCAN_FLAG_BIT); +const unsigned int HOLE_SCAN_MASK = (HOLE_SCAN_FLAG - 1); + +// mTmpOutput +const unsigned int STATUS_LAST_ACTIVE_COUNT = 0; +const unsigned int STATUS_LAST_BENEFIT_SUM = 1; +const unsigned int STATUS_LAST_BENEFIT_MIN = 2; +const unsigned int STATUS_LAST_BENEFIT_MAX = 3; + +namespace nvidia +{ +namespace pxparticleios +{ + +} +} // namespace nvidia + +#endif diff --git a/APEX_1.4/module/pxparticleios/cuda/include/compact.h b/APEX_1.4/module/pxparticleios/cuda/include/compact.h new file mode 100644 index 00000000..f0313c09 --- /dev/null +++ b/APEX_1.4/module/pxparticleios/cuda/include/compact.h @@ -0,0 +1,17 @@ +/* + * 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. + */ + + +APEX_CUDA_TEXTURE_1D(texRefCompactScanSum, unsigned int) + +APEX_CUDA_BOUND_KERNEL(COMPACT_KERNEL_CONFIG, compactKernel, + ((unsigned int, targetCount))((unsigned int, totalCount))((unsigned int, injectorCount)) + ((APEX_MEM_BLOCK(unsigned int), g_outIndices))((APEX_MEM_BLOCK(unsigned int), g_outCount))((APEX_MEM_BLOCK(unsigned int), g_injCounters)) + ) diff --git a/APEX_1.4/module/pxparticleios/cuda/include/histogram.h b/APEX_1.4/module/pxparticleios/cuda/include/histogram.h new file mode 100644 index 00000000..ca45aa5e --- /dev/null +++ b/APEX_1.4/module/pxparticleios/cuda/include/histogram.h @@ -0,0 +1,23 @@ +/* + * 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. + */ + + +APEX_CUDA_SYNC_KERNEL(HISTOGRAM_KERNEL_CONFIG, histogramSyncKernel, ((unsigned int, count)) + ((const float*, g_data))((unsigned int, bound)) + ((float, dataMin))((float, dataMax))((unsigned int*, g_boundParams)) + ((unsigned int*, g_tmpHistograms)) + ) + +APEX_CUDA_BOUND_KERNEL(HISTOGRAM_KERNEL_CONFIG, histogramKernel, + ((APEX_MEM_BLOCK(float), g_data))((unsigned int, bound)) + ((float, dataMin))((float, dataMax))((APEX_MEM_BLOCK(unsigned int), g_boundParams)) + ((APEX_MEM_BLOCK(unsigned int), g_tmpHistograms)) + ((unsigned int, phase))((unsigned int, gridSize)) + ) diff --git a/APEX_1.4/module/pxparticleios/cuda/include/moduleList.h b/APEX_1.4/module/pxparticleios/cuda/include/moduleList.h new file mode 100644 index 00000000..8a8749ce --- /dev/null +++ b/APEX_1.4/module/pxparticleios/cuda/include/moduleList.h @@ -0,0 +1,16 @@ +/* + * 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 "compact.h" +#include "histogram.h" +#include "reduce.h" +#include "scan.h" +#include "simulate.h" diff --git a/APEX_1.4/module/pxparticleios/cuda/include/reduce.h b/APEX_1.4/module/pxparticleios/cuda/include/reduce.h new file mode 100644 index 00000000..adde0ad7 --- /dev/null +++ b/APEX_1.4/module/pxparticleios/cuda/include/reduce.h @@ -0,0 +1,19 @@ +/* + * 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. + */ + + +APEX_CUDA_SYNC_KERNEL(REDUCE_KERNEL_CONFIG, reduceSyncKernel, ((unsigned int, count)) + ((float*, g_benefit))((float4*, g_output))((unsigned int*, g_tmp)) + ) + +APEX_CUDA_BOUND_KERNEL(REDUCE_KERNEL_CONFIG, reduceKernel, + ((APEX_MEM_BLOCK(float), g_benefit))((APEX_MEM_BLOCK(float4), g_output))((APEX_MEM_BLOCK(unsigned int), g_tmp)) + ((unsigned int, phase))((unsigned int, gridSize)) + ) diff --git a/APEX_1.4/module/pxparticleios/cuda/include/scan.h b/APEX_1.4/module/pxparticleios/cuda/include/scan.h new file mode 100644 index 00000000..12553c5f --- /dev/null +++ b/APEX_1.4/module/pxparticleios/cuda/include/scan.h @@ -0,0 +1,25 @@ +/* + * 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. + */ + + +APEX_CUDA_SYNC_KERNEL(SCAN_KERNEL_CONFIG, scanSyncKernel, ((unsigned int, count)) + ((float, benefitMin))((float, benefitMax)) + ((unsigned int*, g_indices))((const float*, g_benefits)) + ((unsigned int*, g_boundParams)) + ((unsigned int*, g_tmpCounts))((unsigned int*, g_tmpCounts1)) + ) + +APEX_CUDA_BOUND_KERNEL(SCAN_KERNEL_CONFIG, scanKernel, + ((float, benefitMin))((float, benefitMax)) + ((APEX_MEM_BLOCK(unsigned int), g_indices))((APEX_MEM_BLOCK(float), g_benefits)) + ((APEX_MEM_BLOCK(unsigned int), g_boundParams)) + ((APEX_MEM_BLOCK(unsigned int), g_tmpCounts))((APEX_MEM_BLOCK(unsigned int), g_tmpCounts1)) + ((unsigned int, phase))((unsigned int, gridSize)) + ) diff --git a/APEX_1.4/module/pxparticleios/cuda/include/simulate.h b/APEX_1.4/module/pxparticleios/cuda/include/simulate.h new file mode 100644 index 00000000..2437c988 --- /dev/null +++ b/APEX_1.4/module/pxparticleios/cuda/include/simulate.h @@ -0,0 +1,99 @@ +/* + * 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. + */ + + +APEX_CUDA_STORAGE(simulateStorage) + + +APEX_CUDA_TEXTURE_1D(texRefPositionMass, float4) +APEX_CUDA_TEXTURE_1D(texRefVelocityLife, float4) +APEX_CUDA_TEXTURE_1D(texRefIofxActorIDs, unsigned int) +APEX_CUDA_TEXTURE_1D(texRefLifeSpan, float) +APEX_CUDA_TEXTURE_1D(texRefLifeTime, float) +APEX_CUDA_TEXTURE_1D(texRefInjector, unsigned int) + +APEX_CUDA_TEXTURE_1D(texRefUserData, unsigned int) + +APEX_CUDA_TEXTURE_1D(texRefHoleScanSum, unsigned int) +APEX_CUDA_TEXTURE_1D(texRefMoveIndices, unsigned int) + +APEX_CUDA_TEXTURE_1D(texRefField, float4) + +APEX_CUDA_TEXTURE_1D(texRefPxPosition, float4) +APEX_CUDA_TEXTURE_1D(texRefPxVelocity, float4) +APEX_CUDA_TEXTURE_1D(texRefPxCollision, float4) +APEX_CUDA_TEXTURE_1D(texRefNvFlags, unsigned int) +APEX_CUDA_TEXTURE_1D(texRefPxDensity, float) + + +APEX_CUDA_BOUND_KERNEL(SIMULATE_KERNEL_CONFIG, simulateKernel, + ((unsigned int, lastCount))((float, deltaTime))((physx::PxVec3, eyePos)) + ((InplaceHandle<InjectorParamsArray>, injectorParamsArrayHandle))((unsigned int, injectorCount)) + ((unsigned int*, g_holeScanSum))((unsigned int*, g_inputIdToParticleIndex))((unsigned int*, g_moveCount))((unsigned int*, g_tmpHistogram))((unsigned int*, g_InjectorsCounters)) + ((float4*, g_positionMass))((float4*, g_velocityLife))((float4*, g_collisionNormalFlags))((unsigned int*, g_userData)) + ((float*, g_lifeSpan))((float*, g_lifeTime))((float*, g_density))((unsigned int*, g_injector))((IofxActorIDIntl*, g_iofxActorIDs)) + ((float*, g_benefit))((float4*, g_pxPosition))((float4*, g_pxVelocity))((float4*, pxCollisionNormals))((float*, pxDensity))((unsigned int*, g_NvFlags)) + ((GridDensityParams, params)) + ) + +APEX_CUDA_BOUND_KERNEL(SIMULATE_KERNEL_CONFIG, simulateApplyFieldKernel, + ((unsigned int, lastCount))((float, deltaTime))((physx::PxVec3, eyePos)) + ((InplaceHandle<InjectorParamsArray>, injectorParamsArrayHandle))((unsigned int, injectorCount)) + ((APEX_MEM_BLOCK(unsigned int), g_holeScanSum))((APEX_MEM_BLOCK(unsigned int), g_inputIdToParticleIndex)) + ((APEX_MEM_BLOCK(unsigned int), g_moveCount)) + ((APEX_MEM_BLOCK(unsigned int), g_tmpHistogram)) + ((APEX_MEM_BLOCK(unsigned int), g_InjectorsCounters)) + ((APEX_MEM_BLOCK(float4), g_positionMass))((APEX_MEM_BLOCK(float4), g_velocityLife)) + ((APEX_MEM_BLOCK(float4), g_collisionNormalFlags))((APEX_MEM_BLOCK(unsigned int),g_userData))((APEX_MEM_BLOCK(float), g_lifeSpan))((APEX_MEM_BLOCK(float), g_lifeTime)) + ((APEX_MEM_BLOCK(float), g_density))((APEX_MEM_BLOCK(unsigned int), g_injector))((APEX_MEM_BLOCK(IofxActorIDIntl), g_iofxActorIDs)) + ((APEX_MEM_BLOCK(float), g_benefit))((APEX_MEM_BLOCK(float4), g_pxPosition))((APEX_MEM_BLOCK(float4), g_pxVelocity)) + ((APEX_MEM_BLOCK(float4), pxCollisionNormals))((APEX_MEM_BLOCK(float), pxDensity))((APEX_MEM_BLOCK(unsigned int), g_NvFlags)) + ((GridDensityParams, params)) + ) + +APEX_CUDA_BOUND_KERNEL((), mergeHistogramKernel, + ((unsigned int*, g_InjectorsCounters))((unsigned int*, g_tmpHistograms))((unsigned int, gridSize))((unsigned int, injectorCount)) + ) + + +APEX_CUDA_BOUND_KERNEL((), stateKernel, + ((unsigned int, lastCount))((unsigned int, targetCount)) + ((APEX_MEM_BLOCK(unsigned int), g_moveCount)) + ((APEX_MEM_BLOCK(unsigned int), g_inStateToInput))((APEX_MEM_BLOCK(unsigned int), g_outStateToInput)) + ) + +APEX_CUDA_BOUND_KERNEL((), testKernel, + ((unsigned int, scalarVar))((APEX_MEM_BLOCK(unsigned int), vectorVar)) + ((InplaceHandle<int>, multHandle)) + ) + +APEX_CUDA_BOUND_KERNEL((), gridDensityGridClearKernel, + ((float*, gridDensityGrid))((GridDensityParams, params)) + ) + +APEX_CUDA_BOUND_KERNEL((), gridDensityGridFillKernel, + ((float4*, positionMass))((float*, gridDensityGrid))((GridDensityParams, params)) + ) + +APEX_CUDA_BOUND_KERNEL((), gridDensityGridApplyKernel, + ((float*, density))((float4*, positionMass))((float*, gridDensityGrid))((GridDensityParams, params)) + ) + +APEX_CUDA_BOUND_KERNEL((), gridDensityGridFillFrustumKernel, + ((float4*, positionMass))((float*, gridDensityGrid))((GridDensityParams, params))((::physx::PxMat44,mat))((GridDensityFrustumParams,frustum)) + ) + +APEX_CUDA_BOUND_KERNEL((), gridDensityGridApplyFrustumKernel, + ((float*, density))((float4*, positionMass))((float*, gridDensityGrid))((GridDensityParams, params))((::physx::PxMat44,mat))((GridDensityFrustumParams,frustum)) + ) + +APEX_CUDA_FREE_KERNEL((), gridDensityGridLowPassKernel, + ((float*, gridDensityGridIn))((float*, gridDensityGridOut))((GridDensityParams, params)) + ) diff --git a/APEX_1.4/module/pxparticleios/include/ModuleEventDefs.h b/APEX_1.4/module/pxparticleios/include/ModuleEventDefs.h new file mode 100644 index 00000000..c04700f7 --- /dev/null +++ b/APEX_1.4/module/pxparticleios/include/ModuleEventDefs.h @@ -0,0 +1,30 @@ +/* + * 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. + */ + + +// This file is used to define a list of AgPerfMon events. +// +// This file is included exclusively by AgPerfMonEventSrcAPI.h +// and by AgPerfMonEventSrcAPI.cpp, for the purpose of building +// an enumeration (enum xx) and an array of strings () +// that contain the list of events. +// +// This file should only contain event definitions, using the +// DEFINE_EVENT macro. E.g.: +// +// DEFINE_EVENT(sample_name_1) +// DEFINE_EVENT(sample_name_2) +// DEFINE_EVENT(sample_name_3) + +DEFINE_EVENT(ParticleIosSceneFetchResults) +DEFINE_EVENT(ParticleIosCreateObjects) +DEFINE_EVENT(ParticleIosFetchResults) + + diff --git a/APEX_1.4/module/pxparticleios/include/ModuleParticleIosImpl.h b/APEX_1.4/module/pxparticleios/include/ModuleParticleIosImpl.h new file mode 100644 index 00000000..8ed0600a --- /dev/null +++ b/APEX_1.4/module/pxparticleios/include/ModuleParticleIosImpl.h @@ -0,0 +1,141 @@ +/* + * 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. + */ + + +#ifndef __MODULE_PARTICLEIOS_IMPL_H__ +#define __MODULE_PARTICLEIOS_IMPL_H__ + +#include "Apex.h" +#include "ModuleParticleIos.h" +#include "ApexSDKIntl.h" +#include "ModuleBase.h" +#include "ModuleIntl.h" +#include "ResourceProviderIntl.h" +#include "ApexSharedUtils.h" +#include "ApexSDKHelpers.h" +#include "ModulePerfScope.h" +#include "ApexAuthorableObject.h" +#include "ParticleIosAssetImpl.h" +#include "ModuleParticleIosRegistration.h" +#include "ApexRWLockable.h" + +namespace nvidia +{ +namespace apex +{ +class ModuleIofxIntl; +class ModuleFieldSamplerIntl; +class ParticleIosActor; +} +namespace pxparticleios +{ + +class ParticleIosScene; + + +/** +\brief ModuleBase descriptor for ParticleIOS module +*/ +class ModuleParticleIosDesc : public ApexDesc +{ +public: + + /** + \brief constructor sets to default. + */ + PX_INLINE ModuleParticleIosDesc() : ApexDesc() + { + init(); + } + + /** + \brief sets members to default values. + */ + PX_INLINE void setToDefault() + { + ApexDesc::setToDefault(); + init(); + } + + /** + \brief checks if this is a valid descriptor. + */ + PX_INLINE bool isValid() const + { + bool retVal = ApexDesc::isValid(); + return retVal; + } + +private: + + PX_INLINE void init() + { + } +}; + +class ModuleParticleIosImpl : public ModuleParticleIos, public ModuleIntl, public ModuleBase, public ApexRWLockable +{ +public: + APEX_RW_LOCKABLE_BOILERPLATE + + ModuleParticleIosImpl(ApexSDKIntl* sdk); + ~ModuleParticleIosImpl(); + + void init(const ModuleParticleIosDesc& desc); + + // base class methods + void init(NvParameterized::Interface&); + NvParameterized::Interface* getDefaultModuleDesc(); + void release() + { + ModuleBase::release(); + } + void destroy(); + const char* getName() const + { + READ_ZONE(); + return ModuleBase::getName(); + } + + //ParticleIosActor * getApexActor( Scene* scene, AuthObjTypeID type ) const; + ApexActor* getApexActor(Actor* nxactor, AuthObjTypeID type) const; + + ModuleSceneIntl* createInternalModuleScene(SceneIntl&, RenderDebugInterface*); + void releaseModuleSceneIntl(ModuleSceneIntl&); + uint32_t forceLoadAssets(); + AuthObjTypeID getModuleID() const; + RenderableIterator* createRenderableIterator(const Scene&); + + virtual const char* getParticleIosTypeName(); + + ParticleIosScene* getParticleIosScene(const Scene& scene); + const ParticleIosScene* getParticleIosScene(const Scene& scene) const; + + ModuleIofxIntl* getInternalModuleIofx(); + ModuleFieldSamplerIntl* getInternalModuleFieldSampler(); + +protected: + + ResourceList mParticleIosSceneList; + ResourceList mAuthorableObjects; + + friend class ParticleIosScene; +private: + + ParticleIosModuleParameters* mModuleParams; + + ModuleIofxIntl* mIofxModule; + ModuleFieldSamplerIntl* mFieldSamplerModule; +}; + +} +} // namespace nvidia + +#endif // __MODULE_PARTICLEIOS_IMPL_H__ diff --git a/APEX_1.4/module/pxparticleios/include/ModulePerfScope.h b/APEX_1.4/module/pxparticleios/include/ModulePerfScope.h new file mode 100644 index 00000000..5dc8faa0 --- /dev/null +++ b/APEX_1.4/module/pxparticleios/include/ModulePerfScope.h @@ -0,0 +1,18 @@ +/* + * 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. + */ + + +#ifndef __MODULE_PERF_SCOPE_H___ +#define __MODULE_PERF_SCOPE_H___ + +#define MODULE_NAMESPACE pxparticleios +#include "ModuleProfileCommon.h" + +#endif
\ No newline at end of file diff --git a/APEX_1.4/module/pxparticleios/include/ParticleIosActorCPU.h b/APEX_1.4/module/pxparticleios/include/ParticleIosActorCPU.h new file mode 100644 index 00000000..4f924875 --- /dev/null +++ b/APEX_1.4/module/pxparticleios/include/ParticleIosActorCPU.h @@ -0,0 +1,104 @@ +/* + * 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. + */ + + +#ifndef __PARTICLE_IOS_ACTOR_CPU_H__ +#define __PARTICLE_IOS_ACTOR_CPU_H__ + +#include "Apex.h" + +#include "ParticleIosActorImpl.h" +#include "ParticleIosAssetImpl.h" +#include "InstancedObjectSimulationIntl.h" +#include "ParticleIosScene.h" +#include "ApexActor.h" +#include "ApexContext.h" +#include "ApexFIFO.h" + +#include "PxTask.h" + +namespace nvidia +{ + +namespace iofx +{ +class RenderVolume; +class IofxAsset; +} + +namespace pxparticleios +{ + +class ParticleIosActorCPU : public ParticleIosActorImpl +{ +public: + APEX_RW_LOCKABLE_BOILERPLATE + + ParticleIosActorCPU(ResourceList&, ParticleIosAssetImpl&, ParticleIosScene&, IofxAsset&); + ~ParticleIosActorCPU(); + + virtual PxTaskID submitTasks(PxTaskManager* tm); + virtual void setTaskDependencies(PxTaskID taskStartAfterID, PxTaskID taskFinishBeforeID); + +private: + /* Internal utility functions */ + void simulateParticles(); + + static const uint32_t HISTOGRAM_BIN_COUNT = 1024; + uint32_t computeHistogram(uint32_t dataCount, float dataMin, float dataMax, uint32_t& bound); + + /* particle data (output to the IOFX actors, and some state) */ + + struct NewParticleData + { + uint32_t destIndex; + PxVec3 position; + PxVec3 velocity; + }; + physx::Array<uint32_t> mNewIndices; + physx::Array<uint32_t> mRemovedParticleList; + physx::Array<NewParticleData> mAddedParticleList; + physx::PxParticleExt::IndexPool* mIndexPool; + + /* Field sampler update velocity */ + physx::Array<uint32_t> mUpdateIndexBuffer; + physx::Array<PxVec3> mUpdateVelocityBuffer; + + class SimulateTask : public PxTask + { + public: + SimulateTask(ParticleIosActorCPU& actor) : mActor(actor) {} + + const char* getName() const + { + return "ParticleIosActorCPU::SimulateTask"; + } + void run() + { + mActor.simulateParticles(); + } + + protected: + ParticleIosActorCPU& mActor; + + private: + SimulateTask& operator=(const SimulateTask&); + }; + SimulateTask mSimulateTask; + + nvidia::apex::ApexCpuInplaceStorage mSimulationStorage; + + friend class ParticleIosAssetImpl; +}; + +} +} // namespace nvidia + +#endif // __PARTICLE_IOS_ACTOR_CPU_H__ diff --git a/APEX_1.4/module/pxparticleios/include/ParticleIosActorGPU.h b/APEX_1.4/module/pxparticleios/include/ParticleIosActorGPU.h new file mode 100644 index 00000000..b7339c46 --- /dev/null +++ b/APEX_1.4/module/pxparticleios/include/ParticleIosActorGPU.h @@ -0,0 +1,131 @@ +/* + * 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. + */ + + +#ifndef __PARTICLE_IOS_ACTOR_GPU_H__ +#define __PARTICLE_IOS_ACTOR_GPU_H__ + +#include "Apex.h" + +#include "ParticleIosActorImpl.h" +#include "ParticleIosAssetImpl.h" +#include "InstancedObjectSimulationIntl.h" +#include "ParticleIosScene.h" +#include "ApexActor.h" +#include "ApexContext.h" +#include "ApexFIFO.h" +#include "FieldSamplerQueryIntl.h" + +#include "PxGpuTask.h" + +namespace nvidia +{ + +namespace iofx +{ +class IofxActor; +class RenderVolume; +} + +namespace pxparticleios +{ + +class ParticleIosActorGPU; + +class ParticleIosActorGPU : public ParticleIosActorImpl +{ +public: + ParticleIosActorGPU(ResourceList&, ParticleIosAssetImpl&, ParticleIosScene&, IofxAsset&); + ~ParticleIosActorGPU(); + + virtual PxTaskID submitTasks(PxTaskManager* tm); + virtual void setTaskDependencies(PxTaskID taskStartAfterID, PxTaskID taskFinishBeforeID); + virtual void fetchResults(); + +private: + bool launch(CUstream stream, int kernelIndex); + void trigger(); + +#if APEX_CUDA_SUPPORT + CUevent mCuSyncEvent; + PxGpuCopyDescQueue mCopyQueue; +#endif + + ApexMirroredArray<uint32_t> mHoleScanSum; + ApexMirroredArray<uint32_t> mMoveIndices; + + ApexMirroredArray<uint32_t> mTmpReduce; + ApexMirroredArray<uint32_t> mTmpHistogram; + ApexMirroredArray<uint32_t> mTmpScan; + ApexMirroredArray<uint32_t> mTmpScan1; + + ApexMirroredArray<uint32_t> mTmpOutput; // 0:STATUS_LASTACTIVECOUNT, ... + ApexMirroredArray<uint32_t> mTmpBoundParams; // min, max + + class LaunchTask : public PxGpuTask + { + public: + LaunchTask(ParticleIosActorGPU& actor) : mActor(actor) {} + const char* getName() const + { + return "ParticleIosActorGPU::LaunchTask"; + } + void run() + { + PX_ALWAYS_ASSERT(); + } + bool launchInstance(CUstream stream, int kernelIndex) + { + return mActor.launch(stream, kernelIndex); + } + PxGpuTaskHint::Enum getTaskHint() const + { + return PxGpuTaskHint::Kernel; + } + + protected: + ParticleIosActorGPU& mActor; + + private: + LaunchTask& operator=(const LaunchTask&); + }; + class TriggerTask : public PxTask + { + public: + TriggerTask(ParticleIosActorGPU& actor) : mActor(actor) {} + + const char* getName() const + { + return "ParticleIosActorGPU::TriggerTask"; + } + void run() + { + mActor.trigger(); + } + + protected: + ParticleIosActorGPU& mActor; + + private: + TriggerTask& operator=(const TriggerTask&); + }; + + + static PX_CUDA_CALLABLE PX_INLINE PxMat44 inverse(const PxMat44& in); + static float distance(PxVec4 a, PxVec4 b); + + LaunchTask mLaunchTask; + TriggerTask mTriggerTask; +}; + +} +} // namespace nvidia + +#endif // __PARTICLE_IOS_ACTOR_GPU_H__ diff --git a/APEX_1.4/module/pxparticleios/include/ParticleIosActorImpl.h b/APEX_1.4/module/pxparticleios/include/ParticleIosActorImpl.h new file mode 100644 index 00000000..51d52341 --- /dev/null +++ b/APEX_1.4/module/pxparticleios/include/ParticleIosActorImpl.h @@ -0,0 +1,321 @@ +/* + * 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. + */ + + +#ifndef __PARTICLE_IOS_ACTOR_IMPL_H__ +#define __PARTICLE_IOS_ACTOR_IMPL_H__ + +#include "Apex.h" + +#include "ParticleIosActor.h" +#include "iofx/IofxActor.h" +#include "ParticleIosAssetImpl.h" +#include "InstancedObjectSimulationIntl.h" +#include "ParticleIosScene.h" +#include "ApexActor.h" +#include "ApexContext.h" +#include "ApexFIFO.h" +#include "ParticleIosCommonCode.h" +#include "InplaceStorage.h" +#include "ApexMirroredArray.h" +#include "PxParticleExt.h" +#include "ApexRWLockable.h" + +namespace nvidia +{ +namespace apex +{ +class FieldSamplerQueryIntl; +class FieldSamplerCallbackIntl; +} +namespace pxparticleios +{ + +/* Class for managing the interactions with each emitter */ +class ParticleParticleInjector : public IosInjectorIntl, public ApexResourceInterface, public ApexResource, public ApexRWLockable +{ +public: + APEX_RW_LOCKABLE_BOILERPLATE + + void setPreferredRenderVolume(RenderVolume* volume); + float getLeastBenefitValue() const + { + return 0.0f; + } + bool isBacklogged() const + { + return false; + } + + void createObjects(uint32_t count, const IosNewObject* createList); +#if APEX_CUDA_SUPPORT + void createObjects(ApexMirroredArray<const IosNewObject>& createArray); +#endif + + void setLODWeights(float maxDistance, float distanceWeight, float speedWeight, float lifeWeight, float separationWeight, float bias); + + PxTaskID getCompletionTaskID() const; + + void release(); + void destroy(); + + // ApexResourceInterface methods + void setListIndex(ResourceList& list, uint32_t index); + + uint32_t getListIndex() const + { + return m_listIndex; + } + + virtual void setPhysXScene(PxScene*) {} + virtual PxScene* getPhysXScene() const + { + return NULL; + } + + void assignSimParticlesCount(uint32_t input) + { + mSimulatedParticlesCount = input; + } + + virtual uint32_t getSimParticlesCount() const + { + return mSimulatedParticlesCount; + } + + virtual uint32_t getActivePaticleCount() const; + + virtual void setObjectScale(float objectScale); + +protected: + ParticleIosActorImpl* mIosActor; + IofxManagerClientIntl* mIofxClient; + RenderVolume* mVolume; + physx::Array<uint16_t> mRandomActorClassIDs; + uint32_t mLastRandomID; + uint16_t mVolumeID; + + uint32_t mInjectorID; + uint32_t mSimulatedParticlesCount; + + + /* insertion buffer */ + ApexFIFO<IosNewObject> mInjectedParticles; + + ParticleParticleInjector(ResourceList& list, ParticleIosActorImpl& actor, uint32_t injectorID); + ~ParticleParticleInjector() {} + + void init(IofxAsset* iofxAsset); + + friend class ParticleIosActorImpl; +}; + + +class ParticleIosActorImpl : public InstancedObjectSimulationIntl, + public ParticleIosActor, + public ApexResourceInterface, + public ApexResource, + public ApexRWLockable +{ +public: + APEX_RW_LOCKABLE_BOILERPLATE + + ParticleIosActorImpl(ResourceList& list, ParticleIosAssetImpl& asset, ParticleIosScene& scene, IofxAsset& iofxAsset, bool isDataOnDevice); + ~ParticleIosActorImpl(); + + // ApexInterface API + void release(); + void destroy(); + + // Actor API + void setPhysXScene(PxScene* s); + PxScene* getPhysXScene() const; + virtual void putInScene(PxScene* scene); + + Asset* getOwner() const + { + READ_ZONE(); + return (Asset*) mAsset; + } + + // ApexContext + void getLodRange(float& min, float& max, bool& intOnly) const; + float getActiveLod() const; + void forceLod(float lod); + /** + \brief Selectively enables/disables debug visualization of a specific APEX actor. Default value it true. + */ + virtual void setEnableDebugVisualization(bool state) + { + WRITE_ZONE(); + ApexActor::setEnableDebugVisualization(state); + } + + // ApexResourceInterface methods + void setListIndex(ResourceList& list, uint32_t index) + { + m_listIndex = index; + m_list = &list; + } + uint32_t getListIndex() const + { + return m_listIndex; + } + + // IOSIntl + float getObjectRadius() const + { + return getParticleRadius(); + } + float getObjectDensity() const + { + return 1.0f; + } // mAsset->getRestDensity(); } + + // ParticleIosActor + float getParticleRadius() const + { + return mAsset->getParticleRadius(); + } + //float getRestDensity() const { return mAsset->getRestDensity();} + uint32_t getParticleCount() const + { + return mParticleCount; + } + + PX_INLINE void setOnStartFSCallback(FieldSamplerCallbackIntl* callback) + { + if (mFieldSamplerQuery) + { + mFieldSamplerQuery->setOnStartCallback(callback); + } + } + PX_INLINE void setOnFinishIOFXCallback(IofxManagerCallbackIntl* callback) + { + if (mIofxMgr) + { + mIofxMgr->setOnFinishCallback(callback); + } + } + + const PxVec3* getRecentPositions(uint32_t& count, uint32_t& stride) const; + + void visualize(); + virtual PxTaskID submitTasks(PxTaskManager* tm) = 0; + virtual void setTaskDependencies(PxTaskID taskStartAfterID, PxTaskID taskFinishBeforeID) = 0; + virtual void fetchResults(); + + IosInjectorIntl* allocateInjector(IofxAsset* iofxAsset); + void releaseInjector(IosInjectorIntl&); + + virtual void setDensityOrigin(const PxVec3& v) + { + mDensityOrigin = v; + } + +protected: + virtual void removeFromScene(); + + void injectNewParticles(); + bool isParticleDescValid( const ParticleIosAssetParam* desc) const; + void initStorageGroups(InplaceStorage& storage); + + void setTaskDependencies(PxTaskID taskStartAfterID, PxTaskID taskFinishBeforeID, PxTask* iosTask, bool isDataOnDevice); + + ParticleIosAssetImpl* mAsset; + ParticleIosScene* mParticleIosScene; + bool mIsParticleSystem; // true:SimpleParticleSystemParams , false:FluidParticleSystemParams + PxActor* mParticleActor; + + IofxManagerIntl* mIofxMgr; + IosBufferDescIntl mBufDesc; + + ResourceList mInjectorList; + + physx::Array<IofxAsset*> mIofxAssets; + physx::Array<uint32_t> mIofxAssetRefs; + + PxVec3 mUp; + float mGravity; + float mTotalElapsedTime; //AM: People, methinks this will backfire eventually due to floating point precision loss! + + uint32_t mMaxParticleCount; + uint32_t mMaxTotalParticleCount; + + uint32_t mParticleCount; + uint32_t mParticleBudget; + + uint32_t mInjectedCount; + float mInjectedBenefitSum; + float mInjectedBenefitMin; + float mInjectedBenefitMax; + + uint32_t mLastActiveCount; + float mLastBenefitSum; + float mLastBenefitMin; + float mLastBenefitMax; + + ApexMirroredArray<float> mLifeSpan; + ApexMirroredArray<float> mLifeTime; + ApexMirroredArray<uint32_t> mInjector; + ApexMirroredArray<float> mBenefit; + ApexMirroredArray<uint32_t> mInjectorsCounters; + ApexMirroredArray<uint32_t> mInputIdToParticleIndex; + + ApexMirroredArray<float> mGridDensityGrid; + ApexMirroredArray<float> mGridDensityGridLowPass; + + // Only for use by the IOS Asset, the actor is unaware of this + bool mIsMesh; + + FieldSamplerQueryIntl* mFieldSamplerQuery; + ApexMirroredArray<PxVec4> mField; + + InplaceStorageGroup mSimulationStorageGroup; + + class InjectTask : public PxTask + { + public: + InjectTask(ParticleIosActorImpl& actor) : mActor(actor) {} + + const char* getName() const + { + return "ParticleIosActorImpl::InjectTask"; + } + void run() + { + mActor.injectNewParticles(); + } + + protected: + ParticleIosActorImpl& mActor; + + private: + InjectTask& operator=(const InjectTask&); + }; + InjectTask mInjectTask; + + // Particle Density Origin + PxVec3 mDensityOrigin; + PxMat44 mDensityDebugMatInv; + + GridDensityParams mGridDensityParams; + + FieldSamplerCallbackIntl* mOnStartCallback; + IofxManagerCallbackIntl* mOnFinishCallback; + + friend class ParticleIosAssetImpl; + friend class ParticleParticleInjector; +}; + +} +} // namespace nvidia + +#endif // __PARTICLE_IOS_ACTOR_IMPL_H__ diff --git a/APEX_1.4/module/pxparticleios/include/ParticleIosAssetImpl.h b/APEX_1.4/module/pxparticleios/include/ParticleIosAssetImpl.h new file mode 100644 index 00000000..daea8d91 --- /dev/null +++ b/APEX_1.4/module/pxparticleios/include/ParticleIosAssetImpl.h @@ -0,0 +1,332 @@ +/* + * 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. + */ + + +#ifndef PARTICLE_IOS_ASSET_IMPL_H +#define PARTICLE_IOS_ASSET_IMPL_H + +#include "Apex.h" +#include "iofx/IofxAsset.h" +#include "ParticleIosAsset.h" +#include "InstancedObjectSimulationIntl.h" +#include "ApexSDKHelpers.h" +#include "ApexAssetAuthoring.h" +#include "ApexString.h" +#include "ResourceProviderIntl.h" +#include "ApexAuthorableObject.h" +#include "ParticleIosAssetParam.h" +#include "ApexAssetTracker.h" +#include "ApexUsingNamespace.h" +#include "ApexRWLockable.h" +#include "ReadCheck.h" +#include "WriteCheck.h" +#include "ApexAuthorableObject.h" + +namespace nvidia +{ + +namespace iofx +{ +class IofxAsset; +} + +namespace pxparticleios +{ + +class ModuleParticleIosImpl; +class ParticleIosActorImpl; + + +/** +\brief Descriptor needed to create a ParticleIOS Actor +*/ +class ParticleIosActorDesc : public ApexDesc +{ +public: + ///Radius of a particle (overrides authered value) + float radius; + ///Density of a particle (overrides authered value) + float density; + + /** + \brief constructor sets to default. + */ + PX_INLINE ParticleIosActorDesc() : ApexDesc() + { + init(); + } + + /** + \brief sets members to default values. + */ + PX_INLINE void setToDefault() + { + ApexDesc::setToDefault(); + init(); + } + + /** + \brief checks if this is a valid descriptor. + */ + PX_INLINE bool isValid() const + { + if (!ApexDesc::isValid()) + { + return false; + } + + return true; + } + +private: + + PX_INLINE void init() + { + // authored values will be used where these default values remain + radius = 0.0f; + density = 0.0f; + } +}; + +class ParticleIosAssetImpl : public ParticleIosAsset, + public ApexResourceInterface, + public ApexResource, + public ApexRWLockable +{ + friend class ParticleIosAssetDummyAuthoring; +public: + APEX_RW_LOCKABLE_BOILERPLATE + + ParticleIosAssetImpl(ModuleParticleIosImpl*, ResourceList&, const char*); + ParticleIosAssetImpl(ModuleParticleIosImpl* module, ResourceList&, NvParameterized::Interface*, const char*); + ~ParticleIosAssetImpl(); + + // Asset + void release(); + const char* getName(void) const + { + return mName.c_str(); + } + AuthObjTypeID getObjTypeID() const + { + return mAssetTypeID; + } + const char* getObjTypeName() const + { + return getClassName(); + } + uint32_t forceLoadAssets(); + + Actor* createIosActor(Scene& scene, IofxAsset* iofxAsset); + void releaseIosActor(Actor&); + bool getSupportsDensity() const + { + READ_ZONE(); + return mParams->DensityBuffer; + } + bool isValidForActorCreation(const ::NvParameterized::Interface& /*actorParams*/, Scene& /*apexScene*/) const + { + return true; + } + + bool isDirty() const + { + return false; + } + + + // Private API for this module only + ParticleIosActorImpl* getIosActorInScene(Scene& scene, bool mesh) const; + + // ApexResourceInterface methods + void setListIndex(ResourceList& list, uint32_t index) + { + m_listIndex = index; + m_list = &list; + } + uint32_t getListIndex() const + { + return m_listIndex; + } + + float getParticleRadius() const + { + READ_ZONE(); + return mParams->particleRadius; + } + //float getRestDensity() const { return mParams->restDensity; } + float getMaxInjectedParticleCount() const + { + READ_ZONE(); + return mParams->maxInjectedParticleCount; + } + uint32_t getMaxParticleCount() const + { + READ_ZONE(); + return mParams->maxParticleCount; + } + const char* getParticleTypeClassName() const + { + return mParams->particleType->className(); + } + const ParticleIosAssetParam* getParticleDesc() const + { + return mParams; + } + float getParticleMass() const + { + READ_ZONE(); + return mParams->particleMass; + } + + const NvParameterized::Interface* getAssetNvParameterized() const + { + READ_ZONE(); + return mParams; + } + /** + * \brief Releases the ApexAsset but returns the NvParameterized::Interface and *ownership* to the caller. + */ + virtual NvParameterized::Interface* releaseAndReturnNvParameterizedInterface(void) + { + NvParameterized::Interface* ret = mParams; + mParams = NULL; + release(); + return ret; + } + + NvParameterized::Interface* getDefaultActorDesc() + { + READ_ZONE(); + APEX_INVALID_OPERATION("Not yet implemented!"); + return NULL; + } + + NvParameterized::Interface* getDefaultAssetPreviewDesc() + { + READ_ZONE(); + APEX_INVALID_OPERATION("Not yet implemented!"); + return NULL; + } + + virtual Actor* createApexActor(const NvParameterized::Interface& /*parms*/, Scene& /*apexScene*/) + { + WRITE_ZONE(); + APEX_INVALID_OPERATION("Not yet implemented!"); + return NULL; + } + + virtual AssetPreview* createApexAssetPreview(const NvParameterized::Interface& /*params*/, AssetPreviewScene* /*previewScene*/) + { + WRITE_ZONE(); + APEX_INVALID_OPERATION("Not yet implemented!"); + return NULL; + } + +protected: + virtual void destroy(); + + static AuthObjTypeID mAssetTypeID; + static const char* getClassName() + { + return PARTICLE_IOS_AUTHORING_TYPE_NAME; + } + + ResourceList mIosActorList; + + ModuleParticleIosImpl* mModule; + ApexSimpleString mName; + + ParticleIosAssetParam* mParams; + + friend class ModuleParticleIosImpl; + friend class ParticleIosActorImpl; + friend class ParticleIosActorCPU; + friend class ParticleIosActorGPU; + template <class T_Module, class T_Asset, class T_AssetAuthoring> friend class nvidia::apex::ApexAuthorableObject; + friend class ParticleIosAuthorableObject; +}; + +#ifndef WITHOUT_APEX_AUTHORING +class ParticleIosAssetAuthoringImpl : public ParticleIosAssetAuthoring, public ApexAssetAuthoring, public ParticleIosAssetImpl +{ +public: + APEX_RW_LOCKABLE_BOILERPLATE + + ParticleIosAssetAuthoringImpl(ModuleParticleIosImpl* module, ResourceList& list); + ParticleIosAssetAuthoringImpl(ModuleParticleIosImpl* module, ResourceList& list, const char* name); + ParticleIosAssetAuthoringImpl(ModuleParticleIosImpl* module, ResourceList& list, NvParameterized::Interface* params, const char* name); + + virtual void release(); + + const char* getName(void) const + { + READ_ZONE(); + return mName.c_str(); + } + const char* getObjTypeName() const + { + READ_ZONE(); + return ParticleIosAssetImpl::getClassName(); + } + virtual bool prepareForPlatform(nvidia::apex::PlatformTag) + { + WRITE_ZONE(); + APEX_INVALID_OPERATION("Not Implemented."); + return false; + } + void setToolString(const char* toolName, const char* toolVersion, uint32_t toolChangelist) + { + WRITE_ZONE(); + ApexAssetAuthoring::setToolString(toolName, toolVersion, toolChangelist); + } + + void setParticleRadius(float radius) + { + mParams->particleRadius = radius; + } + //void setRestDensity( float density ) { mParams->restDensity = density; } + void setMaxInjectedParticleCount(float count) + { + mParams->maxInjectedParticleCount = count; + } + void setMaxParticleCount(uint32_t count) + { + mParams->maxParticleCount = count; + } + void setParticleMass(float mass) + { + mParams->particleMass = mass; + } + + void setCollisionGroupName(const char* collisionGroupName); + void setCollisionGroupMaskName(const char* collisionGroupMaskName); + + NvParameterized::Interface* getNvParameterized() const + { + return (NvParameterized::Interface*)getAssetNvParameterized(); + } + /** + * \brief Releases the ApexAsset but returns the NvParameterized::Interface and *ownership* to the caller. + */ + virtual NvParameterized::Interface* releaseAndReturnNvParameterizedInterface(void) + { + NvParameterized::Interface* ret = mParams; + mParams = NULL; + release(); + return ret; + } +}; +#endif + +} +} // namespace nvidia + +#endif // PARTICLE_IOS_ASSET_IMPL_H diff --git a/APEX_1.4/module/pxparticleios/include/ParticleIosCommon.h b/APEX_1.4/module/pxparticleios/include/ParticleIosCommon.h new file mode 100644 index 00000000..c63ac26d --- /dev/null +++ b/APEX_1.4/module/pxparticleios/include/ParticleIosCommon.h @@ -0,0 +1,62 @@ +/* + * 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. + */ + + +#ifndef __PARTICLE_IOS_COMMON_H__ +#define __PARTICLE_IOS_COMMON_H__ + +#include "PxBounds3.h" +#include "PxVec3.h" +#include "InplaceTypes.h" + +const unsigned int INVALID_PARTICLE_INDEX = (unsigned int)-1; + +namespace nvidia +{ +namespace pxparticleios +{ + +//struct Px3InjectorParams +#define INPLACE_TYPE_STRUCT_NAME Px3InjectorParams +#define INPLACE_TYPE_STRUCT_FIELDS \ + INPLACE_TYPE_FIELD(float, mLODMaxDistance) \ + INPLACE_TYPE_FIELD(float, mLODDistanceWeight) \ + INPLACE_TYPE_FIELD(float, mLODSpeedWeight) \ + INPLACE_TYPE_FIELD(float, mLODLifeWeight) \ + INPLACE_TYPE_FIELD(float, mLODBias) \ + INPLACE_TYPE_FIELD(uint32_t, mLocalIndex) +#include INPLACE_TYPE_BUILD() + +typedef InplaceArray<Px3InjectorParams> InjectorParamsArray; + + +struct GridDensityParams +{ + bool Enabled; + float GridSize; + uint32_t GridMaxCellCount; + uint32_t GridResolution; + PxVec3 DensityOrigin; + GridDensityParams(): Enabled(false) {} +}; + +struct GridDensityFrustumParams +{ + float nearDimX; + float farDimX; + float nearDimY; + float farDimY; + float dimZ; +}; + +} +} // namespace nvidia + +#endif diff --git a/APEX_1.4/module/pxparticleios/include/ParticleIosCommonCode.h b/APEX_1.4/module/pxparticleios/include/ParticleIosCommonCode.h new file mode 100644 index 00000000..86278a0f --- /dev/null +++ b/APEX_1.4/module/pxparticleios/include/ParticleIosCommonCode.h @@ -0,0 +1,288 @@ +/* + * 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. + */ + + +#ifndef __PARTICLE_IOS_COMMON_CODE_H__ +#define __PARTICLE_IOS_COMMON_CODE_H__ + +#include "ParticleIosCommon.h" + + +namespace nvidia +{ +namespace pxparticleios +{ + +#ifdef __CUDACC__ + +#define SIM_FETCH(name, idx) tex1Dfetch(KERNEL_TEX_REF(name), idx) +#define SIM_FLOAT4 float4 +#define SIM_INT_AS_FLOAT(x) *(const float*)(&x) +#define SIM_INJECTOR_ARRAY const InjectorParamsArray& +#define SIM_FETCH_INJECTOR(injectorArray, injParams, injector) injectorArray.fetchElem(INPLACE_STORAGE_ARGS_VAL, injParams, injector) + +PX_CUDA_CALLABLE PX_INLINE float splitFloat4(PxVec3& v3, const SIM_FLOAT4& f4) +{ + v3.x = f4.x; + v3.y = f4.y; + v3.z = f4.z; + return f4.w; +} +PX_CUDA_CALLABLE PX_INLINE SIM_FLOAT4 combineFloat4(const PxVec3& v3, float w) +{ + return make_float4(v3.x, v3.y, v3.z, w); +} + +struct PxInternalParticleFlagGpu +{ + enum Enum + { + //reserved (1<<0), + //reserved (1<<1), + //reserved (1<<2), + //reserved (1<<3), + //reserved (1<<4), + //reserved (1<<5), + eCUDA_NOTIFY_CREATE = (1 << 6), + eCUDA_NOTIFY_SET_POSITION = (1 << 7), + }; +}; +struct PxParticleFlag +{ + enum Enum + { + eVALID = (1 << 0), + eCOLLISION_WITH_STATIC = (1 << 1), + eCOLLISION_WITH_DYNAMIC = (1 << 2), + eCOLLISION_WITH_DRAIN = (1 << 3), + eSPATIAL_DATA_STRUCTURE_OVERFLOW = (1 << 4), + }; +}; +struct PxParticleFlagGpu +{ + uint16_t api; // PxParticleFlag + uint16_t low; // PxInternalParticleFlagGpu +}; + +#else + +#define SIM_FETCH(name, idx) mem##name[idx] +#define SIM_FLOAT4 PxVec4 +#define SIM_INT_AS_FLOAT(x) *(const float*)(&x) +#define SIM_INJECTOR_ARRAY const Px3InjectorParams* +#define SIM_FETCH_INJECTOR(injectorArray, injParams, injector) { injParams = injectorArray[injector]; } + +PX_INLINE float splitFloat4(PxVec3& v3, const SIM_FLOAT4& f4) +{ + v3 = f4.getXYZ(); + return f4.w; +} +PX_INLINE SIM_FLOAT4 combineFloat4(const PxVec3& v3, float w) +{ + return PxVec4(v3.x, v3.y, v3.z, w); +} + +#endif + + +APEX_CUDA_CALLABLE PX_INLINE float calcParticleBenefit( + const Px3InjectorParams& inj, const PxVec3& eyePos, + const PxVec3& pos, const PxVec3& vel, float life) +{ + float benefit = inj.mLODBias; + //distance term + float distance = (eyePos - pos).magnitude(); + benefit += inj.mLODDistanceWeight * (1.0f - PxMin(1.0f, distance / inj.mLODMaxDistance)); + //velocity term, TODO: clamp velocity + float velMag = vel.magnitude(); + benefit += inj.mLODSpeedWeight * velMag; + //life term + benefit += inj.mLODLifeWeight * life; + + return PxClamp(benefit, 0.0f, 1.0f); +} + + + +INPLACE_TEMPL_VA_ARGS_DEF(typename FieldAccessor) +APEX_CUDA_CALLABLE PX_INLINE float simulateParticle( + INPLACE_STORAGE_ARGS_DEF, SIM_INJECTOR_ARRAY injectorArray, + float deltaTime, + PxVec3 eyePos, + bool isNewParticle, + unsigned int srcIdx, + unsigned int dstIdx, + SIM_FLOAT4* memPositionMass, + SIM_FLOAT4* memVelocityLife, + SIM_FLOAT4* memCollisionNormalFlags, + uint32_t* memUserData, + IofxActorIDIntl* memIofxActorIDs, + float* memLifeSpan, + float* memLifeTime, + float* memDensity, + unsigned int* memInjector, + FieldAccessor& fieldAccessor, + unsigned int &injIndex, + const GridDensityParams params, +#ifdef __CUDACC__ + SIM_FLOAT4* memPxPosition, + SIM_FLOAT4* memPxVelocity, + SIM_FLOAT4* memPxCollision, + float* memPxDensity, + unsigned int* memNvFlags +#else + PxVec3& position, + PxVec3& velocity, + PxVec3& collisionNormal, + uint32_t& particleFlags, + float& density +#endif +) +{ + CPU_INPLACE_STORAGE_ARGS_UNUSED + PX_UNUSED(memCollisionNormalFlags); + PX_UNUSED(memDensity); + PX_UNUSED(fieldAccessor); + PX_UNUSED(params); + + float mass; +#ifdef __CUDACC__ + PxVec3 position; + PxVec3 velocity; + PxVec3 collisionNormal; + uint32_t particleFlags; + float density; +#endif + + //read + float lifeSpan = SIM_FETCH(LifeSpan, srcIdx); + unsigned int injector = SIM_FETCH(Injector, srcIdx); + IofxActorIDIntl iofxActorID = IofxActorIDIntl(SIM_FETCH(IofxActorIDs, srcIdx)); + + float lifeTime = lifeSpan; + if (!isNewParticle) + { + lifeTime = SIM_FETCH(LifeTime, srcIdx); + lifeTime = PxMax(lifeTime - deltaTime, 0.0f); + +#ifndef __CUDACC__ + mass = memPositionMass[srcIdx].w; + + /* Apply field sampler velocity */ + fieldAccessor(srcIdx, velocity); +#endif + } + else + { + collisionNormal = PxVec3(0.0f); + particleFlags = 0; + density = 0.0f; + splitFloat4(velocity, SIM_FETCH(VelocityLife, srcIdx)); +#ifdef __CUDACC__ + } + { +#endif + mass = splitFloat4(position, SIM_FETCH(PositionMass, srcIdx)); + } + +#ifdef __CUDACC__ + if (isNewParticle) + { + memPxPosition[dstIdx] = combineFloat4(position, 0); + memPxVelocity[dstIdx] = combineFloat4(velocity, 0); + + PxParticleFlagGpu flags; + flags.api = PxParticleFlag::eVALID; + flags.low = PxInternalParticleFlagGpu::eCUDA_NOTIFY_CREATE; + memNvFlags[dstIdx] = *((unsigned int*)&flags); + } + else + { + const SIM_FLOAT4 pxPosition = SIM_FETCH(PxPosition, srcIdx); + const SIM_FLOAT4 pxVelocity = SIM_FETCH(PxVelocity, srcIdx); + + if (memPxDensity) + { + density = SIM_FETCH(PxDensity, srcIdx); + memPxDensity[dstIdx] = density; + } + splitFloat4(position, pxPosition); + splitFloat4(velocity, pxVelocity); + + PxParticleFlagGpu flags; + *((uint32_t*)&flags) = SIM_FETCH(NvFlags, srcIdx); + + /* Apply field sampler velocity */ + fieldAccessor(srcIdx, velocity); + memPxVelocity[dstIdx] = combineFloat4(velocity, pxVelocity.w); + + splitFloat4(collisionNormal, SIM_FETCH(PxCollision, srcIdx)); + particleFlags = flags.api; + + if (dstIdx != srcIdx) + { + memPxPosition[dstIdx] = pxPosition; + + flags.low |= PxInternalParticleFlagGpu::eCUDA_NOTIFY_SET_POSITION; + memNvFlags[dstIdx] = *((uint32_t*)&flags); + } + } +#endif + + Px3InjectorParams injParams; + SIM_FETCH_INJECTOR(injectorArray, injParams, injector); + injIndex = injParams.mLocalIndex; + // injParams.mLODBias == FLT_MAX if injector was released! + // and IOFX returns IofxActorIDIntl::NO_VOLUME for homeless/dead particles + bool validActorID = (injParams.mLODBias < FLT_MAX) + && (isNewParticle || (iofxActorID.getVolumeID() != IofxActorIDIntl::NO_VOLUME)) + && position.isFinite() && velocity.isFinite(); + if (!validActorID) + { + iofxActorID.setActorClassID(IofxActorIDIntl::IPX_ACTOR); + injIndex = UINT32_MAX; + } + + //write + memLifeTime[dstIdx] = lifeTime; + memPositionMass[dstIdx] = combineFloat4(position, mass); + memVelocityLife[dstIdx] = combineFloat4(velocity, lifeTime / lifeSpan); + + const uint32_t collisionFlags = (particleFlags & uint32_t(PxParticleFlag::eCOLLISION_WITH_STATIC | PxParticleFlag::eCOLLISION_WITH_DYNAMIC)); + memCollisionNormalFlags[dstIdx] = combineFloat4(collisionNormal, SIM_INT_AS_FLOAT(collisionFlags)); + if (memDensity != 0) + { + memDensity[dstIdx] = density; + } + + if (!validActorID || dstIdx != srcIdx) + { + memIofxActorIDs[dstIdx] = iofxActorID; + } + if (dstIdx != srcIdx) + { + memLifeSpan[dstIdx] = lifeSpan; + memInjector[dstIdx] = injector; + + memUserData[dstIdx] = SIM_FETCH(UserData,srcIdx); + } + + float benefit = -FLT_MAX; + if (validActorID && lifeTime > 0.0f) + { + benefit = calcParticleBenefit(injParams, eyePos, position, velocity, lifeTime / lifeSpan); + } + return benefit; +} + +} +} // namespace nvidia + +#endif diff --git a/APEX_1.4/module/pxparticleios/include/ParticleIosScene.h b/APEX_1.4/module/pxparticleios/include/ParticleIosScene.h new file mode 100644 index 00000000..f1a131dd --- /dev/null +++ b/APEX_1.4/module/pxparticleios/include/ParticleIosScene.h @@ -0,0 +1,287 @@ +/* + * 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. + */ + + +#ifndef __PARTICLE_IOS_SCENE_H__ +#define __PARTICLE_IOS_SCENE_H__ + +#include "Apex.h" +#include "ModuleParticleIos.h" +#include "ApexSDKIntl.h" +#include "ModuleIntl.h" +#include "ModuleParticleIosImpl.h" +#include "ApexSharedUtils.h" +#include "ApexSDKHelpers.h" +#include "ApexContext.h" +#include "ApexActor.h" +#include "ModulePerfScope.h" + +#include "PsTime.h" + +#include "DebugRenderParams.h" +#include "ParticleIosDebugRenderParams.h" + +#include "ParticleIosCommon.h" + +#include "FieldSamplerQueryIntl.h" + +#if APEX_CUDA_SUPPORT +#include "ApexCudaWrapper.h" +#include "ApexCuda.h" +#include "CudaModuleScene.h" + +#include "../cuda/include/common.h" + +#define SCENE_CUDA_OBJ(scene, name) static_cast<ParticleIosSceneGPU&>(scene).APEX_CUDA_OBJ_NAME(name) + +#endif + +namespace nvidia +{ +namespace apex +{ +class RenderDebugInterface; +class FieldSamplerManagerIntl; +} + +namespace pxparticleios +{ + +class ParticleIosInjectorStorage +{ +public: + virtual bool growInjectorStorage(uint32_t newSize) = 0; +}; +class ParticleIosInjectorAllocator +{ +public: + ParticleIosInjectorAllocator(ParticleIosInjectorStorage* storage) : mStorage(storage) + { + mFreeInjectorListStart = NULL_INJECTOR_INDEX; + mReleasedInjectorListStart = NULL_INJECTOR_INDEX; + } + + uint32_t allocateInjectorID(); + void releaseInjectorID(uint32_t); + void flushReleased(); + + static const uint32_t NULL_INJECTOR_INDEX = 0xFFFFFFFFu; + static const uint32_t USED_INJECTOR_INDEX = 0xFFFFFFFEu; + +private: + ParticleIosInjectorStorage* mStorage; + + physx::Array<uint32_t> mInjectorList; + uint32_t mFreeInjectorListStart; + uint32_t mReleasedInjectorListStart; +}; + + +class ParticleIosScene : public ModuleSceneIntl, public ApexContext, public ApexResourceInterface, public ApexResource, protected ParticleIosInjectorStorage +{ +public: + ParticleIosScene(ModuleParticleIosImpl& module, SceneIntl& scene, RenderDebugInterface* renderDebug, ResourceList& list); + ~ParticleIosScene(); + + /* ModuleSceneIntl */ + void release() + { + mModule->releaseModuleSceneIntl(*this); + } + + PxScene* getModulePhysXScene() const + { + return mPhysXScene; + } + void setModulePhysXScene(PxScene*); + PxScene* mPhysXScene; + + void visualize(); + + virtual Module* getModule() + { + return mModule; + } + + virtual SceneStats* getStats() + { + return 0; + } + + bool lockRenderResources() + { + renderLockAllActors(); // Lock options not implemented yet + return true; + } + + bool unlockRenderResources() + { + renderUnLockAllActors(); // Lock options not implemented yet + return true; + } + + /* ApexResourceInterface */ + uint32_t getListIndex() const + { + return m_listIndex; + } + void setListIndex(ResourceList& list, uint32_t index) + { + m_listIndex = index; + m_list = &list; + } + + virtual ParticleIosActorImpl* createIosActor(ResourceList& list, ParticleIosAssetImpl& asset, IofxAsset& iofxAsset) = 0; + + void submitTasks(float elapsedTime, float substepSize, uint32_t numSubSteps); + void setTaskDependencies(); + void fetchResults(); + + FieldSamplerManagerIntl* getInternalFieldSamplerManager(); + SceneIntl& getApexScene() const + { + return *mApexScene; + } + PX_INLINE ParticleIosInjectorAllocator& getInjectorAllocator() + { + return mInjectorAllocator; + } + virtual void fetchInjectorParams(uint32_t injectorID, Px3InjectorParams& injParams) = 0; + virtual void updateInjectorParams(uint32_t injectorID, const Px3InjectorParams& injParams) = 0; + +protected: + virtual void onSimulationStart() {} + virtual void onSimulationFinish() + { + mInjectorAllocator.flushReleased(); + } + + void destroy(); + float computeAABBDistanceSquared(const PxBounds3& aabb); + + ModuleParticleIosImpl* mModule; + SceneIntl* mApexScene; + + RenderDebugInterface* mRenderDebug; + float mSumBenefit; + + DebugRenderParams* mDebugRenderParams; + ParticleIosDebugRenderParams* mParticleIosDebugRenderParams; + + FieldSamplerManagerIntl* mFieldSamplerManager; + + ParticleIosInjectorAllocator mInjectorAllocator; + + friend class ParticleIosActorImpl; + friend class ParticleIosAssetImpl; + friend class ModuleParticleIosImpl; +}; + +class ParticleIosSceneCPU : public ParticleIosScene +{ + class TimerCallback : public FieldSamplerCallbackIntl, public IofxManagerCallbackIntl, public UserAllocated + { + shdfnd::Time mTimer; + float mMinTime, mMaxTime; + public: + TimerCallback() {} + void operator()(void* stream = NULL); + void reset(); + float getElapsedTime() const; + }; +public: + ParticleIosSceneCPU(ModuleParticleIosImpl& module, SceneIntl& scene, RenderDebugInterface* debugRender, ResourceList& list); + ~ParticleIosSceneCPU(); + + virtual ParticleIosActorImpl* createIosActor(ResourceList& list, ParticleIosAssetImpl& asset, IofxAsset& iofxAsset); + + virtual void fetchInjectorParams(uint32_t injectorID, Px3InjectorParams& injParams) + { + PX_ASSERT(injectorID < mInjectorParamsArray.size()); + injParams = mInjectorParamsArray[ injectorID ]; + } + virtual void updateInjectorParams(uint32_t injectorID, const Px3InjectorParams& injParams) + { + PX_ASSERT(injectorID < mInjectorParamsArray.size()); + mInjectorParamsArray[ injectorID ] = injParams; + } + + void fetchResults(); + +protected: + virtual bool growInjectorStorage(uint32_t newSize) + { + mInjectorParamsArray.resize(newSize); + return true; + } + +private: + physx::Array<Px3InjectorParams> mInjectorParamsArray; + TimerCallback mTimerCallback; + + friend class ParticleIosActorCPU; +}; + +#if APEX_CUDA_SUPPORT +class ParticleIosSceneGPU : public ParticleIosScene, public CudaModuleScene +{ + class EventCallback : public FieldSamplerCallbackIntl, public IofxManagerCallbackIntl, public UserAllocated + { + void* mEvent; + public: + EventCallback(); + void init(); + virtual ~EventCallback(); + void operator()(void* stream); + PX_INLINE void* getEvent() + { + return mEvent; + } + bool mIsCalled; + }; +public: + ParticleIosSceneGPU(ModuleParticleIosImpl& module, SceneIntl& scene, RenderDebugInterface* debugRender, ResourceList& list); + ~ParticleIosSceneGPU(); + + virtual ParticleIosActorImpl* createIosActor(ResourceList& list, ParticleIosAssetImpl& asset, IofxAsset& iofxAsset); + + virtual void fetchInjectorParams(uint32_t injectorID, Px3InjectorParams& injParams); + virtual void updateInjectorParams(uint32_t injectorID, const Px3InjectorParams& injParams); + + void fetchResults(); + + void* getHeadCudaObj() + { + return CudaModuleScene::getHeadCudaObj(); + } +//CUDA module objects +#include "../cuda/include/moduleList.h" + +protected: + virtual bool growInjectorStorage(uint32_t newSize); + + void onSimulationStart(); + +private: + ApexCudaConstMemGroup mInjectorConstMemGroup; + InplaceHandle<InjectorParamsArray> mInjectorParamsArrayHandle; + + EventCallback mOnSimulationStart; + physx::Array<EventCallback*> mOnStartCallbacks; + physx::Array<EventCallback*> mOnFinishCallbacks; + + friend class ParticleIosActorGPU; +}; +#endif + +} +} // namespace nvidia + +#endif // __PARTICLE_IOS_SCENE_H__ diff --git a/APEX_1.4/module/pxparticleios/include/autogen/FluidParticleSystemParams.h b/APEX_1.4/module/pxparticleios/include/autogen/FluidParticleSystemParams.h new file mode 100644 index 00000000..3644a323 --- /dev/null +++ b/APEX_1.4/module/pxparticleios/include/autogen/FluidParticleSystemParams.h @@ -0,0 +1,232 @@ +// 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 + + +#ifndef HEADER_FluidParticleSystemParams_h +#define HEADER_FluidParticleSystemParams_h + +#include "NvParametersTypes.h" + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +#include "nvparameterized/NvParameterized.h" +#include "nvparameterized/NvParameterizedTraits.h" +#include "NvParameters.h" +#include "NvTraitsInternal.h" +#endif + +namespace nvidia +{ +namespace pxparticleios +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace FluidParticleSystemParamsNS +{ + + + +struct ParametersStruct +{ + + float restParticleDistance; + float stiffness; + float viscosity; + +}; + +static const uint32_t checksum[] = { 0x986c06bb, 0x7de711a7, 0xa8681094, 0x8ee8ef0b, }; + +} // namespace FluidParticleSystemParamsNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class FluidParticleSystemParams : public NvParameterized::NvParameters, public FluidParticleSystemParamsNS::ParametersStruct +{ +public: + FluidParticleSystemParams(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~FluidParticleSystemParams(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("FluidParticleSystemParams"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)0; + + static uint32_t staticVersion(void) + { + return ClassVersion; + } + + uint32_t version(void) const + { + return(staticVersion()); + } + + static const uint32_t ClassAlignment = 8; + + static const uint32_t* staticChecksum(uint32_t& bits) + { + bits = 8 * sizeof(FluidParticleSystemParamsNS::checksum); + return FluidParticleSystemParamsNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const FluidParticleSystemParamsNS::ParametersStruct& parameters(void) const + { + FluidParticleSystemParams* tmpThis = const_cast<FluidParticleSystemParams*>(this); + return *(static_cast<FluidParticleSystemParamsNS::ParametersStruct*>(tmpThis)); + } + + FluidParticleSystemParamsNS::ParametersStruct& parameters(void) + { + return *(static_cast<FluidParticleSystemParamsNS::ParametersStruct*>(this)); + } + + virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const; + virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle); + + void initDefaults(void); + +protected: + + virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void); + virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const; + + + virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const; + +private: + + void buildTree(void); + void initDynamicArrays(void); + void initStrings(void); + void initReferences(void); + void freeDynamicArrays(void); + void freeStrings(void); + void freeReferences(void); + + static bool mBuiltFlag; + static NvParameterized::MutexType mBuiltFlagMutex; +}; + +class FluidParticleSystemParamsFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + FluidParticleSystemParams::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(FluidParticleSystemParams), FluidParticleSystemParams::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, FluidParticleSystemParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class FluidParticleSystemParams"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(FluidParticleSystemParams)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, FluidParticleSystemParams)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, FluidParticleSystemParams::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, FluidParticleSystemParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class FluidParticleSystemParams"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of FluidParticleSystemParams here + // but it may call default constructors of members and spoil the data + NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount); + + // Init vtable (everything else is already initialized) + *(const char**)bufObj = vptr; + + return (FluidParticleSystemParams*)bufObj; + } + + virtual const char* getClassName() + { + return (FluidParticleSystemParams::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (FluidParticleSystemParams::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (FluidParticleSystemParams::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (FluidParticleSystemParams::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace pxparticleios +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/pxparticleios/include/autogen/ModuleParticleIosRegistration.h b/APEX_1.4/module/pxparticleios/include/autogen/ModuleParticleIosRegistration.h new file mode 100644 index 00000000..0b61d5b6 --- /dev/null +++ b/APEX_1.4/module/pxparticleios/include/autogen/ModuleParticleIosRegistration.h @@ -0,0 +1,126 @@ +/* + * 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. + */ + +#ifndef MODULE_MODULEPARTICLEIOSREGISTRATIONH_H +#define MODULE_MODULEPARTICLEIOSREGISTRATIONH_H + +#include "PsAllocator.h" +#include "NvRegistrationsForTraitsBase.h" +#include "nvparameterized/NvParameterizedTraits.h" +#include "PxAssert.h" +#include <stdint.h> + +// INCLUDE GENERATED FACTORIES +#include "ParticleIosModuleParameters.h" +#include "ParticleIosAssetParam.h" +#include "SimpleParticleSystemParams.h" +#include "FluidParticleSystemParams.h" +#include "ParticleIosDebugRenderParams.h" + + +// INCLUDE GENERATED CONVERSION + + +namespace nvidia { +namespace pxparticleios { + + +class ModuleParticleIosRegistration : public NvParameterized::RegistrationsForTraitsBase +{ +public: + static void invokeRegistration(NvParameterized::Traits* parameterizedTraits) + { + if (parameterizedTraits) + { + ModuleParticleIosRegistration().registerAll(*parameterizedTraits); + } + } + + static void invokeUnregistration(NvParameterized::Traits* parameterizedTraits) + { + if (parameterizedTraits) + { + ModuleParticleIosRegistration().unregisterAll(*parameterizedTraits); + } + } + + void registerAvailableFactories(NvParameterized::Traits& parameterizedTraits) + { + ::NvParameterized::Factory* factoriesToRegister[] = { +// REGISTER GENERATED FACTORIES + new nvidia::pxparticleios::ParticleIosModuleParametersFactory(), + new nvidia::pxparticleios::ParticleIosAssetParamFactory(), + new nvidia::pxparticleios::SimpleParticleSystemParamsFactory(), + new nvidia::pxparticleios::FluidParticleSystemParamsFactory(), + new nvidia::pxparticleios::ParticleIosDebugRenderParamsFactory(), + + }; + + for (size_t i = 0; i < sizeof(factoriesToRegister)/sizeof(factoriesToRegister[0]); ++i) + { + parameterizedTraits.registerFactory(*factoriesToRegister[i]); + } + } + + virtual void registerAvailableConverters(NvParameterized::Traits& parameterizedTraits) + { +// REGISTER GENERATED CONVERSION +PX_UNUSED(parameterizedTraits); + + } + + void unregisterAvailableFactories(NvParameterized::Traits& parameterizedTraits) + { + struct FactoryDesc + { + const char* name; + uint32_t version; + }; + + ::NvParameterized::Factory* factoriesToUnregister[] = { +// UNREGISTER GENERATED FACTORIES + new nvidia::pxparticleios::ParticleIosModuleParametersFactory(), + new nvidia::pxparticleios::ParticleIosAssetParamFactory(), + new nvidia::pxparticleios::SimpleParticleSystemParamsFactory(), + new nvidia::pxparticleios::FluidParticleSystemParamsFactory(), + new nvidia::pxparticleios::ParticleIosDebugRenderParamsFactory(), + + }; + + for (size_t i = 0; i < sizeof(factoriesToUnregister)/sizeof(factoriesToUnregister[0]); ++i) + { + ::NvParameterized::Factory* removedFactory = parameterizedTraits.removeFactory(factoriesToUnregister[i]->getClassName(), factoriesToUnregister[i]->getVersion()); + if (!removedFactory) + { + PX_ASSERT_WITH_MESSAGE(0, "Factory can not be removed!"); + } + else + { + removedFactory->freeParameterDefinitionTable(¶meterizedTraits); + delete removedFactory; + delete factoriesToUnregister[i]; + } + } + } + + virtual void unregisterAvailableConverters(NvParameterized::Traits& parameterizedTraits) + { +// UNREGISTER GENERATED CONVERSION +PX_UNUSED(parameterizedTraits); + + } + +}; + + +} +} //nvidia::pxparticleios + +#endif diff --git a/APEX_1.4/module/pxparticleios/include/autogen/ParticleIosAssetParam.h b/APEX_1.4/module/pxparticleios/include/autogen/ParticleIosAssetParam.h new file mode 100644 index 00000000..b0c021c7 --- /dev/null +++ b/APEX_1.4/module/pxparticleios/include/autogen/ParticleIosAssetParam.h @@ -0,0 +1,272 @@ +// 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 + + +#ifndef HEADER_ParticleIosAssetParam_h +#define HEADER_ParticleIosAssetParam_h + +#include "NvParametersTypes.h" + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +#include "nvparameterized/NvParameterized.h" +#include "nvparameterized/NvParameterizedTraits.h" +#include "NvParameters.h" +#include "NvTraitsInternal.h" +#endif + +namespace nvidia +{ +namespace pxparticleios +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace ParticleIosAssetParamNS +{ + +struct ParticleToGridCouplingParams_Type; +struct GridToParticleCouplingParams_Type; + +struct ParticleToGridCouplingParams_Type +{ + float accelTimeConstant; + float decelTimeConstant; + float thresholdMultiplier; +}; +struct GridToParticleCouplingParams_Type +{ + float accelTimeConstant; + float decelTimeConstant; + float thresholdMultiplier; +}; + +struct ParametersStruct +{ + + NvParameterized::Interface* particleType; + uint32_t maxParticleCount; + float particleRadius; + float maxInjectedParticleCount; + float maxMotionDistance; + float contactOffset; + float restOffset; + float gridSize; + float damping; + physx::PxVec3 externalAcceleration; + physx::PxVec3 projectionPlaneNormal; + float projectionPlaneDistance; + float particleMass; + float restitution; + float dynamicFriction; + float staticFriction; + NvParameterized::DummyStringStruct simulationFilterData; + NvParameterized::DummyStringStruct fieldSamplerFilterData; + bool CollisionTwoway; + bool CollisionWithDynamicActors; + bool Enable; + bool ProjectToPlane; + bool PerParticleRestOffset; + bool PerParticleCollisionCacheHint; + bool DensityBuffer; + bool enableTemperatureBuffer; + bool enableCouplingOverride; + ParticleToGridCouplingParams_Type particleToGridCoupling; + GridToParticleCouplingParams_Type gridToParticleCoupling; + +}; + +static const uint32_t checksum[] = { 0x2fe48a73, 0x7f6aafee, 0x621cd7cd, 0x20a3c0e5, }; + +} // namespace ParticleIosAssetParamNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class ParticleIosAssetParam : public NvParameterized::NvParameters, public ParticleIosAssetParamNS::ParametersStruct +{ +public: + ParticleIosAssetParam(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~ParticleIosAssetParam(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("ParticleIosAssetParam"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)4; + + static uint32_t staticVersion(void) + { + return ClassVersion; + } + + uint32_t version(void) const + { + return(staticVersion()); + } + + static const uint32_t ClassAlignment = 8; + + static const uint32_t* staticChecksum(uint32_t& bits) + { + bits = 8 * sizeof(ParticleIosAssetParamNS::checksum); + return ParticleIosAssetParamNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const ParticleIosAssetParamNS::ParametersStruct& parameters(void) const + { + ParticleIosAssetParam* tmpThis = const_cast<ParticleIosAssetParam*>(this); + return *(static_cast<ParticleIosAssetParamNS::ParametersStruct*>(tmpThis)); + } + + ParticleIosAssetParamNS::ParametersStruct& parameters(void) + { + return *(static_cast<ParticleIosAssetParamNS::ParametersStruct*>(this)); + } + + virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const; + virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle); + + void initDefaults(void); + +protected: + + virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void); + virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const; + + + virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const; + +private: + + void buildTree(void); + void initDynamicArrays(void); + void initStrings(void); + void initReferences(void); + void freeDynamicArrays(void); + void freeStrings(void); + void freeReferences(void); + + static bool mBuiltFlag; + static NvParameterized::MutexType mBuiltFlagMutex; +}; + +class ParticleIosAssetParamFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + ParticleIosAssetParam::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(ParticleIosAssetParam), ParticleIosAssetParam::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, ParticleIosAssetParam::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ParticleIosAssetParam"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(ParticleIosAssetParam)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, ParticleIosAssetParam)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, ParticleIosAssetParam::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, ParticleIosAssetParam::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ParticleIosAssetParam"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of ParticleIosAssetParam here + // but it may call default constructors of members and spoil the data + NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount); + + // Init vtable (everything else is already initialized) + *(const char**)bufObj = vptr; + + return (ParticleIosAssetParam*)bufObj; + } + + virtual const char* getClassName() + { + return (ParticleIosAssetParam::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (ParticleIosAssetParam::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (ParticleIosAssetParam::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (ParticleIosAssetParam::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace pxparticleios +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/pxparticleios/include/autogen/ParticleIosDebugRenderParams.h b/APEX_1.4/module/pxparticleios/include/autogen/ParticleIosDebugRenderParams.h new file mode 100644 index 00000000..5e223141 --- /dev/null +++ b/APEX_1.4/module/pxparticleios/include/autogen/ParticleIosDebugRenderParams.h @@ -0,0 +1,231 @@ +// 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 + + +#ifndef HEADER_ParticleIosDebugRenderParams_h +#define HEADER_ParticleIosDebugRenderParams_h + +#include "NvParametersTypes.h" + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +#include "nvparameterized/NvParameterized.h" +#include "nvparameterized/NvParameterizedTraits.h" +#include "NvParameters.h" +#include "NvTraitsInternal.h" +#endif + +namespace nvidia +{ +namespace pxparticleios +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace ParticleIosDebugRenderParamsNS +{ + + + +struct ParametersStruct +{ + + bool VISUALIZE_PARTICLE_IOS_ACTOR; + bool VISUALIZE_PARTICLE_IOS_GRID_DENSITY; + +}; + +static const uint32_t checksum[] = { 0x271c2489, 0x3bbc0436, 0x9f681969, 0x1c05e617, }; + +} // namespace ParticleIosDebugRenderParamsNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class ParticleIosDebugRenderParams : public NvParameterized::NvParameters, public ParticleIosDebugRenderParamsNS::ParametersStruct +{ +public: + ParticleIosDebugRenderParams(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~ParticleIosDebugRenderParams(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("ParticleIosDebugRenderParams"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)0; + + static uint32_t staticVersion(void) + { + return ClassVersion; + } + + uint32_t version(void) const + { + return(staticVersion()); + } + + static const uint32_t ClassAlignment = 8; + + static const uint32_t* staticChecksum(uint32_t& bits) + { + bits = 8 * sizeof(ParticleIosDebugRenderParamsNS::checksum); + return ParticleIosDebugRenderParamsNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const ParticleIosDebugRenderParamsNS::ParametersStruct& parameters(void) const + { + ParticleIosDebugRenderParams* tmpThis = const_cast<ParticleIosDebugRenderParams*>(this); + return *(static_cast<ParticleIosDebugRenderParamsNS::ParametersStruct*>(tmpThis)); + } + + ParticleIosDebugRenderParamsNS::ParametersStruct& parameters(void) + { + return *(static_cast<ParticleIosDebugRenderParamsNS::ParametersStruct*>(this)); + } + + virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const; + virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle); + + void initDefaults(void); + +protected: + + virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void); + virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const; + + + virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const; + +private: + + void buildTree(void); + void initDynamicArrays(void); + void initStrings(void); + void initReferences(void); + void freeDynamicArrays(void); + void freeStrings(void); + void freeReferences(void); + + static bool mBuiltFlag; + static NvParameterized::MutexType mBuiltFlagMutex; +}; + +class ParticleIosDebugRenderParamsFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + ParticleIosDebugRenderParams::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(ParticleIosDebugRenderParams), ParticleIosDebugRenderParams::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, ParticleIosDebugRenderParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ParticleIosDebugRenderParams"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(ParticleIosDebugRenderParams)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, ParticleIosDebugRenderParams)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, ParticleIosDebugRenderParams::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, ParticleIosDebugRenderParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ParticleIosDebugRenderParams"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of ParticleIosDebugRenderParams here + // but it may call default constructors of members and spoil the data + NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount); + + // Init vtable (everything else is already initialized) + *(const char**)bufObj = vptr; + + return (ParticleIosDebugRenderParams*)bufObj; + } + + virtual const char* getClassName() + { + return (ParticleIosDebugRenderParams::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (ParticleIosDebugRenderParams::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (ParticleIosDebugRenderParams::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (ParticleIosDebugRenderParams::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace pxparticleios +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/pxparticleios/include/autogen/ParticleIosModuleParameters.h b/APEX_1.4/module/pxparticleios/include/autogen/ParticleIosModuleParameters.h new file mode 100644 index 00000000..7cb8f445 --- /dev/null +++ b/APEX_1.4/module/pxparticleios/include/autogen/ParticleIosModuleParameters.h @@ -0,0 +1,230 @@ +// 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 + + +#ifndef HEADER_ParticleIosModuleParameters_h +#define HEADER_ParticleIosModuleParameters_h + +#include "NvParametersTypes.h" + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +#include "nvparameterized/NvParameterized.h" +#include "nvparameterized/NvParameterizedTraits.h" +#include "NvParameters.h" +#include "NvTraitsInternal.h" +#endif + +namespace nvidia +{ +namespace pxparticleios +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace ParticleIosModuleParametersNS +{ + + + +struct ParametersStruct +{ + + uint32_t unused; + +}; + +static const uint32_t checksum[] = { 0x53933c71, 0xf953550b, 0x814f74ec, 0x33f15b05, }; + +} // namespace ParticleIosModuleParametersNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class ParticleIosModuleParameters : public NvParameterized::NvParameters, public ParticleIosModuleParametersNS::ParametersStruct +{ +public: + ParticleIosModuleParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~ParticleIosModuleParameters(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("ParticleIosModuleParameters"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)0; + + static uint32_t staticVersion(void) + { + return ClassVersion; + } + + uint32_t version(void) const + { + return(staticVersion()); + } + + static const uint32_t ClassAlignment = 8; + + static const uint32_t* staticChecksum(uint32_t& bits) + { + bits = 8 * sizeof(ParticleIosModuleParametersNS::checksum); + return ParticleIosModuleParametersNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const ParticleIosModuleParametersNS::ParametersStruct& parameters(void) const + { + ParticleIosModuleParameters* tmpThis = const_cast<ParticleIosModuleParameters*>(this); + return *(static_cast<ParticleIosModuleParametersNS::ParametersStruct*>(tmpThis)); + } + + ParticleIosModuleParametersNS::ParametersStruct& parameters(void) + { + return *(static_cast<ParticleIosModuleParametersNS::ParametersStruct*>(this)); + } + + virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const; + virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle); + + void initDefaults(void); + +protected: + + virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void); + virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const; + + + virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const; + +private: + + void buildTree(void); + void initDynamicArrays(void); + void initStrings(void); + void initReferences(void); + void freeDynamicArrays(void); + void freeStrings(void); + void freeReferences(void); + + static bool mBuiltFlag; + static NvParameterized::MutexType mBuiltFlagMutex; +}; + +class ParticleIosModuleParametersFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + ParticleIosModuleParameters::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(ParticleIosModuleParameters), ParticleIosModuleParameters::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, ParticleIosModuleParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ParticleIosModuleParameters"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(ParticleIosModuleParameters)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, ParticleIosModuleParameters)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, ParticleIosModuleParameters::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, ParticleIosModuleParameters::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ParticleIosModuleParameters"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of ParticleIosModuleParameters here + // but it may call default constructors of members and spoil the data + NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount); + + // Init vtable (everything else is already initialized) + *(const char**)bufObj = vptr; + + return (ParticleIosModuleParameters*)bufObj; + } + + virtual const char* getClassName() + { + return (ParticleIosModuleParameters::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (ParticleIosModuleParameters::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (ParticleIosModuleParameters::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (ParticleIosModuleParameters::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace pxparticleios +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif diff --git a/APEX_1.4/module/pxparticleios/include/autogen/SimpleParticleSystemParams.h b/APEX_1.4/module/pxparticleios/include/autogen/SimpleParticleSystemParams.h new file mode 100644 index 00000000..bcc9f129 --- /dev/null +++ b/APEX_1.4/module/pxparticleios/include/autogen/SimpleParticleSystemParams.h @@ -0,0 +1,238 @@ +// 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 + + +#ifndef HEADER_SimpleParticleSystemParams_h +#define HEADER_SimpleParticleSystemParams_h + +#include "NvParametersTypes.h" + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +#include "nvparameterized/NvParameterized.h" +#include "nvparameterized/NvParameterizedTraits.h" +#include "NvParameters.h" +#include "NvTraitsInternal.h" +#endif + +namespace nvidia +{ +namespace pxparticleios +{ + +#if PX_VC +#pragma warning(push) +#pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + +namespace SimpleParticleSystemParamsNS +{ + +struct GridDensityParams_Type; + +struct GridDensityParams_Type +{ + bool Enabled; + const char* Resolution; + float GridSize; + uint32_t MaxCellCount; +}; + +struct ParametersStruct +{ + + GridDensityParams_Type GridDensity; + +}; + +static const uint32_t checksum[] = { 0xf872dc0a, 0x0e40cb32, 0x1627d31b, 0xfa23979d, }; + +} // namespace SimpleParticleSystemParamsNS + +#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS +class SimpleParticleSystemParams : public NvParameterized::NvParameters, public SimpleParticleSystemParamsNS::ParametersStruct +{ +public: + SimpleParticleSystemParams(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0); + + virtual ~SimpleParticleSystemParams(); + + virtual void destroy(); + + static const char* staticClassName(void) + { + return("SimpleParticleSystemParams"); + } + + const char* className(void) const + { + return(staticClassName()); + } + + static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)3; + + static uint32_t staticVersion(void) + { + return ClassVersion; + } + + uint32_t version(void) const + { + return(staticVersion()); + } + + static const uint32_t ClassAlignment = 8; + + static const uint32_t* staticChecksum(uint32_t& bits) + { + bits = 8 * sizeof(SimpleParticleSystemParamsNS::checksum); + return SimpleParticleSystemParamsNS::checksum; + } + + static void freeParameterDefinitionTable(NvParameterized::Traits* traits); + + const uint32_t* checksum(uint32_t& bits) const + { + return staticChecksum(bits); + } + + const SimpleParticleSystemParamsNS::ParametersStruct& parameters(void) const + { + SimpleParticleSystemParams* tmpThis = const_cast<SimpleParticleSystemParams*>(this); + return *(static_cast<SimpleParticleSystemParamsNS::ParametersStruct*>(tmpThis)); + } + + SimpleParticleSystemParamsNS::ParametersStruct& parameters(void) + { + return *(static_cast<SimpleParticleSystemParamsNS::ParametersStruct*>(this)); + } + + virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle) const; + virtual NvParameterized::ErrorType getParameterHandle(const char* long_name, NvParameterized::Handle& handle); + + void initDefaults(void); + +protected: + + virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void); + virtual const NvParameterized::DefinitionImpl* getParameterDefinitionTree(void) const; + + + virtual void getVarPtr(const NvParameterized::Handle& handle, void*& ptr, size_t& offset) const; + +private: + + void buildTree(void); + void initDynamicArrays(void); + void initStrings(void); + void initReferences(void); + void freeDynamicArrays(void); + void freeStrings(void); + void freeReferences(void); + + static bool mBuiltFlag; + static NvParameterized::MutexType mBuiltFlagMutex; +}; + +class SimpleParticleSystemParamsFactory : public NvParameterized::Factory +{ + static const char* const vptr; + +public: + + virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits) + { + SimpleParticleSystemParams::freeParameterDefinitionTable(traits); + } + + virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits) + { + // placement new on this class using mParameterizedTraits + + void* newPtr = paramTraits->alloc(sizeof(SimpleParticleSystemParams), SimpleParticleSystemParams::ClassAlignment); + if (!NvParameterized::IsAligned(newPtr, SimpleParticleSystemParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class SimpleParticleSystemParams"); + paramTraits->free(newPtr); + return 0; + } + + memset(newPtr, 0, sizeof(SimpleParticleSystemParams)); // always initialize memory allocated to zero for default values + return NV_PARAM_PLACEMENT_NEW(newPtr, SimpleParticleSystemParams)(paramTraits); + } + + virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount) + { + if (!NvParameterized::IsAligned(bufObj, SimpleParticleSystemParams::ClassAlignment) + || !NvParameterized::IsAligned(bufStart, SimpleParticleSystemParams::ClassAlignment)) + { + NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class SimpleParticleSystemParams"); + return 0; + } + + // Init NvParameters-part + // We used to call empty constructor of SimpleParticleSystemParams here + // but it may call default constructors of members and spoil the data + NV_PARAM_PLACEMENT_NEW(bufObj, NvParameterized::NvParameters)(paramTraits, bufStart, refCount); + + // Init vtable (everything else is already initialized) + *(const char**)bufObj = vptr; + + return (SimpleParticleSystemParams*)bufObj; + } + + virtual const char* getClassName() + { + return (SimpleParticleSystemParams::staticClassName()); + } + + virtual uint32_t getVersion() + { + return (SimpleParticleSystemParams::staticVersion()); + } + + virtual uint32_t getAlignment() + { + return (SimpleParticleSystemParams::ClassAlignment); + } + + virtual const uint32_t* getChecksum(uint32_t& bits) + { + return (SimpleParticleSystemParams::staticChecksum(bits)); + } +}; +#endif // NV_PARAMETERIZED_ONLY_LAYOUTS + +} // namespace pxparticleios +} // namespace nvidia + +#if PX_VC +#pragma warning(pop) +#endif + +#endif 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*>(¶meters()), 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*>(¶meters()), 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*>(¶meters()), 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*>(¶meters()), 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*>(¶meters()), 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 |