aboutsummaryrefslogtreecommitdiff
path: root/APEX_1.4/module/basicios
diff options
context:
space:
mode:
Diffstat (limited to 'APEX_1.4/module/basicios')
-rw-r--r--APEX_1.4/module/basicios/cuda/include/common.h63
-rw-r--r--APEX_1.4/module/basicios/cuda/include/compact.h17
-rw-r--r--APEX_1.4/module/basicios/cuda/include/histogram.h23
-rw-r--r--APEX_1.4/module/basicios/cuda/include/moduleList.h16
-rw-r--r--APEX_1.4/module/basicios/cuda/include/reduce.h19
-rw-r--r--APEX_1.4/module/basicios/cuda/include/scan.h25
-rw-r--r--APEX_1.4/module/basicios/cuda/include/simulate.h93
-rw-r--r--APEX_1.4/module/basicios/include/BasicIosActorCPU.h99
-rw-r--r--APEX_1.4/module/basicios/include/BasicIosActorGPU.h113
-rw-r--r--APEX_1.4/module/basicios/include/BasicIosActorImpl.h342
-rw-r--r--APEX_1.4/module/basicios/include/BasicIosAssetImpl.h333
-rw-r--r--APEX_1.4/module/basicios/include/BasicIosCommon.h201
-rw-r--r--APEX_1.4/module/basicios/include/BasicIosCommonSrc.h598
-rw-r--r--APEX_1.4/module/basicios/include/BasicIosScene.h194
-rw-r--r--APEX_1.4/module/basicios/include/BasicIosSceneCPU.h80
-rw-r--r--APEX_1.4/module/basicios/include/BasicIosSceneGPU.h93
-rw-r--r--APEX_1.4/module/basicios/include/ModuleBasicIosImpl.h139
-rw-r--r--APEX_1.4/module/basicios/include/ModuleEventDefs.h30
-rw-r--r--APEX_1.4/module/basicios/include/ModuleName.h17
-rw-r--r--APEX_1.4/module/basicios/include/ModulePerfScope.h18
-rw-r--r--APEX_1.4/module/basicios/include/autogen/BasicIOSAssetParam.h282
-rw-r--r--APEX_1.4/module/basicios/include/autogen/BasicIosDebugRenderParams.h232
-rw-r--r--APEX_1.4/module/basicios/include/autogen/BasicIosModuleParameters.h230
-rw-r--r--APEX_1.4/module/basicios/include/autogen/ModuleBasicIosRegistration.h120
-rw-r--r--APEX_1.4/module/basicios/src/BasicIosActorCPU.cpp318
-rw-r--r--APEX_1.4/module/basicios/src/BasicIosActorGPU.cpp802
-rw-r--r--APEX_1.4/module/basicios/src/BasicIosActorImpl.cpp1221
-rw-r--r--APEX_1.4/module/basicios/src/BasicIosAssetImpl.cpp196
-rw-r--r--APEX_1.4/module/basicios/src/BasicIosScene.cpp469
-rw-r--r--APEX_1.4/module/basicios/src/ModuleBasicIosImpl.cpp416
-rw-r--r--APEX_1.4/module/basicios/src/autogen/BasicIOSAssetParam.cpp1406
-rw-r--r--APEX_1.4/module/basicios/src/autogen/BasicIosDebugRenderParams.cpp358
-rw-r--r--APEX_1.4/module/basicios/src/autogen/BasicIosModuleParameters.cpp318
33 files changed, 8881 insertions, 0 deletions
diff --git a/APEX_1.4/module/basicios/cuda/include/common.h b/APEX_1.4/module/basicios/cuda/include/common.h
new file mode 100644
index 00000000..e530b9bc
--- /dev/null
+++ b/APEX_1.4/module/basicios/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 BasicIOS_
+
+#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 basicios
+{
+
+}
+} // namespace nvidia
+
+#endif
diff --git a/APEX_1.4/module/basicios/cuda/include/compact.h b/APEX_1.4/module/basicios/cuda/include/compact.h
new file mode 100644
index 00000000..f0313c09
--- /dev/null
+++ b/APEX_1.4/module/basicios/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/basicios/cuda/include/histogram.h b/APEX_1.4/module/basicios/cuda/include/histogram.h
new file mode 100644
index 00000000..ca45aa5e
--- /dev/null
+++ b/APEX_1.4/module/basicios/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/basicios/cuda/include/moduleList.h b/APEX_1.4/module/basicios/cuda/include/moduleList.h
new file mode 100644
index 00000000..8a8749ce
--- /dev/null
+++ b/APEX_1.4/module/basicios/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/basicios/cuda/include/reduce.h b/APEX_1.4/module/basicios/cuda/include/reduce.h
new file mode 100644
index 00000000..adde0ad7
--- /dev/null
+++ b/APEX_1.4/module/basicios/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/basicios/cuda/include/scan.h b/APEX_1.4/module/basicios/cuda/include/scan.h
new file mode 100644
index 00000000..12553c5f
--- /dev/null
+++ b/APEX_1.4/module/basicios/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/basicios/cuda/include/simulate.h b/APEX_1.4/module/basicios/cuda/include/simulate.h
new file mode 100644
index 00000000..5ade0039
--- /dev/null
+++ b/APEX_1.4/module/basicios/cuda/include/simulate.h
@@ -0,0 +1,93 @@
+/*
+ * 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(texRefConvexPlanes, float4)
+APEX_CUDA_TEXTURE_1D(texRefConvexVerts, float4)
+APEX_CUDA_TEXTURE_1D(texRefConvexPolygonsData, unsigned int)
+
+APEX_CUDA_TEXTURE_1D(texRefTrimeshIndices, unsigned int)
+APEX_CUDA_TEXTURE_1D(texRefTrimeshVerts, float4)
+
+APEX_CUDA_TEXTURE_1D(texRefHoleScanSum, unsigned int)
+APEX_CUDA_TEXTURE_1D(texRefMoveIndices, unsigned int)
+
+APEX_CUDA_TEXTURE_1D(texRefField, float4)
+
+
+APEX_CUDA_BOUND_KERNEL(SIMULATE_KERNEL_CONFIG, simulateKernel,
+ ((unsigned int, lastCount))((float, deltaTime))((physx::PxVec3, gravity))((physx::PxVec3, eyePos))
+ ((InplaceHandle<InjectorParamsArray>, injectorParamsArrayHandle))((unsigned int, injectorCount))
+ ((unsigned int*, g_holeScanSum))((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))((unsigned int*, g_injector))((IofxActorIDIntl*, g_iofxActorIDs))
+ ((float*, g_benefit))((InplaceHandle<SimulationParams>, paramsHandle))
+ )
+
+APEX_CUDA_BOUND_KERNEL(SIMULATE_KERNEL_CONFIG, simulateApplyFieldKernel,
+ ((unsigned int, lastCount))((float, deltaTime))((physx::PxVec3, gravity))((physx::PxVec3, eyePos))
+ ((InplaceHandle<InjectorParamsArray>, injectorParamsArrayHandle))((unsigned int, injectorCount))
+ ((APEX_MEM_BLOCK(unsigned int), g_holeScanSum))((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(unsigned int), g_injector))((APEX_MEM_BLOCK(IofxActorIDIntl), g_iofxActorIDs))
+ ((APEX_MEM_BLOCK(float), g_benefit))((InplaceHandle<SimulationParams>, paramsHandle))
+ )
+
+
+APEX_CUDA_BOUND_KERNEL((), mergeHistogramKernel,
+ ((APEX_MEM_BLOCK(unsigned int), g_InjectorsCounters))
+ ((APEX_MEM_BLOCK(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((), 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))
+ ) \ No newline at end of file
diff --git a/APEX_1.4/module/basicios/include/BasicIosActorCPU.h b/APEX_1.4/module/basicios/include/BasicIosActorCPU.h
new file mode 100644
index 00000000..c2aae8a6
--- /dev/null
+++ b/APEX_1.4/module/basicios/include/BasicIosActorCPU.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.
+ */
+
+
+#ifndef __BASIC_IOS_ACTOR_CPU_H__
+#define __BASIC_IOS_ACTOR_CPU_H__
+
+#include "Apex.h"
+
+#if ENABLE_TEST
+#include "BasicIosTestActor.h"
+#endif
+#include "BasicIosActorImpl.h"
+#include "BasicIosAssetImpl.h"
+#include "InstancedObjectSimulationIntl.h"
+#include "BasicIosSceneCPU.h"
+#include "ApexActor.h"
+#include "ApexContext.h"
+#include "ApexFIFO.h"
+#include "ApexRWLockable.h"
+#include "PxTask.h"
+
+namespace nvidia
+{
+namespace apex
+{
+class RenderVolume;
+}
+namespace basicios
+{
+
+#if ENABLE_TEST
+#define BASIC_IOS_ACTOR BasicIosTestActor
+#else
+#define BASIC_IOS_ACTOR BasicIosActorImpl
+#endif
+
+class BasicIosActorCPU : public BASIC_IOS_ACTOR
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ BasicIosActorCPU(ResourceList&, BasicIosAssetImpl&, BasicIosScene&, nvidia::apex::IofxAsset&);
+ ~BasicIosActorCPU();
+
+ virtual void submitTasks();
+ virtual void setTaskDependencies();
+ virtual void fetchResults();
+
+protected:
+ /* 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);
+
+private:
+ /* particle data (output to the IOFX actors, and some state) */
+
+ physx::Array<uint32_t> mNewIndices;
+
+ class SimulateTask : public PxTask
+ {
+ public:
+ SimulateTask(BasicIosActorCPU& actor) : mActor(actor) {}
+
+ const char* getName() const
+ {
+ return "BasicIosActorCPU::SimulateTask";
+ }
+ void run()
+ {
+ mActor.simulateParticles();
+ }
+
+ protected:
+ BasicIosActorCPU& mActor;
+
+ private:
+ SimulateTask& operator=(const SimulateTask&);
+ };
+ SimulateTask mSimulateTask;
+
+ nvidia::apex::ApexCpuInplaceStorage mSimulationStorage;
+
+ friend class BasicIosAssetImpl;
+};
+
+}
+} // namespace nvidia
+
+#endif // __BASIC_IOS_ACTOR_CPU_H__
diff --git a/APEX_1.4/module/basicios/include/BasicIosActorGPU.h b/APEX_1.4/module/basicios/include/BasicIosActorGPU.h
new file mode 100644
index 00000000..866df869
--- /dev/null
+++ b/APEX_1.4/module/basicios/include/BasicIosActorGPU.h
@@ -0,0 +1,113 @@
+/*
+ * 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 __BASIC_IOS_ACTOR_GPU_H__
+#define __BASIC_IOS_ACTOR_GPU_H__
+
+#include "Apex.h"
+
+#if ENABLE_TEST
+#include "BasicIosTestActor.h"
+#endif
+#include "BasicIosActorImpl.h"
+#include "BasicIosAssetImpl.h"
+#include "InstancedObjectSimulationIntl.h"
+#include "BasicIosSceneGPU.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 basicios
+{
+
+#if ENABLE_TEST
+#define BASIC_IOS_ACTOR BasicIosTestActor
+#else
+#define BASIC_IOS_ACTOR BasicIosActorImpl
+#endif
+
+class BasicIosActorGPU : public BASIC_IOS_ACTOR
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ BasicIosActorGPU(ResourceList&, BasicIosAssetImpl&, BasicIosScene&, nvidia::apex::IofxAsset&, const ApexMirroredPlace::Enum defaultPlace = ApexMirroredPlace::GPU);
+ ~BasicIosActorGPU();
+
+ virtual void submitTasks();
+ virtual void setTaskDependencies();
+ virtual void fetchResults();
+
+protected:
+ bool launch(CUstream stream, int kernelIndex);
+
+ PxGpuCopyDescQueue mCopyQueue;
+
+ 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;
+ ApexMirroredArray<uint32_t> mTmpOutput1;
+
+ class LaunchTask : public PxGpuTask
+ {
+ public:
+ LaunchTask(BasicIosActorGPU& actor) : mActor(actor) {}
+ const char* getName() const
+ {
+ return "BasicIosActorGPU::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:
+ BasicIosActorGPU& mActor;
+
+ private:
+ LaunchTask& operator=(const LaunchTask&);
+ };
+
+ static PX_CUDA_CALLABLE PX_INLINE PxMat44 inverse(const PxMat44& in);
+ static float distance(PxVec4 a, PxVec4 b);
+
+ LaunchTask mLaunchTask;
+};
+
+}
+} // namespace nvidia
+
+#endif // __BASIC_IOS_ACTOR_GPU_H__
diff --git a/APEX_1.4/module/basicios/include/BasicIosActorImpl.h b/APEX_1.4/module/basicios/include/BasicIosActorImpl.h
new file mode 100644
index 00000000..8a738ec4
--- /dev/null
+++ b/APEX_1.4/module/basicios/include/BasicIosActorImpl.h
@@ -0,0 +1,342 @@
+/*
+ * 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 __BASIC_IOS_ACTOR_IMPL_H__
+#define __BASIC_IOS_ACTOR_IMPL_H__
+
+#include "Apex.h"
+
+#include "BasicIosActor.h"
+#include "IofxActor.h"
+#include "BasicIosAssetImpl.h"
+#include "InstancedObjectSimulationIntl.h"
+#include "BasicIosScene.h"
+#include "ApexActor.h"
+#include "ApexContext.h"
+#include "ApexFIFO.h"
+#include "BasicIosCommon.h"
+#include "BasicIosCommonSrc.h"
+#include "InplaceStorage.h"
+#include "ApexMirroredArray.h"
+#include "ApexRand.h"
+
+#include <PxFiltering.h>
+
+#define MAX_CONVEX_PLANES_COUNT 4096
+#define MAX_CONVEX_VERTS_COUNT 4096
+#define MAX_CONVEX_POLYGONS_DATA_SIZE 16384
+
+#define MAX_TRIMESH_VERTS_COUNT 4096
+#define MAX_TRIMESH_INDICES_COUNT 16384
+
+namespace nvidia
+{
+namespace apex
+{
+ class FieldSamplerQueryIntl;
+ class FieldSamplerCallbackIntl;
+}
+namespace iofx
+{
+ class RenderVolume;
+}
+
+namespace basicios
+{
+
+/* Class for managing the interactions with each emitter */
+class BasicParticleInjector : public IosInjectorIntl, public ApexResourceInterface, public ApexResource
+{
+public:
+ void setPreferredRenderVolume(nvidia::apex::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;
+
+ virtual 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
+ {
+ return mSimulatedParticlesCount;
+ }
+
+ virtual void setObjectScale(float objectScale);
+
+protected:
+ BasicIosActorImpl* mIosActor;
+ IofxManagerClientIntl* mIofxClient;
+ nvidia::apex::RenderVolume* mVolume;
+ physx::Array<uint16_t> mRandomActorClassIDs;
+ uint32_t mLastRandomID;
+ uint16_t mVolumeID;
+
+ uint32_t mInjectorID;
+ uint32_t mSimulatedParticlesCount;
+
+ /* insertion buffer */
+ ApexFIFO<IosNewObject> mInjectedParticles;
+
+ QDSRand mRand;
+
+ BasicParticleInjector(ResourceList& list, BasicIosActorImpl& actor, uint32_t injectorID);
+ ~BasicParticleInjector();
+
+ void init(nvidia::apex::IofxAsset* iofxAsset);
+
+ friend class BasicIosActorImpl;
+};
+
+
+class BasicIosActorImpl : public InstancedObjectSimulationIntl,
+ public BasicIosActor,
+ public ApexResourceInterface,
+ public ApexResource,
+ public ApexRWLockable
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ BasicIosActorImpl(ResourceList& list, BasicIosAssetImpl& asset, BasicIosScene& scene, nvidia::apex::IofxAsset& iofxAsset, bool isDataOnDevice);
+ ~BasicIosActorImpl();
+
+ // ApexInterface API
+ void release();
+ void destroy();
+
+ // Actor API
+ void setPhysXScene(PxScene* s);
+ PxScene* getPhysXScene() const;
+ virtual void putInScene(PxScene* scene);
+
+ Asset* getOwner() const
+ {
+ return static_cast<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)
+ {
+ 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 mAsset->getParticleRadius();
+ }
+ float getObjectDensity() const
+ {
+ return mAsset->getRestDensity();
+ }
+
+ // BasicIosActor
+ float getParticleRadius() const
+ {
+ READ_ZONE();
+ return mAsset->getParticleRadius();
+ }
+ float getRestDensity() const
+ {
+ READ_ZONE();
+ return mAsset->getRestDensity();
+ }
+ uint32_t getParticleCount() const
+ {
+ READ_ZONE();
+ 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;
+
+ PxVec3 getGravity() const;
+ void setGravity(PxVec3& gravity);
+
+ void visualize();
+ virtual void submitTasks() = 0;
+ virtual void setTaskDependencies() = 0;
+ virtual void fetchResults();
+
+ IosInjectorIntl* allocateInjector(IofxAsset* iofxAsset);
+ void releaseInjector(IosInjectorIntl&);
+
+ virtual void setDensityOrigin(const PxVec3& v)
+ {
+ mDensityOrigin = v;
+ }
+
+
+protected:
+ //Member functions below have implemented in test actor
+ virtual bool checkBenefit(uint32_t totalCount) {PX_UNUSED(totalCount); return true;};
+ virtual bool checkHoles(uint32_t totalCount) {PX_UNUSED(totalCount); return true;};
+ virtual bool checkInState(uint32_t totalCount) {PX_UNUSED(totalCount); return true;};
+ virtual bool checkHistogram(uint32_t /*bound*/, uint32_t /*beg*/, uint32_t /*back*/) {return true;};
+
+ virtual void removeFromScene();
+
+ void injectNewParticles();
+
+ void initStorageGroups(InplaceStorage& storage);
+
+ void setTaskDependencies(PxTask* iosTask, bool isDataOnDevice);
+
+ void FillCollisionData(CollisionData& baseData, PxShape* shape);
+
+ BasicIosAssetImpl* mAsset;
+ BasicIosScene* mBasicIosScene;
+
+ IofxManagerIntl* mIofxMgr;
+ IosBufferDescIntl mBufDesc;
+
+ ResourceList mInjectorList;
+
+ PxVec3 mGravityVec;
+ 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<PxPlane> mConvexPlanes;
+ ApexMirroredArray<PxVec4> mConvexVerts;
+ ApexMirroredArray<uint32_t> mConvexPolygonsData;
+
+ ApexMirroredArray<PxVec4> mTrimeshVerts;
+ ApexMirroredArray<uint32_t> mTrimeshIndices;
+
+ ApexMirroredArray<uint32_t> mInjectorsCounters;
+
+ ApexMirroredArray<float> mGridDensityGrid;
+ ApexMirroredArray<float> mGridDensityGridLowPass;
+
+ GridDensityParams mGridDensityParams;
+ // Particle Density Origin
+ PxVec3 mDensityOrigin;
+ PxMat44 mDensityDebugMatInv;
+
+ // If true we are
+ bool mTrackGravityChanges;
+
+ // Only for use by the IOS Asset, the actor is unaware of this
+ bool mIsMesh;
+
+ FieldSamplerQueryIntl* mFieldSamplerQuery;
+ ApexMirroredArray<PxVec4> mField;
+
+ PxFilterData mCollisionFilterData;
+ Array<physx::PxOverlapHit> mOverlapHits;
+
+ InplaceStorageGroup mSimulationStorageGroup;
+ InplaceHandle<SimulationParams> mSimulationParamsHandle;
+
+ PxTask* mInjectTask;
+
+ FieldSamplerCallbackIntl* mOnStartCallback;
+ IofxManagerCallbackIntl* mOnFinishCallback;
+
+ friend class BasicIosInjectTask;
+
+ friend class BasicIosAssetImpl;
+ friend class BasicParticleInjector;
+};
+
+}
+} // namespace nvidia
+
+#endif // __BASIC_IOS_ACTOR_IMPL_H__
diff --git a/APEX_1.4/module/basicios/include/BasicIosAssetImpl.h b/APEX_1.4/module/basicios/include/BasicIosAssetImpl.h
new file mode 100644
index 00000000..766858c1
--- /dev/null
+++ b/APEX_1.4/module/basicios/include/BasicIosAssetImpl.h
@@ -0,0 +1,333 @@
+/*
+ * 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 BASIC_IOS_ASSET_IMPL_H
+#define BASIC_IOS_ASSET_IMPL_H
+
+#include "ApexUsingNamespace.h"
+#include "Apex.h"
+#include "IofxAsset.h"
+#include "BasicIosAsset.h"
+#include "InstancedObjectSimulationIntl.h"
+#include "ApexSDKHelpers.h"
+#include "ApexAssetAuthoring.h"
+#include "ApexString.h"
+#include "ResourceProviderIntl.h"
+#include "ApexAuthorableObject.h"
+#include "BasicIOSAssetParam.h"
+#include "ApexAssetTracker.h"
+#include "ApexRand.h"
+#include "ApexRWLockable.h"
+
+#include "ReadCheck.h"
+#include "ApexAuthorableObject.h"
+
+namespace nvidia
+{
+namespace IOFX
+{
+class IofxAsset;
+}
+
+namespace basicios
+{
+
+class ModuleBasicIosImpl;
+class BasicIosActorImpl;
+
+/**
+\brief Descriptor needed to create a BasicIOS Actor
+*/
+class BasicIosActorDesc : 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 BasicIosActorDesc() : 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 BasicIosAssetImpl : public BasicIosAsset,
+ public ApexResourceInterface,
+ public ApexResource,
+ public ApexRWLockable
+{
+ friend class BasicIosAssetDummyAuthoring;
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ BasicIosAssetImpl(ModuleBasicIosImpl*, ResourceList&, const char*);
+ BasicIosAssetImpl(ModuleBasicIosImpl* module, ResourceList&, NvParameterized::Interface*, const char*);
+ ~BasicIosAssetImpl();
+
+ // Asset
+ void release();
+ const char* getName(void) const
+ {
+ return mName.c_str();
+ }
+ AuthObjTypeID getObjTypeID() const
+ {
+ return mAssetTypeID;
+ }
+ const char* getObjTypeName() const
+ {
+ return getClassName();
+ }
+ // TODO: implement forceLoadAssets
+ uint32_t forceLoadAssets();
+
+ Actor* createIosActor(Scene& scene, IofxAsset* iofxAsset);
+ void releaseIosActor(Actor&);
+ bool getSupportsDensity() const;
+
+ // Private API for this module only
+ BasicIosActorImpl* 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
+ {
+ READ_ZONE();
+ return mParams->restDensity;
+ }
+ float getMaxInjectedParticleCount() const
+ {
+ READ_ZONE();
+ return mParams->maxInjectedParticleCount;
+ }
+ uint32_t getMaxParticleCount() const
+ {
+ READ_ZONE();
+ return mParams->maxParticleCount;
+ }
+ float getSceneGravityScale() const
+ {
+ return mParams->sceneGravityScale;
+ }
+ PxVec3& getExternalAcceleration() const
+ {
+ return mParams->externalAcceleration;
+ }
+ float getParticleMass() const;
+
+ const NvParameterized::Interface* getAssetNvParameterized() const
+ {
+ 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()
+ {
+ APEX_INVALID_OPERATION("Not yet implemented!");
+ return NULL;
+ }
+
+ NvParameterized::Interface* getDefaultAssetPreviewDesc()
+ {
+ APEX_INVALID_OPERATION("Not yet implemented!");
+ return NULL;
+ }
+
+ virtual Actor* createApexActor(const NvParameterized::Interface& /*parms*/, Scene& /*apexScene*/)
+ {
+ APEX_INVALID_OPERATION("Not yet implemented!");
+ return NULL;
+ }
+
+ virtual AssetPreview* createApexAssetPreview(const NvParameterized::Interface& /*params*/, AssetPreviewScene* /*previewScene*/)
+ {
+ APEX_INVALID_OPERATION("Not yet implemented!");
+ return NULL;
+ }
+
+ virtual bool isValidForActorCreation(const ::NvParameterized::Interface& /*parms*/, Scene& /*apexScene*/) const
+ {
+ return true; // TODO implement this method
+ }
+
+ virtual bool isDirty() const
+ {
+ return false;
+ }
+
+protected:
+ virtual void destroy();
+
+ static AuthObjTypeID mAssetTypeID;
+ static const char* getClassName()
+ {
+ return BASIC_IOS_AUTHORING_TYPE_NAME;
+ }
+
+ ResourceList mIosActorList;
+
+ ModuleBasicIosImpl* mModule;
+ ApexSimpleString mName;
+
+ BasicIOSAssetParam* mParams;
+
+ mutable QDSRand mSRand;
+ mutable QDNormRand mNormRand;
+
+ enum
+ {
+ UNIFORM,
+ NORMAL
+ } mMassDistribType;
+
+ void processParams();
+
+ friend class ModuleBasicIosImpl;
+ friend class BasicIosActorImpl;
+ friend class BasicIosActorCPU;
+ friend class BasicIosActorGPU;
+ template <class T_Module, class T_Asset, class T_AssetAuthoring> friend class nvidia::apex::ApexAuthorableObject;
+ friend class BasicIosAuthorableObject;
+};
+
+#ifndef WITHOUT_APEX_AUTHORING
+class BasicIosAssetAuthoringImpl : public BasicIosAssetAuthoring, public ApexAssetAuthoring, public BasicIosAssetImpl
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ BasicIosAssetAuthoringImpl(ModuleBasicIosImpl* module, ResourceList& list);
+ BasicIosAssetAuthoringImpl(ModuleBasicIosImpl* module, ResourceList& list, const char* name);
+ BasicIosAssetAuthoringImpl(ModuleBasicIosImpl* module, ResourceList& list, NvParameterized::Interface* params, const char* name);
+
+ virtual void release();
+
+ const char* getName(void) const
+ {
+ return BasicIosAssetImpl::getName();
+ }
+ const char* getObjTypeName() const
+ {
+ return BasicIosAssetImpl::getClassName();
+ }
+ virtual bool prepareForPlatform(nvidia::apex::PlatformTag)
+ {
+ APEX_INVALID_OPERATION("Not Implemented.");
+ return false;
+ }
+ void setToolString(const char* toolName, const char* toolVersion, uint32_t toolChangelist)
+ {
+ 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.center = 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 // BASIC_IOS_ASSET_IMPL_H
diff --git a/APEX_1.4/module/basicios/include/BasicIosCommon.h b/APEX_1.4/module/basicios/include/BasicIosCommon.h
new file mode 100644
index 00000000..8b038518
--- /dev/null
+++ b/APEX_1.4/module/basicios/include/BasicIosCommon.h
@@ -0,0 +1,201 @@
+/*
+ * 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 __BASIC_IOS_COMMON_H__
+#define __BASIC_IOS_COMMON_H__
+
+#include "PxMat44.h"
+#include "PxBounds3.h"
+#include "PxVec3.h"
+#include "InplaceTypes.h"
+
+namespace nvidia
+{
+ namespace apex
+ {
+ class ApexCpuInplaceStorage;
+ }
+ namespace basicios
+ {
+
+//struct InjectorParams
+#define INPLACE_TYPE_STRUCT_NAME InjectorParams
+#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<InjectorParams> InjectorParamsArray;
+
+//struct CollisionData
+#define INPLACE_TYPE_STRUCT_NAME CollisionData
+#define INPLACE_TYPE_STRUCT_FIELDS \
+ INPLACE_TYPE_FIELD(PxVec3, bodyCMassPosition) \
+ INPLACE_TYPE_FIELD(PxVec3, bodyLinearVelocity) \
+ INPLACE_TYPE_FIELD(PxVec3, bodyAngluarVelocity) \
+ INPLACE_TYPE_FIELD(float, materialRestitution)
+#include INPLACE_TYPE_BUILD()
+
+//struct CollisionSphereData
+#define INPLACE_TYPE_STRUCT_NAME CollisionSphereData
+#define INPLACE_TYPE_STRUCT_BASE CollisionData
+#define INPLACE_TYPE_STRUCT_FIELDS \
+ INPLACE_TYPE_FIELD(PxBounds3, aabb) \
+ INPLACE_TYPE_FIELD(PxTransform, pose) \
+ INPLACE_TYPE_FIELD(PxTransform, inversePose) \
+ INPLACE_TYPE_FIELD(float, radius)
+#include INPLACE_TYPE_BUILD()
+
+//struct CollisionCapsuleData
+#define INPLACE_TYPE_STRUCT_NAME CollisionCapsuleData
+#define INPLACE_TYPE_STRUCT_BASE CollisionData
+#define INPLACE_TYPE_STRUCT_FIELDS \
+ INPLACE_TYPE_FIELD(PxBounds3, aabb) \
+ INPLACE_TYPE_FIELD(PxTransform, pose) \
+ INPLACE_TYPE_FIELD(PxTransform, inversePose) \
+ INPLACE_TYPE_FIELD(float, halfHeight) \
+ INPLACE_TYPE_FIELD(float, radius)
+#include INPLACE_TYPE_BUILD()
+
+//struct CollisionBoxData
+#define INPLACE_TYPE_STRUCT_NAME CollisionBoxData
+#define INPLACE_TYPE_STRUCT_BASE CollisionData
+#define INPLACE_TYPE_STRUCT_FIELDS \
+ INPLACE_TYPE_FIELD(PxBounds3, aabb) \
+ INPLACE_TYPE_FIELD(PxTransform, pose) \
+ INPLACE_TYPE_FIELD(PxTransform, inversePose) \
+ INPLACE_TYPE_FIELD(PxVec3, halfSize)
+#include INPLACE_TYPE_BUILD()
+
+//struct CollisionHalfSpaceData
+#define INPLACE_TYPE_STRUCT_NAME CollisionHalfSpaceData
+#define INPLACE_TYPE_STRUCT_BASE CollisionData
+#define INPLACE_TYPE_STRUCT_FIELDS \
+ INPLACE_TYPE_FIELD(PxVec3, normal) \
+ INPLACE_TYPE_FIELD(PxVec3, origin)
+#include INPLACE_TYPE_BUILD()
+
+//struct CollisionConvexMeshData
+#define INPLACE_TYPE_STRUCT_NAME CollisionConvexMeshData
+#define INPLACE_TYPE_STRUCT_BASE CollisionData
+#define INPLACE_TYPE_STRUCT_FIELDS \
+ INPLACE_TYPE_FIELD(PxBounds3, aabb) \
+ INPLACE_TYPE_FIELD(PxTransform, pose) \
+ INPLACE_TYPE_FIELD(PxTransform, inversePose) \
+ INPLACE_TYPE_FIELD(uint32_t, numPolygons) \
+ INPLACE_TYPE_FIELD(uint32_t, firstPlane) \
+ INPLACE_TYPE_FIELD(uint32_t, firstVertex) \
+ INPLACE_TYPE_FIELD(uint32_t, polygonsDataOffset)
+#include INPLACE_TYPE_BUILD()
+
+//struct CollisionTriMeshData
+#define INPLACE_TYPE_STRUCT_NAME CollisionTriMeshData
+#define INPLACE_TYPE_STRUCT_BASE CollisionData
+#define INPLACE_TYPE_STRUCT_FIELDS \
+ INPLACE_TYPE_FIELD(PxBounds3, aabb) \
+ INPLACE_TYPE_FIELD(PxTransform, pose) \
+ INPLACE_TYPE_FIELD(PxTransform, inversePose) \
+ INPLACE_TYPE_FIELD(uint32_t, numTriangles) \
+ INPLACE_TYPE_FIELD(uint32_t, firstIndex) \
+ INPLACE_TYPE_FIELD(uint32_t, firstVertex)
+#include INPLACE_TYPE_BUILD()
+
+//struct SimulationParams
+#define INPLACE_TYPE_STRUCT_NAME SimulationParams
+#define INPLACE_TYPE_STRUCT_FIELDS \
+ INPLACE_TYPE_FIELD(float, collisionThreshold) \
+ INPLACE_TYPE_FIELD(float, collisionDistance) \
+ INPLACE_TYPE_FIELD(InplaceArray<CollisionBoxData>, boxes) \
+ INPLACE_TYPE_FIELD(InplaceArray<CollisionSphereData>, spheres) \
+ INPLACE_TYPE_FIELD(InplaceArray<CollisionCapsuleData>, capsules) \
+ INPLACE_TYPE_FIELD(InplaceArray<CollisionHalfSpaceData>, halfSpaces) \
+ INPLACE_TYPE_FIELD(InplaceArray<CollisionConvexMeshData>, convexMeshes) \
+ INPLACE_TYPE_FIELD(InplaceArray<CollisionTriMeshData>, trimeshes) \
+ INPLACE_TYPE_FIELD(PxPlane*, convexPlanes) \
+ INPLACE_TYPE_FIELD(PxVec4*, convexVerts) \
+ INPLACE_TYPE_FIELD(uint32_t*, convexPolygonsData) \
+ INPLACE_TYPE_FIELD(PxVec4*, trimeshVerts) \
+ INPLACE_TYPE_FIELD(uint32_t*, trimeshIndices)
+#define INPLACE_TYPE_STRUCT_LEAVE_OPEN 1
+#include INPLACE_TYPE_BUILD()
+
+ APEX_CUDA_CALLABLE PX_INLINE SimulationParams() : convexPlanes(NULL), convexVerts(NULL), convexPolygonsData(NULL) {}
+ };
+
+
+ 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;
+ };
+
+#ifdef __CUDACC__
+
+#define SIM_FETCH_PLANE(plane, name, idx) { float4 f4 = tex1Dfetch(KERNEL_TEX_REF(name), idx); plane = PxPlane(f4.x, f4.y, f4.z, f4.w); }
+#define SIM_FETCH(name, idx) tex1Dfetch(KERNEL_TEX_REF(name), idx)
+#define SIM_FLOAT4 float4
+#define SIM_INT_AS_FLOAT(x) __int_as_float(x)
+#define SIM_INJECTOR_ARRAY const InjectorParamsArray&
+#define SIM_FETCH_INJECTOR(injectorArray, injParams, injector) injectorArray.fetchElem(INPLACE_STORAGE_ARGS_VAL, injParams, injector)
+
+ __device__ 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;
+ }
+ __device__ PX_INLINE SIM_FLOAT4 combineFloat4(const PxVec3& v3, float w)
+ {
+ return make_float4(v3.x, v3.y, v3.z, w);
+ }
+#else
+
+#define SIM_FETCH_PLANE(plane, name, idx) plane = mem##name[idx];
+#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 InjectorParams*
+#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
+
+ }
+} // namespace nvidia
+
+#endif
diff --git a/APEX_1.4/module/basicios/include/BasicIosCommonSrc.h b/APEX_1.4/module/basicios/include/BasicIosCommonSrc.h
new file mode 100644
index 00000000..2d1458ce
--- /dev/null
+++ b/APEX_1.4/module/basicios/include/BasicIosCommonSrc.h
@@ -0,0 +1,598 @@
+/*
+ * 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 __BASIC_IOS_COMMON_SRC_H__
+#define __BASIC_IOS_COMMON_SRC_H__
+
+namespace nvidia
+{
+ namespace basicios
+ {
+
+ PX_CUDA_CALLABLE PX_INLINE void updateCollisionVelocity(const CollisionData& data, const PxVec3& normal, const PxVec3& position, PxVec3& velocity)
+ {
+ PxVec3 bodyVelocity = data.bodyLinearVelocity + data.bodyAngluarVelocity.cross(position - data.bodyCMassPosition);
+
+ velocity -= bodyVelocity;
+ float normalVelocity = normal.dot(velocity);
+ if (normalVelocity < 0.0f)
+ {
+ velocity -= normal * ((1.0f + data.materialRestitution) * normalVelocity);
+ }
+ velocity += bodyVelocity;
+ }
+
+
+ PX_CUDA_CALLABLE PX_INLINE void calculatePointSegmentSquaredDist(const PxVec3& a, const PxVec3& b, const PxVec3& point, float& distanceSquared, PxVec3& nearestPoint) // a, b - segment points
+ {
+ PxVec3 v, w, temp; //vectors
+ float c1, c2, ratio; //constants
+ v = a - b;
+ w = point - b;
+ float distSquared = 0;
+
+ c1 = w.dot(v);
+ if(c1 <= 0)
+ {
+ distSquared = (point.x - b.x) * (point.x - b.x) + (point.y - b.y) * (point.y - b.y) + (point.z - b.z) * (point.z - b.z);
+ nearestPoint = b;
+ }
+ else
+ {
+ c2 = v.dot(v);
+ if(c2 <= c1)
+ {
+ distSquared = (point.x - a.x) * (point.x - a.x) + (point.y - a.y) * (point.y - a.y) + (point.z - a.z) * (point.z - a.z);
+ nearestPoint = a;
+ }
+ else
+ {
+ ratio = c1 / c2;
+ temp = b + ratio * v;
+ distSquared = (point.x - temp.x) * (point.x - temp.x) + (point.y - temp.y) * (point.y - temp.y) + (point.z - temp.z) * (point.z - temp.z);
+ nearestPoint = temp;
+ }
+ }
+
+ distanceSquared = distSquared;
+ }
+
+#ifdef __CUDACC__
+ __device__
+#endif
+ PX_INLINE float checkTriangleCollision(const PxVec4* memTrimeshVerts, const uint32_t* memTrimeshIndices, const CollisionTriMeshData& data, float radius, PxVec3 localPosition, PxVec3 &normal)
+ {
+ float minDistSquared = PX_MAX_F32;
+ PxVec3 localNormal(0);
+
+ for(uint32_t j = 0 ; j < data.numTriangles; j++)
+ {
+ PxVec3 p0, p1, p2;
+ uint32_t i0, i1, i2;
+ i0 = SIM_FETCH(TrimeshIndices, data.firstIndex + 3 * j);
+ i1 = SIM_FETCH(TrimeshIndices, data.firstIndex + 3 * j + 1);
+ i2 = SIM_FETCH(TrimeshIndices, data.firstIndex + 3 * j + 2);
+ splitFloat4(p0, SIM_FETCH(TrimeshVerts, data.firstVertex + i0));
+ splitFloat4(p1, SIM_FETCH(TrimeshVerts, data.firstVertex + i1));
+ splitFloat4(p2, SIM_FETCH(TrimeshVerts, data.firstVertex + i2));
+
+ //localNormal = (p1 - p0).cross(p2 - p0);
+ //if(radius > 0) localNormal += localPosition;
+
+ PxBounds3 aabb( (p0.minimum(p1.minimum(p2))), (p0.maximum(p1.maximum(p2))) );
+ aabb.fattenFast( radius );
+ if( !aabb.contains(localPosition) ) continue;
+
+ p0 = p0 - localPosition;
+ p1 = p1 - localPosition;
+ p2 = p2 - localPosition;
+
+ PxVec3 a(p1 - p0);
+ PxVec3 b(p2 - p0);
+ PxVec3 n = a.cross(b);
+ n.normalize();
+
+ //check if point far away from the triangle's plane, then give up
+ if(n.x * p0.x + n.y * p0.y + n.z * p0.z > radius) continue;
+
+ //check if the nearest point is one of the triangle's vertices
+ PxVec3 closestPoint; // closest point
+
+ float det1p0p1, det2p0p2, det2p1p2, det0p0p1, det0p0p2, det1p1p2;
+ //i = 0
+ det1p0p1 = p0.dot(-(p1 - p0));
+ det2p0p2 = p0.dot(-(p2 - p0));
+ //i = 1
+ det0p0p1 = p1.dot(p1 - p0);
+ det2p1p2 = p1.dot(-(p2 - p1));
+ //i = 2
+ det0p0p2 = p2.dot(p2 - p0);
+ det1p1p2 = p2.dot(p2 - p1);
+
+ if(det1p0p1 <= 0 && det2p0p2 <= 0) closestPoint = p0;
+ else if(det0p0p1 <= 0 && det2p1p2 <= 0) closestPoint = p1;
+ else if(det0p0p2 <= 0 && det1p1p2 <= 0) closestPoint = p2;
+ else
+ {
+ //check if the nearest point is internal point of one of the triangle's edges
+ float det0p0p1p2, det1p0p1p2, det2p0p1p2;
+ det0p0p1p2 = det0p0p1 * det1p1p2 + det2p1p2 * p2.dot(p1 - p0);
+ det1p0p1p2 = det1p0p1 * det0p0p2 - det2p0p2 * p2.dot(p1 - p0);
+ det2p0p1p2 = det2p0p2 * det0p0p1 - det1p0p1 * p1.dot(p2 - p0);
+
+ if(det0p0p1p2 <= 0) closestPoint = (p1 * det1p1p2 + p2 * det2p1p2) / (det1p1p2 + det2p1p2);
+ else if(det1p0p1p2 <= 0) closestPoint = (p0 * det0p0p2 + p2 * det2p0p2) / (det0p0p2 + det2p0p2);
+ else if(det2p0p1p2 <= 0) closestPoint = (p0 * det0p0p1 + p1 * det1p0p1) / (det0p0p1 + det1p0p1);
+ //point is inside the triangle
+ else closestPoint = (p0 * det0p0p1p2 + p1 * det1p0p1p2 + p2 * det2p0p1p2) / (det0p0p1p2 + det1p0p1p2 + det2p0p1p2);
+ }
+
+ float distSquared = closestPoint.x * closestPoint.x + closestPoint.y * closestPoint.y + closestPoint.z * closestPoint.z;
+ if(distSquared > radius * radius)
+ {
+ continue;
+ }
+
+ if(distSquared < minDistSquared)
+ {
+ minDistSquared = distSquared;
+ localNormal = n;
+ }
+ }
+ normal = localNormal;
+
+ return minDistSquared;
+ }
+
+ INPLACE_TEMPL_ARGS_DEF
+#ifdef __CUDACC__
+ __device__
+#endif
+ PX_INLINE uint32_t handleCollisions(const SimulationParams* params, INPLACE_STORAGE_ARGS_DEF, PxVec3& position, PxVec3& velocity, PxVec3& normal)
+ {
+ const PxPlane* memConvexPlanes = params->convexPlanes;
+ const PxVec4* memConvexVerts = params->convexVerts;
+ const uint32_t* memConvexPolygonsData = params->convexPolygonsData;
+
+ // Algorithms are similar to CPU version
+ const PxVec4* memTrimeshVerts = params->trimeshVerts;
+ const uint32_t* memTrimeshIndices = params->trimeshIndices;
+
+ float collisionRadius = params->collisionDistance + params->collisionThreshold;
+
+ uint32_t numTriMeshes = params->trimeshes.getSize();
+ for (uint32_t i = 0; i < numTriMeshes; ++i)
+ {
+ CollisionTriMeshData data;
+ params->trimeshes.fetchElem(INPLACE_STORAGE_ARGS_VAL, data, i);
+
+ if (!data.aabb.contains(position)) //check coarse bounds
+ {
+ continue;
+ }
+
+ PxVec3 localPosition = data.inversePose.transform(position);
+
+ PxVec3 localNormal;
+ float minDistSquared = checkTriangleCollision(memTrimeshVerts, memTrimeshIndices, data, collisionRadius, localPosition, localNormal);
+ if (minDistSquared == PX_MAX_F32)
+ {
+ continue;
+ }
+
+ float penDepth = params->collisionDistance - PxSqrt(minDistSquared);
+
+ if( penDepth > 0 )
+ {
+ localPosition += localNormal * penDepth;
+ normal = data.pose.rotate(localNormal);
+ position = data.pose.transform(localPosition);
+ updateCollisionVelocity(data, normal, position, velocity);
+ }
+ return 1;
+ }
+
+ uint32_t numConvexMeshes = params->convexMeshes.getSize();
+ for (uint32_t i = 0; i < numConvexMeshes; ++i)
+ {
+ CollisionConvexMeshData data;
+ params->convexMeshes.fetchElem(INPLACE_STORAGE_ARGS_VAL, data, i);
+
+ if (!data.aabb.contains(position)) //check coarse bounds
+ {
+ continue;
+ }
+
+ PxVec3 localPosition = data.inversePose.transform(position);
+
+ float penDepth = UINT32_MAX;
+ PxVec3 localNormal(0);
+
+ bool insideConvex = true;
+ bool insidePolygon = true;
+ float distSquaredMin = UINT32_MAX;
+ PxVec3 nearestPointMin;
+
+ uint32_t polygonsDataOffset = data.polygonsDataOffset;
+ for (uint32_t polyId = 0; polyId < data.numPolygons; polyId++) // for each polygon
+ {
+ PxPlane plane;
+ SIM_FETCH_PLANE(plane, ConvexPlanes, data.firstPlane + polyId);
+
+ uint32_t vertCount = SIM_FETCH(ConvexPolygonsData, polygonsDataOffset);
+
+ float dist = (localPosition.dot(plane.n) + plane.d);
+ if (dist > 0) //outside convex
+ {
+ insideConvex = false;
+
+ if (dist > collisionRadius)
+ {
+ insidePolygon = false;
+ distSquaredMin = dist * dist;
+ break;
+ }
+
+ insidePolygon = true;
+ PxVec3 polygonNormal = plane.n;
+
+ uint32_t begVertId = SIM_FETCH(ConvexPolygonsData, polygonsDataOffset + vertCount);
+ PxVec3 begVert; splitFloat4(begVert, SIM_FETCH(ConvexVerts, data.firstVertex + begVertId));
+ for (uint32_t vertId = 1; vertId <= vertCount; ++vertId) //for each vertex
+ {
+ uint32_t endVertId = SIM_FETCH(ConvexPolygonsData, polygonsDataOffset + vertId);
+ PxVec3 endVert; splitFloat4(endVert, SIM_FETCH(ConvexVerts, data.firstVertex + endVertId));
+
+ PxVec3 segment = endVert - begVert;
+ PxVec3 segmentNormal = polygonNormal.cross(segment);
+ float sign = segmentNormal.dot(localPosition - begVert);
+ if (sign < 0)
+ {
+ insidePolygon = false;
+
+ float distSquared;
+ PxVec3 nearestPoint;
+ calculatePointSegmentSquaredDist(begVert, endVert, localPosition, distSquared, nearestPoint);
+ if (distSquared < distSquaredMin)
+ {
+ distSquaredMin = distSquared;
+ nearestPointMin = nearestPoint;
+ }
+ }
+
+ begVert = endVert;
+ }
+ if (insidePolygon)
+ {
+ penDepth = params->collisionDistance - dist;
+ localNormal = polygonNormal;
+ break;
+ }
+ }
+
+ if (insideConvex)
+ {
+ float penDepthPlane = params->collisionDistance - dist; //dist is negative inside
+ if (penDepthPlane < penDepth) //inside convex
+ {
+ penDepth = penDepthPlane;
+ localNormal = plane.n;
+ }
+ }
+ polygonsDataOffset += (vertCount + 1);
+ }
+
+ if (!insideConvex && !insidePolygon)
+ {
+ if (distSquaredMin > collisionRadius * collisionRadius)
+ {
+ continue; //no intersection, too far away
+ }
+ float dist = PxSqrt(distSquaredMin);
+
+ localNormal = localPosition - nearestPointMin;
+ localNormal *= (1 / dist); //normalize
+
+ penDepth = params->collisionDistance - dist;
+ }
+
+ if (penDepth > 0)
+ {
+ localPosition += localNormal * penDepth;
+ normal = data.pose.rotate(localNormal);
+ position = data.pose.transform(localPosition);
+ updateCollisionVelocity(data, normal, position, velocity);
+ }
+ return 1;
+ }
+
+ uint32_t numBoxes = params->boxes.getSize();
+ for (uint32_t i = 0; i < numBoxes; ++i)
+ {
+ CollisionBoxData data;
+ params->boxes.fetchElem(INPLACE_STORAGE_ARGS_VAL, data, i);
+
+ if (!data.aabb.contains(position))
+ {
+ continue;
+ }
+
+ PxVec3 localPosition = data.inversePose.transform(position);
+
+
+ PxVec3 closestPoint = PxVec3(PxClamp(localPosition.x, -data.halfSize.x, data.halfSize.x), PxClamp(localPosition.y, -data.halfSize.y, data.halfSize.y), PxClamp(localPosition.z, -data.halfSize.z, data.halfSize.z));
+ PxVec3 v = localPosition - closestPoint;
+ float vMagnitudeSquared = v.magnitudeSquared();
+ if(vMagnitudeSquared > collisionRadius * collisionRadius) continue; //no intersection
+
+ PxBounds3 bounds = PxBounds3(-data.halfSize, data.halfSize);
+ float penDepth;
+
+ PxVec3 localNormal(0);
+ if(vMagnitudeSquared > 0)
+ {
+ float vMagnitude = PxSqrt(vMagnitudeSquared);
+ localNormal = v * (1 / vMagnitude);
+
+ penDepth = params->collisionDistance - vMagnitude;
+ }
+ else
+ {
+ PxVec3 penDepth3D = PxVec3(
+ data.halfSize.x - PxAbs(localPosition.x),
+ data.halfSize.y - PxAbs(localPosition.y),
+ data.halfSize.z - PxAbs(localPosition.z)
+ );
+ float penDepth3Dmin = penDepth3D.minElement();
+
+ if (penDepth3Dmin == penDepth3D.x)
+ {
+ localNormal.x = localPosition.x < 0 ? -1.0f : 1.0f;
+ }
+ else if (penDepth3Dmin == penDepth3D.y)
+ {
+ localNormal.y = localPosition.y < 0 ? -1.0f : 1.0f;
+ }
+ else if (penDepth3Dmin == penDepth3D.z)
+ {
+ localNormal.z = localPosition.z < 0 ? -1.0f : 1.0f;
+ }
+
+ penDepth = params->collisionDistance + penDepth3Dmin;
+ }
+
+ normal = data.pose.rotate(localNormal);
+
+ if (penDepth > 0)
+ {
+ localPosition += localNormal * penDepth;
+ position = data.pose.transform(localPosition);
+
+ updateCollisionVelocity(data, normal, position, velocity);
+ }
+ return 1;
+ }
+
+ uint32_t numCapsules = params->capsules.getSize();
+ for (uint32_t i = 0; i < numCapsules; ++i)
+ {
+ CollisionCapsuleData data;
+ params->capsules.fetchElem(INPLACE_STORAGE_ARGS_VAL, data, i);
+
+ if (!data.aabb.contains(position))
+ {
+ continue;
+ }
+
+ PxVec3 localPosition = data.inversePose.transform(position);
+
+ // Capsule is Minkowski sum of sphere with segment
+ const float closestX = PxClamp(localPosition.x, -data.halfHeight, data.halfHeight);
+ PxVec3 localNormal(localPosition.x - closestX, localPosition.y, localPosition.z);
+
+ float distance = localNormal.magnitude();
+ float penDepth = (data.radius - distance);
+ // No intersection?
+ if (-penDepth > params->collisionThreshold)
+ {
+ continue;
+ }
+ if (distance > 0) // avoid division by zero
+ {
+ localNormal /= distance;
+ }
+ normal = data.pose.rotate(localNormal);
+
+ if (penDepth > 0)
+ {
+ localPosition = data.radius * localNormal;
+ localPosition.x += closestX;
+
+ position = data.pose.transform(localPosition);
+
+ updateCollisionVelocity(data, normal, position, velocity);
+ }
+ return 1;
+ }
+
+ uint32_t numSpheres = params->spheres.getSize();
+ for (uint32_t i = 0; i < numSpheres; ++i)
+ {
+ CollisionSphereData data;
+ params->spheres.fetchElem(INPLACE_STORAGE_ARGS_VAL, data, i);
+
+ if (!data.aabb.contains(position))
+ {
+ continue;
+ }
+
+ PxVec3 localNormal = data.inversePose.transform(position);
+ float distance = localNormal.magnitude();
+
+ float penDepth = (data.radius - distance);
+ // No intersection?
+ if (-penDepth > params->collisionThreshold)
+ {
+ continue;
+ }
+ localNormal /= distance;
+ normal = data.pose.rotate(localNormal);
+
+ if (penDepth > 0)
+ {
+ position = data.pose.transform(data.radius * localNormal);
+
+ updateCollisionVelocity(data, normal, position, velocity);
+ }
+ return 1;
+ }
+
+ uint32_t numHalfSpaces = params->halfSpaces.getSize();
+ for (uint32_t i = 0; i < numHalfSpaces; ++i)
+ {
+ CollisionHalfSpaceData data;
+ params->halfSpaces.fetchElem(INPLACE_STORAGE_ARGS_VAL, data, i);
+
+ float penDepth = (data.origin - position).dot(data.normal);
+
+ // No intersection?
+ if (-penDepth > params->collisionThreshold)
+ {
+ continue;
+ }
+
+ normal = data.normal;
+ if (penDepth > 0)
+ {
+ position += penDepth * data.normal;
+
+ updateCollisionVelocity(data, normal, position, velocity);
+ }
+ return 1;
+ }
+
+ return 0;
+ }
+
+
+
+#ifdef __CUDACC__
+ __device__
+#endif
+ PX_INLINE float calcParticleBenefit(
+ const InjectorParams& 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)
+#ifdef __CUDACC__
+ __device__
+#endif
+ PX_INLINE float simulateParticle(
+ const SimulationParams* params, INPLACE_STORAGE_ARGS_DEF, SIM_INJECTOR_ARRAY injectorArray,
+ float deltaTime, PxVec3 gravity, PxVec3 eyePos,
+ bool isNewParticle, unsigned int srcIdx, unsigned int dstIdx,
+ SIM_FLOAT4* memPositionMass, SIM_FLOAT4* memVelocityLife, IofxActorIDIntl* memIofxActorIDs,
+ float* memLifeSpan, float* memLifeTime, unsigned int* memInjector, SIM_FLOAT4* memCollisionNormalFlags, uint32_t* memUserData,
+ FieldAccessor& fieldAccessor, unsigned int &injIndex
+ )
+ {
+ //read
+ PxVec3 position;
+ PxVec3 velocity;
+ float mass = splitFloat4(position, SIM_FETCH(PositionMass, srcIdx));
+ splitFloat4(velocity, SIM_FETCH(VelocityLife, srcIdx));
+ float lifeSpan = SIM_FETCH(LifeSpan, srcIdx);
+ unsigned int injector = SIM_FETCH(Injector, srcIdx);
+ IofxActorIDIntl iofxActorID = IofxActorIDIntl(SIM_FETCH(IofxActorIDs, srcIdx));
+
+ PxVec3 collisionNormal(0.0f);
+ uint32_t collisionFlags = 0;
+
+ float lifeTime = lifeSpan;
+ if (!isNewParticle)
+ {
+ using namespace nvidia::apex;
+
+ lifeTime = SIM_FETCH(LifeTime, srcIdx);
+
+ //collide using the old state
+ collisionFlags = handleCollisions INPLACE_TEMPL_ARGS_VAL (params, INPLACE_STORAGE_ARGS_VAL, position, velocity, collisionNormal);
+
+ //advance to a new state
+ PxVec3 velocityDelta = deltaTime * gravity;
+ fieldAccessor(srcIdx, velocityDelta);
+
+ velocity += velocityDelta;
+ position += deltaTime * velocity;
+
+ lifeTime = PxMax(lifeTime - deltaTime, 0.0f);
+ }
+
+ InjectorParams 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;
+
+ if (!isNewParticle || dstIdx != srcIdx)
+ {
+ memPositionMass[dstIdx] = combineFloat4(position, mass);
+ memVelocityLife[dstIdx] = combineFloat4(velocity, lifeTime / lifeSpan);
+ }
+ if (!validActorID || dstIdx != srcIdx)
+ {
+ memIofxActorIDs[dstIdx] = iofxActorID;
+ }
+ if (dstIdx != srcIdx)
+ {
+ memLifeSpan[dstIdx] = lifeSpan;
+ memInjector[dstIdx] = injector;
+
+ memUserData[dstIdx] = SIM_FETCH(UserData, srcIdx);
+ }
+ memCollisionNormalFlags[dstIdx] = combineFloat4(collisionNormal, SIM_INT_AS_FLOAT(collisionFlags));
+
+ 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/basicios/include/BasicIosScene.h b/APEX_1.4/module/basicios/include/BasicIosScene.h
new file mode 100644
index 00000000..32691b3f
--- /dev/null
+++ b/APEX_1.4/module/basicios/include/BasicIosScene.h
@@ -0,0 +1,194 @@
+/*
+ * 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 __BASIC_IOS_SCENE_H__
+#define __BASIC_IOS_SCENE_H__
+
+#include "Apex.h"
+#include "ModuleBasicIos.h"
+#include "ApexSDKIntl.h"
+#include "ModuleIntl.h"
+#include "ModuleBasicIosImpl.h"
+#include "ApexSharedUtils.h"
+#include "ApexSDKHelpers.h"
+#include "ApexContext.h"
+#include "ApexActor.h"
+#include "ModulePerfScope.h"
+
+#include "PsTime.h"
+
+#include "DebugRenderParams.h"
+#include "BasicIosDebugRenderParams.h"
+
+#include "BasicIosCommon.h"
+#include "BasicIosCommonSrc.h"
+
+#include "FieldSamplerQueryIntl.h"
+
+#if APEX_CUDA_SUPPORT
+#include "../cuda/include/common.h"
+
+#include "ApexCudaWrapper.h"
+#include "CudaModuleScene.h"
+
+#define SCENE_CUDA_OBJ(scene, name) static_cast<BasicIosSceneGPU&>(scene).APEX_CUDA_OBJ_NAME(name)
+
+#endif
+
+namespace nvidia
+{
+namespace apex
+{
+class RenderDebugInterface;
+class FieldSamplerManagerIntl;
+}
+namespace basicios
+{
+
+class BasicIosInjectorStorage
+{
+public:
+ virtual bool growInjectorStorage(uint32_t newSize) = 0;
+};
+class BasicIosInjectorAllocator
+{
+public:
+ BasicIosInjectorAllocator(BasicIosInjectorStorage* 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:
+ BasicIosInjectorStorage* mStorage;
+
+ physx::Array<uint32_t> mInjectorList;
+ uint32_t mFreeInjectorListStart;
+ uint32_t mReleasedInjectorListStart;
+};
+
+
+class BasicIosScene : public ModuleSceneIntl, public ApexContext, public ApexResourceInterface, public ApexResource, protected BasicIosInjectorStorage
+{
+public:
+ BasicIosScene(ModuleBasicIosImpl& module, SceneIntl& scene, RenderDebugInterface* renderDebug, ResourceList& list);
+ ~BasicIosScene();
+
+ /* 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 BasicIosActorImpl* createIosActor(ResourceList& list, BasicIosAssetImpl& asset, nvidia::apex::IofxAsset& iofxAsset) = 0;
+
+ virtual void submitTasks(float elapsedTime, float substepSize, uint32_t numSubSteps);
+ virtual void setTaskDependencies();
+ virtual void fetchResults();
+
+ FieldSamplerManagerIntl* getInternalFieldSamplerManager();
+
+ SceneIntl& getApexScene() const
+ {
+ return *mApexScene;
+ }
+
+ PX_INLINE BasicIosInjectorAllocator& getInjectorAllocator()
+ {
+ return mInjectorAllocator;
+ }
+ virtual void fetchInjectorParams(uint32_t injectorID, InjectorParams& injParams) = 0;
+ virtual void updateInjectorParams(uint32_t injectorID, const InjectorParams& injParams) = 0;
+
+protected:
+ virtual void onSimulationStart() {}
+ virtual void onSimulationFinish()
+ {
+ mInjectorAllocator.flushReleased();
+ }
+
+
+ ModuleBasicIosImpl* mModule;
+ SceneIntl* mApexScene;
+
+ void destroy();
+
+ float computeAABBDistanceSquared(const PxBounds3& aabb);
+
+ RenderDebugInterface* mDebugRender;
+ float mSumBenefit;
+
+ DebugRenderParams* mDebugRenderParams;
+ BasicIosDebugRenderParams* mBasicIosDebugRenderParams;
+
+ FieldSamplerManagerIntl* mFieldSamplerManager;
+
+ BasicIosInjectorAllocator mInjectorAllocator;
+
+ friend class BasicIosActorImpl;
+ friend class BasicIosAssetImpl;
+ friend class ModuleBasicIosImpl;
+};
+
+
+}
+} // namespace nvidia
+
+#endif // __BASIC_IOS_SCENE_H__
diff --git a/APEX_1.4/module/basicios/include/BasicIosSceneCPU.h b/APEX_1.4/module/basicios/include/BasicIosSceneCPU.h
new file mode 100644
index 00000000..d0c5913f
--- /dev/null
+++ b/APEX_1.4/module/basicios/include/BasicIosSceneCPU.h
@@ -0,0 +1,80 @@
+/*
+ * 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 __BASIC_IOS_SCENE_CPU_H__
+#define __BASIC_IOS_SCENE_CPU_H__
+
+#if ENABLE_TEST
+#include "BasicIosTestScene.h"
+#endif
+#include "BasicIosScene.h"
+
+namespace nvidia
+{
+namespace basicios
+{
+
+#if ENABLE_TEST
+#define BASIC_IOS_SCENE BasicIosTestScene
+#else
+#define BASIC_IOS_SCENE BasicIosScene
+#endif
+
+class BasicIosSceneCPU : public BASIC_IOS_SCENE
+{
+ 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:
+ BasicIosSceneCPU(ModuleBasicIosImpl& module, SceneIntl& scene, RenderDebugInterface* debugRender, ResourceList& list);
+ ~BasicIosSceneCPU();
+
+ virtual BasicIosActorImpl* createIosActor(ResourceList& list, BasicIosAssetImpl& asset, nvidia::apex::IofxAsset& iofxAsset);
+
+ virtual void fetchInjectorParams(uint32_t injectorID, InjectorParams& injParams)
+ {
+ PX_ASSERT(injectorID < mInjectorParamsArray.size());
+ injParams = mInjectorParamsArray[ injectorID ];
+ }
+ virtual void updateInjectorParams(uint32_t injectorID, const InjectorParams& injParams)
+ {
+ PX_ASSERT(injectorID < mInjectorParamsArray.size());
+ mInjectorParamsArray[ injectorID ] = injParams;
+ }
+
+ void fetchResults();
+
+protected:
+ virtual void setCallbacks(BasicIosActorCPU* actor);
+ virtual bool growInjectorStorage(uint32_t newSize)
+ {
+ mInjectorParamsArray.resize(newSize);
+ return true;
+ }
+
+private:
+ physx::Array<InjectorParams> mInjectorParamsArray;
+ TimerCallback mTimerCallback;
+
+ friend class BasicIosActorCPU;
+};
+
+}
+} // namespace nvidia
+
+#endif // __BASIC_IOS_SCENE_H__
diff --git a/APEX_1.4/module/basicios/include/BasicIosSceneGPU.h b/APEX_1.4/module/basicios/include/BasicIosSceneGPU.h
new file mode 100644
index 00000000..26fa5f51
--- /dev/null
+++ b/APEX_1.4/module/basicios/include/BasicIosSceneGPU.h
@@ -0,0 +1,93 @@
+/*
+ * 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 __BASIC_IOS_SCENE_GPU_H__
+#define __BASIC_IOS_SCENE_GPU_H__
+
+#if ENABLE_TEST
+#include "BasicIosTestScene.h"
+#endif
+#include "BasicIosScene.h"
+
+#include "../cuda/include/common.h"
+
+#include "ApexCudaWrapper.h"
+#include "CudaModuleScene.h"
+
+#define SCENE_CUDA_OBJ(scene, name) static_cast<BasicIosSceneGPU&>(scene).APEX_CUDA_OBJ_NAME(name)
+
+namespace nvidia
+{
+namespace basicios
+{
+
+#if ENABLE_TEST
+#define BASIC_IOS_SCENE BasicIosTestScene
+#else
+#define BASIC_IOS_SCENE BasicIosScene
+#endif
+
+class BasicIosSceneGPU : public BASIC_IOS_SCENE, 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:
+ BasicIosSceneGPU(ModuleBasicIosImpl& module, SceneIntl& scene, RenderDebugInterface* debugRender, ResourceList& list);
+ ~BasicIosSceneGPU();
+
+ virtual BasicIosActorImpl* createIosActor(ResourceList& list, BasicIosAssetImpl& asset, nvidia::apex::IofxAsset& iofxAsset);
+
+ virtual void fetchInjectorParams(uint32_t injectorID, InjectorParams& injParams);
+ virtual void updateInjectorParams(uint32_t injectorID, const InjectorParams& injParams);
+
+ virtual void fetchResults();
+
+ void* getHeadCudaObj()
+ {
+ return CudaModuleScene::getHeadCudaObj();
+ }
+
+//CUDA module objects
+#include "../cuda/include/moduleList.h"
+
+protected:
+ virtual void setCallbacks(BasicIosActorGPU* actor);
+ 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 BasicIosActorGPU;
+};
+
+}
+} // namespace nvidia
+
+#endif // __BASIC_IOS_SCENE_H__
diff --git a/APEX_1.4/module/basicios/include/ModuleBasicIosImpl.h b/APEX_1.4/module/basicios/include/ModuleBasicIosImpl.h
new file mode 100644
index 00000000..c0543e77
--- /dev/null
+++ b/APEX_1.4/module/basicios/include/ModuleBasicIosImpl.h
@@ -0,0 +1,139 @@
+/*
+ * 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_BASIC_IOS_IMPL_H__
+#define __MODULE_BASIC_IOS_IMPL_H__
+
+#include "Apex.h"
+#include "ModuleBasicIos.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 "BasicIosAssetImpl.h"
+#include "ModuleBasicIosRegistration.h"
+#include "ApexRWLockable.h"
+
+namespace nvidia
+{
+namespace apex
+{
+class ModuleIofxIntl;
+class ModuleFieldSamplerIntl;
+}
+namespace basicios
+{
+
+class BasicIosScene;
+
+/**
+\brief ModuleBase descriptor for BasicIOS module
+*/
+class ModuleBasicIosDesc : public ApexDesc
+{
+public:
+
+ /**
+ \brief constructor sets to default.
+ */
+ PX_INLINE ModuleBasicIosDesc() : 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 ModuleBasicIosImpl : public ModuleBasicIos, public ModuleIntl, public ModuleBase, public ApexRWLockable
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ ModuleBasicIosImpl(ApexSDKIntl* sdk);
+ ~ModuleBasicIosImpl();
+
+ void init(const ModuleBasicIosDesc& desc);
+
+ // base class methods
+ void init(NvParameterized::Interface&);
+ NvParameterized::Interface* getDefaultModuleDesc();
+ void release()
+ {
+ ModuleBase::release();
+ }
+ void destroy();
+ const char* getName() const
+ {
+ return ModuleBase::getName();
+ }
+
+ //BasicIosActor * 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* getBasicIosTypeName();
+
+ BasicIosScene* getBasicIosScene(const Scene& scene);
+ const BasicIosScene* getBasicIosScene(const Scene& scene) const;
+
+ ModuleIofxIntl* getInternalModuleIofx();
+ ModuleFieldSamplerIntl* getInternalModuleFieldSampler();
+
+ const TestBase* getTestBase(Scene* apexScene) const;
+
+protected:
+
+ ResourceList mBasicIosSceneList;
+ ResourceList mAuthorableObjects;
+
+ friend class BasicIosScene;
+private:
+ BasicIosModuleParameters* mModuleParams;
+
+ ModuleIofxIntl* mIofxModule;
+ ModuleFieldSamplerIntl* mFieldSamplerModule;
+};
+
+}
+} // namespace nvidia
+
+#endif // __MODULE_BASIC_IOS_IMPL_H__
diff --git a/APEX_1.4/module/basicios/include/ModuleEventDefs.h b/APEX_1.4/module/basicios/include/ModuleEventDefs.h
new file mode 100644
index 00000000..cf9f4171
--- /dev/null
+++ b/APEX_1.4/module/basicios/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(BasicIosSceneFetchResults)
+DEFINE_EVENT(BasicIosCreateObjects)
+DEFINE_EVENT(BasicIosFetchResults)
+
+
diff --git a/APEX_1.4/module/basicios/include/ModuleName.h b/APEX_1.4/module/basicios/include/ModuleName.h
new file mode 100644
index 00000000..6620ac06
--- /dev/null
+++ b/APEX_1.4/module/basicios/include/ModuleName.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.
+ */
+
+
+#ifndef __MODULE_NAME_H___
+#define __MODULE_NAME_H___
+
+#define MODULE_NAMESPACE basicios
+
+#endif \ No newline at end of file
diff --git a/APEX_1.4/module/basicios/include/ModulePerfScope.h b/APEX_1.4/module/basicios/include/ModulePerfScope.h
new file mode 100644
index 00000000..fe58f327
--- /dev/null
+++ b/APEX_1.4/module/basicios/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 basicios
+#include "ModuleProfileCommon.h"
+
+#endif \ No newline at end of file
diff --git a/APEX_1.4/module/basicios/include/autogen/BasicIOSAssetParam.h b/APEX_1.4/module/basicios/include/autogen/BasicIOSAssetParam.h
new file mode 100644
index 00000000..4e66e462
--- /dev/null
+++ b/APEX_1.4/module/basicios/include/autogen/BasicIOSAssetParam.h
@@ -0,0 +1,282 @@
+// 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_BasicIOSAssetParam_h
+#define HEADER_BasicIOSAssetParam_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 basicios
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace BasicIOSAssetParamNS
+{
+
+struct RandomF32_Type;
+struct GridDensityParams_Type;
+struct ParticleToGridCouplingParams_Type;
+struct GridToParticleCouplingParams_Type;
+
+struct ParticleToGridCouplingParams_Type
+{
+ float accelTimeConstant;
+ float decelTimeConstant;
+ float thresholdMultiplier;
+};
+struct GridDensityParams_Type
+{
+ bool Enabled;
+ const char* Resolution;
+ float GridSize;
+ uint32_t MaxCellCount;
+};
+struct GridToParticleCouplingParams_Type
+{
+ float accelTimeConstant;
+ float decelTimeConstant;
+ float thresholdMultiplier;
+};
+struct RandomF32_Type
+{
+ float center;
+ float spread;
+ const char* type;
+};
+
+struct ParametersStruct
+{
+
+ float restDensity;
+ float particleRadius;
+ uint32_t maxParticleCount;
+ float maxInjectedParticleCount;
+ uint32_t maxCollidingObjects;
+ float sceneGravityScale;
+ physx::PxVec3 externalAcceleration;
+ RandomF32_Type particleMass;
+ NvParameterized::DummyStringStruct collisionFilterDataName;
+ NvParameterized::DummyStringStruct fieldSamplerFilterDataName;
+ bool staticCollision;
+ float restitutionForStaticShapes;
+ bool dynamicCollision;
+ float restitutionForDynamicShapes;
+ float collisionDistanceMultiplier;
+ float collisionThreshold;
+ bool collisionWithConvex;
+ bool collisionWithTriangleMesh;
+ GridDensityParams_Type GridDensity;
+ bool enableTemperatureBuffer;
+ bool enableDensityBuffer;
+ bool enableCouplingOverride;
+ ParticleToGridCouplingParams_Type particleToGridCoupling;
+ GridToParticleCouplingParams_Type gridToParticleCoupling;
+
+};
+
+static const uint32_t checksum[] = { 0xd1ae20ca, 0xe79f585e, 0x9ab86d65, 0x9964607a, };
+
+} // namespace BasicIOSAssetParamNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class BasicIOSAssetParam : public NvParameterized::NvParameters, public BasicIOSAssetParamNS::ParametersStruct
+{
+public:
+ BasicIOSAssetParam(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~BasicIOSAssetParam();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("BasicIOSAssetParam");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)1 << 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(BasicIOSAssetParamNS::checksum);
+ return BasicIOSAssetParamNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const BasicIOSAssetParamNS::ParametersStruct& parameters(void) const
+ {
+ BasicIOSAssetParam* tmpThis = const_cast<BasicIOSAssetParam*>(this);
+ return *(static_cast<BasicIOSAssetParamNS::ParametersStruct*>(tmpThis));
+ }
+
+ BasicIOSAssetParamNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<BasicIOSAssetParamNS::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 BasicIOSAssetParamFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ BasicIOSAssetParam::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(BasicIOSAssetParam), BasicIOSAssetParam::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, BasicIOSAssetParam::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class BasicIOSAssetParam");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(BasicIOSAssetParam)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, BasicIOSAssetParam)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, BasicIOSAssetParam::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, BasicIOSAssetParam::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class BasicIOSAssetParam");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of BasicIOSAssetParam 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 (BasicIOSAssetParam*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (BasicIOSAssetParam::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (BasicIOSAssetParam::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (BasicIOSAssetParam::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (BasicIOSAssetParam::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace basicios
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/basicios/include/autogen/BasicIosDebugRenderParams.h b/APEX_1.4/module/basicios/include/autogen/BasicIosDebugRenderParams.h
new file mode 100644
index 00000000..caca5349
--- /dev/null
+++ b/APEX_1.4/module/basicios/include/autogen/BasicIosDebugRenderParams.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_BasicIosDebugRenderParams_h
+#define HEADER_BasicIosDebugRenderParams_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 basicios
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace BasicIosDebugRenderParamsNS
+{
+
+
+
+struct ParametersStruct
+{
+
+ bool VISUALIZE_BASIC_IOS_ACTOR;
+ bool VISUALIZE_BASIC_IOS_COLLIDE_SHAPES;
+ bool VISUALIZE_BASIC_IOS_GRID_DENSITY;
+
+};
+
+static const uint32_t checksum[] = { 0xfdf6893d, 0xf8944ef9, 0x2d74bc9a, 0x7fb067bf, };
+
+} // namespace BasicIosDebugRenderParamsNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class BasicIosDebugRenderParams : public NvParameterized::NvParameters, public BasicIosDebugRenderParamsNS::ParametersStruct
+{
+public:
+ BasicIosDebugRenderParams(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~BasicIosDebugRenderParams();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("BasicIosDebugRenderParams");
+ }
+
+ 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(BasicIosDebugRenderParamsNS::checksum);
+ return BasicIosDebugRenderParamsNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const BasicIosDebugRenderParamsNS::ParametersStruct& parameters(void) const
+ {
+ BasicIosDebugRenderParams* tmpThis = const_cast<BasicIosDebugRenderParams*>(this);
+ return *(static_cast<BasicIosDebugRenderParamsNS::ParametersStruct*>(tmpThis));
+ }
+
+ BasicIosDebugRenderParamsNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<BasicIosDebugRenderParamsNS::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 BasicIosDebugRenderParamsFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ BasicIosDebugRenderParams::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(BasicIosDebugRenderParams), BasicIosDebugRenderParams::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, BasicIosDebugRenderParams::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class BasicIosDebugRenderParams");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(BasicIosDebugRenderParams)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, BasicIosDebugRenderParams)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, BasicIosDebugRenderParams::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, BasicIosDebugRenderParams::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class BasicIosDebugRenderParams");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of BasicIosDebugRenderParams 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 (BasicIosDebugRenderParams*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (BasicIosDebugRenderParams::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (BasicIosDebugRenderParams::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (BasicIosDebugRenderParams::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (BasicIosDebugRenderParams::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace basicios
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/basicios/include/autogen/BasicIosModuleParameters.h b/APEX_1.4/module/basicios/include/autogen/BasicIosModuleParameters.h
new file mode 100644
index 00000000..6a382a80
--- /dev/null
+++ b/APEX_1.4/module/basicios/include/autogen/BasicIosModuleParameters.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_BasicIosModuleParameters_h
+#define HEADER_BasicIosModuleParameters_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 basicios
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace BasicIosModuleParametersNS
+{
+
+
+
+struct ParametersStruct
+{
+
+ uint32_t unused;
+
+};
+
+static const uint32_t checksum[] = { 0x3fbae874, 0x2a648c69, 0x7ac9c757, 0x46be4dcd, };
+
+} // namespace BasicIosModuleParametersNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class BasicIosModuleParameters : public NvParameterized::NvParameters, public BasicIosModuleParametersNS::ParametersStruct
+{
+public:
+ BasicIosModuleParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~BasicIosModuleParameters();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("BasicIosModuleParameters");
+ }
+
+ 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(BasicIosModuleParametersNS::checksum);
+ return BasicIosModuleParametersNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const BasicIosModuleParametersNS::ParametersStruct& parameters(void) const
+ {
+ BasicIosModuleParameters* tmpThis = const_cast<BasicIosModuleParameters*>(this);
+ return *(static_cast<BasicIosModuleParametersNS::ParametersStruct*>(tmpThis));
+ }
+
+ BasicIosModuleParametersNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<BasicIosModuleParametersNS::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 BasicIosModuleParametersFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ BasicIosModuleParameters::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(BasicIosModuleParameters), BasicIosModuleParameters::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, BasicIosModuleParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class BasicIosModuleParameters");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(BasicIosModuleParameters)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, BasicIosModuleParameters)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, BasicIosModuleParameters::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, BasicIosModuleParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class BasicIosModuleParameters");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of BasicIosModuleParameters 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 (BasicIosModuleParameters*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (BasicIosModuleParameters::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (BasicIosModuleParameters::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (BasicIosModuleParameters::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (BasicIosModuleParameters::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace basicios
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/basicios/include/autogen/ModuleBasicIosRegistration.h b/APEX_1.4/module/basicios/include/autogen/ModuleBasicIosRegistration.h
new file mode 100644
index 00000000..e5324edf
--- /dev/null
+++ b/APEX_1.4/module/basicios/include/autogen/ModuleBasicIosRegistration.h
@@ -0,0 +1,120 @@
+/*
+ * 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_MODULEBASICIOSREGISTRATIONH_H
+#define MODULE_MODULEBASICIOSREGISTRATIONH_H
+
+#include "PsAllocator.h"
+#include "NvRegistrationsForTraitsBase.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "PxAssert.h"
+#include <stdint.h>
+
+// INCLUDE GENERATED FACTORIES
+#include "BasicIOSAssetParam.h"
+#include "BasicIosDebugRenderParams.h"
+#include "BasicIosModuleParameters.h"
+
+
+// INCLUDE GENERATED CONVERSION
+
+
+namespace nvidia {
+namespace basicios {
+
+
+class ModuleBasicIosRegistration : public NvParameterized::RegistrationsForTraitsBase
+{
+public:
+ static void invokeRegistration(NvParameterized::Traits* parameterizedTraits)
+ {
+ if (parameterizedTraits)
+ {
+ ModuleBasicIosRegistration().registerAll(*parameterizedTraits);
+ }
+ }
+
+ static void invokeUnregistration(NvParameterized::Traits* parameterizedTraits)
+ {
+ if (parameterizedTraits)
+ {
+ ModuleBasicIosRegistration().unregisterAll(*parameterizedTraits);
+ }
+ }
+
+ void registerAvailableFactories(NvParameterized::Traits& parameterizedTraits)
+ {
+ ::NvParameterized::Factory* factoriesToRegister[] = {
+// REGISTER GENERATED FACTORIES
+ new nvidia::basicios::BasicIOSAssetParamFactory(),
+ new nvidia::basicios::BasicIosDebugRenderParamsFactory(),
+ new nvidia::basicios::BasicIosModuleParametersFactory(),
+
+ };
+
+ 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::basicios::BasicIOSAssetParamFactory(),
+ new nvidia::basicios::BasicIosDebugRenderParamsFactory(),
+ new nvidia::basicios::BasicIosModuleParametersFactory(),
+
+ };
+
+ 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(&parameterizedTraits);
+ delete removedFactory;
+ delete factoriesToUnregister[i];
+ }
+ }
+ }
+
+ virtual void unregisterAvailableConverters(NvParameterized::Traits& parameterizedTraits)
+ {
+// UNREGISTER GENERATED CONVERSION
+PX_UNUSED(parameterizedTraits);
+
+ }
+
+};
+
+
+}
+} //nvidia::basicios
+
+#endif
diff --git a/APEX_1.4/module/basicios/src/BasicIosActorCPU.cpp b/APEX_1.4/module/basicios/src/BasicIosActorCPU.cpp
new file mode 100644
index 00000000..aec76a88
--- /dev/null
+++ b/APEX_1.4/module/basicios/src/BasicIosActorCPU.cpp
@@ -0,0 +1,318 @@
+/*
+ * 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 "SceneIntl.h"
+#include "ApexSDKIntl.h"
+
+#include "BasicIosActor.h"
+#include "BasicIosActorCPU.h"
+#include "BasicIosAssetImpl.h"
+#include "IofxAsset.h"
+#include "IofxActor.h"
+#include "ModuleBasicIosImpl.h"
+#include "BasicIosSceneCPU.h"
+#include "RenderDebugInterface.h"
+#include "AuthorableObjectIntl.h"
+#include "FieldSamplerQueryIntl.h"
+#include "PxMath.h"
+#include "ApexMirroredArray.h"
+
+namespace nvidia
+{
+namespace basicios
+{
+
+#pragma warning(disable: 4355) // 'this' : used in base member initializer list
+
+BasicIosActorCPU::BasicIosActorCPU(
+ ResourceList& list,
+ BasicIosAssetImpl& asset,
+ BasicIosScene& scene,
+ nvidia::apex::IofxAsset& iofxAsset)
+ : BASIC_IOS_ACTOR(list, asset, scene, iofxAsset, false)
+ , mSimulateTask(*this)
+{
+ initStorageGroups(mSimulationStorage);
+
+ mLifeTime.setSize(mMaxParticleCount);
+ mLifeSpan.setSize(mMaxTotalParticleCount);
+ mInjector.setSize(mMaxTotalParticleCount);
+ mBenefit.setSize(mMaxTotalParticleCount);
+
+ if (mAsset->mParams->collisionWithConvex)
+ {
+ mConvexPlanes.reserve(MAX_CONVEX_PLANES_COUNT);
+ mConvexVerts.reserve(MAX_CONVEX_VERTS_COUNT);
+ mConvexPolygonsData.reserve(MAX_CONVEX_POLYGONS_DATA_SIZE);
+ }
+ if (mAsset->mParams->collisionWithTriangleMesh)
+ {
+ mTrimeshVerts.reserve(MAX_TRIMESH_VERTS_COUNT);
+ mTrimeshIndices.reserve(MAX_TRIMESH_INDICES_COUNT);
+ }
+
+ mNewIndices.resize(mMaxParticleCount);
+}
+BasicIosActorCPU::~BasicIosActorCPU()
+{
+}
+
+void BasicIosActorCPU::submitTasks()
+{
+ BasicIosActorImpl::submitTasks();
+
+ mInjectorsCounters.setSize(mInjectorList.getSize(), ApexMirroredPlace::CPU);
+ PxTaskManager* tm = mBasicIosScene->getApexScene().getTaskManager();
+ tm->submitUnnamedTask(mSimulateTask);
+}
+
+void BasicIosActorCPU::setTaskDependencies()
+{
+ BasicIosActorImpl::setTaskDependencies(&mSimulateTask, false);
+}
+
+void BasicIosActorCPU::fetchResults()
+{
+ BASIC_IOS_ACTOR::fetchResults();
+}
+
+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 BasicIosActorCPU::simulateParticles()
+{
+ float deltaTime = mBasicIosScene->getApexScene().getPhysXSimulateTime();
+ const PxVec3& eyePos = mBasicIosScene->getApexScene().getEyePosition();
+
+ mTotalElapsedTime += deltaTime;
+
+ PxVec3 gravity = -mUp;
+
+ 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;
+
+ uint32_t boundBin = computeHistogram(totalCount, benefitMin, benefitMax, boundCount);
+ for (uint32_t i = 0, boundIndex = 0; i < totalCount; ++i)
+ {
+ float benefit = mBenefit[i];
+ if (benefit > -FLT_MAX)
+ {
+ PX_ASSERT(benefit >= benefitMin && benefit < benefitMax);
+
+ uint32_t bin = uint32_t((benefit - benefitMin) * HISTOGRAM_BIN_COUNT / (benefitMax - benefitMin));
+ if (bin < boundBin)
+ {
+ mBenefit[i] = -FLT_MAX;
+ continue;
+ }
+ if (bin == boundBin && boundIndex < boundCount)
+ {
+ mBenefit[i] = -FLT_MAX;
+ ++boundIndex;
+ }
+ }
+ }
+
+ checkBenefit(totalCount);
+ checkHoles(totalCount);
+ }
+ mLastActiveCount = 0;
+ mLastBenefitSum = 0.0f;
+ mLastBenefitMin = +FLT_MAX;
+ mLastBenefitMax = -FLT_MAX;
+
+ if (targetCount > 0)
+ {
+ const InjectorParams* injectorParamsList = DYNAMIC_CAST(BasicIosSceneCPU*)(mBasicIosScene)->mInjectorParamsArray.begin();
+
+ FieldAccessor fieldAccessor(mFieldSamplerQuery ? mField.getPtr() : 0);
+
+ SimulationParams simParams;
+ mSimulationParamsHandle.fetch(mSimulationStorage, simParams);
+
+ for (uint32_t dest = 0, srcHole = targetCount; dest < targetCount; ++dest)
+ {
+ uint32_t src = dest;
+ //do we have a hole in dest region?
+ if (!(mBenefit[dest] > -FLT_MAX))
+ {
+ //skip holes in src region
+ while (!(mBenefit[srcHole] > -FLT_MAX))
+ {
+ ++srcHole;
+ }
+ PX_ASSERT(srcHole < totalCount);
+ src = srcHole++;
+ }
+ //do we have a new particle?
+ bool isNewParticle = (src >= mParticleCount);
+
+ unsigned int injIndex;
+ float benefit = simulateParticle(
+ &simParams, mSimulationStorage, injectorParamsList,
+ deltaTime, gravity, eyePos,
+ isNewParticle, src, dest,
+ mBufDesc.pmaPositionMass->getPtr(), mBufDesc.pmaVelocityLife->getPtr(), mBufDesc.pmaActorIdentifiers->getPtr(),
+ mLifeSpan.getPtr(), mLifeTime.getPtr(), mInjector.getPtr(), mBufDesc.pmaCollisionNormalFlags->getPtr(), mBufDesc.pmaUserData->getPtr(),
+ fieldAccessor, injIndex
+ );
+
+ if (injIndex < mInjectorsCounters.getSize())
+ {
+ ++mInjectorsCounters[injIndex];
+ }
+
+ if (!isNewParticle)
+ {
+ mNewIndices[src] = dest;
+ }
+ else
+ {
+ mBufDesc.pmaInStateToInput->get(maxStateID) = dest | IosBufferDescIntl::NEW_PARTICLE_FLAG;
+ ++maxStateID;
+ }
+
+ mBenefit[dest] = benefit;
+ if (benefit > -FLT_MAX)
+ {
+ mLastBenefitSum += benefit;
+ mLastBenefitMin = PxMin(mLastBenefitMin, benefit);
+ mLastBenefitMax = PxMax(mLastBenefitMax, benefit);
+ ++mLastActiveCount;
+ }
+ }
+
+ //update stateToInput
+ for (uint32_t i = 0; i < mParticleCount; ++i)
+ {
+ uint32_t src = mBufDesc.pmaOutStateToInput->get(i);
+ PX_ASSERT( src < mParticleCount );
+ mBufDesc.pmaInStateToInput->get(i) = mNewIndices[src];
+ }
+ }
+ checkInState(totalCount);
+
+ mParticleCount = targetCount;
+
+ /* Oh! Manager of the IOFX! do your thing */
+ mIofxMgr->updateEffectsData(deltaTime, mParticleCount, mParticleCount, maxStateID);
+}
+
+uint32_t BasicIosActorCPU::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;
+ }
+ //accum Histogram
+ for (uint32_t i = 0; i < dataCount; ++i)
+ {
+ float data = dataArray[i];
+ if (data >= dataMin && data < dataMax)
+ {
+ uint32_t bin = uint32_t((data - dataMin) * HISTOGRAM_BIN_COUNT / (dataMax - dataMin));
+ ++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;
+ }
+
+ //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;
+ }
+ }
+
+ checkHistogram(bound, histogram[beg], histogram[HISTOGRAM_BIN_COUNT - 1]);
+
+ if (beg > 0)
+ {
+ bound -= histogram[beg - 1];
+ }
+
+ return beg;
+}
+
+}
+} // namespace nvidia
diff --git a/APEX_1.4/module/basicios/src/BasicIosActorGPU.cpp b/APEX_1.4/module/basicios/src/BasicIosActorGPU.cpp
new file mode 100644
index 00000000..0a4ef4ca
--- /dev/null
+++ b/APEX_1.4/module/basicios/src/BasicIosActorGPU.cpp
@@ -0,0 +1,802 @@
+/*
+ * 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 "BasicIosActor.h"
+#include "BasicIosActorGPU.h"
+#include "BasicIosAssetImpl.h"
+#include "IofxAsset.h"
+#include "IofxActor.h"
+#include "ModuleBasicIosImpl.h"
+#include "BasicIosSceneGPU.h"
+#include "RenderDebugInterface.h"
+#include "AuthorableObjectIntl.h"
+
+#include "PxMath.h"
+
+//CUDA
+#include "PxGpuTask.h"
+#include "ApexCutil.h"
+
+#define CUDA_OBJ(name) SCENE_CUDA_OBJ(*mBasicIosScene, name)
+
+namespace nvidia
+{
+namespace basicios
+{
+
+#pragma warning(disable: 4355) // 'this' : used in base member initializer list
+
+BasicIosActorGPU::BasicIosActorGPU(
+ ResourceList& list,
+ BasicIosAssetImpl& asset,
+ BasicIosScene& scene,
+ nvidia::apex::IofxAsset& iofxAsset,
+ const ApexMirroredPlace::Enum defaultPlace)
+ : BASIC_IOS_ACTOR(list, asset, scene, iofxAsset, true)
+ , mCopyQueue(*scene.getApexScene().getTaskManager()->getGpuDispatcher())
+ , mHoleScanSum(scene.getApexScene())
+ , mMoveIndices(scene.getApexScene())
+ , mTmpReduce(scene.getApexScene())
+ , mTmpHistogram(scene.getApexScene())
+ , mTmpScan(scene.getApexScene())
+ , mTmpScan1(scene.getApexScene())
+ , mTmpOutput(scene.getApexScene())
+ , mTmpOutput1(scene.getApexScene())
+ , mLaunchTask(*this)
+{
+ initStorageGroups(CUDA_OBJ(simulateStorage));
+
+ //CUDA
+ mTmpOutput.setSize(4, ApexMirroredPlace::CPU_GPU);
+ mTmpOutput1.setSize(2, ApexMirroredPlace::CPU_GPU);
+
+ 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);
+
+ 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);
+ }
+ }
+
+ if (mAsset->mParams->collisionWithConvex)
+ {
+ mConvexPlanes.reserve(MAX_CONVEX_PLANES_COUNT, ApexMirroredPlace::CPU_GPU);
+ mConvexVerts.reserve(MAX_CONVEX_VERTS_COUNT, ApexMirroredPlace::CPU_GPU);
+ mConvexPolygonsData.reserve(MAX_CONVEX_POLYGONS_DATA_SIZE, ApexMirroredPlace::CPU_GPU);
+ }
+ if (mAsset->mParams->collisionWithTriangleMesh)
+ {
+ mTrimeshVerts.reserve(MAX_TRIMESH_VERTS_COUNT, ApexMirroredPlace::CPU_GPU);
+ mTrimeshIndices.reserve(MAX_TRIMESH_INDICES_COUNT, ApexMirroredPlace::CPU_GPU);
+ }
+
+ mHoleScanSum.reserve(mMaxTotalParticleCount, defaultPlace);
+ mMoveIndices.reserve(mMaxTotalParticleCount, defaultPlace);
+}
+
+BasicIosActorGPU::~BasicIosActorGPU()
+{
+}
+
+void BasicIosActorGPU::submitTasks()
+{
+ BasicIosActorImpl::submitTasks();
+
+ mInjectorsCounters.setSize(mInjectorList.getSize(), ApexMirroredPlace::CPU_GPU);
+ PxTaskManager* tm = mBasicIosScene->getApexScene().getTaskManager();
+ tm->submitUnnamedTask(mLaunchTask, PxTaskType::TT_GPU);
+}
+
+void BasicIosActorGPU::setTaskDependencies()
+{
+ BasicIosActorImpl::setTaskDependencies(&mLaunchTask, true);
+
+ PxTaskManager* tm = mBasicIosScene->getApexScene().getTaskManager();
+ 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);
+ }
+}
+
+bool BasicIosActorGPU::launch(CUstream stream, int kernelIndex)
+{
+ float deltaTime = mBasicIosScene->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;
+ }
+
+ BasicIosSceneGPU* sceneGPU = static_cast<BasicIosSceneGPU*>(mBasicIosScene);
+ bool useSyncKernels = !sceneGPU->getGpuDispatcher()->getCudaContextManager()->supportsArchSM20();
+
+ switch (kernelIndex)
+ {
+ case 0:
+ if (!mFieldSamplerQuery && mOnStartCallback)
+ {
+ (*mOnStartCallback)(stream);
+ }
+
+ 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 (mAsset->mParams->collisionWithConvex)
+ {
+ mConvexPlanes.copyHostToDeviceQ(mCopyQueue);
+ mConvexVerts.copyHostToDeviceQ(mCopyQueue);
+ mConvexPolygonsData.copyHostToDeviceQ(mCopyQueue);
+ }
+ if (mAsset->mParams->collisionWithTriangleMesh)
+ {
+ mTrimeshVerts.copyHostToDeviceQ(mCopyQueue);
+ mTrimeshIndices.copyHostToDeviceQ(mCopyQueue);
+ }
+ 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,
+ mTmpOutput1.getGpuPtr(),
+ mTmpHistogram.getGpuPtr()
+ );
+ }
+ else
+ {
+ uint32_t histogramGridSize =
+ CUDA_OBJ(histogramKernel)(
+ stream, totalCount,
+ createApexCudaMemRef(mBenefit, totalCount, ApexCudaMemFlags::IN),
+ boundCount, benefitMin, benefitMax,
+ createApexCudaMemRef(mTmpOutput1, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpHistogram, ApexCudaMemFlags::OUT),
+ 1, 0
+ );
+
+ //launch just 1 block
+ CUDA_OBJ(histogramKernel)(
+ stream, APEX_CUDA_SINGLE_BLOCK_LAUNCH,
+ createApexCudaMemRef(mBenefit, totalCount, ApexCudaMemFlags::IN),
+ boundCount, benefitMin, benefitMax,
+ createApexCudaMemRef(mTmpOutput1, 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(),
+ mTmpOutput1.getGpuPtr(),
+ mTmpScan.getGpuPtr(), mTmpScan1.getGpuPtr()
+ );
+ }
+ else
+ {
+ uint32_t scanGridSize =
+ CUDA_OBJ(scanKernel)(
+ stream, totalCount,
+ benefitMin, benefitMax,
+ createApexCudaMemRef(mHoleScanSum, totalCount, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mBenefit, totalCount, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpOutput1, 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, totalCount, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mBenefit, totalCount, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpOutput1, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpScan, ApexCudaMemFlags::IN_OUT),
+ createApexCudaMemRef(mTmpScan1, ApexCudaMemFlags::IN_OUT),
+ 2, scanGridSize
+ );
+
+ CUDA_OBJ(scanKernel)(
+ stream, totalCount,
+ benefitMin, benefitMax,
+ createApexCudaMemRef(mHoleScanSum, totalCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(mBenefit, totalCount, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpOutput1, 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, totalCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(mTmpScan, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(mInjectorsCounters, ApexCudaMemFlags::OUT)
+ );
+
+ }
+ return true;
+ }
+
+
+ case 4:
+ if (targetCount > 0)
+ {
+ uint32_t histogramGridSize = 0;
+ {
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefMoveIndices, mMoveIndices);
+
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefPositionMass, *mBufDesc.pmaPositionMass);
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefVelocityLife, *mBufDesc.pmaVelocityLife);
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefIofxActorIDs, *mBufDesc.pmaActorIdentifiers);
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefLifeSpan, mLifeSpan);
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefLifeTime, mLifeTime);
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefInjector, mInjector);
+
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefUserData, *mBufDesc.pmaUserData);
+
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefConvexPlanes, mConvexPlanes);
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefConvexVerts, mConvexVerts);
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefConvexPolygonsData, mConvexPolygonsData);
+
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefTrimeshVerts, mTrimeshVerts);
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefTrimeshIndices, mTrimeshIndices);
+
+ PxVec3 gravity = -mUp;
+ const PxVec3& eyePos = mBasicIosScene->getApexScene().getEyePosition();
+
+ if (mFieldSamplerQuery != NULL)
+ {
+ APEX_CUDA_TEXTURE_SCOPE_BIND(texRefField, mField);
+
+ histogramGridSize = CUDA_OBJ(simulateApplyFieldKernel)(stream,
+ targetCount,
+ lastCount,
+ deltaTime,
+ gravity,
+ eyePos,
+ sceneGPU->mInjectorConstMemGroup.getStorage().mappedHandle(sceneGPU->mInjectorParamsArrayHandle), mInjectorsCounters.getSize(),
+ createApexCudaMemRef(mHoleScanSum, targetCount, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpScan, 1, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpHistogram, ApexCudaMemFlags::OUT),
+ 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(mBufDesc.pmaUserData->getGpuPtr(), targetCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(mLifeSpan, targetCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(mLifeTime, targetCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(mInjector, targetCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(*(mBufDesc.pmaActorIdentifiers), targetCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(mBenefit, targetCount, ApexCudaMemFlags::OUT),
+ mSimulationStorageGroup.getStorage().mappedHandle(mSimulationParamsHandle)
+ );
+ }
+ else
+ {
+ histogramGridSize = CUDA_OBJ(simulateKernel)(stream, targetCount,
+ lastCount, deltaTime, gravity, eyePos,
+ sceneGPU->mInjectorConstMemGroup.getStorage().mappedHandle(sceneGPU->mInjectorParamsArrayHandle), mInjectorsCounters.getSize(),
+ mHoleScanSum.getGpuPtr(), mTmpScan.getGpuPtr(), mTmpHistogram.getGpuPtr(), mInjectorsCounters.getGpuPtr(),
+ (float4*)mBufDesc.pmaPositionMass->getGpuPtr(),
+ (float4*)mBufDesc.pmaVelocityLife->getGpuPtr(),
+ (float4*)mBufDesc.pmaCollisionNormalFlags->getGpuPtr(),
+ mBufDesc.pmaUserData->getGpuPtr(),
+ mLifeSpan.getGpuPtr(), mLifeTime.getGpuPtr(), mInjector.getGpuPtr(), mBufDesc.pmaActorIdentifiers->getGpuPtr(),
+ mBenefit.getGpuPtr(), mSimulationStorageGroup.getStorage().mappedHandle(mSimulationParamsHandle)
+ );
+ }
+ }
+ //new kernel invocation - to merge temp histograms
+ {
+ if(mInjectorsCounters.getSize() <= HISTOGRAM_SIMULATE_BIN_COUNT)
+ {
+ CUDA_OBJ(mergeHistogramKernel)(stream, APEX_CUDA_SINGLE_BLOCK_LAUNCH,
+ createApexCudaMemRef(mInjectorsCounters, mInjectorsCounters.getSize(), ApexCudaMemFlags::IN),
+ createApexCudaMemRef(mTmpHistogram, ApexCudaMemFlags::IN),
+ histogramGridSize,
+ mInjectorsCounters.getSize()
+ );
+ }
+
+ }
+ // calculate grid grid density
+ if (mGridDensityParams.Enabled)
+ {
+ mGridDensityParams.DensityOrigin = mDensityOrigin;
+ const unsigned int dim = mGridDensityParams.GridResolution;
+ // refreshed non-shared params
+ {
+ BasicIOSAssetParam* gridParams = (BasicIOSAssetParam*)(mAsset->getAssetNvParameterized());
+ mGridDensityParams.GridSize = gridParams->GridDensity.GridSize;
+ mGridDensityParams.GridMaxCellCount = gridParams->GridDensity.MaxCellCount;
+ }
+ // extract frustum
+ if (mBasicIosScene->getApexScene().getNumProjMatrices() > 0)
+ {
+ PxMat44 matDen = PxMat44(PxIdentity);
+ GridDensityFrustumParams frustum;
+ PxMat44 matModel = mBasicIosScene->getApexScene().getViewMatrix();
+ PxMat44 matProj = mBasicIosScene->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;
+ // see how skewed the eye point is
+ PxVec3 eye;
+ {
+ // find the eye point
+ PxVec4 a4 = matInv.transform(PxVec4(1.f,1.f,0.00f,1.f));
+ PxVec4 b4 = matInv.transform(PxVec4(1.f,1.f,0.01f,1.f));
+ PxVec4 c4 = matInv.transform(PxVec4(-1.f,-1.f,0.00f,1.f));
+ PxVec4 d4 = matInv.transform(PxVec4(-1.f,-1.f,0.01f,1.f));
+ PxVec3 a3 = a4.getXYZ()/a4.w;
+ PxVec3 b3 = b4.getXYZ()/b4.w;
+ PxVec3 c3 = c4.getXYZ()/c4.w;
+ PxVec3 d3 = d4.getXYZ()/d4.w;
+ PxVec3 a = b3-a3;
+ PxVec3 b = d3-c3;
+ PxVec3 c = a.cross(b);
+ PxVec3 d = a3-c3;
+ PxMat33 m(a,b,c);
+ PxMat33 mInv = m.getInverse();
+ PxVec3 coord = mInv.transform(d);
+ eye = c3 + (d3-c3)*coord.y;
+ }
+ // 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);
+ PxVec3 eyeOffset = mat1.transform(eye);
+ // do perspective transform
+ PxMat44 mat2 = PxMat44(PxIdentity);
+ {
+ float xshift = -2.f*(eyeOffset.x-0.5f);
+ float yshift = -2.f*(eyeOffset.y-0.5f);
+ float left = -3.0f + xshift;
+ float right = 1.0f + xshift;
+ float top = 1.0f + yshift;
+ float bottom = -3.0f + yshift;
+ 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 = PxMin((float)(mGridDensityParams.GridResolution-4) / (mGridDensityParams.GridResolution),0.75f);
+ {
+ 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, targetCount, 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, targetCount, 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, 1, ApexCudaMemFlags::IN),
+ createApexCudaMemRef(*mBufDesc.pmaInStateToInput, totalCount, ApexCudaMemFlags::OUT),
+ createApexCudaMemRef(*mBufDesc.pmaOutStateToInput, lastCount, ApexCudaMemFlags::IN)
+ );
+
+ }
+ return true;
+
+ case 7:
+ mTmpOutput.copyDeviceToHostQ(mCopyQueue);
+ mInjectorsCounters.copyDeviceToHostQ(mCopyQueue);
+
+ if (mTmpScan.cpuPtrIsValid())
+ {
+ mTmpOutput1.copyDeviceToHostQ(mCopyQueue);
+ mTmpScan.copyDeviceToHostQ(mCopyQueue, 1);
+ mHoleScanSum.copyDeviceToHostQ(mCopyQueue, totalCount);
+ mMoveIndices.copyDeviceToHostQ(mCopyQueue, totalCount);
+ mTmpHistogram.copyDeviceToHostQ(mCopyQueue, HISTOGRAM_BIN_COUNT);
+ mBenefit.copyDeviceToHostQ(mCopyQueue, totalCount);
+ mBufDesc.pmaInStateToInput->copyDeviceToHostQ(mCopyQueue, totalCount);
+ mBufDesc.pmaPositionMass->copyDeviceToHostQ(mCopyQueue, targetCount);
+ }
+ mCopyQueue.flushEnqueued();
+
+ /* Oh! Manager of the IOFX! do your thing */
+ mIofxMgr->updateEffectsData(deltaTime, targetCount, targetCount, totalCount, stream);
+ return false;
+ }
+ return false;
+}
+
+void BasicIosActorGPU::fetchResults()
+{
+ BASIC_IOS_ACTOR::fetchResults();
+
+ uint32_t totalCount = mParticleCount + mInjectedCount;
+ checkBenefit(totalCount);
+ checkHoles(totalCount);
+ checkInState(totalCount);
+ /*checkHistogram(PxMax<int32_t>(mLastActiveCount + mInjectedCount - mParticleBudget, 0), mTmpHistogram[ mTmpOutput1[1] ], mTmpHistogram[ HISTOGRAM_BIN_COUNT - 1 ]);*/
+ //this can be done only after TaskLaunchAfterLod is finished!!!
+
+ 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 BasicIosActorGPU::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 BasicIosActorGPU::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/basicios/src/BasicIosActorImpl.cpp b/APEX_1.4/module/basicios/src/BasicIosActorImpl.cpp
new file mode 100644
index 00000000..5bb6ecd4
--- /dev/null
+++ b/APEX_1.4/module/basicios/src/BasicIosActorImpl.cpp
@@ -0,0 +1,1221 @@
+/*
+ * 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 "SceneIntl.h"
+#include "ApexSDKIntl.h"
+#include "ScopedPhysXLock.h"
+
+#include "BasicIosActor.h"
+#include "BasicIosActorImpl.h"
+#include "BasicIosAssetImpl.h"
+#include "IofxAsset.h"
+#include "IofxActor.h"
+#include "ModuleBasicIosImpl.h"
+#include "BasicIosScene.h"
+#include "RenderDebugInterface.h"
+#include "AuthorableObjectIntl.h"
+#include "ModuleIofxIntl.h"
+#include "FieldSamplerManagerIntl.h"
+#include "FieldSamplerQueryIntl.h"
+#include "ApexMirroredArray.h"
+#include "ApexResourceHelper.h"
+#include "PsAsciiConversion.h"
+
+#include "PxTask.h"
+
+#include <PxScene.h>
+#include <PxConvexMesh.h>
+
+#include <PxShape.h>
+#include <geometry/PxBoxGeometry.h>
+#include <geometry/PxSphereGeometry.h>
+#include <geometry/PxCapsuleGeometry.h>
+#include <geometry/PxPlaneGeometry.h>
+#include <geometry/PxTriangleMeshGeometry.h>
+#include <geometry/PxTriangleMesh.h>
+
+#include <PxMaterial.h>
+
+#include <PxRigidActor.h>
+#include <PxRigidBody.h>
+#include <extensions/PxShapeExt.h>
+
+#include <PsAsciiConversion.h>
+
+#include "Lock.h"
+
+namespace nvidia
+{
+ namespace basicios
+ {
+ using namespace physx;
+
+ class BasicIosInjectTask : public PxTask, public UserAllocated
+ {
+ public:
+ BasicIosInjectTask(BasicIosActorImpl* actor) : mActor(actor) {}
+
+ const char* getName() const
+ {
+ return "BasicIosActorImpl::InjectTask";
+ }
+ void run()
+ {
+ mActor->injectNewParticles();
+ }
+
+ protected:
+ BasicIosActorImpl* mActor;
+ };
+
+ void BasicIosActorImpl::initStorageGroups(InplaceStorage& storage)
+ {
+ mSimulationStorageGroup.init(storage);
+ }
+
+ BasicIosActorImpl::BasicIosActorImpl(
+ ResourceList& list,
+ BasicIosAssetImpl& asset,
+ BasicIosScene& scene,
+ nvidia::apex::IofxAsset& iofxAsset,
+ bool isDataOnDevice)
+ : mAsset(&asset)
+ , mBasicIosScene(&scene)
+ , mIofxMgr(NULL)
+ , mTotalElapsedTime(0.0f)
+ , mParticleCount(0)
+ , mParticleBudget(UINT_MAX)
+ , 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))
+ , mConvexPlanes(scene.getApexScene(), PX_ALLOC_INFO("mConvexPlanes", PARTICLES))
+ , mConvexVerts(scene.getApexScene(), PX_ALLOC_INFO("mConvexVerts", PARTICLES))
+ , mConvexPolygonsData(scene.getApexScene(), PX_ALLOC_INFO("mConvexPolygonsData", PARTICLES))
+ , mTrimeshVerts(scene.getApexScene(), PX_ALLOC_INFO("mTrimeshVerts", PARTICLES))
+ , mTrimeshIndices(scene.getApexScene(), PX_ALLOC_INFO("mTrimeshIndices", PARTICLES))
+ , mInjectorsCounters(scene.getApexScene(), PX_ALLOC_INFO("mInjectorsCounters", 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))
+ , mDensityOrigin(0.f,0.f,0.f)
+ , mOnStartCallback(NULL)
+ , mOnFinishCallback(NULL)
+ {
+ list.add(*this);
+
+ mMaxParticleCount = mAsset->mParams->maxParticleCount;
+ mParticleBudget = mMaxParticleCount;
+ 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(*mBasicIosScene->mApexScene, iofxAsset, desc);
+ mIofxMgr->createSimulationBuffers(mBufDesc);
+ }
+
+ mCollisionFilterData = ApexResourceHelper::resolveCollisionGroup128(mAsset->mParams->fieldSamplerFilterDataName);
+
+ FieldSamplerManagerIntl* fieldSamplerManager = mBasicIosScene->getInternalFieldSamplerManager();
+ if (fieldSamplerManager)
+ {
+ FieldSamplerQueryDescIntl queryDesc;
+ queryDesc.maxCount = mMaxParticleCount;
+ queryDesc.samplerFilterData = ApexResourceHelper::resolveCollisionGroup128(mAsset->mParams->fieldSamplerFilterDataName);
+
+ mFieldSamplerQuery = fieldSamplerManager->createFieldSamplerQuery(queryDesc);
+
+ if (isDataOnDevice)
+ {
+#if APEX_CUDA_SUPPORT
+ mField.reserve(mMaxParticleCount, ApexMirroredPlace::GPU);
+#endif
+ }
+ else
+ {
+ mField.reserve(mMaxParticleCount, ApexMirroredPlace::CPU);
+ }
+ }
+
+ mInjectTask = PX_NEW(BasicIosInjectTask)(this);
+
+ // Pull Grid Density Parameters
+ {
+ if(mBufDesc.pmaDensity)
+ {
+ BasicIOSAssetParam* gridParams = (BasicIOSAssetParam*)(mAsset->getAssetNvParameterized());
+ 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;
+ }
+ }
+
+ addSelfToContext(*scene.mApexScene->getApexContext()); // add self to Scene
+ addSelfToContext(*DYNAMIC_CAST(ApexContext*)(&scene)); // add self to BasicIosScene
+ }
+
+ BasicIosActorImpl::~BasicIosActorImpl()
+ {
+ PX_DELETE(mInjectTask);
+ }
+
+ void BasicIosActorImpl::release()
+ {
+ if (mInRelease)
+ {
+ return;
+ }
+ mInRelease = true;
+ mAsset->releaseIosActor(*this);
+ }
+
+ void BasicIosActorImpl::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())
+ {
+ BasicParticleInjector* inj = DYNAMIC_CAST(BasicParticleInjector*)(mInjectorList.getResource(mInjectorList.getSize() - 1));
+ inj->release();
+ }
+
+ if (mIofxMgr)
+ {
+ mIofxMgr->release();
+ }
+ if (mFieldSamplerQuery)
+ {
+ mFieldSamplerQuery->release();
+ }
+
+ delete this;
+ }
+
+ void BasicIosActorImpl::setPhysXScene(PxScene* scene)
+ {
+ if (scene)
+ {
+ putInScene(scene);
+ }
+ else
+ {
+ removeFromScene();
+ }
+ }
+ PxScene* BasicIosActorImpl::getPhysXScene() const
+ {
+ return NULL;
+ }
+ void BasicIosActorImpl::putInScene(PxScene* scene)
+ {
+ SCOPED_PHYSX_LOCK_READ(scene);
+ PxVec3 gravity = scene->getGravity();
+ setGravity(gravity);
+ }
+
+ void BasicIosActorImpl::getLodRange(float& min, float& max, bool& intOnly) const
+ {
+ PX_UNUSED(min);
+ PX_UNUSED(max);
+ PX_UNUSED(intOnly);
+ APEX_INVALID_OPERATION("not implemented");
+ }
+
+
+ float BasicIosActorImpl::getActiveLod() const
+ {
+ APEX_INVALID_OPERATION("BasicIosActor does not support this operation");
+ return -1.0f;
+ }
+
+
+ void BasicIosActorImpl::forceLod(float lod)
+ {
+ PX_UNUSED(lod);
+ APEX_INVALID_OPERATION("not implemented");
+ }
+
+
+ void BasicIosActorImpl::removeFromScene()
+ {
+ mParticleCount = 0;
+ }
+
+
+ const PxVec3* BasicIosActorImpl::getRecentPositions(uint32_t& count, uint32_t& stride) const
+ {
+ APEX_INVALID_OPERATION("not implemented");
+
+ count = 0;
+ stride = 0;
+ return NULL;
+ }
+
+ PxVec3 BasicIosActorImpl::getGravity() const
+ {
+ return mGravityVec;
+ }
+
+ void BasicIosActorImpl::setGravity(PxVec3& gravity)
+ {
+ mGravityVec = gravity;
+ mUp = mGravityVec;
+
+ // 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;
+
+ mIofxMgr->setSimulationParameters(getObjectRadius(), mUp, mGravity, getObjectDensity());
+ }
+
+ IosInjectorIntl* BasicIosActorImpl::allocateInjector(IofxAsset* iofxAsset)
+ {
+ BasicParticleInjector* inj = 0;
+ //createInjector
+ {
+ uint32_t injectorID = mBasicIosScene->getInjectorAllocator().allocateInjectorID();
+ if (injectorID != BasicIosInjectorAllocator::NULL_INJECTOR_INDEX)
+ {
+ inj = PX_NEW(BasicParticleInjector)(mInjectorList, *this, injectorID);
+ }
+ }
+ if (inj == 0)
+ {
+ APEX_INTERNAL_ERROR("Failed to create new BasicIos injector.");
+ return NULL;
+ }
+
+ inj->init(iofxAsset);
+ return inj;
+ }
+
+ void BasicIosActorImpl::releaseInjector(IosInjectorIntl& injector)
+ {
+ BasicParticleInjector* inj = DYNAMIC_CAST(BasicParticleInjector*)(&injector);
+
+ //destroyInjector
+ {
+ //set mLODBias to FLT_MAX to mark released injector
+ //all particles from released injectors will be removed in simulation
+ InjectorParams injParams;
+ mBasicIosScene->fetchInjectorParams(inj->mInjectorID, injParams);
+ injParams.mLODBias = FLT_MAX;
+ mBasicIosScene->updateInjectorParams(inj->mInjectorID, injParams);
+
+ mBasicIosScene->getInjectorAllocator().releaseInjectorID(inj->mInjectorID);
+ inj->destroy();
+ }
+
+ if (mInjectorList.getSize() == 0)
+ {
+ //if we have no injectors - release self
+ release();
+ }
+ }
+
+
+ void BasicIosActorImpl::visualize()
+ {
+ if ( !mEnableDebugVisualization ) return;
+#ifndef WITHOUT_DEBUG_VISUALIZE
+ RenderDebugInterface* renderer = mBasicIosScene->mDebugRender;
+ const physx::PxMat44& savedPose = *RENDER_DEBUG_IFACE(renderer)->getPoseTyped();
+ RENDER_DEBUG_IFACE(renderer)->setIdentityPose();
+ if(mBasicIosScene->mBasicIosDebugRenderParams->VISUALIZE_BASIC_IOS_GRID_DENSITY)
+ {
+ if(mGridDensityParams.Enabled)
+ {
+ RENDER_DEBUG_IFACE(renderer)->setCurrentColor(0x0000ff);
+ float factor = PxMin((float)(mGridDensityParams.GridResolution-4) / (mGridDensityParams.GridResolution),0.75f);
+ uint32_t onScreenRes = (uint32_t)(factor*mGridDensityParams.GridResolution);
+ 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));
+ }
+ }
+ }
+ if(mBasicIosScene->mBasicIosDebugRenderParams->VISUALIZE_BASIC_IOS_COLLIDE_SHAPES)
+ {
+ INPLACE_STORAGE_GROUP_SCOPE(mSimulationStorageGroup);
+ SimulationParams simParams;
+ mSimulationParamsHandle.fetch(_storage_, simParams);
+
+ RenderDebugInterface* renderer = mBasicIosScene->mDebugRender;
+ RENDER_DEBUG_IFACE(renderer)->setCurrentColor(RENDER_DEBUG_IFACE(renderer)->getDebugColor(RENDER_DEBUG::DebugColors::Blue));
+
+ for(uint32_t i = 0; i < (uint32_t)simParams.boxes.getSize(); ++i)
+ {
+ CollisionBoxData boxData;
+ simParams.boxes.fetchElem(_storage_, boxData, i);
+
+ const PxTransform& pose = boxData.pose;
+ PxVec3 position = pose.p;
+ PxVec3 halfSize = boxData.halfSize;
+ RENDER_DEBUG_IFACE(renderer)->setPose(pose);
+ RENDER_DEBUG_IFACE(renderer)->debugBound(PxBounds3(-halfSize, halfSize));
+ }
+
+ for(uint32_t i = 0; i < (uint32_t)simParams.spheres.getSize(); ++i)
+ {
+ CollisionSphereData sphereData;
+ simParams.spheres.fetchElem(_storage_, sphereData, i);
+
+ float r = sphereData.radius;
+ PxVec3 pos = sphereData.pose.p;
+ RENDER_DEBUG_IFACE(renderer)->debugSphere(pos, r);
+ }
+
+ for(uint32_t i = 0; i < (uint32_t)simParams.capsules.getSize(); ++i)
+ {
+ CollisionCapsuleData capsuleData;
+ simParams.capsules.fetchElem(_storage_, capsuleData, i);
+
+ float r = capsuleData.radius, h = capsuleData.halfHeight;
+ const PxTransform& pose = capsuleData.pose;
+ RENDER_DEBUG_IFACE(renderer)->setPose(pose);
+ RENDER_DEBUG_IFACE(renderer)->debugCapsule(r, 2 * h);
+ }
+ }
+ RENDER_DEBUG_IFACE(renderer)->setPose(savedPose);
+#endif
+ }
+
+ void BasicIosActorImpl::FillCollisionData(CollisionData& baseData, PxShape* shape)
+ {
+ PxTransform actorGlobalPose = shape->getActor()->getGlobalPose();
+
+ if (PxRigidBody* pxBody = shape->getActor()->is<physx::PxRigidBody>())
+ {
+ baseData.bodyCMassPosition = actorGlobalPose.transform(pxBody->getCMassLocalPose().p);
+ baseData.bodyLinearVelocity = pxBody->getLinearVelocity();
+ baseData.bodyAngluarVelocity = pxBody->getAngularVelocity();
+
+ baseData.materialRestitution = mAsset->mParams->restitutionForDynamicShapes;
+ }
+ else
+ {
+ baseData.bodyCMassPosition = actorGlobalPose.p;
+ baseData.bodyLinearVelocity = PxVec3(0, 0, 0);
+ baseData.bodyAngluarVelocity = PxVec3(0, 0, 0);
+
+ baseData.materialRestitution = mAsset->mParams->restitutionForStaticShapes;
+ }
+ //PxMaterial* PxMaterial = shape->getMaterialFromInternalFaceIndex(0);
+ //PX_ASSERT(PxMaterial);
+ //baseData->materialRestitution = PxMaterial->getRestitution();
+ }
+
+ void BasicIosActorImpl::submitTasks()
+ {
+ PxTaskManager* tm = mBasicIosScene->getApexScene().getTaskManager();
+ tm->submitUnnamedTask(*mInjectTask);
+
+ //compile a list of actually colliding objects and process them to be used by the simulation
+ INPLACE_STORAGE_GROUP_SCOPE(mSimulationStorageGroup);
+
+ SimulationParams simParams;
+ if (mSimulationParamsHandle.allocOrFetch(_storage_, simParams))
+ {
+ //one time initialization on alloc
+ simParams.collisionThreshold = mAsset->mParams->collisionThreshold;
+ simParams.collisionDistance = mAsset->mParams->particleRadius * mAsset->mParams->collisionDistanceMultiplier;
+#if APEX_CUDA_SUPPORT
+#define GET_PTR(x) x.getGpuPtr() ? x.getGpuPtr() : x.getPtr()
+#else
+#define GET_PTR(x) x.getPtr()
+#endif
+ simParams.convexPlanes = GET_PTR(mConvexPlanes);
+ simParams.convexVerts = GET_PTR(mConvexVerts);
+ simParams.convexPolygonsData = GET_PTR(mConvexPolygonsData);
+
+ simParams.trimeshVerts = GET_PTR(mTrimeshVerts);
+ simParams.trimeshIndices = GET_PTR(mTrimeshIndices);
+ }
+
+ uint32_t numBoxes = 0;
+ uint32_t numSpheres = 0;
+ uint32_t numCapsules = 0;
+ uint32_t numHalfSpaces = 0;
+ uint32_t numConvexMeshes = 0;
+ uint32_t numTriMeshes = 0;
+
+ mConvexPlanes.setSize(0);
+ mConvexVerts.setSize(0);
+ mConvexPolygonsData.setSize(0);
+
+ mTrimeshVerts.setSize(0);
+ mTrimeshIndices.setSize(0);
+
+ const float collisionRadius = simParams.collisionThreshold + simParams.collisionDistance;
+ uint32_t numCollidingObjects = 0;
+ PxBounds3 bounds = mIofxMgr->getBounds();
+ if ((mAsset->mParams->staticCollision || mAsset->mParams->dynamicCollision) && !bounds.isEmpty())
+ {
+ PX_ASSERT(!bounds.isEmpty());
+ bounds.fattenFast(collisionRadius);
+
+ const uint32_t maxCollidingObjects = mAsset->mParams->maxCollidingObjects;
+
+ mOverlapHits.resize(maxCollidingObjects);
+ PxBoxGeometry overlapGeom(bounds.getExtents());
+ PxTransform overlapPose(bounds.getCenter());
+
+ PxQueryFilterData overlapFilterData;
+ overlapFilterData.data = mCollisionFilterData;
+
+ overlapFilterData.flags = PxQueryFlag::eNO_BLOCK | PxQueryFlag::ePREFILTER;
+ if (mAsset->mParams->staticCollision) overlapFilterData.flags |= PxQueryFlag::eSTATIC;
+ if (mAsset->mParams->dynamicCollision) overlapFilterData.flags |= PxQueryFlag::eDYNAMIC;
+
+ SCOPED_PHYSX_LOCK_READ(mBasicIosScene->getModulePhysXScene());
+
+ class OverlapFilter : public physx::PxQueryFilterCallback
+ {
+ public:
+ virtual PxQueryHitType::Enum preFilter(
+ const PxFilterData& filterData, const PxShape* shape, const PxRigidActor* actor, physx::PxHitFlags& queryFlags)
+ {
+ PX_UNUSED(queryFlags);
+
+ const PxFilterData shapeFilterData = shape->getQueryFilterData();
+ const physx::PxFilterObjectAttributes iosAttributes = PxFilterObjectType::ePARTICLE_SYSTEM;
+ physx::PxFilterObjectAttributes actorAttributes = actor->getType();
+ if (const PxRigidBody* rigidBody = actor->is<physx::PxRigidBody>())
+ {
+ if (rigidBody->getRigidBodyFlags() & PxRigidBodyFlag::eKINEMATIC)
+ {
+ actorAttributes |= PxFilterObjectFlag::eKINEMATIC;
+ }
+ }
+
+ physx::PxPairFlags pairFlags;
+ physx::PxFilterFlags filterFlags = mFilterShader(iosAttributes, filterData, actorAttributes, shapeFilterData, pairFlags, mFilterShaderData, mFilterShaderDataSize);
+ return (filterFlags & (PxFilterFlag::eKILL | PxFilterFlag::eSUPPRESS)) ? PxQueryHitType::eNONE : PxQueryHitType::eTOUCH;
+ }
+
+ virtual PxQueryHitType::Enum postFilter(const PxFilterData& filterData, const PxQueryHit& hit)
+ {
+ PX_UNUSED(filterData);
+ PX_UNUSED(hit);
+ return PxQueryHitType::eNONE;
+ }
+
+ OverlapFilter(PxScene* scene)
+ {
+ mFilterShader = scene->getFilterShader();
+ mFilterShaderData = scene->getFilterShaderData();
+ mFilterShaderDataSize = scene->getFilterShaderDataSize();
+ }
+
+ private:
+ physx::PxSimulationFilterShader mFilterShader;
+ const void* mFilterShaderData;
+ uint32_t mFilterShaderDataSize;
+
+ } overlapFilter(mBasicIosScene->getModulePhysXScene());
+
+ physx::PxOverlapBuffer ovBuffer(&mOverlapHits[0], mOverlapHits.size());
+ mBasicIosScene->getModulePhysXScene()->overlap(overlapGeom, overlapPose, ovBuffer, overlapFilterData, &overlapFilter);
+ numCollidingObjects = ovBuffer.getNbTouches();
+
+ for (uint32_t iShape = 0; iShape < numCollidingObjects; iShape++)
+ {
+ PxShape* shape = mOverlapHits[iShape].shape;
+
+ switch (shape->getGeometryType())
+ {
+ case PxGeometryType::eBOX:
+ {
+ ++numBoxes;
+ }
+ break;
+ case PxGeometryType::eSPHERE:
+ {
+ ++numSpheres;
+ }
+ break;
+ case PxGeometryType::eCAPSULE:
+ {
+ ++numCapsules;
+ }
+ break;
+ case PxGeometryType::ePLANE:
+ {
+ ++numHalfSpaces;
+ }
+ break;
+ case PxGeometryType::eCONVEXMESH:
+ {
+ if (mAsset->mParams->collisionWithConvex)
+ {
+ ++numConvexMeshes;
+ }
+ }
+ break;
+ case PxGeometryType::eTRIANGLEMESH:
+ {
+ if (mAsset->mParams->collisionWithTriangleMesh)
+ {
+ ++numTriMeshes;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ simParams.boxes.resize(_storage_ , numBoxes);
+ simParams.spheres.resize(_storage_ , numSpheres);
+ simParams.capsules.resize(_storage_ , numCapsules);
+ simParams.halfSpaces.resize(_storage_ , numHalfSpaces);
+ simParams.convexMeshes.resize(_storage_ , numConvexMeshes);
+ simParams.trimeshes.resize(_storage_ , numTriMeshes);
+
+ numBoxes = 0;
+ numSpheres = 0;
+ numCapsules = 0;
+ numHalfSpaces = 0;
+ numConvexMeshes = 0;
+ numTriMeshes = 0;
+
+ if (numCollidingObjects > 0)
+ {
+ SCOPED_PHYSX_LOCK_READ(mBasicIosScene->getModulePhysXScene());
+ for (uint32_t iShape = 0; iShape < numCollidingObjects; iShape++)
+ {
+ PxShape* shape = mOverlapHits[iShape].shape;
+ PxRigidActor* actor = mOverlapHits[iShape].actor;
+
+ PxBounds3 shapeWorldBounds = PxShapeExt::getWorldBounds(*shape, *actor);
+ PxTransform actorGlobalPose = shape->getActor()->getGlobalPose();
+ PxTransform shapeGlobalPose = actorGlobalPose.transform(shape->getLocalPose());
+
+ PX_ASSERT(!shapeWorldBounds.isEmpty());
+ shapeWorldBounds.fattenFast(collisionRadius);
+
+ switch (shape->getGeometryType())
+ {
+ case PxGeometryType::eBOX:
+ {
+ PxBoxGeometry boxGeom;
+ shape->getBoxGeometry(boxGeom);
+
+ CollisionBoxData data;
+
+ data.aabb = shapeWorldBounds;
+ data.pose = shapeGlobalPose;
+ data.inversePose = data.pose.getInverse();
+
+ data.halfSize = boxGeom.halfExtents;
+
+ FillCollisionData(data, shape);
+ simParams.boxes.updateElem(_storage_, data, numBoxes++);
+ }
+ break;
+ case PxGeometryType::eSPHERE:
+ {
+ PxSphereGeometry sphereGeom;
+ shape->getSphereGeometry(sphereGeom);
+
+ CollisionSphereData data;
+
+ data.aabb = shapeWorldBounds;
+ data.pose = shapeGlobalPose;
+ data.inversePose = data.pose.getInverse();
+
+ data.radius = sphereGeom.radius;
+ //extend
+ data.radius += simParams.collisionDistance;
+
+ FillCollisionData(data, shape);
+ simParams.spheres.updateElem(_storage_, data, numSpheres++);
+ }
+ break;
+ case PxGeometryType::eCAPSULE:
+ {
+ PxCapsuleGeometry capsuleGeom;
+ shape->getCapsuleGeometry(capsuleGeom);
+
+ CollisionCapsuleData data;
+
+ data.aabb = shapeWorldBounds;
+ data.pose = shapeGlobalPose;
+ data.inversePose = data.pose.getInverse();
+
+ data.halfHeight = capsuleGeom.halfHeight;
+ data.radius = capsuleGeom.radius;
+ //extend
+ data.radius += simParams.collisionDistance;
+
+ FillCollisionData(data, shape);
+ simParams.capsules.updateElem(_storage_, data, numCapsules++);
+ }
+ break;
+ case PxGeometryType::ePLANE:
+ {
+ CollisionHalfSpaceData data;
+
+ data.origin = shapeGlobalPose.p;
+ data.normal = shapeGlobalPose.rotate(PxVec3(1, 0, 0));
+ //extend
+ data.origin += data.normal * simParams.collisionDistance;
+
+ FillCollisionData(data, shape);
+ simParams.halfSpaces.updateElem(_storage_, data, numHalfSpaces++);
+ }
+ break;
+ case PxGeometryType::eCONVEXMESH:
+ {
+ if (mAsset->mParams->collisionWithConvex)
+ {
+ PxConvexMeshGeometry convexGeom;
+ shape->getConvexMeshGeometry(convexGeom);
+
+ CollisionConvexMeshData data;
+
+ data.aabb = shapeWorldBounds;
+ data.pose = shapeGlobalPose;
+ data.inversePose = data.pose.getInverse();
+
+ //get ConvexMesh
+ const PxConvexMesh* convexMesh = convexGeom.convexMesh;
+
+ uint32_t numPolygons = convexMesh->getNbPolygons();
+ uint32_t numVertices = convexMesh->getNbVertices();
+ uint32_t polygonsDataSize = 0;
+ for (uint32_t i = 0; i < numPolygons; i++)
+ {
+ physx::PxHullPolygon polygon;
+ bool polygonDataTest = convexMesh->getPolygonData(i, polygon);
+ PX_UNUSED( polygonDataTest );
+ PX_ASSERT( polygonDataTest );
+
+ polygonsDataSize += (1 + polygon.mNbVerts);
+ }
+
+ if (mConvexPlanes.getSize() + numPolygons <= mConvexPlanes.getCapacity() &&
+ mConvexVerts.getSize() + numVertices <= mConvexVerts.getCapacity() &&
+ mConvexPolygonsData.getSize() + polygonsDataSize <= mConvexPolygonsData.getCapacity())
+ {
+ data.numPolygons = numPolygons;
+ data.firstPlane = mConvexPlanes.getSize();
+ data.firstVertex = mConvexVerts.getSize();
+ data.polygonsDataOffset = mConvexPolygonsData.getSize();
+
+ PxPlane* convexPlanes = mConvexPlanes.getPtr() + data.firstPlane;
+ PxVec4* convexVerts = mConvexVerts.getPtr() + data.firstVertex;
+ uint32_t* convexPolygonsData = mConvexPolygonsData.getPtr() + data.polygonsDataOffset;
+
+ mConvexPlanes.setSize(data.firstPlane + numPolygons);
+ mConvexVerts.setSize(data.firstVertex + numVertices);
+ mConvexPolygonsData.setSize(data.polygonsDataOffset + polygonsDataSize);
+
+ const PxMeshScale convexScaleInv( convexGeom.scale.getInverse() );
+ //copy Convex Planes & Polygon Data
+ const uint8_t* srcIndices = convexMesh->getIndexBuffer();
+ for (uint32_t i = 0; i < numPolygons; i++)
+ {
+ physx::PxHullPolygon polygon;
+ bool polygonDataTest = convexMesh->getPolygonData(i, polygon);
+ PX_UNUSED( polygonDataTest );
+ PX_ASSERT( polygonDataTest );
+ PxPlane plane(polygon.mPlane[0], polygon.mPlane[1], polygon.mPlane[2], polygon.mPlane[3]);
+ plane.n = convexScaleInv.transform(plane.n);
+ plane.normalize();
+ *convexPlanes++ = plane;
+
+ const uint32_t polygonVertCount = polygon.mNbVerts;
+ const uint8_t* polygonIndices = srcIndices + polygon.mIndexBase;
+
+ *convexPolygonsData++ = polygonVertCount;
+ for (uint32_t j = 0; j < polygonVertCount; ++j)
+ {
+ *convexPolygonsData++ = *polygonIndices++;
+ }
+ }
+
+ //copy Convex Vertices
+ const PxVec3* srcVertices = convexMesh->getVertices();
+ for (uint32_t i = 0; i < numVertices; i++)
+ {
+ *convexVerts++ = PxVec4(convexGeom.scale.transform(*srcVertices++), 0);
+ }
+ }
+ else
+ {
+ APEX_DEBUG_WARNING("BasicIosActorImpl: out of memory to store Convex data");
+
+ data.numPolygons = 0;
+ data.firstPlane = 0;
+ data.firstVertex = 0;
+ data.polygonsDataOffset = 0;
+ }
+
+ FillCollisionData(data, shape);
+ simParams.convexMeshes.updateElem(_storage_, data, numConvexMeshes++);
+ }
+ break;
+ }
+ case PxGeometryType::eTRIANGLEMESH:
+ {
+ if (mAsset->mParams->collisionWithTriangleMesh)
+ {
+ PxTriangleMeshGeometry trimeshGeom;
+ shape->getTriangleMeshGeometry(trimeshGeom);
+
+ CollisionTriMeshData data;
+
+ data.aabb = shapeWorldBounds;
+ PX_ASSERT(!data.aabb.isEmpty());
+ data.aabb.fattenFast( simParams.collisionDistance + simParams.collisionThreshold );
+ data.pose = shapeGlobalPose;
+ data.inversePose = data.pose.getInverse();
+
+ //triangle mesh data
+ const PxTriangleMesh* trimesh = trimeshGeom.triangleMesh;
+
+ const uint32_t numTrimeshIndices = trimesh->getNbTriangles() * 3;
+ const uint32_t numTrimeshVerts = trimesh->getNbVertices();
+
+ if (mTrimeshIndices.getSize() + numTrimeshIndices <= mTrimeshIndices.getCapacity() &&
+ mTrimeshVerts.getSize() + numTrimeshVerts <= mTrimeshVerts.getCapacity())
+ {
+ data.numTriangles = trimesh->getNbTriangles();
+ data.firstIndex = mTrimeshIndices.getSize();
+ data.firstVertex = mTrimeshVerts.getSize();
+
+ mTrimeshIndices.setSize(data.firstIndex + numTrimeshIndices);
+ //copy TriangleMesh indices
+ uint32_t* trimeshIndices = mTrimeshIndices.getPtr() + data.firstIndex;
+
+ const bool has16BitIndices = (trimesh->getTriangleMeshFlags() & PxTriangleMeshFlag::e16_BIT_INDICES);
+ if (has16BitIndices)
+ {
+ const uint16_t* srcIndices = static_cast<const uint16_t*>(trimesh->getTriangles());
+ for( uint32_t i = 0; i < numTrimeshIndices; i++)
+ {
+ trimeshIndices[i] = srcIndices[i];
+ }
+ }
+ else
+ {
+ const uint32_t* srcIndices = static_cast<const uint32_t*>(trimesh->getTriangles());
+ for( uint32_t i = 0; i < numTrimeshIndices; i++)
+ {
+ trimeshIndices[i] = srcIndices[i];
+ }
+ }
+
+ mTrimeshVerts.setSize(data.firstVertex + numTrimeshVerts);
+ //copy TriangleMesh vertices
+ PxVec4* trimeshVerts = mTrimeshVerts.getPtr() + data.firstVertex;
+ const PxVec3* srcVertices = trimesh->getVertices();
+ for( uint32_t i = 0; i < numTrimeshVerts; i++)
+ {
+ trimeshVerts[i] = PxVec4(trimeshGeom.scale.transform(srcVertices[i]), 0);
+ }
+ }
+ else
+ {
+ APEX_DEBUG_WARNING("BasicIosActorImpl: out of memory to store TriangleMesh data");
+
+ data.numTriangles = 0;
+ data.firstIndex = 0;
+ data.firstVertex = 0;
+ }
+
+ FillCollisionData(data, shape);
+ simParams.trimeshes.updateElem(_storage_, data, numTriMeshes++);
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ }
+
+ }
+ mSimulationParamsHandle.update(_storage_, simParams);
+ }
+
+ void BasicIosActorImpl::setTaskDependencies(PxTask* iosTask, bool isDataOnDevice)
+ {
+ PxTaskManager* tm = mBasicIosScene->getApexScene().getTaskManager();
+
+ iosTask->startAfter(mInjectTask->getTaskID());
+
+ if (mFieldSamplerQuery != NULL)
+ {
+ float deltaTime = mBasicIosScene->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());
+ }
+
+ PxTaskID postIofxTaskID = tm->getNamedTask(AST_PHYSX_FETCH_RESULTS);
+ PxTaskID iofxTaskID = mIofxMgr->getUpdateEffectsTaskID(postIofxTaskID);
+ if (iofxTaskID == (PxTaskID)0xFFFFFFFF)
+ {
+ iofxTaskID = postIofxTaskID;
+ }
+ iosTask->finishBefore(iofxTaskID);
+ }
+
+ void BasicIosActorImpl::fetchResults()
+ {
+ for(uint32_t i = 0; i < mInjectorList.getSize(); ++i)
+ {
+ BasicParticleInjector* inj = DYNAMIC_CAST(BasicParticleInjector*)(mInjectorList.getResource(i));
+ inj->assignSimParticlesCount(mInjectorsCounters.get(i));
+ }
+ }
+
+ void BasicIosActorImpl::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++)
+ {
+ BasicParticleInjector* inj = DYNAMIC_CAST(BasicParticleInjector*)(mInjectorList.getResource(i));
+ if (inj->mInjectedParticles.size() == 0)
+ {
+ continue;
+ }
+
+ if (injectCount < maxInjectCount)
+ {
+ IosNewObject obj;
+ if (inj->mInjectedParticles.popFront(obj))
+ {
+ 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.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++)
+ {
+ BasicParticleInjector* inj = DYNAMIC_CAST(BasicParticleInjector*)(mInjectorList.getResource(i));
+
+ IosNewObject obj;
+ while (inj->mInjectedParticles.popFront(obj))
+ {
+ ;
+ }
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////
+
+ BasicParticleInjector::BasicParticleInjector(ResourceList& list, BasicIosActorImpl& actor, uint32_t injectorID)
+ : mIosActor(&actor)
+ , mIofxClient(NULL)
+ , mVolume(NULL)
+ , mLastRandomID(0)
+ , mVolumeID(IofxActorIDIntl::NO_VOLUME)
+ , mInjectorID(injectorID)
+ , mSimulatedParticlesCount(0)
+ {
+ mRand.setSeed(actor.mBasicIosScene->getApexScene().getSeed());
+
+ list.add(*this);
+
+ setLODWeights(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f);
+
+ mInjectedParticles.reserve(actor.mMaxTotalParticleCount);
+ }
+
+ BasicParticleInjector::~BasicParticleInjector()
+ {
+ }
+
+ void BasicParticleInjector::setListIndex(ResourceList& list, uint32_t index)
+ {
+ m_listIndex = index;
+ m_list = &list;
+
+ InjectorParams injParams;
+ mIosActor->mBasicIosScene->fetchInjectorParams(mInjectorID, injParams);
+
+ injParams.mLocalIndex = index;
+
+ mIosActor->mBasicIosScene->updateInjectorParams(mInjectorID, injParams);
+ }
+
+
+ /* Emitter calls this function to adjust their particle weights with respect to other emitters */
+ void BasicParticleInjector::setLODWeights(float maxDistance, float distanceWeight, float speedWeight, float lifeWeight, float separationWeight, float bias)
+ {
+ PX_UNUSED(separationWeight);
+
+ InjectorParams injParams;
+ mIosActor->mBasicIosScene->fetchInjectorParams(mInjectorID, injParams);
+
+ //normalize weights
+ float totalWeight = distanceWeight + speedWeight + lifeWeight;
+ if (totalWeight > PX_EPS_F32)
+ {
+ distanceWeight /= totalWeight;
+ speedWeight /= totalWeight;
+ lifeWeight /= totalWeight;
+ }
+
+ injParams.mLODMaxDistance = maxDistance;
+ injParams.mLODDistanceWeight = distanceWeight;
+ injParams.mLODSpeedWeight = speedWeight;
+ injParams.mLODLifeWeight = lifeWeight;
+ injParams.mLODBias = bias;
+
+ mIosActor->mBasicIosScene->updateInjectorParams(mInjectorID, injParams);
+ }
+
+
+ PxTaskID BasicParticleInjector::getCompletionTaskID() const
+ {
+ return mIosActor->mInjectTask->getTaskID();
+ }
+
+ void BasicParticleInjector::setObjectScale(float objectScale)
+ {
+ PX_ASSERT(mIofxClient);
+ IofxManagerClientIntl::Params params;
+ mIofxClient->getParams(params);
+ params.objectScale = objectScale;
+ mIofxClient->setParams(params);
+ }
+
+ void BasicParticleInjector::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)mRand.getScaled(0, (float)temp.size());
+ mRandomActorClassIDs.pushBack(temp[ index ]);
+ temp.replaceWithLast(index);
+ }
+ }
+
+
+ void BasicParticleInjector::release()
+ {
+ if (mInRelease)
+ {
+ return;
+ }
+ mInRelease = true;
+ mIosActor->releaseInjector(*this);
+ }
+
+ void BasicParticleInjector::destroy()
+ {
+ ApexActor::destroy();
+
+ mIosActor->mIofxMgr->releaseClient(mIofxClient);
+
+ delete this;
+ }
+
+ void BasicParticleInjector::setPreferredRenderVolume(nvidia::apex::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 BasicParticleInjector::createObjects(uint32_t count, const IosNewObject* createList)
+ {
+ PX_PROFILE_ZONE("BasicIosCreateObjects", GetInternalApexSDK()->getContextId());
+
+ if (mRandomActorClassIDs.size() == 0)
+ {
+ return;
+ }
+
+ PxVec3 eyePos;
+ {
+ SceneIntl& apexScene = mIosActor->mBasicIosScene->getApexScene();
+ READ_LOCK(apexScene);
+ eyePos = apexScene.getEyePosition();
+ }
+ InjectorParams injParams;
+ mIosActor->mBasicIosScene->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 BasicParticleInjector::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
+
+ }
+} // namespace nvidia
+
diff --git a/APEX_1.4/module/basicios/src/BasicIosAssetImpl.cpp b/APEX_1.4/module/basicios/src/BasicIosAssetImpl.cpp
new file mode 100644
index 00000000..5fbf7296
--- /dev/null
+++ b/APEX_1.4/module/basicios/src/BasicIosAssetImpl.cpp
@@ -0,0 +1,196 @@
+/*
+ * 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 "BasicIosAssetImpl.h"
+#include "BasicIosActorImpl.h"
+//#include "ApexSharedSerialization.h"
+#include "ModuleBasicIosImpl.h"
+#include "ApexUsingNamespace.h"
+
+#if APEX_CUDA_SUPPORT
+#include "BasicIosActorGPU.h"
+#endif
+
+namespace nvidia
+{
+namespace basicios
+{
+
+void BasicIosAssetImpl::processParams()
+{
+ NvParameterized::Handle handle(mParams);
+ if (NvParameterized::ERROR_NONE != mParams->getParameterHandle("particleMass.type", handle))
+ {
+ PX_ALWAYS_ASSERT();
+ return;
+ }
+
+ const char* type = 0;
+ if (NvParameterized::ERROR_NONE != handle.getParamEnum(type))
+ {
+ PX_ALWAYS_ASSERT();
+ return;
+ }
+
+ mMassDistribType = 0 == nvidia::strcmp("uniform", type) ? UNIFORM : NORMAL;
+}
+
+BasicIosAssetImpl::BasicIosAssetImpl(ModuleBasicIosImpl* module, ResourceList& list, NvParameterized::Interface* params, const char* name) :
+ mModule(module),
+ mName(name),
+ mParams((BasicIOSAssetParam*)params)
+{
+ list.add(*this);
+ processParams();
+}
+
+BasicIosAssetImpl::BasicIosAssetImpl(ModuleBasicIosImpl* module, ResourceList& list, const char* name):
+ mModule(module),
+ mName(name),
+ mParams(0)
+{
+ NvParameterized::Traits* traits = GetInternalApexSDK()->getParameterizedTraits();
+ mParams = (BasicIOSAssetParam*)traits->createNvParameterized(BasicIOSAssetParam::staticClassName());
+
+ list.add(*this);
+
+ processParams();
+}
+
+float BasicIosAssetImpl::getParticleMass() const
+{
+ READ_ZONE();
+ float m = 0.0f;
+ switch (mMassDistribType)
+ {
+ case UNIFORM:
+ m = mParams->particleMass.center + mParams->particleMass.spread * mSRand.getNext();
+ break;
+ case NORMAL:
+ m = mNormRand.getScaled(mParams->particleMass.center, mParams->particleMass.spread);
+ break;
+ default:
+ PX_ALWAYS_ASSERT();
+ }
+
+ return m <= 0 ? mParams->particleMass.center : m; // Clamp
+}
+
+void BasicIosAssetImpl::release()
+{
+ mModule->mSdk->releaseAsset(*this);
+}
+
+void BasicIosAssetImpl::destroy()
+{
+ if (mParams)
+ {
+ mParams->destroy();
+ mParams = NULL;
+ }
+
+ delete this;
+}
+
+BasicIosAssetImpl::~BasicIosAssetImpl()
+{
+}
+
+BasicIosActorImpl* BasicIosAssetImpl::getIosActorInScene(Scene& scene, bool mesh) const
+{
+ BasicIosScene* iosScene = mModule->getBasicIosScene(scene);
+ if (iosScene != 0)
+ {
+ for (uint32_t i = 0 ; i < mIosActorList.getSize() ; i++)
+ {
+ BasicIosActorImpl* iosActor = DYNAMIC_CAST(BasicIosActorImpl*)(mIosActorList.getResource(i));
+ if (iosActor->mBasicIosScene == iosScene && iosActor->mIsMesh == mesh)
+ {
+ return iosActor;
+ }
+ }
+ }
+ return NULL;
+}
+
+Actor* BasicIosAssetImpl::createIosActor(Scene& scene, nvidia::apex::IofxAsset* iofxAsset)
+{
+ BasicIosActorImpl* iosActor = getIosActorInScene(scene, iofxAsset->getMeshAssetCount() > 0);
+ if (iosActor == 0)
+ {
+ BasicIosScene* iosScene = mModule->getBasicIosScene(scene);
+ if (iosScene != 0)
+ {
+ iosActor = iosScene->createIosActor(mIosActorList, *this, *iofxAsset);
+ iosActor->mIsMesh = iofxAsset->getMeshAssetCount() > 0;
+ }
+ }
+ PX_ASSERT(iosActor);
+ return iosActor;
+}
+
+void BasicIosAssetImpl::releaseIosActor(Actor& actor)
+{
+ BasicIosActorImpl* iosActor = DYNAMIC_CAST(BasicIosActorImpl*)(&actor);
+ iosActor->destroy();
+}
+
+uint32_t BasicIosAssetImpl::forceLoadAssets()
+{
+ return 0;
+}
+
+bool BasicIosAssetImpl::getSupportsDensity() const
+{
+ BasicIOSAssetParam* gridParams = (BasicIOSAssetParam*)(getAssetNvParameterized());
+ return (gridParams->GridDensity.Enabled);
+}
+
+#ifndef WITHOUT_APEX_AUTHORING
+/******************* BasicIosAssetAuthoringImpl *******************/
+BasicIosAssetAuthoringImpl::BasicIosAssetAuthoringImpl(ModuleBasicIosImpl* module, ResourceList& list):
+ BasicIosAssetImpl(module, list, "Authoring")
+{
+}
+BasicIosAssetAuthoringImpl::BasicIosAssetAuthoringImpl(ModuleBasicIosImpl* module, ResourceList& list, const char* name):
+ BasicIosAssetImpl(module, list, name)
+{
+}
+
+BasicIosAssetAuthoringImpl::BasicIosAssetAuthoringImpl(ModuleBasicIosImpl* module, ResourceList& list, NvParameterized::Interface* params, const char* name) :
+ BasicIosAssetImpl(module, list, params, name)
+{
+}
+
+void BasicIosAssetAuthoringImpl::release()
+{
+ delete this;
+}
+
+void BasicIosAssetAuthoringImpl::setCollisionGroupName(const char* collisionGroupName)
+{
+ NvParameterized::Handle h(*mParams, "collisionGroupName");
+ h.setParamString(collisionGroupName);
+}
+
+void BasicIosAssetAuthoringImpl::setCollisionGroupMaskName(const char* collisionGroupMaskName)
+{
+ NvParameterized::Handle h(*mParams, "collisionGroupMaskName");
+ h.setParamString(collisionGroupMaskName);
+}
+
+
+#endif
+
+}
+} // namespace nvidia
diff --git a/APEX_1.4/module/basicios/src/BasicIosScene.cpp b/APEX_1.4/module/basicios/src/BasicIosScene.cpp
new file mode 100644
index 00000000..c142a5e4
--- /dev/null
+++ b/APEX_1.4/module/basicios/src/BasicIosScene.cpp
@@ -0,0 +1,469 @@
+/*
+ * 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 "BasicIosScene.h"
+#include "ModuleBasicIosImpl.h"
+#include "BasicIosActorImpl.h"
+#include "BasicIosActorCPU.h"
+#include "ApexUsingNamespace.h"
+#include "SceneIntl.h"
+#include "ModulePerfScope.h"
+#include "ModuleFieldSamplerIntl.h"
+#include "RenderDebugInterface.h"
+
+#if APEX_CUDA_SUPPORT
+#include <cuda.h>
+#include "ApexCutil.h"
+#include "BasicIosActorGPU.h"
+
+#include "ApexCudaSource.h"
+#endif
+
+#include <PxScene.h>
+
+namespace nvidia
+{
+namespace basicios
+{
+
+#pragma warning(push)
+#pragma warning(disable:4355)
+
+BasicIosScene::BasicIosScene(ModuleBasicIosImpl& _module, SceneIntl& scene, RenderDebugInterface* debugRender, ResourceList& list)
+ : mPhysXScene(NULL)
+ , mModule(&_module)
+ , mApexScene(&scene)
+ , mDebugRender(debugRender)
+ , mSumBenefit(0.0f)
+ , mFieldSamplerManager(NULL)
+ , mInjectorAllocator(this)
+{
+ list.add(*this);
+
+ /* Initialize reference to BasicIosDebugRenderParams */
+ 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(BasicIosDebugRenderParams::staticClassName(), true);
+ }
+ }
+
+ /* Load reference to BasicIosDebugRenderParams */
+ NvParameterized::Interface* refPtr = NULL;
+ memberHandle.getParamRef(refPtr);
+ mBasicIosDebugRenderParams = DYNAMIC_CAST(BasicIosDebugRenderParams*)(refPtr);
+ PX_ASSERT(mBasicIosDebugRenderParams);
+}
+
+#pragma warning(pop)
+
+BasicIosScene::~BasicIosScene()
+{
+}
+
+void BasicIosScene::destroy()
+{
+ removeAllActors();
+ mApexScene->moduleReleased(*this);
+ delete this;
+}
+
+void BasicIosScene::setModulePhysXScene(PxScene* s)
+{
+ if (mPhysXScene == s)
+ {
+ return;
+ }
+
+ mPhysXScene = s;
+ for (uint32_t i = 0; i < mActorArray.size(); ++i)
+ {
+ BasicIosActorImpl* actor = DYNAMIC_CAST(BasicIosActorImpl*)(mActorArray[i]);
+ actor->setPhysXScene(mPhysXScene);
+ }
+}
+
+void BasicIosScene::visualize()
+{
+#ifndef WITHOUT_DEBUG_VISUALIZE
+ if (!mBasicIosDebugRenderParams->VISUALIZE_BASIC_IOS_ACTOR)
+ {
+ return;
+ }
+
+ RENDER_DEBUG_IFACE(mDebugRender)->pushRenderState();
+ for (uint32_t i = 0 ; i < mActorArray.size() ; i++)
+ {
+ BasicIosActorImpl* testActor = DYNAMIC_CAST(BasicIosActorImpl*)(mActorArray[ i ]);
+ testActor->visualize();
+ }
+ RENDER_DEBUG_IFACE(mDebugRender)->popRenderState();
+#endif
+}
+
+void BasicIosScene::submitTasks(float /*elapsedTime*/, float /*substepSize*/, uint32_t /*numSubSteps*/)
+{
+ for (uint32_t i = 0; i < mActorArray.size(); ++i)
+ {
+ BasicIosActorImpl* actor = DYNAMIC_CAST(BasicIosActorImpl*)(mActorArray[i]);
+ if (mPhysXScene)
+ {
+ PxVec3 gravity = mApexScene->getGravity();
+
+ if (actor->getGravity() != gravity)
+ {
+ actor->setGravity(gravity);
+ }
+ }
+ actor->submitTasks();
+ }
+}
+
+void BasicIosScene::setTaskDependencies()
+{
+ for (uint32_t i = 0; i < mActorArray.size(); ++i)
+ {
+ BasicIosActorImpl* actor = DYNAMIC_CAST(BasicIosActorImpl*)(mActorArray[i]);
+ actor->setTaskDependencies();
+ }
+
+ onSimulationStart();
+}
+
+void BasicIosScene::fetchResults()
+{
+ onSimulationFinish();
+
+ for (uint32_t i = 0; i < mActorArray.size(); ++i)
+ {
+ BasicIosActorImpl* actor = DYNAMIC_CAST(BasicIosActorImpl*)(mActorArray[i]);
+ actor->fetchResults();
+ }
+}
+
+FieldSamplerManagerIntl* BasicIosScene::getInternalFieldSamplerManager()
+{
+ if (mFieldSamplerManager == NULL)
+ {
+ ModuleFieldSamplerIntl* moduleFieldSampler = mModule->getInternalModuleFieldSampler();
+ if (moduleFieldSampler != NULL)
+ {
+ mFieldSamplerManager = moduleFieldSampler->getInternalFieldSamplerManager(*mApexScene);
+ PX_ASSERT(mFieldSamplerManager != NULL);
+ }
+ }
+ return mFieldSamplerManager;
+}
+
+/******************************** CPU Version ********************************/
+
+void BasicIosSceneCPU::TimerCallback::operator()(void* stream)
+{
+ PX_UNUSED(stream);
+
+ float elapsed = (float)mTimer.peekElapsedSeconds();
+ mMinTime = PxMin(elapsed, mMinTime);
+ mMaxTime = PxMax(elapsed, mMaxTime);
+}
+
+void BasicIosSceneCPU::TimerCallback::reset()
+{
+ mTimer.getElapsedSeconds();
+ mMinTime = 1e20;
+ mMaxTime = 0.f;
+}
+
+float BasicIosSceneCPU::TimerCallback::getElapsedTime() const
+{
+ return (mMaxTime - mMinTime) * 1000.f;
+}
+
+BasicIosSceneCPU::BasicIosSceneCPU(ModuleBasicIosImpl& module, SceneIntl& scene, RenderDebugInterface* debugRender, ResourceList& list)
+ : BASIC_IOS_SCENE(module, scene, debugRender, list)
+{
+}
+
+BasicIosSceneCPU::~BasicIosSceneCPU()
+{
+}
+
+
+void BasicIosSceneCPU::setCallbacks(BasicIosActorCPU* actor)
+{
+ actor->setOnStartFSCallback(&mTimerCallback);
+ actor->setOnFinishIOFXCallback(&mTimerCallback);
+}
+
+
+BasicIosActorImpl* BasicIosSceneCPU::createIosActor(ResourceList& list, BasicIosAssetImpl& asset, nvidia::apex::IofxAsset& iofxAsset)
+{
+ BasicIosActorCPU* actor = PX_NEW(BasicIosActorCPU)(list, asset, *this, iofxAsset);
+ setCallbacks(actor);
+ return actor;
+}
+
+void BasicIosSceneCPU::fetchResults()
+{
+ BasicIosScene::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
+
+BasicIosSceneGPU::EventCallback::EventCallback() : mIsCalled(false), mEvent(NULL)
+{
+}
+void BasicIosSceneGPU::EventCallback::init()
+{
+ if (mEvent == NULL)
+ {
+ CUT_SAFE_CALL(cuEventCreate((CUevent*)(&mEvent), CU_EVENT_DEFAULT));
+ }
+}
+
+BasicIosSceneGPU::EventCallback::~EventCallback()
+{
+ if (mEvent != NULL)
+ {
+ CUT_SAFE_CALL(cuEventDestroy((CUevent)mEvent));
+ }
+}
+
+void BasicIosSceneGPU::EventCallback::operator()(void* stream)
+{
+ if (mEvent != NULL)
+ {
+ CUT_SAFE_CALL(cuEventRecord((CUevent)mEvent, (CUstream)stream));
+ mIsCalled = true;
+ }
+}
+
+BasicIosSceneGPU::BasicIosSceneGPU(ModuleBasicIosImpl& module, SceneIntl& scene, RenderDebugInterface* debugRender, ResourceList& list)
+ : BASIC_IOS_SCENE(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());
+
+ mInjectorConstMemGroup.end();
+ }
+
+}
+
+BasicIosSceneGPU::~BasicIosSceneGPU()
+{
+ 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);
+}
+
+
+void BasicIosSceneGPU::setCallbacks(BasicIosActorGPU* actor)
+{
+ 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());
+}
+
+
+BasicIosActorImpl* BasicIosSceneGPU::createIosActor(ResourceList& list, BasicIosAssetImpl& asset, nvidia::apex::IofxAsset& iofxAsset)
+{
+ BasicIosActorGPU* actor = PX_NEW(BasicIosActorGPU)(list, asset, *this, iofxAsset);
+ setCallbacks(actor);
+ return actor;
+}
+
+void BasicIosSceneGPU::fetchInjectorParams(uint32_t injectorID, InjectorParams& 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 BasicIosSceneGPU::updateInjectorParams(uint32_t injectorID, const InjectorParams& injParams)
+{
+ APEX_CUDA_CONST_MEM_GROUP_SCOPE(mInjectorConstMemGroup);
+
+ InjectorParamsArray injectorParamsArray;
+ mInjectorParamsArrayHandle.fetch(_storage_, injectorParamsArray);
+ PX_ASSERT(injectorID < injectorParamsArray.getSize());
+ injectorParamsArray.updateElem(_storage_, injParams, injectorID);
+}
+
+bool BasicIosSceneGPU::growInjectorStorage(uint32_t newSize)
+{
+ APEX_CUDA_CONST_MEM_GROUP_SCOPE(mInjectorConstMemGroup);
+
+ if (mApexScene->isSimulating())
+ {
+ APEX_INTERNAL_ERROR("BasicIosSceneGPU::growInjectorStorage - is called while ApexScene in simulating!");
+ PX_ASSERT(0);
+ }
+
+ InjectorParamsArray injectorParamsArray;
+ mInjectorParamsArrayHandle.fetch(_storage_, injectorParamsArray);
+ if (injectorParamsArray.resize(_storage_, newSize))
+ {
+ mInjectorParamsArrayHandle.update(_storage_, injectorParamsArray);
+ return true;
+ }
+ return false;
+}
+
+
+void BasicIosSceneGPU::onSimulationStart()
+{
+ BasicIosScene::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);
+}
+
+void BasicIosSceneGPU::fetchResults()
+{
+ BasicIosScene::fetchResults();
+
+ PxGpuDispatcher* gd = mApexScene->getTaskManager()->getGpuDispatcher();
+ PX_ASSERT(gd != NULL);
+ PxScopedCudaLock _lock_(*gd->getCudaContextManager());
+
+ 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);
+ }
+}
+#endif
+
+// BasicIosInjectorAllocator
+uint32_t BasicIosInjectorAllocator::allocateInjectorID()
+{
+ uint32_t size = mInjectorList.size();
+ if (mFreeInjectorListStart == NULL_INJECTOR_INDEX)
+ {
+ //try to get new injectors
+ 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 BasicIosInjectorAllocator::releaseInjectorID(uint32_t injectorID)
+{
+ //add to released injector list
+ PX_ASSERT(mInjectorList[injectorID] == USED_INJECTOR_INDEX);
+ mInjectorList[injectorID] = mReleasedInjectorListStart;
+ mReleasedInjectorListStart = injectorID;
+}
+
+void BasicIosInjectorAllocator::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/basicios/src/ModuleBasicIosImpl.cpp b/APEX_1.4/module/basicios/src/ModuleBasicIosImpl.cpp
new file mode 100644
index 00000000..4d149ded
--- /dev/null
+++ b/APEX_1.4/module/basicios/src/ModuleBasicIosImpl.cpp
@@ -0,0 +1,416 @@
+/*
+ * 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 "ApexSDKIntl.h"
+#include "ModuleBasicIosImpl.h"
+#include "ModuleBasicIosRegistration.h"
+#include "ModulePerfScope.h"
+#include "ApexUsingNamespace.h"
+#include "BasicIosSceneCPU.h"
+#if APEX_CUDA_SUPPORT
+#include "BasicIosSceneGPU.h"
+#endif
+#if ENABLE_TEST
+#include "BasicIosTestSceneCPU.h"
+#if APEX_CUDA_SUPPORT
+#include "BasicIosTestSceneGPU.h"
+#endif
+#endif
+#include "BasicIosAssetImpl.h"
+#include "BasicIosActorImpl.h"
+
+#include "SceneIntl.h"
+#include "ModuleIofxIntl.h"
+#include "ModuleFieldSamplerIntl.h"
+#include "PsMemoryBuffer.h"
+
+#include "Lock.h"
+
+#include "ReadCheck.h"
+
+using namespace basicios;
+
+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;
+ }
+
+ /* Setup common module global variables */
+ gApexSdk = inSdk;
+
+ ModuleBasicIosImpl* impl = PX_NEW(ModuleBasicIos)(inSdk);
+ *niRef = (ModuleIntl*) impl;
+ return (ModuleBase*) impl;
+}
+#else
+/* Statically linking entry function */
+void instantiateModuleBasicIos()
+{
+ ApexSDKIntl* sdk = GetInternalApexSDK();
+ basicios::ModuleBasicIosImpl* impl = PX_NEW(basicios::ModuleBasicIosImpl)(sdk);
+ sdk->registerExternalModule((Module*) impl, (ModuleIntl*) impl);
+}
+#endif
+}
+
+namespace basicios
+{
+/* =================== ModuleBasicIosImpl =================== */
+
+
+AuthObjTypeID BasicIosAssetImpl::mAssetTypeID;
+
+#ifdef WITHOUT_APEX_AUTHORING
+
+class BasicIosAssetDummyAuthoring : public AssetAuthoring, public UserAllocated
+{
+public:
+ BasicIosAssetDummyAuthoring(ModuleBasicIosImpl* module, ResourceList& list, NvParameterized::Interface* params, const char* name)
+ {
+ PX_UNUSED(module);
+ PX_UNUSED(list);
+ PX_UNUSED(params);
+ PX_UNUSED(name);
+ }
+
+ BasicIosAssetDummyAuthoring(ModuleBasicIosImpl* module, ResourceList& list, const char* name)
+ {
+ PX_UNUSED(module);
+ PX_UNUSED(list);
+ PX_UNUSED(name);
+ }
+
+ BasicIosAssetDummyAuthoring(ModuleBasicIosImpl* 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 Returns the name of this APEX authorable object type
+ */
+ virtual const char* getObjTypeName() const
+ {
+ return BasicIosAssetImpl::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<ModuleBasicIosImpl, BasicIosAssetImpl, BasicIosAssetDummyAuthoring> BasicIOSAO;
+
+#else
+typedef ApexAuthorableObject<ModuleBasicIosImpl, BasicIosAssetImpl, BasicIosAssetAuthoringImpl> BasicIOSAO;
+#endif
+
+ModuleBasicIosImpl::ModuleBasicIosImpl(ApexSDKIntl* sdk)
+{
+ mSdk = sdk;
+ mApiProxy = this;
+ mName = "BasicIOS";
+ mModuleParams = NULL;
+ mIofxModule = NULL;
+ mFieldSamplerModule = NULL;
+
+ /* Register this module's authorable object types and create their namespaces */
+ const char* pName = BasicIOSAssetParam::staticClassName();
+ BasicIOSAO* eAO = PX_NEW(BasicIOSAO)(this, mAuthorableObjects, pName);
+ BasicIosAssetImpl::mAssetTypeID = eAO->getResID();
+
+ /* Register the NvParameterized factories */
+ NvParameterized::Traits* traits = mSdk->getParameterizedTraits();
+ ModuleBasicIosRegistration::invokeRegistration(traits);
+}
+
+AuthObjTypeID ModuleBasicIosImpl::getModuleID() const
+{
+ return BasicIosAssetImpl::mAssetTypeID;
+}
+
+ModuleBasicIosImpl::~ModuleBasicIosImpl()
+{
+}
+
+void ModuleBasicIosImpl::destroy()
+{
+ NvParameterized::Traits* traits = mSdk->getParameterizedTraits();
+
+ if (mModuleParams)
+ {
+ mModuleParams->destroy();
+ mModuleParams = NULL;
+ }
+
+ ModuleBase::destroy();
+
+ if (traits)
+ {
+ /* Remove the NvParameterized factories */
+ ModuleBasicIosRegistration::invokeUnregistration(traits);
+ }
+
+ delete this;
+}
+
+void ModuleBasicIosImpl::init(const ModuleBasicIosDesc&)
+{
+}
+
+void ModuleBasicIosImpl::init(NvParameterized::Interface&)
+{
+ ModuleBasicIosDesc desc;
+ init(desc);
+}
+
+NvParameterized::Interface* ModuleBasicIosImpl::getDefaultModuleDesc()
+{
+ NvParameterized::Traits* traits = mSdk->getParameterizedTraits();
+
+ if (!mModuleParams)
+ {
+ mModuleParams = DYNAMIC_CAST(BasicIosModuleParameters*)
+ (traits->createNvParameterized("BasicIosModuleParameters"));
+ PX_ASSERT(mModuleParams);
+ }
+ else
+ {
+ mModuleParams->initDefaults();
+ }
+
+ return mModuleParams;
+}
+
+uint32_t ModuleBasicIosImpl::forceLoadAssets()
+{
+ return 0;
+}
+
+BasicIosScene* ModuleBasicIosImpl::getBasicIosScene(const Scene& apexScene)
+{
+ const SceneIntl* niScene = DYNAMIC_CAST(const SceneIntl*)(&apexScene);
+ for (uint32_t i = 0 ; i < mBasicIosSceneList.getSize() ; i++)
+ {
+ BasicIosScene* ps = DYNAMIC_CAST(BasicIosScene*)(mBasicIosSceneList.getResource(i));
+ if (ps->mApexScene == niScene)
+ {
+ return ps;
+ }
+ }
+
+ PX_ASSERT(!"Unable to locate an appropriate BasicIosScene");
+ return NULL;
+}
+
+const BasicIosScene* ModuleBasicIosImpl::getBasicIosScene(const Scene& apexScene) const
+{
+ const SceneIntl* niScene = DYNAMIC_CAST(const SceneIntl*)(&apexScene);
+ for (uint32_t i = 0 ; i < mBasicIosSceneList.getSize() ; i++)
+ {
+ BasicIosScene* ps = DYNAMIC_CAST(BasicIosScene*)(mBasicIosSceneList.getResource(i));
+ if (ps->mApexScene == niScene)
+ {
+ return ps;
+ }
+ }
+
+ PX_ASSERT(!"Unable to locate an appropriate BasicIosScene");
+ return NULL;
+}
+
+RenderableIterator* ModuleBasicIosImpl::createRenderableIterator(const Scene& apexScene)
+{
+ BasicIosScene* ps = getBasicIosScene(apexScene);
+ if (ps)
+ {
+ return ps->createRenderableIterator();
+ }
+
+ return NULL;
+}
+
+ModuleSceneIntl* ModuleBasicIosImpl::createInternalModuleScene(SceneIntl& scene, RenderDebugInterface* renderDebug)
+{
+ READ_LOCK(scene);
+#if APEX_CUDA_SUPPORT
+ if (scene.getTaskManager()->getGpuDispatcher() && scene.isUsingCuda())
+ {
+#if ENABLE_TEST
+ return PX_NEW(BasicIosTestSceneGPU)(*this, scene, renderDebug, mBasicIosSceneList);
+#else
+ return PX_NEW(BasicIosSceneGPU)(*this, scene, renderDebug, mBasicIosSceneList);
+#endif
+ }
+ else
+#endif
+ {
+#if ENABLE_TEST
+ return PX_NEW(BasicIosTestSceneCPU)(*this, scene, renderDebug, mBasicIosSceneList);
+#else
+ return PX_NEW(BasicIosSceneCPU)(*this, scene, renderDebug, mBasicIosSceneList);
+#endif
+ }
+}
+
+void ModuleBasicIosImpl::releaseModuleSceneIntl(ModuleSceneIntl& scene)
+{
+ BasicIosScene* ps = DYNAMIC_CAST(BasicIosScene*)(&scene);
+ ps->destroy();
+}
+
+const char* ModuleBasicIosImpl::getBasicIosTypeName()
+{
+ READ_ZONE();
+ return BasicIosAssetImpl::getClassName();
+}
+
+
+ApexActor* ModuleBasicIosImpl::getApexActor(Actor* nxactor, AuthObjTypeID type) const
+{
+ if (type == BasicIosAssetImpl::mAssetTypeID)
+ {
+ return static_cast<BasicIosActorImpl*>(nxactor);
+ }
+
+ return NULL;
+}
+
+ModuleIofxIntl* ModuleBasicIosImpl::getInternalModuleIofx()
+{
+ if (!mIofxModule )
+ {
+ ModuleIntl* nim = mSdk->getInternalModuleByName("IOFX");
+ if (nim)
+ {
+ mIofxModule = DYNAMIC_CAST(ModuleIofxIntl*)(nim);
+ }
+ }
+ return mIofxModule;
+}
+
+ModuleFieldSamplerIntl* ModuleBasicIosImpl::getInternalModuleFieldSampler()
+{
+ if (!mFieldSamplerModule)
+ {
+ ModuleIntl* nim = mSdk->getInternalModuleByName("FieldSampler");
+ if (nim)
+ {
+ mFieldSamplerModule = DYNAMIC_CAST(ModuleFieldSamplerIntl*)(nim);
+ }
+ }
+ return mFieldSamplerModule;
+}
+
+const TestBase* ModuleBasicIosImpl::getTestBase(Scene* apexScene) const
+{
+
+ const BasicIosScene* scene = getBasicIosScene(*apexScene);
+
+#if APEX_CUDA_SUPPORT && ENABLE_TEST
+ if (scene->getApexScene().getTaskManager()->getGpuDispatcher() && scene->getApexScene().isUsingCuda())
+ {
+ return static_cast<const TestBase*>(DYNAMIC_CAST(const BasicIosTestSceneGPU*)(scene));
+ }
+#endif
+
+#if ENABLE_TEST
+ return static_cast<const TestBase*>(DYNAMIC_CAST(const BasicIosTestSceneCPU*)(scene));
+#else
+ PX_UNUSED(scene);
+ return 0;
+#endif
+
+}
+
+}
+} // namespace nvidia
diff --git a/APEX_1.4/module/basicios/src/autogen/BasicIOSAssetParam.cpp b/APEX_1.4/module/basicios/src/autogen/BasicIOSAssetParam.cpp
new file mode 100644
index 00000000..2fd5f901
--- /dev/null
+++ b/APEX_1.4/module/basicios/src/autogen/BasicIOSAssetParam.cpp
@@ -0,0 +1,1406 @@
+// 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 "BasicIOSAssetParam.h"
+#include <string.h>
+#include <stdlib.h>
+
+using namespace NvParameterized;
+
+namespace nvidia
+{
+namespace basicios
+{
+
+using namespace BasicIOSAssetParamNS;
+
+const char* const BasicIOSAssetParamFactory::vptr =
+ NvParameterized::getVptr<BasicIOSAssetParam, BasicIOSAssetParam::ClassAlignment>();
+
+const uint32_t NumParamDefs = 38;
+static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs];
+
+
+static const size_t ParamLookupChildrenTable[] =
+{
+ 1, 2, 3, 4, 5, 6, 7, 8, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 27, 28, 29, 30,
+ 34, 9, 10, 11, 23, 24, 25, 26, 31, 32, 33, 35, 36, 37,
+};
+
+#define TENUM(type) nvidia::##type
+#define CHILDREN(index) &ParamLookupChildrenTable[index]
+static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] =
+{
+ { TYPE_STRUCT, false, 0, CHILDREN(0), 24 },
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->restDensity), NULL, 0 }, // restDensity
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->particleRadius), NULL, 0 }, // particleRadius
+ { TYPE_U32, false, (size_t)(&((ParametersStruct*)0)->maxParticleCount), NULL, 0 }, // maxParticleCount
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->maxInjectedParticleCount), NULL, 0 }, // maxInjectedParticleCount
+ { TYPE_U32, false, (size_t)(&((ParametersStruct*)0)->maxCollidingObjects), NULL, 0 }, // maxCollidingObjects
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->sceneGravityScale), NULL, 0 }, // sceneGravityScale
+ { TYPE_VEC3, false, (size_t)(&((ParametersStruct*)0)->externalAcceleration), NULL, 0 }, // externalAcceleration
+ { TYPE_STRUCT, false, (size_t)(&((ParametersStruct*)0)->particleMass), CHILDREN(24), 3 }, // particleMass
+ { TYPE_F32, false, (size_t)(&((RandomF32_Type*)0)->center), NULL, 0 }, // particleMass.center
+ { TYPE_F32, false, (size_t)(&((RandomF32_Type*)0)->spread), NULL, 0 }, // particleMass.spread
+ { TYPE_ENUM, false, (size_t)(&((RandomF32_Type*)0)->type), NULL, 0 }, // particleMass.type
+ { TYPE_STRING, false, (size_t)(&((ParametersStruct*)0)->collisionFilterDataName), NULL, 0 }, // collisionFilterDataName
+ { TYPE_STRING, false, (size_t)(&((ParametersStruct*)0)->fieldSamplerFilterDataName), NULL, 0 }, // fieldSamplerFilterDataName
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->staticCollision), NULL, 0 }, // staticCollision
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->restitutionForStaticShapes), NULL, 0 }, // restitutionForStaticShapes
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->dynamicCollision), NULL, 0 }, // dynamicCollision
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->restitutionForDynamicShapes), NULL, 0 }, // restitutionForDynamicShapes
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->collisionDistanceMultiplier), NULL, 0 }, // collisionDistanceMultiplier
+ { TYPE_F32, false, (size_t)(&((ParametersStruct*)0)->collisionThreshold), NULL, 0 }, // collisionThreshold
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->collisionWithConvex), NULL, 0 }, // collisionWithConvex
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->collisionWithTriangleMesh), NULL, 0 }, // collisionWithTriangleMesh
+ { TYPE_STRUCT, false, (size_t)(&((ParametersStruct*)0)->GridDensity), CHILDREN(27), 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
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->enableTemperatureBuffer), NULL, 0 }, // enableTemperatureBuffer
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->enableDensityBuffer), NULL, 0 }, // enableDensityBuffer
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->enableCouplingOverride), NULL, 0 }, // enableCouplingOverride
+ { TYPE_STRUCT, false, (size_t)(&((ParametersStruct*)0)->particleToGridCoupling), CHILDREN(31), 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(34), 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 BasicIOSAssetParam::mBuiltFlag = false;
+NvParameterized::MutexType BasicIOSAssetParam::mBuiltFlagMutex;
+
+BasicIOSAssetParam::BasicIOSAssetParam(NvParameterized::Traits* traits, void* buf, int32_t* refCount) :
+ NvParameters(traits, buf, refCount)
+{
+ //mParameterizedTraits->registerFactory(className(), &BasicIOSAssetParamFactoryInst);
+
+ if (!buf) //Do not init data if it is inplace-deserialized
+ {
+ initDynamicArrays();
+ initStrings();
+ initReferences();
+ initDefaults();
+ }
+}
+
+BasicIOSAssetParam::~BasicIOSAssetParam()
+{
+ freeStrings();
+ freeReferences();
+ freeDynamicArrays();
+}
+
+void BasicIOSAssetParam::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->~BasicIOSAssetParam();
+
+ NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf);
+}
+
+const NvParameterized::DefinitionImpl* BasicIOSAssetParam::getParameterDefinitionTree(void)
+{
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+ if (!mBuiltFlag)
+ {
+ buildTree();
+ }
+ }
+
+ return(&ParamDefTable[0]);
+}
+
+const NvParameterized::DefinitionImpl* BasicIOSAssetParam::getParameterDefinitionTree(void) const
+{
+ BasicIOSAssetParam* tmpParam = const_cast<BasicIOSAssetParam*>(this);
+
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+ if (!mBuiltFlag)
+ {
+ tmpParam->buildTree();
+ }
+ }
+
+ return(&ParamDefTable[0]);
+}
+
+NvParameterized::ErrorType BasicIOSAssetParam::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 BasicIOSAssetParam::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 BasicIOSAssetParam::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const
+{
+ ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<BasicIOSAssetParam::ParametersStruct*>(&parameters()), handle, offset);
+}
+
+
+/* Dynamic Handle Indices */
+
+void BasicIOSAssetParam::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 BasicIOSAssetParam::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="restDensity"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1];
+ ParamDef->init("restDensity", 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[1].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", "\nAuthored density of the instanced objects simulated by this IOS. Emitters need this\nvalue for constant density emitter effects.\n", true);
+ HintTable[2].init("min", uint64_t(0), true);
+ HintTable[3].init("shortDescription", "Rest density of particles", true);
+ ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 4);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=2, longName="particleRadius"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2];
+ 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[2].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", "\nRadius of a particle.\n", true);
+ HintTable[2].init("min", uint64_t(0), true);
+ HintTable[3].init("shortDescription", "Radius of a particle", true);
+ ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 4);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=3, longName="maxParticleCount"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3];
+ 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[3].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[3].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#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", "\nThe 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="maxCollidingObjects"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[5];
+ ParamDef->init("maxCollidingObjects", 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(1), 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", "Maximum number of objects that are able to collide with each other (boxes, spheres, capsules, hspaces, convexmeshes, trimeshes).\n", true);
+ HintTable[1].init("min", uint64_t(1), true);
+ HintTable[2].init("shortDescription", "Maximum number of particles that are able to collide with each other.", true);
+ ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 3);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=6, longName="sceneGravityScale"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[6];
+ ParamDef->init("sceneGravityScale", 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[6].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", "Used to scale, or even disable the basic IOS's gravity", true);
+ ParamDefTable[6].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=7, longName="externalAcceleration"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[7];
+ ParamDef->init("externalAcceleration", TYPE_VEC3, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("gameScale", "true", true);
+ ParamDefTable[7].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("gameScale", "true", true);
+ HintTable[1].init("shortDescription", "Acceleration (m/s^2) applied to all particles at all time steps (added to the scaled scene gravity).", true);
+ ParamDefTable[7].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=8, longName="particleMass"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[8];
+ ParamDef->init("particleMass", TYPE_STRUCT, "RandomF32", true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("longDescription", "Defines parameters of probability distribution of particle masses.\n", true);
+ HintTable[1].init("shortDescription", "Probability distribution of particle masses for this IOS.", true);
+ ParamDefTable[8].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=9, longName="particleMass.center"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[9];
+ ParamDef->init("center", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "Center of distribution", true);
+ ParamDefTable[9].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=10, longName="particleMass.spread"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[10];
+ ParamDef->init("spread", 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", "Spread is std deviation for normal distribution or halfwidth for uniform distribution.\n", true);
+ HintTable[1].init("shortDescription", "Spread of distribution", true);
+ ParamDefTable[10].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=11, longName="particleMass.type"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[11];
+ ParamDef->init("type", 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", "Type of probability distribution (currently only normal and uniform are supported).\n", true);
+ HintTable[1].init("shortDescription", "Distribution type", true);
+ ParamDefTable[11].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+ static const char* const EnumVals[] = { "uniform", "normal" };
+ ParamDefTable[11].setEnumVals((const char**)EnumVals, 2);
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=12, longName="collisionFilterDataName"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[12];
+ ParamDef->init("collisionFilterDataName", 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[12].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#else
+
+ static HintImpl HintTable[2];
+ static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
+ HintTable[0].init("HIDDEN", uint64_t(1), true);
+ HintTable[1].init("shortDescription", "The filter data (group/groupsMask) name for IOS vs PhysX interaction.", true);
+ ParamDefTable[12].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=13, longName="fieldSamplerFilterDataName"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[13];
+ ParamDef->init("fieldSamplerFilterDataName", TYPE_STRING, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+#else
+
+ static HintImpl HintTable[1];
+ static Hint* HintPtrTable[1] = { &HintTable[0], };
+ HintTable[0].init("shortDescription", "The filter data name for IOS vs FieldSampler interaction.", true);
+ ParamDefTable[13].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=14, longName="staticCollision"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[14];
+ ParamDef->init("staticCollision", 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(1), true);
+ ParamDefTable[14].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(1), true);
+ HintTable[1].init("shortDescription", "Enables collision with static shapes", true);
+ ParamDefTable[14].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=15, longName="restitutionForStaticShapes"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[15];
+ ParamDef->init("restitutionForStaticShapes", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[3];
+ static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], };
+ HintTable[0].init("defaultValue", double(0.5), true);
+ HintTable[1].init("max", uint64_t(1), true);
+ HintTable[2].init("min", uint64_t(0), true);
+ ParamDefTable[15].setHints((const NvParameterized::Hint**)HintPtrTable, 3);
+
+#else
+
+ static HintImpl HintTable[4];
+ static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], };
+ HintTable[0].init("defaultValue", double(0.5), true);
+ HintTable[1].init("max", uint64_t(1), true);
+ HintTable[2].init("min", uint64_t(0), true);
+ HintTable[3].init("shortDescription", "Defines the restitution coefficient used for collisions with static shapes.", true);
+ ParamDefTable[15].setHints((const NvParameterized::Hint**)HintPtrTable, 4);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=16, longName="dynamicCollision"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[16];
+ ParamDef->init("dynamicCollision", 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(1), true);
+ ParamDefTable[16].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(1), true);
+ HintTable[1].init("shortDescription", "Enables collision with dynamic shapes", true);
+ ParamDefTable[16].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=17, longName="restitutionForDynamicShapes"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[17];
+ ParamDef->init("restitutionForDynamicShapes", TYPE_F32, NULL, true);
+
+#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
+
+ static HintImpl HintTable[3];
+ static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], };
+ HintTable[0].init("defaultValue", double(0.5), true);
+ HintTable[1].init("max", uint64_t(1), true);
+ HintTable[2].init("min", uint64_t(0), true);
+ ParamDefTable[17].setHints((const NvParameterized::Hint**)HintPtrTable, 3);
+
+#else
+
+ static HintImpl HintTable[4];
+ static Hint* HintPtrTable[4] = { &HintTable[0], &HintTable[1], &HintTable[2], &HintTable[3], };
+ HintTable[0].init("defaultValue", double(0.5), true);
+ HintTable[1].init("max", uint64_t(1), true);
+ HintTable[2].init("min", uint64_t(0), true);
+ HintTable[3].init("shortDescription", "Defines the restitution coefficient used for collisions with dynamic shapes.", true);
+ ParamDefTable[17].setHints((const NvParameterized::Hint**)HintPtrTable, 4);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=18, longName="collisionDistanceMultiplier"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[18];
+ ParamDef->init("collisionDistanceMultiplier", 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[18].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", "Defines the distance (= collisionDistanceMultiplier*particleRadius) between particles and collision geometry, which is maintained during simulation.", true);
+ ParamDefTable[18].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=19, longName="collisionThreshold"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[19];
+ ParamDef->init("collisionThreshold", 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[19].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#else
+
+ static HintImpl HintTable[3];
+ static Hint* HintPtrTable[3] = { &HintTable[0], &HintTable[1], &HintTable[2], };
+ HintTable[0].init("gameScale", "true", true);
+ HintTable[1].init("min", uint64_t(0), true);
+ HintTable[2].init("shortDescription", "Defines the threshold for collision between particles and collision geometry, inside this threshold collision contact is generated without a response.", true);
+ ParamDefTable[19].setHints((const NvParameterized::Hint**)HintPtrTable, 3);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=20, longName="collisionWithConvex"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[20];
+ ParamDef->init("collisionWithConvex", 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(1), true);
+ ParamDefTable[20].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(1), true);
+ HintTable[1].init("shortDescription", "Enables collision with convex shapes", true);
+ ParamDefTable[20].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=21, longName="collisionWithTriangleMesh"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[21];
+ ParamDef->init("collisionWithTriangleMesh", 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[21].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 collision with triangle mesh shapes", true);
+ ParamDefTable[21].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=22, longName="GridDensity"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[22];
+ 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[22].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=23, longName="GridDensity.Enabled"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[23];
+ 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; density will be computed based on the grouping of particles in a 3d grid\n", true);
+ HintTable[1].init("shortDescription", "Compute Density Using a Grid", true);
+ ParamDefTable[23].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=24, longName="GridDensity.Resolution"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[24];
+ 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[24].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[24].setEnumVals((const char**)EnumVals, 6);
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=25, longName="GridDensity.GridSize"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[25];
+ 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[25].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 a 10 units\nMust be positive.\n", true);
+ HintTable[2].init("min", uint64_t(0), true);
+ HintTable[3].init("shortDescription", "Depth of grid.", true);
+ ParamDefTable[25].setHints((const NvParameterized::Hint**)HintPtrTable, 4);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=26, longName="GridDensity.MaxCellCount"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[26];
+ 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[26].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 gridcell for a density of 1", true);
+ ParamDefTable[26].setHints((const NvParameterized::Hint**)HintPtrTable, 3);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=27, longName="enableTemperatureBuffer"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[27];
+ 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[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", "Enables temperature buffer.", true);
+ ParamDefTable[27].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=28, longName="enableDensityBuffer"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[28];
+ ParamDef->init("enableDensityBuffer", 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[28].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 density buffer.", true);
+ ParamDefTable[28].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=29, longName="enableCouplingOverride"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[29];
+ 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[29].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[29].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=30, longName="particleToGridCoupling"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[30];
+ 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[30].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=31, longName="particleToGridCoupling.accelTimeConstant"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[31];
+ 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[31].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=32, longName="particleToGridCoupling.decelTimeConstant"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[32];
+ 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[32].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=33, longName="particleToGridCoupling.thresholdMultiplier"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[33];
+ 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[33].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=34, longName="gridToParticleCoupling"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[34];
+ 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[34].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=35, longName="gridToParticleCoupling.accelTimeConstant"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[35];
+ 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[35].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=36, longName="gridToParticleCoupling.decelTimeConstant"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[36];
+ 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[36].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=37, longName="gridToParticleCoupling.thresholdMultiplier"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[37];
+ 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[37].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // SetChildren for: nodeIndex=0, longName=""
+ {
+ static Definition* Children[24];
+ 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(12);
+ Children[9] = PDEF_PTR(13);
+ Children[10] = PDEF_PTR(14);
+ Children[11] = PDEF_PTR(15);
+ Children[12] = PDEF_PTR(16);
+ Children[13] = PDEF_PTR(17);
+ Children[14] = PDEF_PTR(18);
+ Children[15] = PDEF_PTR(19);
+ Children[16] = PDEF_PTR(20);
+ Children[17] = PDEF_PTR(21);
+ Children[18] = PDEF_PTR(22);
+ Children[19] = PDEF_PTR(27);
+ Children[20] = PDEF_PTR(28);
+ Children[21] = PDEF_PTR(29);
+ Children[22] = PDEF_PTR(30);
+ Children[23] = PDEF_PTR(34);
+
+ ParamDefTable[0].setChildren(Children, 24);
+ }
+
+ // SetChildren for: nodeIndex=8, longName="particleMass"
+ {
+ static Definition* Children[3];
+ Children[0] = PDEF_PTR(9);
+ Children[1] = PDEF_PTR(10);
+ Children[2] = PDEF_PTR(11);
+
+ ParamDefTable[8].setChildren(Children, 3);
+ }
+
+ // SetChildren for: nodeIndex=22, longName="GridDensity"
+ {
+ static Definition* Children[4];
+ Children[0] = PDEF_PTR(23);
+ Children[1] = PDEF_PTR(24);
+ Children[2] = PDEF_PTR(25);
+ Children[3] = PDEF_PTR(26);
+
+ ParamDefTable[22].setChildren(Children, 4);
+ }
+
+ // SetChildren for: nodeIndex=30, longName="particleToGridCoupling"
+ {
+ static Definition* Children[3];
+ Children[0] = PDEF_PTR(31);
+ Children[1] = PDEF_PTR(32);
+ Children[2] = PDEF_PTR(33);
+
+ ParamDefTable[30].setChildren(Children, 3);
+ }
+
+ // SetChildren for: nodeIndex=34, longName="gridToParticleCoupling"
+ {
+ static Definition* Children[3];
+ Children[0] = PDEF_PTR(35);
+ Children[1] = PDEF_PTR(36);
+ Children[2] = PDEF_PTR(37);
+
+ ParamDefTable[34].setChildren(Children, 3);
+ }
+
+ mBuiltFlag = true;
+
+}
+void BasicIOSAssetParam::initStrings(void)
+{
+ collisionFilterDataName.isAllocated = true;
+ collisionFilterDataName.buf = NULL;
+ fieldSamplerFilterDataName.isAllocated = true;
+ fieldSamplerFilterDataName.buf = NULL;
+}
+
+void BasicIOSAssetParam::initDynamicArrays(void)
+{
+}
+
+void BasicIOSAssetParam::initDefaults(void)
+{
+
+ freeStrings();
+ freeReferences();
+ freeDynamicArrays();
+ restDensity = float(0);
+ particleRadius = float(1);
+ maxParticleCount = uint32_t(16384);
+ maxInjectedParticleCount = float(0.1);
+ maxCollidingObjects = uint32_t(32);
+ sceneGravityScale = float(1);
+ externalAcceleration = physx::PxVec3(init(0, 0, 0));
+ particleMass.center = float(0);
+ particleMass.spread = float(0);
+ particleMass.type = (const char*)"uniform";
+
+ particleMass.center = 1.0f;
+
+ staticCollision = bool(1);
+ restitutionForStaticShapes = float(0.5f);
+ dynamicCollision = bool(1);
+ restitutionForDynamicShapes = float(0.5f);
+ collisionDistanceMultiplier = float(1.0f);
+ collisionThreshold = float(0.001f);
+ collisionWithConvex = bool(1);
+ collisionWithTriangleMesh = bool(0);
+ GridDensity.Enabled = bool(0);
+ GridDensity.Resolution = (const char*)"GDG_16";
+ GridDensity.GridSize = float(10);
+ GridDensity.MaxCellCount = uint32_t(16);
+ enableTemperatureBuffer = bool(0);
+ enableDensityBuffer = 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 BasicIOSAssetParam::initReferences(void)
+{
+}
+
+void BasicIOSAssetParam::freeDynamicArrays(void)
+{
+}
+
+void BasicIOSAssetParam::freeStrings(void)
+{
+
+ if (collisionFilterDataName.isAllocated && collisionFilterDataName.buf)
+ {
+ mParameterizedTraits->strfree((char*)collisionFilterDataName.buf);
+ }
+
+ if (fieldSamplerFilterDataName.isAllocated && fieldSamplerFilterDataName.buf)
+ {
+ mParameterizedTraits->strfree((char*)fieldSamplerFilterDataName.buf);
+ }
+}
+
+void BasicIOSAssetParam::freeReferences(void)
+{
+}
+
+} // namespace basicios
+} // namespace nvidia
diff --git a/APEX_1.4/module/basicios/src/autogen/BasicIosDebugRenderParams.cpp b/APEX_1.4/module/basicios/src/autogen/BasicIosDebugRenderParams.cpp
new file mode 100644
index 00000000..beafae10
--- /dev/null
+++ b/APEX_1.4/module/basicios/src/autogen/BasicIosDebugRenderParams.cpp
@@ -0,0 +1,358 @@
+// 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 "BasicIosDebugRenderParams.h"
+#include <string.h>
+#include <stdlib.h>
+
+using namespace NvParameterized;
+
+namespace nvidia
+{
+namespace basicios
+{
+
+using namespace BasicIosDebugRenderParamsNS;
+
+const char* const BasicIosDebugRenderParamsFactory::vptr =
+ NvParameterized::getVptr<BasicIosDebugRenderParams, BasicIosDebugRenderParams::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_BOOL, false, (size_t)(&((ParametersStruct*)0)->VISUALIZE_BASIC_IOS_ACTOR), NULL, 0 }, // VISUALIZE_BASIC_IOS_ACTOR
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->VISUALIZE_BASIC_IOS_COLLIDE_SHAPES), NULL, 0 }, // VISUALIZE_BASIC_IOS_COLLIDE_SHAPES
+ { TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->VISUALIZE_BASIC_IOS_GRID_DENSITY), NULL, 0 }, // VISUALIZE_BASIC_IOS_GRID_DENSITY
+};
+
+
+bool BasicIosDebugRenderParams::mBuiltFlag = false;
+NvParameterized::MutexType BasicIosDebugRenderParams::mBuiltFlagMutex;
+
+BasicIosDebugRenderParams::BasicIosDebugRenderParams(NvParameterized::Traits* traits, void* buf, int32_t* refCount) :
+ NvParameters(traits, buf, refCount)
+{
+ //mParameterizedTraits->registerFactory(className(), &BasicIosDebugRenderParamsFactoryInst);
+
+ if (!buf) //Do not init data if it is inplace-deserialized
+ {
+ initDynamicArrays();
+ initStrings();
+ initReferences();
+ initDefaults();
+ }
+}
+
+BasicIosDebugRenderParams::~BasicIosDebugRenderParams()
+{
+ freeStrings();
+ freeReferences();
+ freeDynamicArrays();
+}
+
+void BasicIosDebugRenderParams::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->~BasicIosDebugRenderParams();
+
+ NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf);
+}
+
+const NvParameterized::DefinitionImpl* BasicIosDebugRenderParams::getParameterDefinitionTree(void)
+{
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+ if (!mBuiltFlag)
+ {
+ buildTree();
+ }
+ }
+
+ return(&ParamDefTable[0]);
+}
+
+const NvParameterized::DefinitionImpl* BasicIosDebugRenderParams::getParameterDefinitionTree(void) const
+{
+ BasicIosDebugRenderParams* tmpParam = const_cast<BasicIosDebugRenderParams*>(this);
+
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+ if (!mBuiltFlag)
+ {
+ tmpParam->buildTree();
+ }
+ }
+
+ return(&ParamDefTable[0]);
+}
+
+NvParameterized::ErrorType BasicIosDebugRenderParams::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 BasicIosDebugRenderParams::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 BasicIosDebugRenderParams::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const
+{
+ ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<BasicIosDebugRenderParams::ParametersStruct*>(&parameters()), handle, offset);
+}
+
+
+/* Dynamic Handle Indices */
+
+void BasicIosDebugRenderParams::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 BasicIosDebugRenderParams::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_BASIC_IOS_ACTOR"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1];
+ ParamDef->init("VISUALIZE_BASIC_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 the 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_BASIC_IOS_COLLIDE_SHAPES"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2];
+ ParamDef->init("VISUALIZE_BASIC_IOS_COLLIDE_SHAPES", 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 the IOS collision shapes in view window", true);
+ ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
+
+
+
+
+
+ }
+
+ // Initialize DefinitionImpl node: nodeIndex=3, longName="VISUALIZE_BASIC_IOS_GRID_DENSITY"
+ {
+ NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3];
+ ParamDef->init("VISUALIZE_BASIC_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", "Render the IOS Grid Density in the view window", true);
+ ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
+
+#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 BasicIosDebugRenderParams::initStrings(void)
+{
+}
+
+void BasicIosDebugRenderParams::initDynamicArrays(void)
+{
+}
+
+void BasicIosDebugRenderParams::initDefaults(void)
+{
+
+ freeStrings();
+ freeReferences();
+ freeDynamicArrays();
+ VISUALIZE_BASIC_IOS_ACTOR = bool(true);
+ VISUALIZE_BASIC_IOS_COLLIDE_SHAPES = bool(false);
+ VISUALIZE_BASIC_IOS_GRID_DENSITY = bool(false);
+
+ initDynamicArrays();
+ initStrings();
+ initReferences();
+}
+
+void BasicIosDebugRenderParams::initReferences(void)
+{
+}
+
+void BasicIosDebugRenderParams::freeDynamicArrays(void)
+{
+}
+
+void BasicIosDebugRenderParams::freeStrings(void)
+{
+}
+
+void BasicIosDebugRenderParams::freeReferences(void)
+{
+}
+
+} // namespace basicios
+} // namespace nvidia
diff --git a/APEX_1.4/module/basicios/src/autogen/BasicIosModuleParameters.cpp b/APEX_1.4/module/basicios/src/autogen/BasicIosModuleParameters.cpp
new file mode 100644
index 00000000..618171a5
--- /dev/null
+++ b/APEX_1.4/module/basicios/src/autogen/BasicIosModuleParameters.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 "BasicIosModuleParameters.h"
+#include <string.h>
+#include <stdlib.h>
+
+using namespace NvParameterized;
+
+namespace nvidia
+{
+namespace basicios
+{
+
+using namespace BasicIosModuleParametersNS;
+
+const char* const BasicIosModuleParametersFactory::vptr =
+ NvParameterized::getVptr<BasicIosModuleParameters, BasicIosModuleParameters::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 BasicIosModuleParameters::mBuiltFlag = false;
+NvParameterized::MutexType BasicIosModuleParameters::mBuiltFlagMutex;
+
+BasicIosModuleParameters::BasicIosModuleParameters(NvParameterized::Traits* traits, void* buf, int32_t* refCount) :
+ NvParameters(traits, buf, refCount)
+{
+ //mParameterizedTraits->registerFactory(className(), &BasicIosModuleParametersFactoryInst);
+
+ if (!buf) //Do not init data if it is inplace-deserialized
+ {
+ initDynamicArrays();
+ initStrings();
+ initReferences();
+ initDefaults();
+ }
+}
+
+BasicIosModuleParameters::~BasicIosModuleParameters()
+{
+ freeStrings();
+ freeReferences();
+ freeDynamicArrays();
+}
+
+void BasicIosModuleParameters::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->~BasicIosModuleParameters();
+
+ NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf);
+}
+
+const NvParameterized::DefinitionImpl* BasicIosModuleParameters::getParameterDefinitionTree(void)
+{
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+ if (!mBuiltFlag)
+ {
+ buildTree();
+ }
+ }
+
+ return(&ParamDefTable[0]);
+}
+
+const NvParameterized::DefinitionImpl* BasicIosModuleParameters::getParameterDefinitionTree(void) const
+{
+ BasicIosModuleParameters* tmpParam = const_cast<BasicIosModuleParameters*>(this);
+
+ if (!mBuiltFlag) // Double-checked lock
+ {
+ NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
+ if (!mBuiltFlag)
+ {
+ tmpParam->buildTree();
+ }
+ }
+
+ return(&ParamDefTable[0]);
+}
+
+NvParameterized::ErrorType BasicIosModuleParameters::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 BasicIosModuleParameters::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 BasicIosModuleParameters::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const
+{
+ ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<BasicIosModuleParameters::ParametersStruct*>(&parameters()), handle, offset);
+}
+
+
+/* Dynamic Handle Indices */
+
+void BasicIosModuleParameters::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 BasicIosModuleParameters::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 ModuleBasicIos.", 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 BasicIosModuleParameters::initStrings(void)
+{
+}
+
+void BasicIosModuleParameters::initDynamicArrays(void)
+{
+}
+
+void BasicIosModuleParameters::initDefaults(void)
+{
+
+ freeStrings();
+ freeReferences();
+ freeDynamicArrays();
+ unused = uint32_t(0);
+
+ initDynamicArrays();
+ initStrings();
+ initReferences();
+}
+
+void BasicIosModuleParameters::initReferences(void)
+{
+}
+
+void BasicIosModuleParameters::freeDynamicArrays(void)
+{
+}
+
+void BasicIosModuleParameters::freeStrings(void)
+{
+}
+
+void BasicIosModuleParameters::freeReferences(void)
+{
+}
+
+} // namespace basicios
+} // namespace nvidia