aboutsummaryrefslogtreecommitdiff
path: root/APEX_1.4/module/clothing/include
diff options
context:
space:
mode:
authorgit perforce import user <a@b>2016-10-25 12:29:14 -0600
committerSheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees>2016-10-25 18:56:37 -0500
commit3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch)
treefa6485c169e50d7415a651bf838f5bcd0fd3bfbd /APEX_1.4/module/clothing/include
downloadphysx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz
physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip
Initial commit:
PhysX 3.4.0 Update @ 21294896 APEX 1.4.0 Update @ 21275617 [CL 21300167]
Diffstat (limited to 'APEX_1.4/module/clothing/include')
-rw-r--r--APEX_1.4/module/clothing/include/AbstractMeshDescription.h87
-rw-r--r--APEX_1.4/module/clothing/include/ClothStructs.h51
-rw-r--r--APEX_1.4/module/clothing/include/ClothingActorData.h116
-rw-r--r--APEX_1.4/module/clothing/include/ClothingActorImpl.h529
-rw-r--r--APEX_1.4/module/clothing/include/ClothingActorProxy.h392
-rw-r--r--APEX_1.4/module/clothing/include/ClothingActorTasks.h96
-rw-r--r--APEX_1.4/module/clothing/include/ClothingAssetAuthoringImpl.h265
-rw-r--r--APEX_1.4/module/clothing/include/ClothingAssetData.h287
-rw-r--r--APEX_1.4/module/clothing/include/ClothingAssetImpl.h494
-rw-r--r--APEX_1.4/module/clothing/include/ClothingCollisionImpl.h422
-rw-r--r--APEX_1.4/module/clothing/include/ClothingCooking.h114
-rw-r--r--APEX_1.4/module/clothing/include/ClothingGlobals.h39
-rw-r--r--APEX_1.4/module/clothing/include/ClothingPhysicalMeshImpl.h207
-rw-r--r--APEX_1.4/module/clothing/include/ClothingPreviewProxy.h122
-rw-r--r--APEX_1.4/module/clothing/include/ClothingRenderProxyImpl.h123
-rw-r--r--APEX_1.4/module/clothing/include/ClothingScene.h233
-rw-r--r--APEX_1.4/module/clothing/include/Cooking.h167
-rw-r--r--APEX_1.4/module/clothing/include/CookingAbstract.h134
-rw-r--r--APEX_1.4/module/clothing/include/CookingPhysX.h50
-rw-r--r--APEX_1.4/module/clothing/include/ModuleClothingHelpers.h461
-rw-r--r--APEX_1.4/module/clothing/include/ModuleClothingImpl.h268
-rw-r--r--APEX_1.4/module/clothing/include/ModuleEventDefs.h53
-rw-r--r--APEX_1.4/module/clothing/include/ModulePerfScope.h18
-rw-r--r--APEX_1.4/module/clothing/include/Simulation.h315
-rw-r--r--APEX_1.4/module/clothing/include/SimulationAbstract.h261
-rw-r--r--APEX_1.4/module/clothing/include/autogen/ClothingActorParam.h351
-rw-r--r--APEX_1.4/module/clothing/include/autogen/ClothingAssetParameters.h374
-rw-r--r--APEX_1.4/module/clothing/include/autogen/ClothingCookedParam.h297
-rw-r--r--APEX_1.4/module/clothing/include/autogen/ClothingCookedPhysX3Param.h310
-rw-r--r--APEX_1.4/module/clothing/include/autogen/ClothingDebugRenderParams.h270
-rw-r--r--APEX_1.4/module/clothing/include/autogen/ClothingGraphicalLodParameters.h335
-rw-r--r--APEX_1.4/module/clothing/include/autogen/ClothingMaterialLibraryParameters.h277
-rw-r--r--APEX_1.4/module/clothing/include/autogen/ClothingModuleParameters.h240
-rw-r--r--APEX_1.4/module/clothing/include/autogen/ClothingPhysicalMeshParameters.h373
-rw-r--r--APEX_1.4/module/clothing/include/autogen/ClothingPreviewParam.h243
-rw-r--r--APEX_1.4/module/clothing/include/autogen/ModuleClothingRegistration.h141
36 files changed, 8515 insertions, 0 deletions
diff --git a/APEX_1.4/module/clothing/include/AbstractMeshDescription.h b/APEX_1.4/module/clothing/include/AbstractMeshDescription.h
new file mode 100644
index 00000000..aac0e1e7
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/AbstractMeshDescription.h
@@ -0,0 +1,87 @@
+/*
+ * 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 ABSTRACT_MESH_DESCRIPTION_H
+#define ABSTRACT_MESH_DESCRIPTION_H
+
+#include <ApexUsingNamespace.h>
+#include "PxVec3.h"
+
+class ClothConstrainCoefficients;
+
+
+namespace nvidia
+{
+namespace apex
+{
+
+class RenderDebugInterface;
+/**
+\brief a simplified, temporal container for a mesh with non-interleaved vertex buffers
+*/
+
+struct AbstractMeshDescription
+{
+ AbstractMeshDescription() : numVertices(0), numIndices(0), numBonesPerVertex(0),
+ pPosition(NULL), pNormal(NULL), pTangent(NULL), pTangent4(NULL), pBitangent(NULL),
+ pBoneIndices(NULL), pBoneWeights(NULL), pConstraints(NULL), pVertexFlags(NULL), pIndices(NULL),
+ avgEdgeLength(0.0f), avgTriangleArea(0.0f), pMin(0.0f), pMax(0.0f), centroid(0.0f), radius(0.0f) {}
+
+ /// the number of vertices in the mesh
+ uint32_t numVertices;
+ /// the number of indices in the mesh
+ uint32_t numIndices;
+ /// the number of bones per vertex in the boneIndex and boneWeights buffer. Can be 0
+ uint32_t numBonesPerVertex;
+
+ /// pointer to the positions array
+ PxVec3* PX_RESTRICT pPosition;
+ /// pointer to the normals array
+ PxVec3* PX_RESTRICT pNormal;
+ /// pointer to the tangents array
+ PxVec3* PX_RESTRICT pTangent;
+ /// alternative pointer to the tangents array, with float4
+ PxVec4* PX_RESTRICT pTangent4;
+ /// pointer to the bitangents/binormal array
+ PxVec3* PX_RESTRICT pBitangent;
+ /// pointer to the bone indices array
+ uint16_t* PX_RESTRICT pBoneIndices;
+ /// pointer to the bone weights array
+ float* PX_RESTRICT pBoneWeights;
+ /// pointer to the cloth constraints array
+ ClothConstrainCoefficients* PX_RESTRICT pConstraints;
+ /// pointer to per-vertex flags
+ uint32_t* PX_RESTRICT pVertexFlags;
+ /// pointer to the indices array
+ uint32_t* PX_RESTRICT pIndices;
+
+ /// updates the derived data
+ void UpdateDerivedInformation(RenderDebugInterface* renderDebug);
+
+ /// Derived Data, average Edge Length
+ float avgEdgeLength;
+ /// Derived Data, average Triangle Area
+ float avgTriangleArea;
+ /// Derived Data, Bounding Box min value
+ PxVec3 pMin;
+ /// Derived Data, Bounding Box max value
+ PxVec3 pMax;
+ /// Derived Data, Average of pMin and pMax
+ PxVec3 centroid;
+ /// Derived Data, Half the distance between pMin and pMax
+ float radius;
+};
+
+}
+}
+
+
+#endif // ABSTRACT_MESH_DESCRIPTION_H
diff --git a/APEX_1.4/module/clothing/include/ClothStructs.h b/APEX_1.4/module/clothing/include/ClothStructs.h
new file mode 100644
index 00000000..6a1bd07b
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ClothStructs.h
@@ -0,0 +1,51 @@
+/*
+ * 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 CLOTH_STRUCTS_H
+#define CLOTH_STRUCTS_H
+
+
+namespace nvidia
+{
+
+namespace shdfnd
+{
+template <typename Alloc> class MutexT;
+}
+
+namespace cloth
+{
+ class Factory;
+}
+
+namespace clothing
+{
+
+struct ClothFactory
+{
+ PX_INLINE ClothFactory(cloth::Factory* f, nvidia::MutexT< ReflectionAllocator<MutexImpl> >* m) : factory(f), mutex(m) {}
+
+ PX_INLINE void clear()
+ {
+ factory = NULL;
+ mutex = NULL;
+ }
+
+ cloth::Factory* factory;
+ nvidia::MutexT< ReflectionAllocator<MutexImpl> >* mutex;
+};
+
+
+}
+}
+
+
+#endif // CLOTH_STRUCTS_H
diff --git a/APEX_1.4/module/clothing/include/ClothingActorData.h b/APEX_1.4/module/clothing/include/ClothingActorData.h
new file mode 100644
index 00000000..fa788054
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ClothingActorData.h
@@ -0,0 +1,116 @@
+/*
+ * 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 CLOTHING_ACTOR_DATA_H
+#define CLOTHING_ACTOR_DATA_H
+
+#include "ClothingAssetData.h"
+#include "PsMutex.h"
+#include "PxMat44.h"
+#include "PxVec3.h"
+
+#define BLOCK_SIZE_SKIN_PHYSICS (32768*6) + (8192*0)
+
+namespace nvidia
+{
+namespace clothing
+{
+
+/*
+ * A wrapper around the data contained in ClothingActorImpl minus all the interface stuff
+ */
+class ClothingActorData
+{
+public:
+
+ ClothingActorData();
+ ~ClothingActorData();
+
+ void skinToAnimation_NoPhysX(bool fromFetchResults);
+
+ void skinPhysicsMaxDist0Normals_NoPhysx();
+
+ void renderDataLock();
+
+ void renderDataUnLock();
+
+ void skinToPhysicalMesh_NoPhysX(bool fromFetchResults);
+
+ void skinToImmediateMap(const uint32_t* immediateClothMap_, uint32_t numGraphicalVertices_, uint32_t numSrcVertices_,
+ const PxVec3* srcPositions_);
+
+ void skinToImmediateMap(const uint32_t* immediateClothMap_, uint32_t numGraphicalVertices_, uint32_t numSrcVertices_,
+ const PxVec3* srcPositions_, const PxVec3* srcNormals_);
+
+ void finalizeSkinning_NoPhysX(bool fromFetchResults);
+
+ template <bool withNormals, bool withTangents>
+ void computeTangentSpaceUpdate(AbstractMeshDescription& destMesh, const ClothingMeshAssetData& rendermesh, uint32_t submeshIndex, const uint32_t* compressedTangentW);
+
+ void tickSynchAfterFetchResults_LocksPhysX();
+
+ uint32_t skinPhysicsSimpleMem() const;
+ void skinPhysicsMeshSimple();
+
+ PxBounds3 getRenderMeshAssetBoundsTransformed();
+
+ // is valid only after lodTick
+ bool calcIfSimplePhysicsMesh() const;
+
+ PX_ALIGN(16, nvidia::AtomicLockCopy mRenderLock);
+
+ ClothingAssetData mAsset;
+
+ PxBounds3 mNewBounds;
+
+ PX_ALIGN(16, PxMat44 mGlobalPose);
+ PxMat44 mInternalGlobalPose;
+
+ PxMat44* mInternalBoneMatricesCur;
+ PxMat44* mInternalBoneMatricesPrev;
+
+ PxVec3* mRenderingDataPosition;
+ PxVec3* mRenderingDataNormal;
+ PxVec4* mRenderingDataTangent;
+ PxVec3* mMorphDisplacementBuffer;
+
+ PxVec3* mSdkWritebackNormal;
+ PxVec3* mSdkWritebackPositions;
+
+ PxVec3* mSkinnedPhysicsPositions;
+ PxVec3* mSkinnedPhysicsNormals;
+
+ uint32_t mInternalMatricesCount;
+ uint32_t mMorphDisplacementBufferCount;
+ uint32_t mSdkDeformableVerticesCount;
+ uint32_t mSdkDeformableIndicesCount;
+
+ uint32_t mCurrentGraphicalLodId;
+ uint32_t mCurrentPhysicsSubmesh;
+
+ float mActorScale;
+
+ // Note - all these modified bools need to be written back to the actor!!!!
+ bool bInternalFrozen;
+ bool bShouldComputeRenderData;
+ bool bIsInitialized;
+ bool bIsSimulationMeshDirty;
+ bool bRecomputeNormals;
+ bool bRecomputeTangents;
+ bool bCorrectSimulationNormals;
+ bool bParallelCpuSkinning;
+ bool bIsClothingSimulationNull;
+};
+
+}
+} // namespace nvidia
+
+#endif // CLOTHING_ACTOR_DATA_H
diff --git a/APEX_1.4/module/clothing/include/ClothingActorImpl.h b/APEX_1.4/module/clothing/include/ClothingActorImpl.h
new file mode 100644
index 00000000..665cb740
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ClothingActorImpl.h
@@ -0,0 +1,529 @@
+/*
+ * 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 CLOTHING_ACTOR_IMPL_H
+#define CLOTHING_ACTOR_IMPL_H
+
+#include "ApexActor.h"
+#include "ModuleClothingHelpers.h"
+
+#include "ClothingActorParam.h"
+#include "ClothingMaterialLibraryParameters.h"
+#include "ClothingActorTasks.h"
+
+#include "ClothingActor.h"
+#include "ClothingActorData.h"
+
+#include "ClothingCollisionImpl.h"
+
+#include "ClothingRenderProxyImpl.h"
+
+#if !APEX_UE4
+#include "PsSync.h"
+#endif
+
+#pragma warning(push)
+#pragma warning(disable:4324)
+
+namespace physx
+{
+ namespace pvdsdk
+ {
+ class PvdDataStream;
+ class PvdConnectionManager;
+ }
+}
+
+namespace nvidia
+{
+namespace apex
+{
+class RenderMeshActorIntl;
+class RenderDebugInterface;
+class ClothingVelocityCallback;
+}
+namespace clothing
+{
+
+class ClothingActorProxy;
+class ClothingAssetImpl;
+class ClothingCookingTask;
+class ClothingMaterial;
+class ClothingPreviewProxy;
+class ClothingScene;
+class ClothingCookedParam;
+class SimulationAbstract;
+
+namespace ClothingMaterialLibraryParametersNS
+{
+struct ClothingMaterial_Type;
+}
+
+namespace ClothingPhysicalMeshParametersNS
+{
+struct SkinClothMapB_Type;
+struct SkinClothMapD_Type;
+struct PhysicalMesh_Type;
+}
+
+
+
+struct ClothingGraphicalMeshActor
+{
+ ClothingGraphicalMeshActor() : active(false), needsTangents(false), renderProxy(NULL)
+ {
+ }
+
+ bool active;
+ bool needsTangents;
+ Array<uint32_t> morphTargetVertexOffsets;
+
+ ClothingRenderProxyImpl* renderProxy;
+};
+
+
+#if !APEX_UE4
+class ClothingWaitForFetchTask : public PxTask
+{
+public:
+ ClothingWaitForFetchTask()
+ {
+ mWaiting.set();
+ }
+
+ virtual void run();
+ virtual void release();
+ virtual const char* getName() const;
+
+ Sync mWaiting;
+};
+#endif
+
+
+class ClothingActorImpl : public ApexActor, public ApexResource
+{
+public:
+ ClothingActorImpl(const NvParameterized::Interface& desc, ClothingActorProxy* apiProxy, ClothingPreviewProxy*, ClothingAssetImpl* asset, ClothingScene* scene);
+
+ ClothingActorProxy* mActorProxy;
+ ClothingPreviewProxy* mPreviewProxy;
+
+ // from ApexInterface
+ void release();
+
+ // from Actor
+ PX_INLINE ClothingAssetImpl* getOwner() const
+ {
+ return mAsset;
+ }
+ Renderable* getRenderable();
+
+ // from Renderable
+ void dispatchRenderResources(UserRenderer& api);
+
+ void initializeActorData();
+
+ void fetchResults();
+ void waitForFetchResults();
+
+ void syncActorData();
+ void reinitActorData()
+ {
+ bReinitActorData = 1;
+ }
+
+ ClothingActorData& getActorData();
+
+ void markRenderProxyReady();
+
+ // from ResourceProvider
+ void lockRenderResources()
+ {
+ ApexRenderable::renderDataLock();
+ }
+ void unlockRenderResources()
+ {
+ ApexRenderable::renderDataUnLock();
+ }
+ void updateRenderResources(bool rewriteBuffers, void* userRenderData);
+
+ // from ClothingActor
+ NvParameterized::Interface* getActorDesc();
+ void updateState(const PxMat44& globalPose, const PxMat44* newBoneMatrices, uint32_t boneMatricesByteStride, uint32_t numBoneMatrices, ClothingTeleportMode::Enum teleportMode);
+ void updateMaxDistanceScale(float scale, bool multipliable);
+ const PxMat44& getGlobalPose() const;
+ void setWind(float windAdaption, const PxVec3& windVelocity);
+ void setMaxDistanceBlendTime(float blendTime);
+ float getMaxDistanceBlendTime() const;
+ void setVisible(bool enable);
+ bool isVisibleBuffered() const;
+ bool isVisible() const;
+ void setFrozen(bool enable);
+ bool isFrozenBuffered() const;
+ bool shouldComputeRenderData() const;
+ ClothSolverMode::Enum getClothSolverMode() const;
+ void setGraphicalLOD(uint32_t lod);
+ uint32_t getGraphicalLod();
+
+ ClothingRenderProxy* acquireRenderProxy();
+
+ bool rayCast(const PxVec3& worldOrigin, const PxVec3& worldDirection, float& time, PxVec3& normal, uint32_t& vertexIndex);
+ void attachVertexToGlobalPosition(uint32_t vertexIndex, const PxVec3& worldPosition);
+ void freeVertex(uint32_t vertexIndex);
+
+ uint32_t getClothingMaterial() const;
+ void setClothingMaterial(uint32_t index);
+ void setOverrideMaterial(uint32_t submeshIndex, const char* overrideMaterialName);
+ void setVelocityCallback(ClothingVelocityCallback* callback)
+ {
+ mVelocityCallback = callback;
+ }
+ void setInterCollisionChannels(uint32_t channels)
+ {
+ mInterCollisionChannels = channels;
+ }
+ uint32_t getInterCollisionChannels()
+ {
+ return mInterCollisionChannels;
+ }
+ bool isHalfPrecisionAllowed() const
+ {
+ return mIsAllowedHalfPrecisionSolver;
+ }
+ void setHalfPrecision(bool isAllowed)
+ {
+ mIsAllowedHalfPrecisionSolver = isAllowed;
+ }
+
+ virtual void getLodRange(float& min, float& max, bool& intOnly) const;
+ virtual float getActiveLod() const;
+ virtual void forceLod(float lod);
+
+ virtual void getPhysicalMeshPositions(void* buffer, uint32_t byteStride);
+ virtual void getPhysicalMeshNormals(void* buffer, uint32_t byteStride);
+ virtual float getMaximumSimulationBudget() const;
+ virtual uint32_t getNumSimulationVertices() const;
+ virtual const PxVec3* getSimulationPositions();
+ virtual const PxVec3* getSimulationNormals();
+ virtual bool getSimulationVelocities(PxVec3* velocities);
+ virtual uint32_t getNumGraphicalVerticesActive(uint32_t submeshIndex) const;
+ virtual PxMat44 getRenderGlobalPose() const;
+ virtual const PxMat44* getCurrentBoneSkinningMatrices() const;
+
+ // PhysX scene management
+#if PX_PHYSICS_VERSION_MAJOR == 3
+ void setPhysXScene(PxScene*);
+ PxScene* getPhysXScene() const;
+#endif
+
+ // scene ticks
+ void tickSynchBeforeSimulate_LocksPhysX(float simulationDelta, float substepSize, uint32_t substepNumber, uint32_t numSubSteps);
+ void applyLockingTasks();
+ void updateConstrainPositions_LocksPhysX();
+ void applyCollision_LocksPhysX();
+ void applyGlobalPose_LocksPhysX();
+ void applyClothingMaterial_LocksPhysX();
+ void skinPhysicsMesh(bool useInterpolatedMatrices, float substepFraction);
+ void tickAsynch_NoPhysX();
+ bool needsManualSubstepping();
+ bool isSkinningDirty();
+
+ // LoD stuff
+ float getCost() const; // Should be removed?
+
+ // debug rendering
+#ifndef WITHOUT_PVD
+ void initPvdInstances(pvdsdk::PvdDataStream& pvdStream);
+ void destroyPvdInstances();
+ void updatePvd();
+#endif
+ void visualize();
+
+ // cleanup
+ void destroy();
+
+ // Tasks
+#if APEX_UE4
+ void initBeforeTickTasks(PxF32 deltaTime, PxF32 substepSize, PxU32 numSubSteps, PxTaskManager* taskManager, PxTaskID before, PxTaskID after);
+#else
+ void initBeforeTickTasks(float deltaTime, float substepSize, uint32_t numSubSteps);
+#endif
+
+ void submitTasksDuring(PxTaskManager* taskManager);
+ void setTaskDependenciesBefore(PxBaseTask* after);
+ PxTaskID setTaskDependenciesDuring(PxTaskID before, PxTaskID after);
+
+ void startBeforeTickTask();
+
+ PxTaskID getDuringTickTaskID()
+ {
+ return mDuringTickTask.getTaskID();
+ }
+
+#if !APEX_UE4
+ void setFetchContinuation();
+#endif
+ void startFetchTasks();
+
+ // teleport
+ void applyTeleport(bool skinningReady, uint32_t substepNumber);
+
+ // validation
+ static bool isValidDesc(const NvParameterized::Interface& params);
+
+ // Per Actor runtime cooking stuff
+ float getActorScale()
+ {
+ return mActorDesc->actorScale;
+ }
+ bool getHardwareAllowed()
+ {
+ return mActorDesc->useHardwareCloth;
+ }
+ ClothingCookedParam* getRuntimeCookedDataPhysX();
+
+
+ // collision functions
+ virtual ClothingPlane* createCollisionPlane(const PxPlane& pose);
+ virtual ClothingConvex* createCollisionConvex(ClothingPlane** planes, uint32_t numPlanes);
+ virtual ClothingSphere* createCollisionSphere(const PxVec3& positions, float radius);
+ virtual ClothingCapsule* createCollisionCapsule(ClothingSphere& sphere1, ClothingSphere& sphere2);
+ virtual ClothingTriangleMesh* createCollisionTriangleMesh();
+
+ void releaseCollision(ClothingCollisionImpl& collision);
+ void notifyCollisionChange()
+ {
+ bActorCollisionChanged = 1;
+ }
+
+#if APEX_UE4
+ void simulate(PxF32 dt);
+ void setFetchResultsSync() { mFetchResultsSync.set(); }
+#endif
+
+protected:
+ struct WriteBackInfo;
+
+ // rendering
+ void updateBoneBuffer(ClothingRenderProxyImpl* renderProxy);
+ void updateRenderMeshActorBuffer(bool freeBuffers, uint32_t graphicalLodId);
+ PxBounds3 getRenderMeshAssetBoundsTransformed();
+ void updateRenderProxy();
+
+ // handling interpolated skinning matrices
+ bool allocateEnoughBoneBuffers_NoPhysX(bool prepareForSubstepping);
+
+ // double buffering internal stuff
+ bool isSimulationRunning() const;
+ void updateScaledGravity(float substepSize);
+ void updateStateInternal_NoPhysX(bool prepareForSubstepping);
+
+ // compute intensive skinning stuff
+ template<bool withBackstop>
+ void skinPhysicsMeshInternal(bool useInterpolatedMatrices, float substepFraction);
+ void fillWritebackData_LocksPhysX(const WriteBackInfo& writeBackInfo);
+
+ // wind
+ void applyVelocityChanges_LocksPhysX(float simulationDelta);
+
+ // handling entities
+ bool isCookedDataReady();
+ void getSimulation(const WriteBackInfo& writeBackInfo);
+ void createPhysX_LocksPhysX(float simulationDelta);
+ void removePhysX_LocksPhysX();
+ void changePhysicsMesh_LocksPhysX(uint32_t oldGraphicalLodId, float simulationDelta);
+ void updateCollision_LocksPhysX(bool useInterpolatedMatrices);
+ void updateConstraintCoefficients_LocksPhysX();
+ void copyPositionAndNormal_NoPhysX(uint32_t numCopyVertices, SimulationAbstract* oldClothingSimulation);
+ void copyAndComputeVelocities_LocksPhysX(uint32_t numCopyVertices, SimulationAbstract* oldClothingSimulation, PxVec3* velocities, float simulationDelta) const;
+ void transferVelocities_LocksPhysX(const SimulationAbstract& oldClothingSimulation,
+ const ClothingPhysicalMeshParametersNS::SkinClothMapB_Type* pTCMB,
+ const ClothingPhysicalMeshParametersNS::SkinClothMapD_Type* pTCM,
+ uint32_t numVerticesInMap, const uint32_t* srcIndices, uint32_t numSrcIndices, uint32_t numSrcVertices,
+ PxVec3* oldVelocities, PxVec3* newVelocites, float simulationDelta);
+ PxVec3 computeVertexVelFromAnim(uint32_t vertexIndex, const ClothingPhysicalMeshParametersNS::PhysicalMesh_Type* physicalMesh, float simulationDelta) const;
+ void freeze_LocksPhysX(bool on);
+
+ // handling Abstract Simulation
+ void createSimulation(uint32_t physicalMeshId, NvParameterized::Interface* cookedData, const WriteBackInfo& writeBackInfo);
+
+
+ // handling Lod
+ uint32_t getGraphicalMeshIndex(uint32_t lod) const;
+ void lodTick_LocksPhysX(float simulationDelta);
+
+ // debug rendering
+ void visualizeSkinnedPositions(RenderDebugInterface& renderDebug, float positionRadius, bool maxDistanceOut, bool maxDistanceIn) const;
+ void visualizeBackstop(RenderDebugInterface& renderDebug) const;
+ void visualizeBackstopPrecise(RenderDebugInterface& renderDebug, float scale) const;
+ void visualizeBoneConnections(RenderDebugInterface& renderDebug, const PxVec3* positions, const uint16_t* boneIndices,
+ const float* boneWeights, uint32_t numBonesPerVertex, uint32_t numVertices) const;
+ void visualizeSpheres(RenderDebugInterface& renderDebug, const PxVec3* positions, uint32_t numPositions, float radius, uint32_t color, bool wire) const;
+
+ RenderMeshActorIntl* createRenderMeshActor(RenderMeshAssetIntl* renderMeshAsset);
+
+ ClothingMaterialLibraryParametersNS::ClothingMaterial_Type* getCurrentClothingMaterial() const;
+ bool clothingMaterialsEqual(ClothingMaterialLibraryParametersNS::ClothingMaterial_Type& a, ClothingMaterialLibraryParametersNS::ClothingMaterial_Type& b);
+
+ struct WriteBackInfo
+ {
+ WriteBackInfo() : oldSimulation(NULL), oldGraphicalLodId(0), simulationDelta(0.0f) {}
+ SimulationAbstract* oldSimulation;
+ uint32_t oldGraphicalLodId;
+ float simulationDelta;
+ };
+
+ // internal variables
+ ClothingAssetImpl* mAsset;
+ ClothingScene* mClothingScene;
+#if PX_PHYSICS_VERSION_MAJOR == 3
+ PxScene* mPhysXScene;
+#endif
+
+ ClothingActorParam* mActorDesc;
+ const char* mBackendName;
+
+ // current pose of this actor. If using skinning it could be set to idenftity matrix and simply rely on the skinning matrices (bones)
+ PX_ALIGN(16, PxMat44) mInternalGlobalPose;
+ PxMat44 mOldInternalGlobalPose;
+ PxMat44 mInternalInterpolatedGlobalPose;
+
+ // Bone matrices for physical mesh skinning - provided by the application either in the initial ClothingActorDesc or "updateBoneMatrices"
+ // number 0 is current, 1 is one frame old, 2 is 2 frames old
+ //PxMat44* mInternalBoneMatrices[2];
+ PxMat44* mInternalInterpolatedBoneMatrices;
+
+ // Number of cloth solver iterations that will be performed.
+ // If this is set to 0 the simulation enters "static" mode
+ uint32_t mCurrentSolverIterations;
+
+ PxVec3 mInternalScaledGravity;
+
+ float mInternalMaxDistanceBlendTime;
+ float mMaxDistReduction;
+
+ uint32_t mBufferedGraphicalLod;
+ uint32_t mCurrentGraphicalLodId;
+
+
+ Array<ClothingGraphicalMeshActor> mGraphicalMeshes;
+
+ Mutex mRenderProxyMutex;
+ ClothingRenderProxyImpl* mRenderProxyReady;
+
+ // for backwards compatibility, to make sure that dispatchRenderResources is
+ // called on the same render proxy as updateRenderResources
+ ClothingRenderProxyImpl* mRenderProxyURR;
+
+ ClothingActorData mData;
+
+ // PhysX SDK simulation objects
+ // Per-actor "skinned physical mesh" data is in mSimulationBulk.dynamicSimulationData
+ // these are skinned by APEX in "tickAsynch" using bone matrices provided by the application
+ // they are passed as constraints to the PhysX SDK (mCloth) in "tickSync"
+ // Per-actor "skinned rendering mesh" data - only used in if the ClothingAssetImpl uses the "skin cloth" approach
+ // these are skinned by APEX in "tickSynch" using the appropriate mesh-to-mesh skinning algorithm in the ClothingAssetImpl
+ SimulationAbstract* mClothingSimulation;
+
+ // Wind
+ ClothingActorParamNS::WindParameters_Type mInternalWindParams;
+
+ ClothingActorParamNS::ClothingActorFlags_Type mInternalFlags;
+
+ // max distance scale
+ ClothingActorParamNS::MaxDistanceScale_Type mInternalMaxDistanceScale;
+
+ // only needed to detect when it changes on the fly
+ float mCurrentMaxDistanceBias;
+
+ // bounds that are computed for the current frame, get copied over to RenderMeshActor during fetchResults
+ PxBounds3 mNewBounds;
+
+ bool bIsSimulationOn;
+ int32_t mForceSimulation;
+ PxVec3 mLodCentroid;
+ float mLodRadiusSquared;
+
+ // The Clothing Material
+ ClothingMaterialLibraryParametersNS::ClothingMaterial_Type mClothingMaterial;
+
+ // velocity callback
+ ClothingVelocityCallback* mVelocityCallback;
+
+ // inter collision
+ uint32_t mInterCollisionChannels;
+
+ bool mIsAllowedHalfPrecisionSolver;
+
+ // The tasks
+ ClothingActorBeforeTickTask mBeforeTickTask;
+ ClothingActorDuringTickTask mDuringTickTask;
+ ClothingActorFetchResultsTask mFetchResultsTask;
+
+ ClothingCookingTask* mActiveCookingTask;
+
+#if APEX_UE4
+ physx::shdfnd::Sync mFetchResultsSync;
+#else
+ ClothingWaitForFetchTask mWaitForFetchTask;
+#endif
+ bool mFetchResultsRunning;
+ Mutex mFetchResultsRunningMutex;
+
+ nvidia::Array<PxVec3> mWindDebugRendering;
+
+ // TODO make a better overrideMaterials API
+ HashMap<uint32_t, ApexSimpleString> mOverrideMaterials;
+
+ ResourceList mCollisionPlanes;
+ ResourceList mCollisionConvexes;
+ ResourceList mCollisionSpheres;
+ ResourceList mCollisionCapsules;
+ ResourceList mCollisionTriangleMeshes;
+
+ // bit flags - aggregate them at the end
+ uint32_t bGlobalPoseChanged : 1; // mBufferedGlobalPose was updated
+ uint32_t bBoneMatricesChanged : 1; // mBufferedBoneMatrices were updated
+ uint32_t bBoneBufferDirty : 1; // need to sync bones to the render mesh actor
+ uint32_t bMaxDistanceScaleChanged : 1; // mBufferedMaxDistanceScale was updated
+ uint32_t bBlendingAllowed : 1;
+
+ uint32_t bDirtyActorTemplate : 1;
+ uint32_t bDirtyShapeTemplate : 1;
+ uint32_t bDirtyClothingTemplate : 1;
+
+ uint32_t bBufferedVisible : 1;
+ uint32_t bInternalVisible : 1;
+
+ uint32_t bUpdateFrozenFlag : 1;
+ uint32_t bBufferedFrozen : 1;
+ uint32_t bInternalFrozen : 1;
+
+ uint32_t bPressureWarning : 1;
+ uint32_t bUnsucessfullCreation : 1;
+
+ ClothingTeleportMode::Enum bInternalTeleportDue : 3;
+
+ uint32_t bInternalScaledGravityChanged : 1;
+ uint32_t bReinitActorData : 1;
+
+ uint32_t bInternalLocalSpaceSim : 1;
+
+ uint32_t bActorCollisionChanged : 1;
+};
+
+}
+} // namespace nvidia
+
+
+#pragma warning(pop)
+
+#endif // CLOTHING_ACTOR_IMPL_H
diff --git a/APEX_1.4/module/clothing/include/ClothingActorProxy.h b/APEX_1.4/module/clothing/include/ClothingActorProxy.h
new file mode 100644
index 00000000..63e8b4a5
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ClothingActorProxy.h
@@ -0,0 +1,392 @@
+/*
+ * 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 CLOTHING_ACTOR_PROXY_H
+#define CLOTHING_ACTOR_PROXY_H
+
+#include "ClothingActor.h"
+#include "PsUserAllocated.h"
+#include "ClothingAssetImpl.h"
+#include "ApexRWLockable.h"
+#include "ClothingActorImpl.h"
+
+#include "ReadCheck.h"
+#include "WriteCheck.h"
+
+namespace nvidia
+{
+namespace clothing
+{
+
+class ClothingActorProxy : public ClothingActor, public UserAllocated, public ApexResourceInterface, ApexRWLockable
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ ClothingActorImpl impl;
+
+#pragma warning(push)
+#pragma warning( disable : 4355 ) // disable warning about this pointer in argument list
+
+ ClothingActorProxy(const NvParameterized::Interface& desc, ClothingAssetImpl* asset, ClothingScene& clothingScene, ResourceList* list) :
+ impl(desc, this, NULL, asset, &clothingScene)
+ {
+ list->add(*this);
+ }
+
+#pragma warning(pop)
+
+ virtual void release()
+ {
+ impl.release(); // calls release method on asset
+ }
+
+ virtual uint32_t getListIndex() const
+ {
+ return impl.m_listIndex;
+ }
+
+ virtual void setListIndex(class ResourceList& list, uint32_t index)
+ {
+ impl.m_list = &list;
+ impl.m_listIndex = index;
+ }
+
+#ifndef WITHOUT_PVD
+ virtual void initPvdInstances(pvdsdk::PvdDataStream& pvdStream)
+ {
+ impl.initPvdInstances(pvdStream);
+ }
+#endif
+
+ virtual void destroy()
+ {
+ impl.destroy();
+ delete this;
+ }
+
+ // Actor base class
+ virtual Asset* getOwner() const
+ {
+ return impl.getOwner();
+ }
+ virtual PxBounds3 getBounds() const
+ {
+ return impl.getBounds();
+ }
+
+ virtual void lockRenderResources()
+ {
+ impl.lockRenderResources();
+ }
+
+ virtual void unlockRenderResources()
+ {
+ impl.unlockRenderResources();
+ }
+
+ virtual void updateRenderResources(bool rewriteBuffers, void* userRenderData)
+ {
+ URR_SCOPE;
+ impl.updateRenderResources(rewriteBuffers, userRenderData);
+ }
+
+ virtual void dispatchRenderResources(UserRenderer& renderer)
+ {
+ impl.dispatchRenderResources(renderer);
+ }
+
+ virtual NvParameterized::Interface* getActorDesc()
+ {
+ READ_ZONE();
+ return impl.getActorDesc();
+ }
+
+ virtual void updateState(const PxMat44& globalPose, const PxMat44* newBoneMatrices, uint32_t boneMatricesByteStride, uint32_t numBoneMatrices, ClothingTeleportMode::Enum teleportMode)
+ {
+ WRITE_ZONE();
+ impl.updateState(globalPose, newBoneMatrices, boneMatricesByteStride, numBoneMatrices, teleportMode);
+ }
+
+ virtual void updateMaxDistanceScale(float scale, bool multipliable)
+ {
+ WRITE_ZONE();
+ impl.updateMaxDistanceScale(scale, multipliable);
+ }
+
+ virtual const PxMat44& getGlobalPose() const
+ {
+ READ_ZONE();
+ return impl.getGlobalPose();
+ }
+
+ virtual void setWind(float windAdaption, const PxVec3& windVelocity)
+ {
+ WRITE_ZONE();
+ impl.setWind(windAdaption, windVelocity);
+ }
+
+ virtual void setMaxDistanceBlendTime(float blendTime)
+ {
+ WRITE_ZONE();
+ impl.setMaxDistanceBlendTime(blendTime);
+ }
+
+ virtual float getMaxDistanceBlendTime() const
+ {
+ READ_ZONE();
+ return impl.getMaxDistanceBlendTime();
+ }
+
+ virtual void getPhysicalMeshPositions(void* buffer, uint32_t byteStride)
+ {
+ READ_ZONE();
+ impl.getPhysicalMeshPositions(buffer, byteStride);
+ }
+
+ virtual void getPhysicalMeshNormals(void* buffer, uint32_t byteStride)
+ {
+ READ_ZONE();
+ impl.getPhysicalMeshNormals(buffer, byteStride);
+ }
+
+ virtual float getMaximumSimulationBudget() const
+ {
+ READ_ZONE();
+ return impl.getMaximumSimulationBudget();
+ }
+
+ virtual uint32_t getNumSimulationVertices() const
+ {
+ READ_ZONE();
+ return impl.getNumSimulationVertices();
+ }
+
+ virtual const PxVec3* getSimulationPositions()
+ {
+ READ_ZONE();
+ return impl.getSimulationPositions();
+ }
+
+ virtual const PxVec3* getSimulationNormals()
+ {
+ READ_ZONE();
+ return impl.getSimulationNormals();
+ }
+
+ virtual bool getSimulationVelocities(PxVec3* velocities)
+ {
+ READ_ZONE();
+ return impl.getSimulationVelocities(velocities);
+ }
+
+ virtual uint32_t getNumGraphicalVerticesActive(uint32_t submeshIndex) const
+ {
+ READ_ZONE();
+ return impl.getNumGraphicalVerticesActive(submeshIndex);
+ }
+
+ virtual PxMat44 getRenderGlobalPose() const
+ {
+ READ_ZONE();
+ return impl.getRenderGlobalPose();
+ }
+
+ virtual const PxMat44* getCurrentBoneSkinningMatrices() const
+ {
+ READ_ZONE();
+ return impl.getCurrentBoneSkinningMatrices();
+ }
+
+ virtual void setVisible(bool enable)
+ {
+ WRITE_ZONE();
+ impl.setVisible(enable);
+ }
+
+ virtual bool isVisible() const
+ {
+ READ_ZONE();
+ return impl.isVisibleBuffered();
+ }
+
+ virtual void setFrozen(bool enable)
+ {
+ WRITE_ZONE();
+ impl.setFrozen(enable);
+ }
+
+ virtual bool isFrozen() const
+ {
+ READ_ZONE();
+ return impl.isFrozenBuffered();
+ }
+
+ virtual ClothSolverMode::Enum getClothSolverMode() const
+ {
+ READ_ZONE();
+ return impl.getClothSolverMode();
+ }
+
+ virtual void setGraphicalLOD(uint32_t lod)
+ {
+ WRITE_ZONE();
+ impl.setGraphicalLOD(lod);
+ }
+
+ virtual uint32_t getGraphicalLod()
+ {
+ READ_ZONE();
+ return impl.getGraphicalLod();
+ }
+
+ virtual bool rayCast(const PxVec3& worldOrigin, const PxVec3& worldDirection, float& time, PxVec3& normal, uint32_t& vertexIndex)
+ {
+ READ_ZONE();
+ return impl.rayCast(worldOrigin, worldDirection, time, normal, vertexIndex);
+ }
+
+ virtual void attachVertexToGlobalPosition(uint32_t vertexIndex, const PxVec3& globalPosition)
+ {
+ WRITE_ZONE();
+ impl.attachVertexToGlobalPosition(vertexIndex, globalPosition);
+ }
+
+ virtual void freeVertex(uint32_t vertexIndex)
+ {
+ WRITE_ZONE();
+ impl.freeVertex(vertexIndex);
+ }
+
+ virtual uint32_t getClothingMaterial() const
+ {
+ READ_ZONE();
+ return impl.getClothingMaterial();
+ }
+
+ virtual void setClothingMaterial(uint32_t index)
+ {
+ WRITE_ZONE();
+ impl.setClothingMaterial(index);
+ }
+
+ virtual void setOverrideMaterial(uint32_t submeshIndex, const char* overrideMaterialName)
+ {
+ WRITE_ZONE();
+ impl.setOverrideMaterial(submeshIndex, overrideMaterialName);
+ }
+
+ virtual void setVelocityCallback(ClothingVelocityCallback* callback)
+ {
+ WRITE_ZONE();
+ impl.setVelocityCallback(callback);
+ }
+
+ virtual void setInterCollisionChannels(uint32_t channels)
+ {
+ WRITE_ZONE();
+ impl.setInterCollisionChannels(channels);
+ }
+
+ virtual uint32_t getInterCollisionChannels()
+ {
+ READ_ZONE();
+ return impl.getInterCollisionChannels();
+ }
+
+ virtual bool isHalfPrecisionAllowed() const
+ {
+ READ_ZONE();
+ return impl.isHalfPrecisionAllowed();
+ }
+
+ virtual void setHalfPrecision(bool isAllowed)
+ {
+ WRITE_ZONE();
+ return impl.setHalfPrecision(isAllowed);
+ }
+
+ virtual void getLodRange(float& min, float& max, bool& intOnly) const
+ {
+ READ_ZONE();
+ impl.getLodRange(min, max, intOnly);
+ }
+
+ virtual float getActiveLod() const
+ {
+ READ_ZONE();
+ return impl.getActiveLod();
+ }
+
+ virtual void forceLod(float lod)
+ {
+ WRITE_ZONE();
+ impl.forceLod(lod);
+ }
+
+ /**
+ \brief Selectively enables/disables debug visualization of a specific APEX actor. Default value it true.
+ */
+ virtual void setEnableDebugVisualization(bool state)
+ {
+ impl.setEnableDebugVisualization(state);
+ }
+
+ virtual ClothingPlane* createCollisionPlane(const PxPlane& plane)
+ {
+ WRITE_ZONE();
+ return impl.createCollisionPlane(plane);
+ }
+
+ virtual ClothingConvex* createCollisionConvex(ClothingPlane** planes, uint32_t numPlanes)
+ {
+ WRITE_ZONE();
+ return impl.createCollisionConvex(planes, numPlanes);
+ }
+
+ virtual ClothingSphere* createCollisionSphere(const PxVec3& position, float radius)
+ {
+ WRITE_ZONE();
+ return impl.createCollisionSphere(position, radius);
+ }
+
+ virtual ClothingCapsule* createCollisionCapsule(ClothingSphere& sphere1, ClothingSphere& sphere2)
+ {
+ WRITE_ZONE();
+ return impl.createCollisionCapsule(sphere1, sphere2);
+ }
+
+ virtual ClothingTriangleMesh* createCollisionTriangleMesh()
+ {
+ WRITE_ZONE();
+ return impl.createCollisionTriangleMesh();
+ }
+
+ virtual ClothingRenderProxy* acquireRenderProxy()
+ {
+ READ_ZONE();
+ return impl.acquireRenderProxy();
+ }
+
+#if APEX_UE4
+ virtual void simulate(PxF32 dt)
+ {
+ WRITE_ZONE();
+ impl.simulate(dt);
+ }
+#endif
+};
+
+
+}
+} // namespace nvidia
+
+#endif // CLOTHING_ACTOR_PROXY_H
diff --git a/APEX_1.4/module/clothing/include/ClothingActorTasks.h b/APEX_1.4/module/clothing/include/ClothingActorTasks.h
new file mode 100644
index 00000000..329c2142
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ClothingActorTasks.h
@@ -0,0 +1,96 @@
+/*
+ * 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 CLOTHING_ACTOR_TASKS_H
+#define CLOTHING_ACTOR_TASKS_H
+
+#include "PxTask.h"
+
+#if APEX_UE4
+#include "PsSync.h"
+#include "ApexInterface.h"
+#endif
+
+namespace nvidia
+{
+namespace clothing
+{
+
+class ClothingActorImpl;
+class ClothingActorData;
+
+
+class ClothingActorBeforeTickTask : public physx::PxLightCpuTask
+{
+public:
+ ClothingActorBeforeTickTask(ClothingActorImpl* actor) : mActor(actor), mDeltaTime(0.0f), mSubstepSize(0.0f), mNumSubSteps(0) {}
+#if APEX_UE4
+ ~ClothingActorBeforeTickTask() {}
+#endif
+
+ PX_INLINE void setDeltaTime(float simulationDelta, float substepSize, uint32_t numSubSteps)
+ {
+ mDeltaTime = simulationDelta;
+ mSubstepSize = substepSize;
+ mNumSubSteps = numSubSteps;
+ }
+
+ virtual void run();
+ virtual const char* getName() const;
+
+private:
+ ClothingActorImpl* mActor;
+ float mDeltaTime;
+ float mSubstepSize;
+ uint32_t mNumSubSteps;
+};
+
+
+
+class ClothingActorDuringTickTask : public physx::PxTask
+{
+public:
+ ClothingActorDuringTickTask(ClothingActorImpl* actor) : mActor(actor) {}
+
+ virtual void run();
+ virtual const char* getName() const;
+
+private:
+ ClothingActorImpl* mActor;
+};
+
+
+
+class ClothingActorFetchResultsTask :
+#if APEX_UE4
+ public PxTask
+#else
+ public physx::PxLightCpuTask
+#endif
+{
+public:
+ ClothingActorFetchResultsTask(ClothingActorImpl* actor) : mActor(actor) {}
+
+ virtual void run();
+ virtual const char* getName() const;
+#if APEX_UE4
+ virtual void release();
+#endif
+
+private:
+ ClothingActorImpl* mActor;
+};
+
+
+}
+} // namespace nvidia
+
+#endif
diff --git a/APEX_1.4/module/clothing/include/ClothingAssetAuthoringImpl.h b/APEX_1.4/module/clothing/include/ClothingAssetAuthoringImpl.h
new file mode 100644
index 00000000..06f8dafb
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ClothingAssetAuthoringImpl.h
@@ -0,0 +1,265 @@
+/*
+ * 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 CLOTHING_ASSET_AUTHORING_IMPL_H
+#define CLOTHING_ASSET_AUTHORING_IMPL_H
+
+
+#include "ClothingAssetAuthoring.h"
+#include "ClothingAssetImpl.h"
+#include "ClothingGraphicalLodParameters.h"
+#include "ApexAssetAuthoring.h"
+
+#include "ReadCheck.h"
+#include "WriteCheck.h"
+
+#ifndef WITHOUT_APEX_AUTHORING
+
+namespace nvidia
+{
+namespace clothing
+{
+
+class ClothingPhysicalMeshImpl;
+
+
+class ClothingAssetAuthoringImpl : public ClothingAssetAuthoring, public ApexAssetAuthoring, public ClothingAssetImpl
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ ClothingAssetAuthoringImpl(ModuleClothingImpl* module, ResourceList& list, const char* name);
+ ClothingAssetAuthoringImpl(ModuleClothingImpl* module, ResourceList& list);
+ ClothingAssetAuthoringImpl(ModuleClothingImpl* module, ResourceList& list, NvParameterized::Interface* params, const char* name);
+
+ // from AssetAuthoring
+ virtual const char* getName(void) const
+ {
+ return ClothingAssetImpl::getName();
+ }
+ virtual const char* getObjTypeName() const
+ {
+ return CLOTHING_AUTHORING_TYPE_NAME;
+ }
+ virtual bool prepareForPlatform(nvidia::apex::PlatformTag);
+
+ virtual void setToolString(const char* toolName, const char* toolVersion, uint32_t toolChangelist)
+ {
+ ApexAssetAuthoring::setToolString(toolName, toolVersion, toolChangelist);
+ }
+
+ // from ApexInterface
+ virtual void release();
+
+ // from ClothingAssetAuthoring
+ virtual void setDefaultConstrainCoefficients(const ClothingConstrainCoefficients& coeff)
+ {
+ WRITE_ZONE();
+ mDefaultConstrainCoefficients = coeff;
+ }
+ virtual void setInvalidConstrainCoefficients(const ClothingConstrainCoefficients& coeff)
+ {
+ WRITE_ZONE();
+ mInvalidConstrainCoefficients = coeff;
+ }
+
+ virtual void setMeshes(uint32_t lod, RenderMeshAssetAuthoring* asset, ClothingPhysicalMesh* mesh,
+ float normalResemblance = 90, bool ignoreUnusedVertices = true,
+ IProgressListener* progress = NULL);
+ virtual bool addPlatformToGraphicalLod(uint32_t lod, PlatformTag platform);
+ virtual bool removePlatform(uint32_t lod, PlatformTag platform);
+ virtual uint32_t getNumPlatforms(uint32_t lod) const;
+ virtual PlatformTag getPlatform(uint32_t lod, uint32_t i) const;
+ virtual uint32_t getNumLods() const;
+ virtual int32_t getLodValue(uint32_t lod) const;
+ virtual void clearMeshes();
+ virtual ClothingPhysicalMesh* getClothingPhysicalMesh(uint32_t graphicalLod) const;
+
+ virtual void setBoneInfo(uint32_t boneIndex, const char* boneName, const PxMat44& bindPose, int32_t parentIndex);
+ virtual void setRootBone(const char* boneName);
+ virtual uint32_t addBoneConvex(const char* boneName, const PxVec3* positions, uint32_t numPositions);
+ virtual uint32_t addBoneConvex(uint32_t boneIndex, const PxVec3* positions, uint32_t numPositions);
+ virtual void addBoneCapsule(const char* boneName, float capsuleRadius, float capsuleHeight, const PxMat44& localPose);
+ virtual void addBoneCapsule(uint32_t boneIndex, float capsuleRadius, float capsuleHeight, const PxMat44& localPose);
+ virtual void clearBoneActors(const char* boneName);
+ virtual void clearBoneActors(uint32_t boneIndex);
+ virtual void clearAllBoneActors();
+
+ virtual void setCollision(const char** boneNames, float* radii, PxVec3* localPositions,
+ uint32_t numSpheres, uint16_t* pairs, uint32_t numPairs);
+ virtual void setCollision(uint32_t* boneIndices, float* radii, PxVec3* localPositions, uint32_t numSpheres,
+ uint16_t* pairs, uint32_t numPairs);
+ virtual void clearCollision();
+
+ virtual void setSimulationHierarchicalLevels(uint32_t levels)
+ {
+ WRITE_ZONE();
+ mParams->simulation.hierarchicalLevels = levels;
+ clearCooked();
+ }
+ virtual void setSimulationThickness(float thickness)
+ {
+ WRITE_ZONE();
+ mParams->simulation.thickness = thickness;
+ }
+ virtual void setSimulationVirtualParticleDensity(float density)
+ {
+ WRITE_ZONE();
+ PX_ASSERT(density >= 0.0f);
+ PX_ASSERT(density <= 1.0f);
+ mParams->simulation.virtualParticleDensity = PxClamp(density, 0.0f, 1.0f);
+ }
+ virtual void setSimulationSleepLinearVelocity(float sleep)
+ {
+ WRITE_ZONE();
+ mParams->simulation.sleepLinearVelocity = sleep;
+ }
+ virtual void setSimulationGravityDirection(const PxVec3& gravity)
+ {
+ WRITE_ZONE();
+ mParams->simulation.gravityDirection = gravity.getNormalized();
+ }
+
+ virtual void setSimulationDisableCCD(bool disable)
+ {
+ WRITE_ZONE();
+ mParams->simulation.disableCCD = disable;
+ }
+ virtual void setSimulationTwowayInteraction(bool enable)
+ {
+ WRITE_ZONE();
+ mParams->simulation.twowayInteraction = enable;
+ }
+ virtual void setSimulationUntangling(bool enable)
+ {
+ WRITE_ZONE();
+ mParams->simulation.untangling = enable;
+ }
+ virtual void setSimulationRestLengthScale(float scale)
+ {
+ WRITE_ZONE();
+ mParams->simulation.restLengthScale = scale;
+ }
+
+ virtual void setExportScale(float scale)
+ {
+ WRITE_ZONE();
+ mExportScale = scale;
+ }
+ virtual void applyTransformation(const PxMat44& transformation, float scale, bool applyToGraphics, bool applyToPhysics);
+ virtual void updateBindPoses(const PxMat44* newBindPoses, uint32_t newBindPosesCount, bool isInternalOrder, bool collisionMaintainWorldPose);
+ virtual void setDeriveNormalsFromBones(bool enable)
+ {
+ WRITE_ZONE();
+ mDeriveNormalsFromBones = enable;
+ }
+ virtual NvParameterized::Interface* getMaterialLibrary();
+ virtual bool setMaterialLibrary(NvParameterized::Interface* materialLibrary, uint32_t materialIndex, bool transferOwnership);
+ virtual NvParameterized::Interface* getRenderMeshAssetAuthoring(uint32_t lodLevel) const;
+
+ // parameterization
+ NvParameterized::Interface* getNvParameterized() const
+ {
+ return mParams;
+ }
+ virtual NvParameterized::Interface* releaseAndReturnNvParameterizedInterface();
+
+ // from NvParameterized::SerializationCallback
+ virtual void preSerialize(void* userData);
+
+ // from ApexAssetAuthoring
+ virtual void setToolString(const char* toolString);
+
+ // internal
+ void destroy();
+
+ virtual bool setBoneBindPose(uint32_t boneIndex, const PxMat44& bindPose);
+ virtual bool getBoneBindPose(uint32_t boneIndex, PxMat44& bindPose) const;
+
+private:
+ // bones
+ uint32_t addBoneConvexInternal(uint32_t boneIndex, const PxVec3* positions, uint32_t numPositions);
+ void addBoneCapsuleInternal(uint32_t boneIndex, float capsuleRadius, float capsuleHeight, const PxMat44& localPose);
+ void clearBoneActorsInternal(int32_t internalBoneIndex);
+ void compressBones() const;
+ void compressBoneCollision();
+ void collectBoneIndices(uint32_t numVertices, const uint16_t* boneIndices, const float* boneWeights, uint32_t numBonesPerVertex) const;
+
+ void updateMappingAuthoring(ClothingGraphicalLodParameters& graphLod, RenderMeshAssetIntl* renderMeshAssetCopy,
+ RenderMeshAssetAuthoringIntl* renderMeshAssetOrig, float normalResemblance,
+ bool ignoreUnusedVertices, IProgressListener* progress);
+ void sortSkinMapB(SkinClothMapB* skinClothMap, uint32_t skinClothMapSize, uint32_t* immediateClothMap, uint32_t immediateClothMapSize);
+
+ void setupPhysicalMesh(ClothingPhysicalMeshParameters& physicalMeshParameters) const;
+
+ bool checkSetMeshesInput(uint32_t lod, ClothingPhysicalMesh* nxPhysicalMesh, uint32_t& graphicalLodIndexTest);
+ void sortPhysicalMeshes();
+
+ // mesh reordering
+ void sortDeformableIndices(ClothingPhysicalMeshImpl& physicalMesh);
+
+
+ bool getGraphicalLodIndex(uint32_t lod, uint32_t& graphicalLodIndex) const;
+ uint32_t addGraphicalLod(uint32_t lod);
+
+ // cooking
+ void clearCooked();
+
+ // access
+ bool addGraphicalMesh(RenderMeshAssetAuthoring* renderMesh, uint32_t graphicalLodIndex);
+
+ Array<ClothingPhysicalMeshImpl*> mPhysicalMeshesInput;
+
+ float mExportScale;
+ bool mDeriveNormalsFromBones;
+ bool mOwnsMaterialLibrary;
+
+ ClothingConstrainCoefficients mDefaultConstrainCoefficients;
+ ClothingConstrainCoefficients mInvalidConstrainCoefficients;
+
+ const char* mPreviousCookedType;
+
+ ApexSimpleString mRootBoneName;
+
+ void initParams();
+
+ // immediate cloth: 1-to-1 mapping from physical to rendering mesh (except for LOD)
+ bool generateImmediateClothMap(const AbstractMeshDescription* targetMeshes, uint32_t numTargetMeshes,
+ ClothingPhysicalMeshParametersNS::PhysicalMesh_Type& physicalMesh,
+ uint32_t* masterFlags, float epsilon, uint32_t& numNotFoundVertices,
+ float normalResemblance, ParamArray<uint32_t>& result, IProgressListener* progress) const;
+ bool generateSkinClothMap(const AbstractMeshDescription* targetMeshes, uint32_t numTargetMeshes,
+ ClothingPhysicalMeshParametersNS::PhysicalMesh_Type& physicalMesh, uint32_t* masterFlags,
+ uint32_t* immediateMap, uint32_t numEmptyInImmediateMap, ParamArray<SkinClothMap>& result,
+ float& offsetAlongNormal, bool integrateImmediateMap, IProgressListener* progress) const;
+
+ void removeMaxDistance0Mapping(ClothingGraphicalLodParameters& graphicalLod, RenderMeshAssetIntl* renderMeshAsset) const;
+
+ bool generateTetraMap(const AbstractMeshDescription* targetMeshes, uint32_t numTargetMeshes,
+ ClothingPhysicalMeshParametersNS::PhysicalMesh_Type& physicalMesh, uint32_t* masterFlags,
+ ParamArray<ClothingGraphicalLodParametersNS::TetraLink_Type>& result, IProgressListener* progress) const;
+ float computeBaryError(float baryX, float baryY) const;
+ float computeTriangleError(const TriangleWithNormals& triangle, const PxVec3& normal) const;
+
+
+ bool hasTangents(const RenderMeshAssetIntl& rma);
+ uint32_t getMaxNumGraphicalVertsActive(const ClothingGraphicalLodParameters& graphicalLod, uint32_t submeshIndex);
+ bool isMostlyImmediateSkinned(const RenderMeshAssetIntl& rma, const ClothingGraphicalLodParameters& graphicalLod);
+ bool conditionalMergeMapping(const RenderMeshAssetIntl& rma, ClothingGraphicalLodParameters& graphicalLod);
+
+};
+
+}
+} // namespace nvidia
+
+#endif // WITHOUT_APEX_AUTHORING
+
+#endif // CLOTHING_ASSET_AUTHORING_IMPL_H
diff --git a/APEX_1.4/module/clothing/include/ClothingAssetData.h b/APEX_1.4/module/clothing/include/ClothingAssetData.h
new file mode 100644
index 00000000..2e3d4f18
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ClothingAssetData.h
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
+ *
+ * NVIDIA CORPORATION and its licensors retain all intellectual property
+ * and proprietary rights in and to this software, related documentation
+ * and any modifications thereto. Any use, reproduction, disclosure or
+ * distribution of this software and related documentation without an express
+ * license agreement from NVIDIA CORPORATION is strictly prohibited.
+ */
+
+
+#ifndef CLOTHING_ASSET_DATA
+#define CLOTHING_ASSET_DATA
+
+#include "PxSimpleTypes.h"
+#include "PxAssert.h"
+#include "AbstractMeshDescription.h"
+#include "RenderDataFormat.h"
+#include "PxBounds3.h"
+#include "PsAllocator.h"
+#include "RenderMeshAsset.h"
+
+namespace nvidia
+{
+namespace clothing
+{
+
+// forward declarations
+namespace ClothingGraphicalLodParametersNS
+{
+struct SkinClothMapB_Type;
+struct SkinClothMapD_Type;
+struct TetraLink_Type;
+}
+
+}
+
+//typedef ClothingGraphicalLodParametersNS::SkinClothMapB_Type SkinClothMapB_TypeLocal;
+//typedef ClothingGraphicalLodParametersNS::SkinClothMapC_Type SkinClothMapC_TypeLocal;
+//typedef ClothingGraphicalLodParametersNS::TetraLink_Type TetraLink_TypeLocal;
+
+struct VertexUVLocal
+{
+ VertexUVLocal() {}
+ VertexUVLocal(float _u, float _v)
+ {
+ set(_u, _v);
+ }
+ VertexUVLocal(const float uv[])
+ {
+ set(uv);
+ }
+
+ void set(float _u, float _v)
+ {
+ u = _u;
+ v = _v;
+ }
+
+ void set(const float uv[])
+ {
+ u = uv[0];
+ v = uv[1];
+ }
+
+ float& operator [](int i)
+ {
+ PX_ASSERT(i >= 0 && i <= 1);
+ return (&u)[i];
+ }
+
+ const float& operator [](int i) const
+ {
+ PX_ASSERT(i >= 0 && i <= 1);
+ return (&u)[i];
+ }
+
+ float u, v;
+};
+
+PX_COMPILE_TIME_ASSERT(sizeof(VertexUVLocal) == sizeof(VertexUV));
+
+struct TetraEncoding_Local
+{
+ float sign[4];
+ uint32_t lastVtxIdx;
+};
+
+#define TETRA_LUT_SIZE_LOCAL 6
+static const TetraEncoding_Local tetraTableLocal[TETRA_LUT_SIZE_LOCAL] =
+{
+ { {0, 0, 0, 1}, 0},
+ { {1, 0, 0, 1}, 2},
+ { {1, 0, 1, 1}, 1},
+
+ { { -1, -1, -1, 0}, 0},
+ { {0, -1, -1, 0}, 2 },
+ { {0, -1, 0, 0}, 1 }
+};
+
+
+namespace clothing
+{
+
+//This seems to be the data we are interested in in each submesh...
+class ClothingAssetSubMesh
+{
+
+public:
+ ClothingAssetSubMesh();
+
+ const PxVec3* PX_RESTRICT mPositions;
+ const PxVec3* PX_RESTRICT mNormals;
+ const PxVec4* PX_RESTRICT mTangents;
+
+ const float* PX_RESTRICT mBoneWeights;
+ const uint16_t* PX_RESTRICT mBoneIndices;
+
+ const uint32_t* PX_RESTRICT mIndices;
+
+ VertexUVLocal* mUvs;
+
+ RenderDataFormat::Enum mPositionOutFormat;
+ RenderDataFormat::Enum mNormalOutFormat;
+ RenderDataFormat::Enum mTangentOutFormat;
+ RenderDataFormat::Enum mBoneWeightOutFormat;
+ RenderDataFormat::Enum mUvFormat;
+
+ uint32_t mVertexCount;
+ uint32_t mIndicesCount;
+ uint32_t mUvCount;
+ uint32_t mNumBonesPerVertex;
+
+ uint32_t mCurrentMaxVertexSimulation;
+ uint32_t mCurrentMaxVertexAdditionalSimulation;
+ uint32_t mCurrentMaxIndexSimulation;
+};
+
+class ClothingMeshAssetData
+{
+public:
+
+ ClothingMeshAssetData();
+
+ const uint32_t* mImmediateClothMap;
+ ClothingGraphicalLodParametersNS::SkinClothMapD_Type* mSkinClothMap;
+ ClothingGraphicalLodParametersNS::SkinClothMapB_Type* mSkinClothMapB;
+ ClothingGraphicalLodParametersNS::TetraLink_Type* mTetraMap;
+
+ uint32_t mImmediateClothMapCount;
+ uint32_t mSkinClothMapCount;
+ uint32_t mSkinClothMapBCount;
+ uint32_t mTetraMapCount;
+
+ uint32_t mSubmeshOffset;
+ uint32_t mSubMeshCount;
+
+ //Index of the physics mesh this lod relates to
+ uint32_t mPhysicalMeshId;
+
+ float mSkinClothMapThickness;
+ float mSkinClothMapOffset;
+
+ PxBounds3 mBounds;
+
+ bool bActive;
+ bool bNeedsTangents;
+};
+
+
+//A physical clothing mesh
+class ClothingPhysicalMeshData
+{
+public:
+ ClothingPhysicalMeshData();
+
+ PxVec3* mVertices;
+ uint32_t mVertexCount;
+ uint32_t mSimulatedVertexCount;
+ uint32_t mMaxDistance0VerticesCount;
+
+ PxVec3* mNormals;
+ PxVec3* mSkinningNormals;
+ uint16_t* mBoneIndices;
+ float* mBoneWeights;
+ uint8_t* mOptimizationData;
+ uint32_t* mIndices;
+
+ uint32_t mSkinningNormalsCount;
+ uint32_t mBoneWeightsCount;
+ uint32_t mOptimizationDataCount;
+ uint32_t mIndicesCount;
+ uint32_t mSimulatedIndicesCount;
+
+ uint32_t mNumBonesPerVertex;
+};
+
+//A clothing asset contains a set of submeshes + some other data that we might be interested in...
+class ClothingAssetData
+{
+public:
+ ClothingAssetData();
+ ~ClothingAssetData();
+
+ uint8_t* mData;
+ uint32_t* mCompressedNumBonesPerVertex;
+ uint32_t* mCompressedTangentW;
+ uint32_t* mExt2IntMorphMapping;
+ uint32_t mCompressedNumBonesPerVertexCount;
+ uint32_t mCompressedTangentWCount;
+ uint32_t mExt2IntMorphMappingCount;
+
+ uint32_t mAssetSize;
+ uint32_t mGraphicalLodsCount;
+ uint32_t mPhysicalMeshesCount;
+ uint32_t mPhysicalMeshOffset;
+
+
+ uint32_t mBoneCount;
+
+ uint32_t mRootBoneIndex;
+
+ ClothingMeshAssetData* GetLod(const uint32_t lod) const
+ {
+ return ((ClothingMeshAssetData*)mData) + lod;
+ }
+
+ ClothingAssetSubMesh* GetSubmesh(const uint32_t lod, const uint32_t submeshIndex) const
+ {
+ return GetSubmesh(GetLod(lod), submeshIndex);
+ }
+
+ ClothingAssetSubMesh* GetSubmesh(const ClothingMeshAssetData* asset, const uint32_t submeshIndex) const
+ {
+ return ((ClothingAssetSubMesh*)(mData + asset->mSubmeshOffset)) + submeshIndex;
+ }
+
+ ClothingPhysicalMeshData* GetPhysicalMesh(const uint32_t index) const
+ {
+ return ((ClothingPhysicalMeshData*)(mData + mPhysicalMeshOffset)) + index;
+ }
+
+ const uint32_t* getCompressedNumBonesPerVertex(uint32_t graphicalLod, uint32_t submeshIndex, uint32_t& mapSize);
+ const uint32_t* getCompressedTangentW(uint32_t graphicalLod, uint32_t submeshIndex, uint32_t& mapSize);
+
+ uint32_t* getMorphMapping(uint32_t graphicalLod);
+
+ template<bool withNormals, bool withBones, bool withMorph, bool withTangents>
+ void skinToBonesInternal(AbstractMeshDescription& destMesh, uint32_t submeshIndex, uint32_t graphicalMeshIndex, uint32_t startVertex,
+ PxMat44* compositeMatrices, PxVec3* morphDisplacements);
+
+ void skinToBones(AbstractMeshDescription& destMesh, uint32_t submeshIndex, uint32_t graphicalMeshIndex, uint32_t startVertex,
+ PxMat44* compositeMatrices, PxVec3* morphDisplacements);
+
+ template<bool computeNormals>
+ uint32_t skinClothMap(PxVec3* dstPositions, PxVec3* dstNormals, PxVec4* dstTangents, uint32_t numVertices,
+ const AbstractMeshDescription& srcPM, ClothingGraphicalLodParametersNS::SkinClothMapD_Type* map,
+ uint32_t numVerticesInMap, float offsetAlongNormal, float actorScale) const;
+
+ void getNormalsAndVerticesForFace(PxVec3* vtx, PxVec3* nrm, uint32_t i, const AbstractMeshDescription& srcPM) const;
+
+ uint32_t skinClothMapBSkinVertex(PxVec3& dstPos, PxVec3* dstNormal, uint32_t vIndex,
+ ClothingGraphicalLodParametersNS::SkinClothMapB_Type* pTCMB, const ClothingGraphicalLodParametersNS::SkinClothMapB_Type* pTCMBEnd,
+ const AbstractMeshDescription& srcPM) const;
+
+ uint32_t skinClothMapB(PxVec3* dstPositions, PxVec3* dstNormals, uint32_t numVertices,
+ const AbstractMeshDescription& srcPM, ClothingGraphicalLodParametersNS::SkinClothMapB_Type* map,
+ uint32_t numVerticesInMap, bool computeNormals) const;
+
+ bool skinToTetraMesh(AbstractMeshDescription& destMesh,
+ const AbstractMeshDescription& srcPM,
+ const ClothingMeshAssetData& graphicalLod);
+
+ ClothingPhysicalMeshData* GetPhysicalMeshFromLod(const uint32_t graphicalLod) const
+ {
+ PX_ASSERT(graphicalLod < mGraphicalLodsCount);
+ const uint32_t physicalMeshId = GetLod(graphicalLod)->mPhysicalMeshId;
+ PX_ASSERT(physicalMeshId < mPhysicalMeshesCount);
+ return GetPhysicalMesh(physicalMeshId);
+ }
+
+};
+
+}
+} // namespace nvidia
+
+#endif // CLOTHING_ASSET_DATA
diff --git a/APEX_1.4/module/clothing/include/ClothingAssetImpl.h b/APEX_1.4/module/clothing/include/ClothingAssetImpl.h
new file mode 100644
index 00000000..6809d53e
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ClothingAssetImpl.h
@@ -0,0 +1,494 @@
+/*
+ * 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 CLOTHING_ASSET_IMPL_H
+#define CLOTHING_ASSET_IMPL_H
+
+#include "ClothingAsset.h"
+
+#include "ApexResource.h"
+#include "PsMemoryBuffer.h"
+#include "ApexRWLockable.h"
+#include "ClothingCooking.h"
+#include "ModuleClothingImpl.h"
+#include "ModuleClothingHelpers.h"
+
+#include "RenderDebugInterface.h"
+#include "ApexAssetTracker.h"
+#include "ParamArray.h"
+
+#include "ReadCheck.h"
+#include "WriteCheck.h"
+
+namespace nvidia
+{
+namespace apex
+{
+struct AbstractMeshDescription;
+class ApexActorSource;
+class ApexRenderMeshAsset;
+class PhysXObjectDescIntl;
+class RenderMeshAssetIntl;
+
+template <class T_Module, class T_Asset, class T_AssetAuthoring>
+class ApexAuthorableObject;
+}
+namespace clothing
+{
+typedef ClothingGraphicalLodParametersNS::SkinClothMapB_Type SkinClothMapB;
+typedef ClothingGraphicalLodParametersNS::SkinClothMapD_Type SkinClothMap;
+typedef ClothingGraphicalLodParametersNS::TetraLink_Type TetraLink;
+
+
+class ClothingActorImpl;
+class ClothingActorProxy;
+class ClothingAssetData;
+class ClothingMaterial;
+class ClothingPhysicalMeshImpl;
+class CookingAbstract;
+class ClothingPreviewProxy;
+
+class SimulationAbstract;
+class ClothingPlaneImpl;
+
+#define NUM_VERTICES_PER_CACHE_BLOCK 8 // 128 / sizeof boneWeights per vertex (4 float), this is the biggest per vertex data
+
+
+#define DEFAULT_PM_OFFSET_ALONG_NORMAL_FACTOR 0.1f // Magic value that phil introduced for the mesh-mesh-skinning
+
+struct TetraEncoding
+{
+ float sign[4];
+ uint32_t lastVtxIdx;
+};
+
+
+
+#define TETRA_LUT_SIZE 6
+static const TetraEncoding tetraTable[TETRA_LUT_SIZE] =
+{
+ { { 0, 0, 0, 1 }, 0},
+ { { 1, 0, 0, 1 }, 2},
+ { { 1, 0, 1, 1 }, 1},
+
+ { { -1, -1, -1, 0 }, 0},
+ { { 0, -1, -1, 0 }, 2},
+ { { 0, -1, 0, 0 }, 1}
+};
+
+
+
+struct ClothingGraphicalMeshAssetWrapper
+{
+ ClothingGraphicalMeshAssetWrapper(const RenderMeshAsset* renderMeshAsset) : meshAsset(renderMeshAsset)
+ {
+ }
+ const RenderMeshAsset* meshAsset;
+
+ uint32_t getSubmeshCount() const
+ {
+ if (meshAsset == NULL)
+ return 0;
+
+ return meshAsset->getSubmeshCount();
+ }
+
+ uint32_t getNumTotalVertices() const
+ {
+ if (meshAsset == NULL)
+ return 0;
+
+ uint32_t count = 0;
+ for (uint32_t i = 0; i < meshAsset->getSubmeshCount(); i++)
+ {
+ count += meshAsset->getSubmesh(i).getVertexCount(0); // only 1 part is supported
+ }
+ return count;
+ }
+
+ uint32_t getNumVertices(uint32_t submeshIndex) const
+ {
+ if (meshAsset == NULL)
+ return 0;
+
+ return meshAsset->getSubmesh(submeshIndex).getVertexBuffer().getVertexCount();
+ }
+
+ uint32_t getNumBonesPerVertex(uint32_t submeshIndex) const
+ {
+ if (meshAsset == NULL)
+ return 0;
+
+ if (submeshIndex < meshAsset->getSubmeshCount())
+ {
+ const VertexFormat& format = meshAsset->getSubmesh(submeshIndex).getVertexBuffer().getFormat();
+ return vertexSemanticFormatElementCount(RenderVertexSemantic::BONE_INDEX,
+ format.getBufferFormat((uint32_t)format.getBufferIndexFromID(format.getSemanticID(RenderVertexSemantic::BONE_INDEX))));
+ }
+ return 0;
+ }
+
+ const void* getVertexBuffer(uint32_t submeshIndex, RenderVertexSemantic::Enum semantic, RenderDataFormat::Enum& outFormat) const
+ {
+ if (meshAsset == NULL)
+ return NULL;
+
+ const VertexBuffer& vb = meshAsset->getSubmesh(submeshIndex).getVertexBuffer();
+ const VertexFormat& vf = vb.getFormat();
+ uint32_t bufferIndex = (uint32_t)vf.getBufferIndexFromID(vf.getSemanticID((RenderVertexSemantic::Enum)semantic));
+ return vb.getBufferAndFormat(outFormat, bufferIndex);
+ }
+
+ uint32_t getNumIndices(uint32_t submeshIndex)
+ {
+ if (meshAsset == NULL)
+ return 0;
+
+ return meshAsset->getSubmesh(submeshIndex).getIndexCount(0);
+ }
+
+ const void* getIndexBuffer(uint32_t submeshIndex)
+ {
+ if (meshAsset == NULL)
+ return NULL;
+
+ return meshAsset->getSubmesh(submeshIndex).getIndexBuffer(0);
+ }
+
+ bool hasChannel(const char* bufferName = NULL, RenderVertexSemantic::Enum semantic = RenderVertexSemantic::NUM_SEMANTICS) const
+ {
+ if (meshAsset == NULL)
+ return false;
+
+ PX_ASSERT((bufferName != NULL) != (semantic != RenderVertexSemantic::NUM_SEMANTICS));
+ PX_ASSERT((bufferName == NULL) != (semantic == RenderVertexSemantic::NUM_SEMANTICS));
+
+ for (uint32_t i = 0; i < meshAsset->getSubmeshCount(); i++)
+ {
+ RenderDataFormat::Enum outFormat = RenderDataFormat::UNSPECIFIED;
+ const VertexFormat& format = meshAsset->getSubmesh(i).getVertexBuffer().getFormat();
+
+ VertexFormat::BufferID id = bufferName ? format.getID(bufferName) : format.getSemanticID(semantic);
+ outFormat = format.getBufferFormat((uint32_t)format.getBufferIndexFromID(id));
+
+ if (outFormat != RenderDataFormat::UNSPECIFIED)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+private:
+ void operator=(ClothingGraphicalMeshAssetWrapper&);
+};
+
+
+
+class ClothingAssetImpl : public ClothingAsset, public ApexResourceInterface, public ApexResource, public ClothingCookingLock, public NvParameterized::SerializationCallback, public ApexRWLockable
+{
+protected:
+ // used for authoring asset creation only!
+ ClothingAssetImpl(ModuleClothingImpl* module, ResourceList& list, const char* name);
+ ClothingAssetImpl(ModuleClothingImpl*, ResourceList&, NvParameterized::Interface*, const char*);
+
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ uint32_t initializeAssetData(ClothingAssetData& assetData, const uint32_t uvChannel);
+
+ // from Asset
+ PX_INLINE const char* getName() const
+ {
+ return mName.c_str();
+ }
+ PX_INLINE AuthObjTypeID getObjTypeID() const
+ {
+ return mAssetTypeID;
+ }
+ PX_INLINE const char* getObjTypeName() const
+ {
+ return CLOTHING_AUTHORING_TYPE_NAME;
+ }
+
+ virtual uint32_t forceLoadAssets();
+ virtual NvParameterized::Interface* getDefaultActorDesc();
+ virtual NvParameterized::Interface* getDefaultAssetPreviewDesc();
+ virtual const NvParameterized::Interface* getAssetNvParameterized() const
+ {
+ return mParams;
+ }
+ virtual Actor* createApexActor(const NvParameterized::Interface& params, Scene& apexScene);
+
+ virtual AssetPreview* createApexAssetPreview(const ::NvParameterized::Interface& /*params*/, AssetPreviewScene* /*previewScene*/)
+ {
+ PX_ALWAYS_ASSERT();
+ return NULL;
+ }
+
+ virtual NvParameterized::Interface* releaseAndReturnNvParameterizedInterface();
+ virtual bool isValidForActorCreation(const ::NvParameterized::Interface& parms, Scene& apexScene) const;
+ virtual bool isDirty() const;
+
+ // from ApexInterface
+ virtual void release();
+
+ // from ClothingAsset
+ PX_INLINE uint32_t getNumActors() const
+ {
+ READ_ZONE();
+ return mActors.getSize();
+ }
+ virtual ClothingActor* getActor(uint32_t index);
+ PX_INLINE PxBounds3 getBoundingBox() const
+ {
+ READ_ZONE();
+ return mParams->boundingBox;
+ }
+ virtual float getMaximumSimulationBudget(uint32_t solverIterations) const;
+ virtual uint32_t getNumGraphicalLodLevels() const;
+ virtual uint32_t getGraphicalLodValue(uint32_t lodLevel) const;
+ virtual float getBiggestMaxDistance() const;
+ virtual bool remapBoneIndex(const char* name, uint32_t newIndex);
+ PX_INLINE uint32_t getNumBones() const
+ {
+ READ_ZONE();
+ return mBones.size();
+ }
+ PX_INLINE uint32_t getNumUsedBones() const
+ {
+ READ_ZONE();
+ return mParams->bonesReferenced;
+ }
+ PX_INLINE uint32_t getNumUsedBonesForMesh() const
+ {
+ return mParams->bonesReferencedByMesh;
+ }
+ virtual const char* getBoneName(uint32_t internalIndex) const;
+ virtual bool getBoneBasePose(uint32_t internalIndex, PxMat44& result) const;
+ virtual void getBoneMapping(uint32_t* internal2externalMap) const;
+ virtual uint32_t prepareMorphTargetMapping(const PxVec3* originalPositions, uint32_t numPositions, float epsilon);
+
+ // from ApexResource
+ uint32_t getListIndex() const
+ {
+ READ_ZONE();
+ return m_listIndex;
+ }
+ void setListIndex(class ResourceList& list, uint32_t index)
+ {
+ m_list = &list;
+ m_listIndex = index;
+ }
+
+ // from NvParameterized::SerializationCallback
+ virtual void preSerialize(void* userData_);
+
+ // graphical meshes
+ PX_INLINE uint32_t getNumGraphicalMeshes() const
+ {
+ return mGraphicalLods.size();
+ }
+
+ RenderMeshAssetIntl* getGraphicalMesh(uint32_t index);
+ const ClothingGraphicalLodParameters* getGraphicalLod(uint32_t index) const;
+
+ // actor handling
+ void releaseClothingActor(ClothingActor& actor);
+ void releaseClothingPreview(ClothingPreview& preview);
+
+ // module stuff
+ PX_INLINE ModuleClothingImpl* getModuleClothing() const
+ {
+ PX_ASSERT(mModule != NULL);
+ return mModule;
+ }
+
+ // actor access to the asset
+ bool writeBoneMatrices(PxMat44 localPose, const PxMat44* newBoneMatrices,
+ const uint32_t byteStride, const uint32_t numBones, PxMat44* dest, bool isInternalOrder, bool multInvBindPose);
+ ClothingPhysicalMeshParametersNS::PhysicalMesh_Type* getPhysicalMeshFromLod(uint32_t graphicalLodId) const;
+
+ void releaseCookedInstances();
+
+ PX_INLINE bool getSimulationDisableCCD() const
+ {
+ return mParams->simulation.disableCCD;
+ }
+ ClothingPhysicalMeshParametersNS::SkinClothMapB_Type* getTransitionMapB(uint32_t dstPhysicalMeshId, uint32_t srcPhysicalMeshId, float& thickness, float& offset);
+ ClothingPhysicalMeshParametersNS::SkinClothMapD_Type* getTransitionMap(uint32_t dstPhysicalMeshId, uint32_t srcPhysicalMeshId, float& thickness, float& offset);
+
+ // cooked stuff
+ NvParameterized::Interface* getCookedData(float actorScale);
+ uint32_t getCookedPhysXVersion() const;
+ ClothSolverMode::Enum getClothSolverMode() const;
+
+ // create deformables
+ SimulationAbstract* getSimulation(uint32_t physicalMeshId, NvParameterized::Interface* cookedParam, ClothingScene* clothingScene);
+ void returnSimulation(SimulationAbstract* simulation);
+ void destroySimulation(SimulationAbstract* simulation);
+
+ void initCollision( SimulationAbstract* simulation, const PxMat44* boneTansformations,
+ ResourceList& actorPlanes,
+ ResourceList& actorConvexes,
+ ResourceList& actorSpheres,
+ ResourceList& actorCapsules,
+ ResourceList& actorTriangleMeshes,
+ const ClothingActorParam* actorParam,
+ const PxMat44& globalPose, bool localSpaceSim);
+
+ void updateCollision(SimulationAbstract* simulation, const PxMat44* boneTansformationse,
+ ResourceList& actorPlanes,
+ ResourceList& actorConvexes,
+ ResourceList& actorSpheres,
+ ResourceList& actorCapsules,
+ ResourceList& actorTriangleMeshes,
+ bool teleport);
+
+ uint32_t getPhysicalMeshID(uint32_t graphicalLodId) const;
+
+ // bone stuff
+ PX_INLINE const PxMat44& getBoneBindPose(uint32_t i)
+ {
+ PX_ASSERT(i < mBones.size());
+ return mBones[i].bindPose;
+ }
+
+ PX_INLINE uint32_t getBoneExternalIndex(uint32_t i)
+ {
+ PX_ASSERT(i < mBones.size());
+ return (uint32_t)mBones[i].externalIndex;
+ }
+
+ // debug rendering
+ void visualizeSkinCloth(RenderDebugInterface& renderDebug,
+ AbstractMeshDescription& srcPM, bool showTets, float actorScale) const;
+ void visualizeSkinClothMap(RenderDebugInterface& renderDebug, AbstractMeshDescription& srcPM,
+ SkinClothMapB* skinClothMapB, uint32_t skinClothMapBSize,
+ SkinClothMap* skinClothMap, uint32_t skinClothMapSize,
+ float actorScale, bool onlyBad, bool invalidBary) const;
+ void visualizeBones(RenderDebugInterface& renderDebug, const PxMat44* matrices, bool skeleton, float boneFramesScale, float boneNamesScale);
+
+
+ // expose render data
+ virtual const RenderMeshAsset* getRenderMeshAsset(uint32_t lodLevel) const;
+ virtual uint32_t getMeshSkinningMapSize(uint32_t lod);
+ virtual void getMeshSkinningMap(uint32_t lod, ClothingMeshSkinningMap* map);
+ virtual bool releaseGraphicalData();
+
+ void setupInvBindMatrices();
+
+ // unified cooking
+ void prepareCookingJob(CookingAbstract& job, float scale, PxVec3* gravityDirection, PxVec3* morphedPhysicalMesh);
+
+ // morph targets
+ uint32_t* getMorphMapping(uint32_t graphicalLod, uint32_t submeshIndex);
+ uint32_t getPhysicalMeshOffset(uint32_t physicalMeshId);
+ void getDisplacedPhysicalMeshPositions(PxVec3* morphDisplacements, ParamArray<PxVec3> displacedMeshPositions);
+
+ // faster cpu skinning
+ void initializeCompressedNumBonesPerVertex();
+ uint32_t getRootBoneIndex();
+
+ uint32_t getInterCollisionChannels();
+
+protected:
+ void destroy();
+
+ int32_t getBoneInternalIndex(const char* boneName) const;
+ int32_t getBoneInternalIndex(uint32_t boneIndex) const;
+
+ bool reorderGraphicsVertices(uint32_t graphicalLodId, bool perfWarning);
+ bool reorderDeformableVertices(ClothingPhysicalMeshImpl& physicalMesh);
+
+ float getMaxMaxDistance(ClothingPhysicalMeshParametersNS::PhysicalMesh_Type& physicalMesh,
+ uint32_t index, uint32_t numIndices) const;
+
+ uint32_t getCorrespondingPhysicalVertices(const ClothingGraphicalLodParameters& graphLod, uint32_t submeshIndex,
+ uint32_t graphicalVertexIndex, const AbstractMeshDescription& pMesh,
+ uint32_t submeshVertexOffset, uint32_t indices[4], float trust[4]) const;
+
+ void getNormalsAndVerticesForFace(PxVec3* vtx, PxVec3* nrm, uint32_t i,
+ const AbstractMeshDescription& srcPM) const;
+ bool setBoneName(uint32_t internalIndex, const char* name);
+ void clearMapping(uint32_t graphicalLodId);
+ void updateBoundingBox();
+
+ bool mergeMapping(ClothingGraphicalLodParameters* graphicalLod);
+ bool findTriangleForImmediateVertex(uint32_t& faceIndex, uint32_t& indexInTriangle, uint32_t physVertIndex,
+ ClothingPhysicalMeshParametersNS::PhysicalMesh_Type& physicalMesh) const;
+
+#ifndef WITHOUT_PVD
+ void initPvdInstances(pvdsdk::PvdDataStream& pvdStream);
+ void destroyPvdInstances();
+#endif
+
+ // the parent
+ ModuleClothingImpl* mModule;
+
+ // the parameterized object
+ ClothingAssetParameters* mParams;
+
+ // the meshes
+ ParamArray<ClothingPhysicalMeshParameters*> mPhysicalMeshes;
+
+ ParamArray<ClothingGraphicalLodParameters*> mGraphicalLods;
+
+ mutable ParamArray<ClothingAssetParametersNS::BoneEntry_Type> mBones;
+ Array<PxMat44> mInvBindPoses; // not serialized!
+
+ mutable ParamArray<ClothingAssetParametersNS::BoneSphere_Type> mBoneSpheres;
+ mutable ParamArray<uint16_t> mSpherePairs;
+ mutable ParamArray<ClothingAssetParametersNS::ActorEntry_Type> mBoneActors;
+ mutable ParamArray<PxVec3> mBoneVertices;
+ mutable ParamArray<ClothingAssetParametersNS::BonePlane_Type> mBonePlanes;
+ mutable ParamArray<uint32_t> mCollisionConvexes; // bitmap for indices into mBonePlanes array
+
+private:
+ // internal methods
+ float getMaxDistReduction(ClothingPhysicalMeshParameters& physicalMesh, float maxDistanceMultiplier) const;
+
+ static const char* getClassName()
+ {
+ return CLOTHING_AUTHORING_TYPE_NAME;
+ }
+
+ Array<uint32_t> mCompressedNumBonesPerVertex;
+ Array<uint32_t> mCompressedTangentW;
+ nvidia::Mutex mCompressedNumBonesPerVertexMutex;
+
+ ApexSimpleString mName;
+
+ // Keep track of all ClothingActorImpl objects created from this ClothingAssetImpl
+ ResourceList mActors;
+ ResourceList mPreviews;
+
+
+ Array<SimulationAbstract*> mUnusedSimulation;
+ nvidia::Mutex mUnusedSimulationMutex;
+
+ static AuthObjTypeID mAssetTypeID;
+ friend class ModuleClothingImpl;
+
+
+ Array<uint32_t> mExt2IntMorphMapping;
+ uint32_t mExt2IntMorphMappingMaxValue; // this is actually one larger than max
+
+ bool mDirty;
+ bool mMorphMappingWarning;
+
+ template <class T_Module, class T_Asset, class T_AssetAuthoring>
+ friend class nvidia::apex::ApexAuthorableObject;
+};
+
+}
+} // namespace nvidia
+
+#endif // CLOTHING_ASSET_IMPL_H
diff --git a/APEX_1.4/module/clothing/include/ClothingCollisionImpl.h b/APEX_1.4/module/clothing/include/ClothingCollisionImpl.h
new file mode 100644
index 00000000..efac0473
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ClothingCollisionImpl.h
@@ -0,0 +1,422 @@
+/*
+ * 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 CLOTHING_COLLISION_IMPL_H
+#define CLOTHING_COLLISION_IMPL_H
+
+#include "ApexResource.h"
+#include "ApexSDKHelpers.h"
+#include "ClothingCollision.h"
+#include "ApexRWLockable.h"
+
+#include "ReadCheck.h"
+#include "WriteCheck.h"
+
+namespace nvidia
+{
+namespace clothing
+{
+
+class ClothingActorImpl;
+
+
+class ClothingCollisionImpl : public ApexResource, public ApexResourceInterface, public ApexRWLockable
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ ClothingCollisionImpl(ResourceList& list, ClothingActorImpl& owner);
+
+ /* ApexResourceInterface */
+ virtual void release();
+
+ uint32_t getListIndex() const
+ {
+ return m_listIndex;
+ }
+ void setListIndex(ResourceList& list, uint32_t index)
+ {
+ m_listIndex = index;
+ m_list = &list;
+ }
+
+ void destroy();
+
+ void setId(int32_t id)
+ {
+ mId = id;
+ }
+ int32_t getId() const
+ {
+ return mId;
+ }
+
+ virtual ClothingPlane* isPlane() { READ_ZONE(); return NULL;}
+ virtual ClothingConvex* isConvex() { READ_ZONE(); return NULL;}
+ virtual ClothingSphere* isSphere() { READ_ZONE(); return NULL;}
+ virtual ClothingCapsule* isCapsule() { READ_ZONE(); return NULL;}
+ virtual ClothingTriangleMesh* isTriangleMesh() { READ_ZONE(); return NULL;}
+
+protected:
+
+ ClothingActorImpl& mOwner;
+ bool mInRelease;
+
+ int32_t mId;
+
+private:
+ ClothingCollisionImpl& operator=(const ClothingCollisionImpl&);
+};
+
+
+/************************************************************************/
+// ClothingPlaneImpl
+/************************************************************************/
+class ClothingPlaneImpl : public ClothingPlane, public ClothingCollisionImpl
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ ClothingPlaneImpl(ResourceList& list, ClothingActorImpl& owner, const PxPlane& plane) :
+ ClothingCollisionImpl(list, owner),
+ mPlane(plane),
+ mRefCount(0)
+ {
+ }
+
+ virtual ClothingCollisionType::Enum getType() const
+ {
+ READ_ZONE();
+ return ClothingCollisionType::Plane;
+ }
+ virtual ClothingPlane* isPlane() { return this; }
+ virtual ClothingConvex* isConvex() { return NULL; }
+ virtual ClothingSphere* isSphere() { return NULL; }
+ virtual ClothingCapsule* isCapsule() { return NULL; }
+ virtual ClothingTriangleMesh* isTriangleMesh() { return NULL; }
+
+ virtual void release()
+ {
+ if (mRefCount > 0)
+ {
+ APEX_DEBUG_WARNING("Cannot release ClothingPlane that is referenced by a ClothingConvex. Release convex first.");
+ return;
+ }
+
+ ClothingCollisionImpl::release();
+ }
+
+ virtual void setPlane(const PxPlane& plane);
+ virtual PxPlane& getPlane()
+ {
+ return mPlane;
+ }
+
+ void incRefCount()
+ {
+ ++mRefCount;
+ }
+ void decRefCount()
+ {
+ PX_ASSERT(mRefCount > 0);
+ --mRefCount;
+ }
+ virtual uint32_t getRefCount() const
+ {
+ return (uint32_t)mRefCount;
+ }
+
+protected:
+ PxPlane mPlane;
+
+ int32_t mRefCount;
+};
+
+
+
+/************************************************************************/
+// ClothingConvexImpl
+/************************************************************************/
+class ClothingConvexImpl : public ClothingConvex, public ClothingCollisionImpl
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ ClothingConvexImpl(ResourceList& list, ClothingActorImpl& owner, ClothingPlane** planes, uint32_t numPlanes) :
+ ClothingCollisionImpl(list, owner)
+ {
+ mPlanes.resize(numPlanes);
+ for (uint32_t i = 0; i < numPlanes; ++i)
+ {
+ mPlanes[i] = DYNAMIC_CAST(ClothingPlaneImpl*)(planes[i]);
+ mPlanes[i]->incRefCount();
+ }
+ }
+
+ virtual ClothingCollisionType::Enum getType() const
+ {
+ return ClothingCollisionType::Convex;
+ }
+ virtual ClothingPlane* isPlane() { return NULL; }
+ virtual ClothingConvex* isConvex() { return this; }
+ virtual ClothingSphere* isSphere() { return NULL; }
+ virtual ClothingCapsule* isCapsule() { return NULL; }
+ virtual ClothingTriangleMesh* isTriangleMesh() { return NULL; }
+
+ virtual void release()
+ {
+ for (uint32_t i = 0; i < mPlanes.size(); ++i)
+ {
+ mPlanes[i]->decRefCount();
+ }
+
+ ClothingCollisionImpl::release();
+ }
+
+ virtual void releaseWithPlanes()
+ {
+ for (uint32_t i = 0; i < mPlanes.size(); ++i)
+ {
+ mPlanes[i]->decRefCount();
+ mPlanes[i]->release();
+ }
+
+ ClothingCollisionImpl::release();
+ }
+
+ virtual uint32_t getNumPlanes()
+ {
+ return mPlanes.size();
+ }
+
+ virtual ClothingPlane** getPlanes()
+ {
+ return (ClothingPlane**)&mPlanes[0];
+ }
+
+protected:
+ Array<ClothingPlaneImpl*> mPlanes;
+};
+
+
+
+
+/************************************************************************/
+// ClothingSphereImpl
+/************************************************************************/
+class ClothingSphereImpl : public ClothingSphere, public ClothingCollisionImpl
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ ClothingSphereImpl(ResourceList& list, ClothingActorImpl& owner, const PxVec3& position, float radius) :
+ ClothingCollisionImpl(list, owner),
+ mPosition(position),
+ mRadius(radius),
+ mRefCount(0)
+ {
+ }
+
+ virtual ClothingCollisionType::Enum getType() const
+ {
+ return ClothingCollisionType::Sphere;
+ }
+ virtual ClothingPlane* isPlane() { return NULL; }
+ virtual ClothingConvex* isConvex() { return NULL; }
+ virtual ClothingSphere* isSphere() { return this; }
+ virtual ClothingCapsule* isCapsule() { return NULL; }
+ virtual ClothingTriangleMesh* isTriangleMesh() { return NULL; }
+
+ virtual void release()
+ {
+ if (mRefCount > 0)
+ {
+ APEX_DEBUG_WARNING("Cannot release ClothingSphere that is referenced by an ClothingCapsule. Release capsule first.");
+ return;
+ }
+
+ ClothingCollisionImpl::release();
+ }
+
+ virtual void setPosition(const PxVec3& position);
+ virtual const PxVec3& getPosition() const
+ {
+ return mPosition;
+ }
+
+ virtual void setRadius(float radius);
+ virtual float getRadius() const
+ {
+ return mRadius;
+ }
+
+ void incRefCount()
+ {
+ ++mRefCount;
+ }
+ void decRefCount()
+ {
+ PX_ASSERT(mRefCount > 0);
+ --mRefCount;
+ }
+ virtual uint32_t getRefCount() const
+ {
+ return mRefCount;
+ }
+
+protected:
+ PxVec3 mPosition;
+ float mRadius;
+
+ uint32_t mRefCount;
+};
+
+
+
+
+/************************************************************************/
+// ClothingCapsuleImpl
+/************************************************************************/
+class ClothingCapsuleImpl : public ClothingCapsule, public ClothingCollisionImpl
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ ClothingCapsuleImpl(ResourceList& list, ClothingActorImpl& owner, ClothingSphere& sphere1, ClothingSphere& sphere2) :
+ ClothingCollisionImpl(list, owner)
+ {
+ mSpheres[0] = (DYNAMIC_CAST(ClothingSphereImpl*)(&sphere1));
+ mSpheres[0]->incRefCount();
+
+ mSpheres[1] = (DYNAMIC_CAST(ClothingSphereImpl*)(&sphere2));
+ mSpheres[1]->incRefCount();
+ }
+
+ virtual ClothingCollisionType::Enum getType() const
+ {
+ return ClothingCollisionType::Capsule;
+ }
+ virtual ClothingPlane* isPlane() { return NULL; }
+ virtual ClothingConvex* isConvex() { return NULL; }
+ virtual ClothingSphere* isSphere() { return NULL; }
+ virtual ClothingCapsule* isCapsule() { return this; }
+ virtual ClothingTriangleMesh* isTriangleMesh() { return NULL; }
+
+ virtual void release()
+ {
+ mSpheres[0]->decRefCount();
+ mSpheres[1]->decRefCount();
+
+ ClothingCollisionImpl::release();
+ }
+
+ virtual void releaseWithSpheres()
+ {
+ mSpheres[0]->decRefCount();
+ mSpheres[1]->decRefCount();
+
+ mSpheres[0]->release();
+ mSpheres[1]->release();
+
+ ClothingCollisionImpl::release();
+ }
+
+ virtual ClothingSphere** getSpheres()
+ {
+ return (ClothingSphere**)mSpheres;
+ }
+
+protected:
+ ClothingSphereImpl* mSpheres[2];
+};
+
+
+
+
+/************************************************************************/
+// ClothingTriangleMeshImpl
+/************************************************************************/
+
+struct ClothingTriangle
+{
+ PxVec3 v[3];
+ uint32_t id;
+
+ bool operator<(const ClothingTriangle& other) const
+ {
+ return id < other.id;
+ }
+};
+
+class ClothingTriangleMeshImpl : public ClothingTriangleMesh, public ClothingCollisionImpl
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ ClothingTriangleMeshImpl(ResourceList& list, ClothingActorImpl& owner) :
+ ClothingCollisionImpl(list, owner),
+ mPose(PxMat44(PxIdentity))
+ {
+ }
+
+ virtual ClothingCollisionType::Enum getType() const
+ {
+ return ClothingCollisionType::TriangleMesh;
+ }
+ virtual ClothingPlane* isPlane() { return NULL; }
+ virtual ClothingConvex* isConvex() { return NULL; }
+ virtual ClothingSphere* isSphere() { return NULL; }
+ virtual ClothingCapsule* isCapsule() { return NULL; }
+ virtual ClothingTriangleMesh* isTriangleMesh() { return this; }
+
+ virtual uint32_t lockTriangles(const uint32_t** ids, const PxVec3** triangles);
+ virtual uint32_t lockTrianglesWrite(const uint32_t** ids, PxVec3** triangles);
+ virtual void unlockTriangles();
+
+ virtual void addTriangle(uint32_t id, const PxVec3& v0, const PxVec3& v1, const PxVec3& v2);
+ virtual void addTriangles(const uint32_t* ids, const PxVec3* triangleVertices, uint32_t numTriangles);
+
+ virtual void removeTriangle(uint32_t id);
+ virtual void removeTriangles(const uint32_t* ids, uint32_t numTriangles);
+ virtual void clearTriangles();
+
+ virtual void release()
+ {
+ ClothingCollisionImpl::release();
+ }
+
+ virtual void setPose(PxMat44 pose);
+ virtual const PxMat44& getPose() const
+ {
+ return mPose;
+ }
+
+ void update(const PxTransform& tm, const nvidia::Array<PxVec3>& allTrianglesOld, nvidia::Array<PxVec3>& allTrianglesOldTemp, nvidia::Array<PxVec3>& allTriangles);
+
+protected:
+ void sortAddAndRemoves();
+
+ PxMat44 mPose;
+ Array<PxVec3> mTriangles;
+ Array<uint32_t> mIds;
+
+ Array<uint32_t> mRemoved;
+ Array<ClothingTriangle> mAddedTriangles;
+
+ Mutex mLock;
+};
+
+
+}
+} // namespace nvidia
+
+
+#endif // CLOTHING_COLLISION_IMPL_H \ No newline at end of file
diff --git a/APEX_1.4/module/clothing/include/ClothingCooking.h b/APEX_1.4/module/clothing/include/ClothingCooking.h
new file mode 100644
index 00000000..9292539c
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ClothingCooking.h
@@ -0,0 +1,114 @@
+/*
+ * 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 CLOTHING_COOKING_H
+#define CLOTHING_COOKING_H
+
+#include "ApexUsingNamespace.h"
+#include "PsUserAllocated.h"
+
+#include "PxTask.h"
+
+namespace NvParameterized
+{
+class Interface;
+}
+
+
+namespace nvidia
+{
+namespace clothing
+{
+
+class ClothingScene;
+class CookingAbstract;
+
+
+class ClothingCookingLock
+{
+public:
+ ClothingCookingLock() : mNumCookingDependencies(0) {}
+ ~ClothingCookingLock()
+ {
+ PX_ASSERT(mNumCookingDependencies == 0);
+ }
+
+ int32_t numCookingDependencies()
+ {
+ return mNumCookingDependencies;
+ }
+ void lockCooking();
+ void unlockCooking();
+private:
+ int32_t mNumCookingDependencies;
+};
+
+
+
+/* These tasks contain a cooking job. They have no dependencies on each other, but the ClothingScene
+ * make sure there's only ever one of them running (per ClothingScene that is).
+ * ClothingScene::submitCookingTasks() will launch a new one only if no other cooking task is running.
+ * At ClothingScene::fetchResults() this will be checked again.
+ */
+class ClothingCookingTask : public UserAllocated, public PxLightCpuTask
+{
+public:
+ ClothingCookingTask(ClothingScene* clothingScene, CookingAbstract& job);
+ ~ClothingCookingTask();
+
+
+ CookingAbstract* job;
+ ClothingCookingTask* nextTask;
+
+ // from LightCpuTask
+ void initCooking(PxTaskManager& tm, PxBaseTask* c);
+ virtual const char* getName() const
+ {
+ return "ClothingCookingTask";
+ }
+ virtual void run();
+
+ NvParameterized::Interface* getResult();
+
+ void lockObject(ClothingCookingLock* lockedObject);
+ void unlockObject();
+
+ bool waitsForBeingScheduled()
+ {
+ return mRefCount > 0;
+ }
+ bool readyForRelease()
+ {
+ return mState == ReadyForRelease;
+ }
+ void abort();
+
+private:
+ enum State
+ {
+ Uninit,
+ WaitForRun,
+ Running,
+ Aborting,
+ WaitForFetch,
+ ReadyForRelease,
+ };
+ State mState;
+ ClothingScene* mClothingScene;
+ NvParameterized::Interface* mResult;
+ ClothingCookingLock* mLockedObject;
+};
+
+}
+} // namespace nvidia
+
+
+#endif // CLOTHING_COOKING_H
diff --git a/APEX_1.4/module/clothing/include/ClothingGlobals.h b/APEX_1.4/module/clothing/include/ClothingGlobals.h
new file mode 100644
index 00000000..1ceb8554
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ClothingGlobals.h
@@ -0,0 +1,39 @@
+/*
+ * 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 CLOTHING_GLOBALS_H
+#define CLOTHING_GLOBALS_H
+
+#include "ApexUsingNamespace.h"
+
+namespace nvidia
+{
+namespace clothing
+{
+
+
+struct ClothingConstants
+{
+ enum Enum
+ {
+ ImmediateClothingInSkinFlag = 0x80000000, // only highest (sign?) bit. The rest is the index in the clothSkinMapB
+ ImmediateClothingInvertNormal = 0x40000000, // if second highest bit is set, invert the normal from Cloth
+ ImmediateClothingBadNormal = 0x20000000, // the normal is neither correct nor inverted, just different, use mesh-mesh skinning from neighboring triangles
+ ImmediateClothingInvalidValue = 0x1fffffff, // the lowest bit is set, all others are maxed out
+ ImmediateClothingReadMask = 0x0fffffff, // read mask, use this to read the number (two flags can still be put there so far)
+ };
+};
+
+}
+} // namespace nvidia
+
+
+#endif // CLOTHING_GLOBALS_H
diff --git a/APEX_1.4/module/clothing/include/ClothingPhysicalMeshImpl.h b/APEX_1.4/module/clothing/include/ClothingPhysicalMeshImpl.h
new file mode 100644
index 00000000..c78f8ede
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ClothingPhysicalMeshImpl.h
@@ -0,0 +1,207 @@
+/*
+ * 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 CLOTHING_PHYSICAL_MESH_IMPL_H
+#define CLOTHING_PHYSICAL_MESH_IMPL_H
+
+#include "ClothingPhysicalMesh.h"
+#include "PsUserAllocated.h"
+#include "ApexResource.h"
+#include "PsArray.h"
+#include "ParamArray.h"
+#include "ClothingPhysicalMeshParameters.h"
+#include "ModuleClothingImpl.h"
+#include "ApexRWLockable.h"
+#include "nvparameterized/NvParameterized.h"
+#include "ReadCheck.h"
+
+namespace nvidia
+{
+namespace apex
+{
+class ApexQuadricSimplifier;
+}
+namespace clothing
+{
+class ModuleClothingImpl;
+
+
+class ClothingPhysicalMeshImpl : public ClothingPhysicalMesh, public ApexResourceInterface, public ApexResource, public NvParameterized::SerializationCallback, public ApexRWLockable
+{
+private:
+ ClothingPhysicalMeshImpl(ModuleClothingImpl* module, ClothingPhysicalMeshParameters* params, ResourceList* list);
+ friend class ModuleClothingImpl;
+
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ virtual void release();
+ void destroy();
+
+ virtual uint32_t getNumVertices() const;
+ virtual uint32_t getNumSimulatedVertices() const;
+ virtual uint32_t getNumMaxDistance0Vertices() const;
+
+ virtual uint32_t getNumIndices() const;
+ virtual uint32_t getNumSimulatedIndices() const;
+
+ virtual uint32_t getNumBonesPerVertex() const
+ {
+ READ_ZONE();
+ return mParams->physicalMesh.numBonesPerVertex;
+ }
+
+ virtual void getIndices(void* indexDestination, uint32_t byteStride, uint32_t numIndices) const;
+
+ virtual bool isTetrahedralMesh() const
+ {
+ READ_ZONE();
+ return mParams->physicalMesh.isTetrahedralMesh;
+ }
+
+ virtual void simplify(uint32_t subdivisions, int32_t maxSteps, float maxError, IProgressListener* progress);
+
+ // user overwrites geometry
+ virtual void setGeometry(bool tetraMesh, uint32_t numVertices, uint32_t vertexByteStride, const void* vertices, const uint32_t* masterFlags,
+ uint32_t numIndices, uint32_t indexByteStride, const void* indices);
+
+ // direct access to specific buffers
+ virtual bool getIndices(uint32_t* indices, uint32_t byteStride) const;
+ virtual bool getVertices(PxVec3* vertices, uint32_t byteStride) const ;
+ virtual bool getNormals(PxVec3* vertices, uint32_t byteStride) const ;
+ virtual bool getBoneIndices(uint16_t* boneIndices, uint32_t byteStride) const;
+ virtual bool getBoneWeights(float* boneWeights, uint32_t byteStride) const;
+ virtual bool getConstrainCoefficients(ClothingConstrainCoefficients* values, uint32_t byteStride) const;
+ virtual void getStats(ClothingPhysicalMeshStats& stats) const;
+
+ virtual void allocateMasterFlagsBuffer();
+ virtual void allocateConstrainCoefficientBuffer();
+ virtual ClothingConstrainCoefficients* getConstrainCoefficientBuffer() const
+ {
+ READ_ZONE();
+ PX_COMPILE_TIME_ASSERT(sizeof(ClothingConstrainCoefficients) == sizeof(ClothingPhysicalMeshParametersNS::ConstrainCoefficient_Type));
+ return (ClothingConstrainCoefficients*)mParams->physicalMesh.constrainCoefficients.buf;
+ }
+
+ // from NvParameterized::SerializationCallback
+ void preSerialize(void* userData_ = NULL);
+
+ void permuteBoneIndices(Array<int32_t>& old2newBoneIndices);
+ void applyTransformation(const PxMat44& transformation, float scale);
+ void applyPermutation(const Array<uint32_t>& permutation);
+
+ void makeCopy(ClothingPhysicalMeshParameters* params);
+ void allocateNormalBuffer();
+ void allocateSkinningNormalsBuffer();
+ void allocateBoneIndexAndWeightBuffers();
+ void freeAdditionalBuffers();
+ PX_INLINE void setNumBonesPerVertex(uint32_t numBonesPerVertex)
+ {
+ mParams->physicalMesh.numBonesPerVertex = numBonesPerVertex;
+ }
+
+ PX_INLINE uint16_t* getBoneIndicesBuffer()
+ {
+ return mParams->physicalMesh.boneIndices.buf;
+ }
+ PX_INLINE float* getBoneWeightsBuffer()
+ {
+ return mParams->physicalMesh.boneWeights.buf;
+ }
+ PX_INLINE PxVec3* getPositionBuffer()
+ {
+ return mParams->physicalMesh.vertices.buf;
+ }
+ PX_INLINE PxVec3* getNormalBuffer()
+ {
+ return mParams->physicalMesh.normals.buf;
+ }
+ PX_INLINE PxVec3* getSkinningNormalBuffer()
+ {
+ return mParams->physicalMesh.skinningNormals.buf;
+ }
+ PX_INLINE uint32_t* getMasterFlagsBuffer()
+ {
+ return mMasterFlags.begin();
+ }
+
+ PX_INLINE uint32_t* getIndicesBuffer()
+ {
+ return mParams->physicalMesh.indices.buf;
+ }
+
+ PX_INLINE float getMaxMaxDistance()
+ {
+ return mParams->physicalMesh.maximumMaxDistance;
+ }
+ void updateMaxMaxDistance();
+
+ void addBoneToVertex(uint32_t vertexNumber, uint16_t boneIndex, float boneWeight);
+ void sortBonesOfVertex(uint32_t vertexNumber);
+ void normalizeBonesOfVertex(uint32_t vertexNumber);
+
+ void updateSkinningNormals();
+ void smoothNormals(uint32_t numIterations);
+
+ void updateOptimizationData();
+
+ ClothingPhysicalMeshParameters* getNvParameterized() const
+ {
+ return mParams;
+ }
+
+ // from ApexResource
+ uint32_t getListIndex() const
+ {
+ return m_listIndex;
+ }
+ void setListIndex(class ResourceList& list, uint32_t index)
+ {
+ m_list = &list;
+ m_listIndex = index;
+ }
+
+private:
+ void writeBackData();
+ void clearMiscBuffers();
+ void computeEdgeLengths() const;
+
+ bool removeDuplicatedTriangles(uint32_t numIndices, uint32_t indexByteStride, const void* indices);
+ void computeNeighborInformation(Array<int32_t> &neighbors);
+ void fixTriangleOrientations();
+
+ ModuleClothingImpl* mModule;
+
+ ClothingPhysicalMeshParameters* mParams;
+ bool ownsParams;
+
+ ParamArray<PxVec3> mVertices;
+ ParamArray<PxVec3> mNormals;
+ ParamArray<PxVec3> mSkinningNormals;
+ ParamArray<ClothingPhysicalMeshParametersNS::ConstrainCoefficient_Type> mConstrainCoefficients;
+ ParamArray<uint16_t> mBoneIndices;
+ ParamArray<float> mBoneWeights;
+ ParamArray<uint32_t> mIndices;
+
+ uint32_t mNumSimulatedVertices;
+ uint32_t mNumMaxDistanc0Vertices;
+ uint32_t mNumSimulatedIndices;
+
+ Array<uint32_t> mMasterFlags;
+
+ ApexQuadricSimplifier* mSimplifier;
+ bool isDirty;
+};
+
+}
+} // namespace nvidia
+
+#endif // CLOTHING_PHYSICAL_MESH_IMPL_H
diff --git a/APEX_1.4/module/clothing/include/ClothingPreviewProxy.h b/APEX_1.4/module/clothing/include/ClothingPreviewProxy.h
new file mode 100644
index 00000000..39ffedee
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ClothingPreviewProxy.h
@@ -0,0 +1,122 @@
+/*
+ * 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 CLOTHING_PREVIEW_PROXY_H
+#define CLOTHING_PREVIEW_PROXY_H
+
+#include "ClothingPreview.h"
+#include "ClothingActorImpl.h"
+#include "Renderable.h"
+#include "ApexRWLockable.h"
+#include "WriteCheck.h"
+#include "ReadCheck.h"
+
+namespace nvidia
+{
+namespace clothing
+{
+
+class ClothingPreviewProxy : public ClothingPreview, public UserAllocated, public ApexResourceInterface, public ApexRWLockable
+{
+ ClothingActorImpl impl;
+
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+#pragma warning( disable : 4355 ) // disable warning about this pointer in argument list
+ ClothingPreviewProxy(const NvParameterized::Interface& desc, ClothingAssetImpl* asset, ResourceList* list) :
+ impl(desc, NULL, this, asset, NULL)
+ {
+ list->add(*this);
+ }
+
+ virtual void release()
+ {
+ impl.release();
+ }
+
+ virtual uint32_t getListIndex() const
+ {
+ return impl.m_listIndex;
+ }
+
+ virtual void setListIndex(class ResourceList& list, uint32_t index)
+ {
+ impl.m_list = &list;
+ impl.m_listIndex = index;
+ }
+
+ virtual void setPose(const PxMat44& pose)
+ {
+ WRITE_ZONE();
+ impl.updateState(pose, NULL, 0, 0, ClothingTeleportMode::Continuous);
+ }
+
+ virtual const PxMat44 getPose() const
+ {
+ READ_ZONE();
+ return impl.getGlobalPose();
+ }
+
+ virtual void lockRenderResources()
+ {
+ impl.lockRenderResources();
+ }
+
+ virtual void unlockRenderResources()
+ {
+ impl.unlockRenderResources();
+ }
+
+ virtual void updateRenderResources(bool rewriteBuffers = false, void* userRenderData = 0)
+ {
+ Renderable* renderable = impl.getRenderable();
+ if (renderable != NULL)
+ {
+ renderable->updateRenderResources(rewriteBuffers, userRenderData);
+ }
+ }
+
+ virtual void dispatchRenderResources(UserRenderer& renderer)
+ {
+ WRITE_ZONE();
+ Renderable* renderable = impl.getRenderable();
+ if (renderable != NULL)
+ {
+ renderable->dispatchRenderResources(renderer);
+ }
+ }
+
+ virtual PxBounds3 getBounds() const
+ {
+ READ_ZONE();
+ return impl.getBounds();
+ }
+
+
+ virtual void updateState(const PxMat44& globalPose, const PxMat44* newBoneMatrices, uint32_t boneMatricesByteStride, uint32_t numBoneMatrices)
+ {
+ WRITE_ZONE();
+ impl.updateState(globalPose, newBoneMatrices, boneMatricesByteStride, numBoneMatrices, ClothingTeleportMode::Continuous);
+ }
+
+ void destroy()
+ {
+ impl.destroy();
+ delete this;
+ }
+
+ virtual ~ClothingPreviewProxy() {}
+};
+
+}
+} // namespace nvidia
+
+#endif // CLOTHING_PREVIEW_PROXY_H
diff --git a/APEX_1.4/module/clothing/include/ClothingRenderProxyImpl.h b/APEX_1.4/module/clothing/include/ClothingRenderProxyImpl.h
new file mode 100644
index 00000000..f5a42833
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ClothingRenderProxyImpl.h
@@ -0,0 +1,123 @@
+/*
+ * 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 CLOTHING_RENDER_PROXY_IMPL_H
+#define CLOTHING_RENDER_PROXY_IMPL_H
+
+#include "ClothingRenderProxy.h"
+#include "PxMat44.h"
+#include "PxBounds3.h"
+#include "PsHashMap.h"
+#include "ApexString.h"
+#include "ApexRWLockable.h"
+
+namespace nvidia
+{
+namespace apex
+{
+class RenderMeshActorIntl;
+class RenderMeshAssetIntl;
+}
+namespace clothing
+{
+class ClothingActorParam;
+class ClothingScene;
+
+
+class ClothingRenderProxyImpl : public ClothingRenderProxy, public UserAllocated, public ApexRWLockable
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ ClothingRenderProxyImpl(RenderMeshAssetIntl* rma, bool useFallbackSkinning, bool useCustomVertexBuffer, const nvidia::HashMap<uint32_t, ApexSimpleString>& overrideMaterials, const PxVec3* morphTargetNewPositions, const uint32_t* morphTargetVertexOffsets, ClothingScene* scene);
+ virtual ~ClothingRenderProxyImpl();
+
+ // from ApexInterface
+ virtual void release();
+
+ // from Renderable
+ virtual void dispatchRenderResources(UserRenderer& api);
+ virtual PxBounds3 getBounds() const
+ {
+ return mBounds;
+ }
+ void setBounds(const PxBounds3& bounds)
+ {
+ mBounds = bounds;
+ }
+
+ // from RenderDataProvider.h
+ virtual void lockRenderResources();
+ virtual void unlockRenderResources();
+ virtual void updateRenderResources(bool rewriteBuffers = false, void* userRenderData = 0);
+
+ void setPose(const PxMat44& pose)
+ {
+ mPose = pose;
+ }
+
+ // from ClothingRenderProxy.h
+ virtual bool hasSimulatedData() const;
+
+ RenderMeshActorIntl* getRenderMeshActor();
+ RenderMeshAssetIntl* getRenderMeshAsset();
+
+ bool usesFallbackSkinning() const
+ {
+ return mUseFallbackSkinning;
+ }
+
+ bool usesCustomVertexBuffer() const
+ {
+ return renderingDataPosition != NULL;
+ }
+
+ const PxVec3* getMorphTargetBuffer() const
+ {
+ return mMorphTargetNewPositions;
+ }
+
+ void setOverrideMaterial(uint32_t i, const char* overrideMaterialName);
+ bool overrideMaterialsEqual(const nvidia::HashMap<uint32_t, ApexSimpleString>& overrideMaterials);
+
+ uint32_t getTimeInPool() const;
+ void setTimeInPool(uint32_t time);
+
+ void notifyAssetRelease();
+
+ PxVec3* renderingDataPosition;
+ PxVec3* renderingDataNormal;
+ PxVec4* renderingDataTangent;
+
+private:
+ RenderMeshActorIntl* createRenderMeshActor(RenderMeshAssetIntl* renderMeshAsset, ClothingActorParam* actorDesc);
+
+ PxBounds3 mBounds;
+ PxMat44 mPose;
+
+ RenderMeshActorIntl* mRenderMeshActor;
+ RenderMeshAssetIntl* mRenderMeshAsset;
+
+ ClothingScene* mScene;
+
+ bool mUseFallbackSkinning;
+ HashMap<uint32_t, ApexSimpleString> mOverrideMaterials;
+ const PxVec3* mMorphTargetNewPositions; // just to compare, only read it in constructor (it may be released)
+
+ uint32_t mTimeInPool;
+
+ Mutex mRMALock;
+};
+
+}
+} // namespace nvidia
+
+#endif // CLOTHING_RENDER_PROXY_IMPL_H
diff --git a/APEX_1.4/module/clothing/include/ClothingScene.h b/APEX_1.4/module/clothing/include/ClothingScene.h
new file mode 100644
index 00000000..0e194358
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ClothingScene.h
@@ -0,0 +1,233 @@
+/*
+ * 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 CLOTHING_SCENE_H
+#define CLOTHING_SCENE_H
+
+#include "ApexContext.h"
+#include "ModuleIntl.h"
+#include "ApexResource.h"
+
+#include "ClothStructs.h"
+
+#include "PsSync.h"
+#include "PxTask.h"
+#include "PsTime.h"
+
+#if APEX_UE4
+#define CLOTHING_BEFORE_TICK_START_TASK_NAME "ClothingScene::ClothingBeforeTickStartTask"
+#endif
+
+#if APEX_CUDA_SUPPORT
+namespace nvidia
+{
+class PhysXGpuIndicator;
+}
+#endif
+
+namespace nvidia
+{
+
+namespace cloth
+{
+class Cloth;
+class Factory;
+class Solver;
+}
+
+
+namespace apex
+{
+class DebugRenderParams;
+class RenderMeshAssetIntl;
+class ApexSimpleString;
+}
+
+namespace clothing
+{
+class ModuleClothingImpl;
+class ClothingAssetImpl;
+class ClothingCookingTask;
+class ClothingDebugRenderParams;
+
+class ClothingRenderProxyImpl;
+
+
+class ClothingScene : public ModuleSceneIntl, public ApexContext, public ApexResourceInterface, public ApexResource
+{
+public:
+ ClothingScene(ModuleClothingImpl& module, SceneIntl& scene, RenderDebugInterface* renderDebug, ResourceList& list);
+ ~ClothingScene();
+
+ /* ModuleSceneIntl */
+ virtual void simulate(float elapsedTime);
+ virtual bool needsManualSubstepping() const;
+ virtual void interStep(uint32_t substepNumber, uint32_t maxSubSteps);
+ virtual void submitTasks(float elapsedTime, float substepSize, uint32_t numSubSteps);
+ virtual void setTaskDependencies();
+ virtual void fetchResults();
+
+#if PX_PHYSICS_VERSION_MAJOR == 3
+ void setModulePhysXScene(PxScene*);
+ PxScene* getModulePhysXScene() const
+ {
+ return mPhysXScene;
+ }
+#endif
+
+ void release();
+ void visualize();
+
+ virtual Module* getModule();
+
+ 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;
+ }
+
+ bool isSimulating() const;
+
+ void registerAsset(ClothingAssetImpl* asset);
+ void unregisterAsset(ClothingAssetImpl* asset);
+ void removeRenderProxies(ClothingAssetImpl* asset);
+
+ uint32_t submitCookingTask(ClothingCookingTask* newTask);
+
+ float getAverageSimulationFrequency()
+ {
+ return mAverageSimulationFrequency;
+ }
+
+ SceneIntl* getApexScene()
+ {
+ return mApexScene;
+ }
+
+ const ClothingDebugRenderParams* getDebugRenderParams() const
+ {
+ return mClothingDebugRenderParams;
+ }
+
+ ClothFactory getClothFactory(bool& useCuda);
+ cloth::Solver* getClothSolver(bool useCuda);
+
+ void lockScene();
+ void unlockScene();
+
+ void setSceneRunning(bool on);
+
+ void embeddedPostSim();
+
+ // render proxy pool
+ ClothingRenderProxyImpl* getRenderProxy(RenderMeshAssetIntl* rma, bool useFallbackSkinning, bool useCustomVertexBuffer, const HashMap<uint32_t, ApexSimpleString>& overrideMaterials, const PxVec3* morphTargetNewPositions, const uint32_t* morphTargetVertexOffsets);
+ void tickRenderProxies();
+
+protected:
+
+ ModuleClothingImpl* mModule;
+ SceneIntl* mApexScene;
+#if PX_PHYSICS_VERSION_MAJOR == 3
+ PxScene* mPhysXScene;
+#endif
+
+ Array<ClothingAssetImpl*> mClothingAssets;
+ nvidia::Mutex mClothingAssetsMutex;
+
+ float mSumBenefit;
+
+ void destroy();
+
+ class ClothingBeforeTickStartTask : public PxTask
+ {
+ public:
+ ClothingBeforeTickStartTask() : m_pScene(NULL)
+ {
+ }
+
+ void setScene(ClothingScene* pScene)
+ {
+ m_pScene = pScene;
+ }
+
+ virtual void run();
+ virtual const char* getName() const;
+
+ ClothingScene* m_pScene;
+ } mClothingBeforeTickStartTask;
+
+private:
+
+ class WaitForSolverTask* mWaitForSolverTask;
+ class ClothingSceneSimulateTask* mSimulationTask;
+ nvidia::Mutex mSceneLock;
+ int32_t mSceneRunning;
+
+ RenderDebugInterface* mRenderDebug;
+
+ DebugRenderParams* mDebugRenderParams;
+ ClothingDebugRenderParams* mClothingDebugRenderParams;
+
+ ClothingCookingTask* mCurrentCookingTask;
+ nvidia::Mutex mCookingTaskMutex;
+
+ Array<float> mLastSimulationDeltas;
+ uint32_t mCurrentSimulationDelta;
+ float mAverageSimulationFrequency;
+
+#ifndef _DEBUG
+ // For statistics
+ uint32_t mFramesCount;
+ float mSimulatedTime;
+ float mTimestep;
+#endif
+
+ nvidia::Time mClothingSimulationTime;
+
+ ClothFactory mCpuFactory;
+#if APEX_CUDA_SUPPORT
+ ClothFactory mGpuFactory;
+ PhysXGpuIndicator* mPhysXGpuIndicator;
+#endif
+
+ Mutex mRenderProxiesLock;
+ nvidia::HashMap<RenderMeshAssetIntl*, nvidia::Array<ClothingRenderProxyImpl*> > mRenderProxies;
+
+ friend class ModuleClothingImpl;
+ friend class ClothingActorImpl;
+};
+
+}
+} // namespace nvidia
+
+#endif // CLOTHING_SCENE_H
diff --git a/APEX_1.4/module/clothing/include/Cooking.h b/APEX_1.4/module/clothing/include/Cooking.h
new file mode 100644
index 00000000..c8f3e8a4
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/Cooking.h
@@ -0,0 +1,167 @@
+/*
+ * 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 COOKING_H
+#define COOKING_H
+
+#include "CookingAbstract.h"
+
+#include <PxVec3.h>
+#include <PsArray.h>
+
+// Tae - 301 -> 302: fiberless cooker change
+#define COOKED_DATA_VERSION 302
+
+namespace nvidia
+{
+namespace clothing
+{
+
+class ClothingCookedPhysX3Param;
+
+class Cooking : public CookingAbstract
+{
+public:
+ Cooking(bool withFibers) : mWithFibers(withFibers) {}
+
+ virtual NvParameterized::Interface* execute();
+ static uint32_t getCookingVersion()
+ {
+ return COOKED_DATA_VERSION;
+ }
+
+private:
+ ClothingCookedPhysX3Param* trivialCooker(uint32_t subMeshIndex) const;
+ ClothingCookedPhysX3Param* fiberCooker(uint32_t subMeshIndex) const;
+
+ void computeUniqueEdges(uint32_t subMeshIndex);
+ void refineUniqueEdges(uint32_t physicalMeshIndex);
+ void computeVertexWeights(ClothingCookedPhysX3Param* cookedData, uint32_t subMeshIndex) const;
+ void createVirtualParticles(ClothingCookedPhysX3Param* cookedData, uint32_t subMeshIndex);
+ void createSelfcollisionIndices(ClothingCookedPhysX3Param* cookedData, uint32_t subMeshIndex) const;
+ bool verifyValidity(const ClothingCookedPhysX3Param* cookedData, uint32_t subMeshIndex);
+ void fillOutSetsDesc(ClothingCookedPhysX3Param* cookedData);
+ void groupPhases(ClothingCookedPhysX3Param* cookedData, uint32_t subMeshIndex, uint32_t startIndex, uint32_t endIndex, Array<uint32_t>& phaseEnds) const;
+
+ void dumpObj(const char* filename, uint32_t subMeshIndex) const;
+ void dumpApx(const char* filename, const NvParameterized::Interface* data) const;
+
+ bool mWithFibers;
+
+ static bool mTetraWarning;
+
+ struct Edge
+ {
+ Edge();
+ Edge(uint32_t v0, uint32_t v1, uint32_t v2);
+
+ uint32_t vertex0, vertex1;
+ uint32_t vertex2, vertex3;
+ float maxAngle;
+ bool isQuadDiagonal;
+ bool isUsed;
+
+ PX_FORCE_INLINE bool operator()(const Edge& e1, const Edge& e2) const
+ {
+ return e1 < e2;
+ }
+
+ PX_FORCE_INLINE bool operator!=(const Edge& other) const
+ {
+ return vertex0 != other.vertex0 || vertex1 != other.vertex1;
+ }
+ PX_FORCE_INLINE bool operator==(const Edge& other) const
+ {
+ return vertex0 == other.vertex0 && vertex1 == other.vertex1;
+ }
+ PX_FORCE_INLINE bool operator<(const Edge& other) const
+ {
+ if (vertex0 != other.vertex0)
+ {
+ return vertex0 < other.vertex0;
+ }
+
+ return vertex1 < other.vertex1;
+ }
+
+ PX_FORCE_INLINE uint32_t largestIndex() const
+ {
+ uint32_t largest = PxMax(vertex0, vertex1);
+ largest = PxMax(largest, vertex2);
+ if (vertex3 != 0xffffffff)
+ {
+ largest = PxMax(largest, vertex3);
+ }
+ return largest;
+ }
+ };
+
+ struct SortHiddenEdges
+ {
+ SortHiddenEdges(nvidia::Array<Edge>& uniqueEdges) : mUniqueEdges(uniqueEdges) {}
+
+ bool operator()(uint32_t a, uint32_t b) const
+ {
+ return mUniqueEdges[a].maxAngle < mUniqueEdges[b].maxAngle;
+ }
+
+ private:
+ SortHiddenEdges& operator=(const SortHiddenEdges&);
+
+ nvidia::Array<Edge>& mUniqueEdges;
+ };
+
+ nvidia::Array<Edge> mUniqueEdges;
+ uint32_t findUniqueEdge(uint32_t index1, uint32_t index2) const;
+
+ struct VirtualParticle
+ {
+ VirtualParticle(uint32_t i0, uint32_t i1, uint32_t i2)
+ {
+ indices[0] = i0;
+ indices[1] = i1;
+ indices[2] = i2;
+ tableIndex = 0;
+ }
+
+ void rotate(uint32_t count)
+ {
+ while (count--)
+ {
+ const uint32_t temp = indices[2];
+ indices[2] = indices[1];
+ indices[1] = indices[0];
+ indices[0] = temp;
+ }
+ }
+
+ uint32_t indices[3];
+ uint32_t tableIndex;
+ };
+
+ struct EdgeAndLength
+ {
+ EdgeAndLength(uint32_t edgeNumber, float length) : mEdgeNumber(edgeNumber), mLength(length) {}
+ uint32_t mEdgeNumber;
+ float mLength;
+
+ bool operator<(const EdgeAndLength& other) const
+ {
+ return mLength < other.mLength;
+ }
+ };
+};
+
+}
+}
+
+
+#endif // COOKING_H
diff --git a/APEX_1.4/module/clothing/include/CookingAbstract.h b/APEX_1.4/module/clothing/include/CookingAbstract.h
new file mode 100644
index 00000000..992d7a78
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/CookingAbstract.h
@@ -0,0 +1,134 @@
+/*
+ * 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 COOKING_ABSTRACT_H
+#define COOKING_ABSTRACT_H
+
+#include "PsUserAllocated.h"
+#include "PxVec3.h"
+#include "PsArray.h"
+#include "ApexUsingNamespace.h"
+
+namespace NvParameterized
+{
+class Interface;
+}
+
+namespace nvidia
+{
+namespace clothing
+{
+
+namespace ClothingAssetParametersNS
+{
+struct BoneEntry_Type;
+struct ActorEntry_Type;
+}
+
+typedef ClothingAssetParametersNS::BoneEntry_Type BoneEntry;
+typedef ClothingAssetParametersNS::ActorEntry_Type BoneActorEntry;
+
+using namespace physx::shdfnd;
+
+class CookingAbstract : public nvidia::UserAllocated
+{
+public:
+ CookingAbstract() : mBoneActors(NULL), mNumBoneActors(0), mBoneEntries(NULL), mNumBoneEntries(0), mBoneVertices(NULL), mMaxConvexVertices(256),
+ mFreeTempMemoryWhenDone(NULL), mScale(1.0f), mVirtualParticleDensity(0.0f), mSelfcollisionRadius(0.0f)
+ {
+ }
+
+ virtual ~CookingAbstract()
+ {
+ if (mFreeTempMemoryWhenDone != NULL)
+ {
+ PX_FREE(mFreeTempMemoryWhenDone);
+ mFreeTempMemoryWhenDone = NULL;
+ }
+ }
+
+ struct PhysicalMesh
+ {
+ PhysicalMesh() : meshID(0), isTetrahedral(false), vertices(NULL), numVertices(0), numSimulatedVertices(0), numMaxDistance0Vertices(0),
+ indices(NULL), numIndices(0), numSimulatedIndices(0), largestTriangleArea(0.0f), smallestTriangleArea(0.0f) {}
+
+ uint32_t meshID;
+ bool isTetrahedral;
+
+ PxVec3* vertices;
+ uint32_t numVertices;
+ uint32_t numSimulatedVertices;
+ uint32_t numMaxDistance0Vertices;
+
+ uint32_t* indices;
+ uint32_t numIndices;
+ uint32_t numSimulatedIndices;
+
+ void computeTriangleAreas();
+ float largestTriangleArea;
+ float smallestTriangleArea;
+ };
+
+ void addPhysicalMesh(const PhysicalMesh& physicalMesh);
+ void setConvexBones(const BoneActorEntry* boneActors, uint32_t numBoneActors, const BoneEntry* boneEntries, uint32_t numBoneEntries, const PxVec3* boneVertices, uint32_t maxConvexVertices);
+
+ void freeTempMemoryWhenDone(void* memory)
+ {
+ mFreeTempMemoryWhenDone = memory;
+ }
+ void setScale(float scale)
+ {
+ mScale = scale;
+ }
+ void setVirtualParticleDensity(float density)
+ {
+ PX_ASSERT(density >= 0.0f);
+ PX_ASSERT(density <= 1.0f);
+ mVirtualParticleDensity = density;
+ }
+ void setSelfcollisionRadius(float radius)
+ {
+ PX_ASSERT(radius >= 0.0f);
+ mSelfcollisionRadius = radius;
+ }
+ void setGravityDirection(const PxVec3& gravityDir)
+ {
+ mGravityDirection = gravityDir;
+ mGravityDirection.normalize();
+ }
+
+ virtual NvParameterized::Interface* execute() = 0;
+
+ bool isValid() const;
+
+protected:
+ Array<PhysicalMesh> mPhysicalMeshes;
+
+ const BoneActorEntry* mBoneActors;
+ uint32_t mNumBoneActors;
+ const BoneEntry* mBoneEntries;
+ uint32_t mNumBoneEntries;
+ const PxVec3* mBoneVertices;
+ uint32_t mMaxConvexVertices;
+
+ void* mFreeTempMemoryWhenDone;
+ float mScale;
+
+ float mVirtualParticleDensity;
+ float mSelfcollisionRadius;
+
+ PxVec3 mGravityDirection;
+};
+
+}
+} // namespace nvidia
+
+#endif // COOKING_ABSTRACT_H
diff --git a/APEX_1.4/module/clothing/include/CookingPhysX.h b/APEX_1.4/module/clothing/include/CookingPhysX.h
new file mode 100644
index 00000000..60ff9aaa
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/CookingPhysX.h
@@ -0,0 +1,50 @@
+/*
+ * 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 COOKING_PHYS_X_H
+#define COOKING_PHYS_X_H
+
+#include "CookingAbstract.h"
+
+namespace nvidia
+{
+namespace apex
+{
+template<class T>
+class ParamArray;
+}
+namespace clothing
+{
+
+
+class CookingPhysX : public CookingAbstract
+{
+public:
+
+ virtual NvParameterized::Interface* execute() { return 0;}
+
+ static uint32_t getCookingVersion()
+ {
+#if PX_PHYSICS_VERSION_MAJOR == 3
+ return PX_PHYSICS_VERSION;
+#else
+ return 0;
+#endif
+ }
+
+protected:
+};
+
+}
+} // namespace nvidia
+
+
+#endif // COOKING_PHYS_X_H
diff --git a/APEX_1.4/module/clothing/include/ModuleClothingHelpers.h b/APEX_1.4/module/clothing/include/ModuleClothingHelpers.h
new file mode 100644
index 00000000..f2f43c1c
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ModuleClothingHelpers.h
@@ -0,0 +1,461 @@
+/*
+ * 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_CLOTHING_HELPERS_H
+#define MODULE_CLOTHING_HELPERS_H
+
+#include "RenderMeshAssetIntl.h"
+#include "RenderDebugInterface.h"
+#include "PsUserAllocated.h"
+#include "ApexSharedUtils.h"
+
+namespace nvidia
+{
+namespace clothing
+{
+
+class ClothingCookedParam;
+
+// used for mesh skinning map creation
+struct TriangleWithNormals
+{
+ void init()
+ {
+ // bestDot and worstDot store the difference of the vertex normals from the face normal
+ PxVec3 faceNormal = (vertices[1] - vertices[0]).cross(vertices[2] - vertices[0]);
+ faceNormal.normalize();
+ float bestDot = -1.0f;
+ float worstDot = 1.0f;
+ for (uint32_t j = 0; j < 3; j++)
+ {
+ const float dot = faceNormal.dot(normals[j]);
+ bestDot = PxMax(bestDot, dot);
+ worstDot = PxMin(worstDot, dot);
+ }
+
+ doNotUse = worstDot < 0.0f || bestDot < 0.5f; // bestDot has more than 60 degrees difference from faceNormal
+
+ // init the rest of the triangle members
+ timestamp = -1;
+ valid = 0;
+
+ bounds.minimum = bounds.maximum = vertices[0];
+ bounds.include(vertices[1]);
+ bounds.include(vertices[2]);
+ PX_ASSERT(!bounds.isEmpty());
+ }
+
+ PxVec3 vertices[3];
+ PxVec3 normals[3];
+ uint32_t faceIndex0;
+ int32_t timestamp : 30;
+ uint32_t valid : 2;
+
+ PxBounds3 bounds;
+
+ PxVec3 tempBaryVertex;
+ PxVec3 tempBaryNormal;
+ PxVec3 tempBaryTangent;
+
+ uint32_t master;
+
+ bool doNotUse;
+};
+
+
+
+class ModuleClothingHelpers
+{
+public:
+ /**
+ \brief A fast inverse square root. Mainly used to normalize vectors more quickly (and less accurately)
+ */
+ inline static float invSqrt(float input)
+ {
+ const float halfInput = 0.5f * input;
+ int32_t i = *(int*)&input;
+
+ i = 0x5f375a86 - (i >> 1);
+ input = *(float*) & i;
+ input = input * (1.5f - halfInput * input * input);
+ return input;
+ }
+
+
+ static float triangleArea(const PxVec3& v1, const PxVec3& v2, const PxVec3& v3)
+ {
+ const PxVec3 a = v2 - v1;
+ const PxVec3 b = v3 - v1;
+ const PxVec3 c = a.cross(b);
+ //PxVec3 normal = c;
+ //normal.normalize();
+ //const float area = normal.dot(c) * 0.5f;
+ //return area;
+ return c.magnitude() * 0.5f;
+ }
+
+#pragma warning(push)
+#pragma warning(disable:4127) // (conditional expression is constant)
+ template<bool method1>
+ static PxVec3 computeTriBarycentricCoords(const PxVec3& a, const PxVec3& b, const PxVec3& c, const PxVec3& g)
+ {
+ PxVec3 bary(0, 0, 0);
+ if (method1)
+ {
+ const float abc = triangleArea(a, b, c);
+
+ // Convert our position from local space into barycentric coordinates + offset from surface.
+ if (abc > 0.0f)
+ {
+ PxVec3 Edge0 = b - a;
+ PxVec3 Edge1 = c - a;
+
+ PxVec3 planeNormal = Edge0.cross(Edge1);
+ planeNormal.normalize();
+
+ // See comments in set() for computation of d
+ float planeD = -a.dot(planeNormal);
+
+ // Valid for plane equation a*x + b*y + c*z + d = 0
+ const float distance = g.dot(planeNormal) + planeD;
+
+ // project on plane
+ const PxVec3 p = g - planeNormal * distance;
+
+ bary.x = triangleArea(p, b, c) / abc;
+ bary.y = triangleArea(p, c, a) / abc;
+ bary.z = distance;
+ }
+ }
+ else
+ {
+ // triangle's normal
+ PxVec3 faceNormal = (b - a).cross(c - a);
+ faceNormal.normalize();
+
+ // distance to plane
+ float h = (g - a).dot(faceNormal);
+
+ // project g onto plane
+ PxVec3 pg = g - (h * faceNormal);
+
+ // compute barycentric coordinates of g in <a,b,c>
+ float s(0), t(0);
+ generateBarycentricCoordinatesTri(a, b, c, pg, s, t);
+
+ // PH: s and t are not the barycentric coordinate of a and b, but of b and c
+ bary.x = 1 - s - t;
+ bary.y = s;
+ bary.z = h;
+ }
+ return bary;
+ }
+#pragma warning(pop)
+
+ static float TetraVolume(const PxVec3& p0, const PxVec3& p1, const PxVec3& p2, const PxVec3& p3)
+ {
+ return (p1 - p0).cross(p2 - p0).dot(p3 - p0) * (1.0f / 6.0f);
+ }
+
+
+
+ static PxVec3 computeTetraBarycentricCoords(const PxVec3& p0, const PxVec3& p1, const PxVec3& p2, const PxVec3& p3, const PxVec3& p)
+ {
+ float tetraVol = TetraVolume(p0, p1, p2, p3);
+ PX_ASSERT(tetraVol != 0.0f);
+ PxVec3 bary;
+ bary.x = TetraVolume(p, p1, p2, p3) / tetraVol;
+ bary.y = TetraVolume(p, p2, p0, p3) / tetraVol;
+ bary.z = TetraVolume(p, p3, p0, p1) / tetraVol;
+ /*
+ bary.x = PxAbs(bary.x);
+ bary.y = PxAbs(bary.y);
+ bary.z = PxAbs(bary.z);
+ */
+
+ return bary;
+ }
+
+
+
+ static float barycentricDist(const PxVec3& barycentricCoords)
+ {
+ float dist = 0.0f;
+ if (-barycentricCoords.x > dist)
+ {
+ dist = -barycentricCoords.x;
+ }
+ if (-barycentricCoords.y > dist)
+ {
+ dist = -barycentricCoords.y;
+ }
+ if (-barycentricCoords.z > dist)
+ {
+ dist = -barycentricCoords.z;
+ }
+ float sum = barycentricCoords.x + barycentricCoords.y + barycentricCoords.z - 1.0f;
+ if (sum > dist)
+ {
+ dist = sum;
+ }
+ return dist;
+ }
+
+
+ static bool pointInTetra(const PxVec3& p0, const PxVec3& p1, const PxVec3& p2, const PxVec3& p3, const PxVec3& p, const float epsilon)
+ {
+ PxVec3 n = (p1 - p0).cross(p2 - p0);
+ float s0 = n.dot(p - p0);
+
+ n = (p2 - p0).cross(p3 - p0);
+ float s1 = n.dot(p - p0);
+
+ n = (p3 - p0).cross(p1 - p0);
+ float s2 = n.dot(p - p0);
+
+ n = (p3 - p1).cross(p2 - p1);
+ float s3 = n.dot(p - p1);
+
+ return ((s0 >= -epsilon) && (s1 >= -epsilon) && (s2 >= -epsilon) && (s3 >= -epsilon)) ||
+ ((s0 <= epsilon) && (s1 <= epsilon) && (s2 <= epsilon) && (s3 <= epsilon));
+ }
+
+
+
+ struct Ellipsoid
+ {
+ PxVec3 center;
+ PxVec3 xAxis; // contains scale
+ PxVec3 yAxis; // contains scale
+ PxVec3 zAxis; // contains scale
+ };
+
+
+
+ float GetWeight(float value, float maxValue)
+ {
+ float x = PxAbs(value) / PxAbs(maxValue);
+ if (value > 1.0)
+ {
+ value = 1.0;
+ }
+ if (value < 0.0)
+ {
+ value = 0.0;
+ }
+ //return cos(HalfPi*x)*cos(HalfPi*x);
+ return PxExp(-x * x * 4);
+ }
+
+
+
+ // Returns a value 0 and 1 if inside, > 1 if outside
+ float GetEllipsoidDistance(const Ellipsoid& e, const PxVec3& p)
+ {
+#define SQR(_x) ((_x)*(_x))
+
+ PxVec3 cp = p - e.center;
+ float xProj = cp.dot(e.xAxis);
+ float yProj = cp.dot(e.yAxis);
+ float zProj = cp.dot(e.zAxis);
+
+ return sqrtf(SQR(xProj) + SQR(yProj) + SQR(zProj));
+ }
+
+
+
+ float GetEllipsoidWeight(const Ellipsoid& e, const PxVec3& p)
+ {
+ float d = GetEllipsoidDistance(e, p);
+ return GetWeight(d, 1.0f);
+ }
+
+
+
+ static PxVec3 projectOnPlane(const PxVec3& planeNormal, float planeD, const PxVec3& point, const PxVec3& projectionDirection)
+ {
+ // from http://en.wikipedia.org/wiki/Line-plane_intersection
+
+ //t={-d-\mathbf{l}_a\cdot\mathbf{n} \over (\mathbf{l}_b-\mathbf{l}_a)\cdot\mathbf{n}}.
+
+ const float nominator = -planeD - point.dot(planeNormal);
+ const float denominator = projectionDirection.dot(planeNormal);
+
+ if (denominator != 0.0f)
+ {
+ const float t = nominator / denominator;
+
+ return point + t * projectionDirection;
+ }
+
+ return point;
+ }
+
+
+ /**
+ Given target point p and triangle with points p1, p2, p3 and normals n1, n2, n3.
+ Find barycentric coordinates (x, y, z) and height h, such that z = 1-x-y and
+ x*p1+y*p2+z*p3 + (x*n1+y*p2+y*p3)*h
+
+ This means finding a point on the triangle where the interpolated normal goes through the target point.
+ FinalBary will contain (x, y, h).
+ */
+ static bool iterateOnTriangle(uint32_t maxIterations, float convergenceThreshold, const TriangleWithNormals& triangle, const PxVec3& position,
+ PxVec3& finalBary)
+ {
+ uint32_t iteration = 0;
+
+ PxVec3 planeNormal = (triangle.vertices[1] - triangle.vertices[0]).cross(triangle.vertices[2] - triangle.vertices[0]);
+ planeNormal.normalize();
+ const float planeD = -triangle.vertices[0].dot(planeNormal);
+
+ // start with normal from the middle of the triangle
+ PxVec3 trustedBary(1.0f / 3.0f);
+ //PxVec3 tempNormal = planeNormal;
+ PxVec3 tempNormal = trustedBary.x * triangle.normals[0] + trustedBary.y * triangle.normals[1] + trustedBary.z * triangle.normals[2];
+
+ float baryConvergence = PX_MAX_F32;
+
+ float trust = 1.0f;
+ while (iteration++ < maxIterations)
+ {
+ PxVec3 tempPosOnTriangle = projectOnPlane(planeNormal, planeD, position, tempNormal);
+ PxVec3 tempBary = ModuleClothingHelpers::computeTriBarycentricCoords<false>(triangle.vertices[0], triangle.vertices[1], triangle.vertices[2], tempPosOnTriangle);
+
+ // projectOnPlane should lead to position on plane
+ if (PxAbs(tempBary.z) > 0.001f)
+ {
+ return false;
+ }
+
+ // compute real bary coordinate
+ tempBary.z = 1.0f - tempBary.x - tempBary.y;
+
+ const PxVec3 errorVec = tempBary - trustedBary;
+ baryConvergence = errorVec.dot(errorVec);
+
+ // average bary coordinate, graded sum of new values
+ trustedBary *= (1.0f - trust);
+ trustedBary += trust * tempBary;
+
+ // do we still maintain the barycentric invariant?
+ if (PxAbs(1.0f - (trustedBary.x + trustedBary.y + trustedBary.z)) > 0.001f)
+ {
+ return false;
+ }
+
+ // find new normal
+ tempNormal = trustedBary.x * triangle.normals[0] + trustedBary.y * triangle.normals[1] + trustedBary.z * triangle.normals[2];
+
+ if (baryConvergence < convergenceThreshold)
+ {
+ break;
+ }
+
+ trust *= 0.8f;
+ }
+
+ if (baryConvergence < convergenceThreshold)
+ {
+ const PxVec3 posOnTriangle = trustedBary.x * triangle.vertices[0] + trustedBary.y * triangle.vertices[1] + trustedBary.z * triangle.vertices[2];
+
+ const float length = tempNormal.normalize();
+ float avgHeight = tempNormal.dot(position - posOnTriangle) / length;
+
+ finalBary = trustedBary;
+ finalBary.z = avgHeight;
+
+ return true;
+ }
+
+ return false;
+ }
+
+
+
+ static void computeTriangleBarys(TriangleWithNormals& triangle, const PxVec3& position, const PxVec3& normal, const PxVec3& tangent, float thickness, int32_t timeStamp, bool onlyTangent)
+ {
+ // todo PH: assert is finite!
+
+ if (triangle.timestamp < timeStamp)
+ {
+ triangle.valid = 0;
+
+ // This is the value that is used when nothing is hit
+ triangle.tempBaryVertex = PxVec3(PX_MAX_F32);
+ triangle.tempBaryNormal = PxVec3(PX_MAX_F32);
+ triangle.tempBaryTangent = PxVec3(PX_MAX_F32);
+
+ PxVec3 positionBary(PX_MAX_F32);
+ PxVec3 normalBary(PX_MAX_F32);
+ PxVec3 tangentBary(PX_MAX_F32);
+
+ if (onlyTangent || iterateOnTriangle(100, 0.0001f, triangle, position, positionBary))
+ {
+ triangle.valid = 1;
+
+ triangle.tempBaryVertex = positionBary;
+ PX_ASSERT(triangle.tempBaryVertex.isFinite());
+
+ if (!normal.isZero())
+ {
+ if (iterateOnTriangle(100, 0.0001f, triangle, normal, normalBary))
+ {
+ triangle.valid = 2;
+
+ triangle.tempBaryNormal = normalBary;
+ PX_ASSERT(triangle.tempBaryNormal.isFinite());
+ }
+ else
+ {
+ PxVec3 newNormal = normal;
+ for (uint32_t iter = 0; iter < 10; iter++)
+ {
+ // changing normal size might help
+ newNormal = (position + newNormal) / 2.0f;
+ if (iterateOnTriangle(10, 0.0001f, triangle, newNormal, normalBary))
+ {
+ triangle.valid = 2;
+
+ triangle.tempBaryNormal = normalBary;
+ PX_ASSERT(triangle.tempBaryNormal.isFinite());
+
+ break;
+ }
+ }
+ if (triangle.valid != 2)
+ {
+ // now this is a really low approximation, but still better than nothing
+ triangle.tempBaryNormal = triangle.tempBaryVertex;
+ triangle.tempBaryNormal.z += thickness;
+ }
+ }
+ }
+
+ if (!tangent.isZero())
+ {
+ if(iterateOnTriangle(1, PX_MAX_F32, triangle, tangent, tangentBary))
+ {
+ triangle.tempBaryTangent = tangentBary;
+ PX_ASSERT(triangle.tempBaryTangent.isFinite());
+ }
+ }
+ }
+
+ triangle.timestamp = timeStamp;
+ }
+ }
+};
+
+}
+} // namespace nvidia
+
+#endif // MODULE_CLOTHING_HELPERS_H
diff --git a/APEX_1.4/module/clothing/include/ModuleClothingImpl.h b/APEX_1.4/module/clothing/include/ModuleClothingImpl.h
new file mode 100644
index 00000000..4cf91642
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ModuleClothingImpl.h
@@ -0,0 +1,268 @@
+/*
+ * 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_CLOTHING_IMPL_H
+#define MODULE_CLOTHING_IMPL_H
+
+#include "ModuleClothing.h"
+#include "ClothingAsset.h"
+#include "ApexSDKIntl.h"
+#include "ModuleIntl.h"
+#include "ModuleBase.h"
+#include "ApexSDKHelpers.h"
+#include "ModuleClothingRegistration.h"
+#include "ClothStructs.h"
+#include "ApexRWLockable.h"
+#include "ApexPvdClient.h"
+// The clothing GPU source is in a separate DLL, we're going to load it and get a CuFactory create method
+#if PX_WINDOWS_FAMILY
+#include "ModuleUpdateLoader.h"
+#endif
+
+class ClothingPhysicalMeshParameters;
+
+namespace physx
+{
+ class PxCudaContextManager;
+}
+
+namespace nvidia
+{
+#if APEX_CUDA_SUPPORT
+ namespace cloth
+ {
+ class CuFactory;
+ }
+#endif
+
+namespace apex
+{
+class ApexIsoMesh;
+class RenderMeshAssetAuthoringIntl;
+class ClothingAsset;
+class ClothingAssetAuthoring;
+}
+namespace clothing
+{
+class ClothingScene;
+class ClothingAssetImpl;
+class ClothingAssetAuthoringImpl;
+class ClothingPhysicalMeshImpl;
+class CookingAbstract;
+class DummyActor;
+class DummyAsset;
+class SimulationAbstract;
+
+
+class BackendFactory
+{
+public:
+ virtual bool isMatch(const char* simulationBackend) = 0;
+ virtual const char* getName() = 0;
+ virtual uint32_t getCookingVersion() = 0;
+ virtual uint32_t getCookedDataVersion(const NvParameterized::Interface* cookedData) = 0;
+ virtual CookingAbstract* createCookingJob() = 0;
+ virtual void releaseCookedInstances(NvParameterized::Interface* cookedData) = 0;
+ virtual SimulationAbstract* createSimulation(ClothingScene* clothingScene, bool useHW) = 0;
+};
+
+
+
+class ModuleClothingImpl : public ModuleClothing, public ModuleIntl, public ModuleBase, public ApexRWLockable
+{
+public:
+ APEX_RW_LOCKABLE_BOILERPLATE
+
+ ModuleClothingImpl(ApexSDKIntl* sdk);
+
+ // from ApexInterface
+ PX_INLINE void release()
+ {
+ ModuleBase::release();
+ }
+
+ // from Module
+ void init(NvParameterized::Interface& desc);
+ NvParameterized::Interface* getDefaultModuleDesc();
+ PX_INLINE const char* getName() const
+ {
+ return ModuleBase::getName();
+ }
+ AuthObjTypeID getModuleID() const;
+
+ RenderableIterator* createRenderableIterator(const Scene&);
+
+ ClothingPhysicalMesh* createEmptyPhysicalMesh();
+ ClothingPhysicalMesh* createSingleLayeredMesh(RenderMeshAssetAuthoring* asset, uint32_t subdivisionSize, bool mergeVertices, bool closeHoles, IProgressListener* progress);
+
+ PX_INLINE NvParameterized::Interface* getApexClothingActorParams(void) const
+ {
+ return mApexClothingActorParams;
+ }
+ PX_INLINE NvParameterized::Interface* getApexClothingPreviewParams(void) const
+ {
+ return mApexClothingPreviewParams;
+ }
+
+ // from ModuleIntl
+ virtual void destroy();
+ virtual ModuleSceneIntl* createInternalModuleScene(SceneIntl&, RenderDebugInterface*);
+ virtual void releaseModuleSceneIntl(ModuleSceneIntl&);
+ virtual uint32_t forceLoadAssets();
+
+#ifndef WITHOUT_PVD
+ virtual void initPvdClasses(pvdsdk::PvdDataStream& pvdDataStream);
+ virtual void initPvdInstances(pvdsdk::PvdDataStream& pvdDataStream);
+ virtual void destroyPvdInstances();
+#endif
+
+ // own methods
+
+ ClothingScene* getClothingScene(const Scene& scene);
+
+ ClothingPhysicalMeshImpl* createPhysicalMeshInternal(ClothingPhysicalMeshParameters* mesh);
+
+ void releasePhysicalMesh(ClothingPhysicalMeshImpl* physicalMesh);
+ void unregisterAssetWithScenes(ClothingAssetImpl* asset);
+ void notifyReleaseGraphicalData(ClothingAssetImpl* asset);
+
+ Actor* getDummyActor();
+
+ // This pointer will not be released by this module!
+ virtual void registerBackendFactory(BackendFactory* factory);
+ virtual void unregisterBackendFactory(BackendFactory* factory);
+ // this works both with the name of the simulation backend, or the cooking data type
+ BackendFactory* getBackendFactory(const char* simulationBackend);
+
+ ClothFactory createClothFactory(PxCudaContextManager* contextManager);
+ void releaseClothFactory(PxCudaContextManager* contextManager);
+
+ PX_INLINE uint32_t getMaxUnusedPhysXResources() const
+ {
+ return mInternalModuleParams.maxUnusedPhysXResources;
+ }
+ PX_INLINE uint32_t getMaxNumCompartments() const
+ {
+ return mInternalModuleParams.maxNumCompartments;
+ }
+ PX_INLINE bool allowAsyncFetchResults() const
+ {
+ return mInternalModuleParams.asyncFetchResults;
+ }
+ PX_INLINE bool allowAsyncCooking() const
+ {
+ return mInternalModuleParams.allowAsyncCooking;
+ }
+ PX_INLINE uint32_t getAvgSimFrequencyWindowSize() const
+ {
+ return mInternalModuleParams.avgSimFrequencyWindow;
+ }
+ PX_INLINE bool allowApexWorkBetweenSubsteps() const
+ {
+ return mInternalModuleParams.allowApexWorkBetweenSubsteps;
+ }
+ PX_INLINE float getInterCollisionDistance() const
+ {
+ return mInternalModuleParams.interCollisionDistance;
+ }
+ PX_INLINE float getInterCollisionStiffness() const
+ {
+ return mInternalModuleParams.interCollisionStiffness;
+ }
+ PX_INLINE uint32_t getInterCollisionIterations() const
+ {
+ return mInternalModuleParams.interCollisionIterations;
+ }
+ PX_INLINE void setInterCollisionDistance(float distance)
+ {
+ mInternalModuleParams.interCollisionDistance = distance;
+ }
+ PX_INLINE void setInterCollisionStiffness(float stiffness)
+ {
+ mInternalModuleParams.interCollisionStiffness = stiffness;
+ }
+ PX_INLINE void setInterCollisionIterations(uint32_t iterations)
+ {
+ mInternalModuleParams.interCollisionIterations = iterations;
+ }
+ PX_INLINE bool useSparseSelfCollision() const
+ {
+ return mInternalModuleParams.sparseSelfCollision;
+ }
+ PX_INLINE uint32_t getMaxTimeRenderProxyInPool() const
+ {
+ return mInternalModuleParams.maxTimeRenderProxyInPool;
+ }
+
+private:
+ ClothingPhysicalMesh* createSingleLayeredMeshInternal(RenderMeshAssetAuthoringIntl* asset, uint32_t subdivisionSize, bool mergeVertices, bool closeHoles, IProgressListener* progress);
+
+ ResourceList mClothingSceneList;
+ ResourceList mPhysicalMeshes;
+ ResourceList mAssetAuthorableObjectFactories;
+
+ DummyActor* mDummyActor;
+ DummyAsset* mDummyAsset;
+ nvidia::Mutex mDummyProtector;
+
+ class ClothingBackendFactory : public BackendFactory, public nvidia::UserAllocated
+ {
+ public:
+ virtual bool isMatch(const char* simulationBackend);
+ virtual const char* getName();
+ virtual uint32_t getCookingVersion();
+ virtual uint32_t getCookedDataVersion(const NvParameterized::Interface* cookedData);
+ virtual CookingAbstract* createCookingJob();
+ virtual void releaseCookedInstances(NvParameterized::Interface* cookedData);
+ virtual SimulationAbstract* createSimulation(ClothingScene* clothingScene, bool useHW);
+ };
+
+ ClothingBackendFactory mBackendFactory;
+
+ Array<BackendFactory*> mBackendFactories;
+
+ ClothingModuleParameters* mModuleParams;
+ ClothingModuleParametersNS::ParametersStruct mInternalModuleParams;
+
+ NvParameterized::Interface* mApexClothingActorParams;
+ NvParameterized::Interface* mApexClothingPreviewParams;
+
+ nvidia::Mutex mFactoryMutex;
+ cloth::Factory* mCpuFactory;
+ uint32_t mCpuFactoryReferenceCount;
+
+#if APEX_CUDA_SUPPORT
+ void* mGpuDllHandle;
+
+ // this function is declared in CreateCuFactory.h and implemented in CreateCuFactory.cpp, which is in in APEX_ClothingGPU
+ typedef nvidia::cloth::CuFactory* (PxCreateCuFactory_FUNC)(PxCudaContextManager* contextManager);
+ PxCreateCuFactory_FUNC* mPxCreateCuFactoryFunc;
+
+ struct GpuFactoryEntry
+ {
+ GpuFactoryEntry(cloth::Factory* f, PxCudaContextManager* c) : factoryGpu(f), contextManager(c), referenceCount(0) {}
+
+ cloth::Factory* factoryGpu;
+ PxCudaContextManager* contextManager;
+ uint32_t referenceCount;
+ };
+
+ nvidia::Array<GpuFactoryEntry> mGpuFactories;
+#endif
+
+
+ virtual ~ModuleClothingImpl() {}
+};
+
+}
+} // namespace nvidia
+
+#endif // MODULE_CLOTHING_IMPL_H
diff --git a/APEX_1.4/module/clothing/include/ModuleEventDefs.h b/APEX_1.4/module/clothing/include/ModuleEventDefs.h
new file mode 100644
index 00000000..27aa23db
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/ModuleEventDefs.h
@@ -0,0 +1,53 @@
+/*
+ * 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(ClothingActorCPUSkinningGraphics)
+DEFINE_EVENT(ClothingActorCreatePhysX)
+DEFINE_EVENT(ClothingActorFallbackSkinning)
+
+DEFINE_EVENT(ClothingActorUpdateStateInternal)
+DEFINE_EVENT(ClothingActorInterpolateMatrices)
+DEFINE_EVENT(ClothingActorUpdateCollision)
+DEFINE_EVENT(ClothingActorApplyVelocityChanges)
+
+DEFINE_EVENT(ClothingActorLodTick)
+DEFINE_EVENT(ClothingActorMeshMeshSkinning)
+DEFINE_EVENT(ClothingActorMorphTarget)
+DEFINE_EVENT(ClothingActorRecomputeTangentSpace)
+DEFINE_EVENT(ClothingActorSDKCreateClothSoftbody)
+DEFINE_EVENT(ClothingActorUpdateBounds)
+DEFINE_EVENT(ClothingActorUpdateCompressedSkinning)
+DEFINE_EVENT(ClothingActorUpdateRenderResources)
+DEFINE_EVENT(ClothingActorUpdateVertexBuffer)
+DEFINE_EVENT(ClothingActorVelocityShader)
+DEFINE_EVENT(ClothingActorWind)
+DEFINE_EVENT(ClothingActorTeleport)
+DEFINE_EVENT(ClothingActorTransformGraphicalMeshes)
+
+DEFINE_EVENT(ClothingAssetDeserialize)
+DEFINE_EVENT(ClothingAssetLoad)
+
+DEFINE_EVENT(ClothingSceneDistributeSolverIterations)
diff --git a/APEX_1.4/module/clothing/include/ModulePerfScope.h b/APEX_1.4/module/clothing/include/ModulePerfScope.h
new file mode 100644
index 00000000..94e74d98
--- /dev/null
+++ b/APEX_1.4/module/clothing/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 clothing
+#include "ModuleProfileCommon.h"
+
+#endif
diff --git a/APEX_1.4/module/clothing/include/Simulation.h b/APEX_1.4/module/clothing/include/Simulation.h
new file mode 100644
index 00000000..a576074b
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/Simulation.h
@@ -0,0 +1,315 @@
+/*
+ * 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 SIMULATION_H
+#define SIMULATION_H
+
+#include "SimulationAbstract.h"
+
+#include <PsHashMap.h>
+#include <PxTask.h>
+#include <PxProfileZone.h>
+#include <PxProfileZoneManager.h>
+
+#include "Range.h"
+#include "Types.h"
+#include "PhaseConfig.h"
+
+#include "ClothStructs.h"
+
+#if PX_WINDOWS_FAMILY
+#include "ApexString.h"
+#endif
+
+
+namespace physx
+{
+ namespace pvdsdk
+ {
+ class ApexPvdClient;
+ }
+}
+
+namespace nvidia
+{
+using namespace physx::profile;
+
+namespace cloth
+{
+class Cloth;
+class Factory;
+class Solver;
+}
+
+
+namespace apex
+{
+class SceneIntl;
+class DebugRenderParams;
+class RenderDebugInterface;
+}
+namespace clothing
+{
+class ModuleClothingImpl;
+class ClothingCookedPhysX3Param;
+class ClothingDebugRenderParams;
+
+class ClothingConvexImpl;
+
+
+struct TriangleMeshId
+{
+ TriangleMeshId(uint32_t id_, uint32_t numTriangles_) : id(id_), numTriangles(numTriangles_)
+ {
+ }
+
+ uint32_t id;
+ uint32_t numTriangles;
+
+ bool operator<(const TriangleMeshId& other) const
+ {
+ return id < other.id;
+ }
+};
+
+class Simulation : public SimulationAbstract
+{
+public:
+
+ Simulation(ClothingScene* clothingScene, bool useCuda);
+ virtual ~Simulation();
+
+ virtual bool needsExpensiveCreation();
+ virtual bool needsAdaptiveTargetFrequency();
+ virtual bool needsManualSubstepping();
+ virtual bool needsLocalSpaceGravity();
+ virtual uint32_t getNumSolverIterations() const;
+ virtual SimulationType::Enum getType() const { return SimulationType::CLOTH3x; }
+ virtual bool setCookedData(NvParameterized::Interface* cookedData, float actorScale);
+ virtual bool initPhysics(uint32_t _physicalMeshId, uint32_t* indices, PxVec3* restPositions, tMaterial* material, const PxMat44& globalPose, const PxVec3& scaledGravity, bool localSpaceSim);
+
+ virtual void initCollision(tBoneActor* boneActors, uint32_t numBoneActors,
+ tBoneSphere* boneSpheres, uint32_t numBoneSpheres,
+ uint16_t* spherePairIndices, uint32_t numSpherePairs,
+ tBonePlane* bonePlanes, uint32_t numBonePlanes,
+ uint32_t* convexes, uint32_t numConvexes,
+ tBoneEntry* bones, const PxMat44* boneTransforms,
+ ResourceList& actorPlanes,
+ ResourceList& actorConvexes,
+ ResourceList& actorSpheres,
+ ResourceList& actorCapsules,
+ ResourceList& actorTriangleMeshes,
+ const tActorDescTemplate& actorDesc, const tShapeDescTemplate& shapeDesc, float actorScale,
+ const PxMat44& globalPose, bool localSpaceSim);
+
+ virtual void updateCollision(tBoneActor* boneActors, uint32_t numBoneActors,
+ tBoneSphere* boneSpheres, uint32_t numBoneSpheres,
+ tBonePlane* bonePlanes, uint32_t numBonePlanes,
+ tBoneEntry* bones, const PxMat44* boneTransforms,
+ ResourceList& actorPlanes,
+ ResourceList& actorConvexes,
+ ResourceList& actorSpheres,
+ ResourceList& actorCapsules,
+ ResourceList& actorTriangleMeshes,
+ bool teleport);
+
+ virtual void releaseCollision(ClothingCollisionImpl& releaseCollision);
+
+ virtual void updateCollisionDescs(const tActorDescTemplate& actorDesc, const tShapeDescTemplate& shapeDesc);
+
+ virtual void disablePhysX(Actor* dummy);
+ virtual void reenablePhysX(Actor* newMaster, const PxMat44& globalPose);
+
+ virtual void fetchResults(bool computePhysicsMeshNormals);
+ virtual bool isSimulationMeshDirty() const;
+ virtual void clearSimulationMeshDirt();
+
+ virtual void setStatic(bool on);
+ virtual bool applyPressure(float pressure);
+
+ virtual bool raycast(const PxVec3& rayOrigin, const PxVec3& rayDirection, float& hitTime, PxVec3& hitNormal, uint32_t& vertexIndex);
+ virtual void attachVertexToGlobalPosition(uint32_t vertexIndex, const PxVec3& globalPosition);
+ virtual void freeVertex(uint32_t vertexIndex);
+
+ virtual void setGlobalPose(const PxMat44& globalPose);
+ virtual void applyGlobalPose();
+
+ virtual NvParameterized::Interface* getCookedData();
+
+ // debugging and debug rendering
+ virtual void verifyTimeStep(float substepSize);
+ virtual void visualize(RenderDebugInterface& renderDebug, ClothingDebugRenderParams& clothingDebugParams);
+#ifndef WITHOUT_PVD
+ virtual void updatePvd(pvdsdk::PvdDataStream& pvdStream, pvdsdk::PvdUserRenderer& pvdRenderer, ApexResourceInterface* clothingActor, bool localSpaceSim);
+#endif
+ virtual GpuSimMemType::Enum getGpuSimMemType() const;
+
+ // R/W Access to simulation data
+ virtual void setPositions(PxVec3* positions);
+ virtual void setConstrainCoefficients(const tConstrainCoeffs* assetCoeffs, float maxDistanceBias, float maxDistanceScale, float maxDistanceDeform, float actorScale);
+ virtual void getVelocities(PxVec3* velocities) const;
+ virtual void setVelocities(PxVec3* velocities);
+ virtual bool applyWind(PxVec3* velocities, const PxVec3* normals, const tConstrainCoeffs* assetCoeffs, const PxVec3& wind, float adaption, float dt);
+
+ // actually important
+ virtual void setTeleportWeight(float weight, bool reset, bool localSpaceSim);
+ virtual void setSolverIterations(uint32_t iterations);
+ virtual void updateConstrainPositions(bool isDirty);
+ virtual bool applyClothingMaterial(tMaterial* material, PxVec3 scaledGravity);
+ virtual void applyClothingDesc(tClothingDescTemplate& clothingTemplate);
+ virtual void setInterCollisionChannels(uint32_t channels);
+ virtual void setHalfPrecisionOption(bool isAllowed);
+
+#if APEX_UE4
+ virtual void simulate(float dt);
+#endif
+
+ // cleanup code
+ static void releaseFabric(NvParameterized::Interface* cookedData);
+
+private:
+ void applyCollision();
+
+ void setRestPositions(bool on);
+
+#ifndef WITHOUT_DEBUG_VISUALIZE
+ void visualizeConvexes(RenderDebugInterface& renderDebug);
+ void visualizeConvexesInvalid(RenderDebugInterface& renderDebug);
+ void createAttenuationData();
+#endif
+
+ struct MappedArray
+ {
+ cloth::Range<PxVec4> deviceMemory;
+ nvidia::Array<PxVec4> hostMemory;
+ };
+
+ static bool allocateHostMemory(MappedArray& mappedMemory);
+
+ // data owned by asset or actor
+ ClothingCookedPhysX3Param* mCookedData;
+
+ // data owned by asset
+ const uint32_t* mIndices;
+ const PxVec3* mRestPositions;
+ const tConstrainCoeffs* mConstrainCoeffs;
+
+ // own data
+ cloth::Cloth* mCloth;
+
+ nvidia::Array<uint32_t> mCollisionCapsules;
+ nvidia::Array<uint32_t> mCollisionCapsulesInvalid;
+ nvidia::Array<PxVec4> mCollisionSpheres;
+ nvidia::Array<PxVec4> mCollisionPlanes;
+ nvidia::Array<uint32_t> mCollisionConvexes;
+ nvidia::Array<ClothingConvexImpl*> mCollisionConvexesInvalid;
+ nvidia::Array<PxVec3> mCollisionTrianglesOld;
+ nvidia::Array<PxVec3> mCollisionTriangles;
+ uint32_t mNumAssetSpheres;
+ uint32_t mNumAssetCapsules;
+ uint32_t mNumAssetCapsulesInvalid;
+ uint32_t mNumAssetConvexes;
+ nvidia::Array<uint32_t> mReleasedSphereIds;
+ nvidia::Array<uint32_t> mReleasedPlaneIds;
+
+ struct ConstrainConstants
+ {
+ ConstrainConstants() : motionConstrainDistance(0.0f), backstopDistance(0.0f), backstopRadius(0.0f) {}
+ float motionConstrainDistance;
+ float backstopDistance;
+ float backstopRadius;
+ };
+
+ nvidia::Array<ConstrainConstants> mConstrainConstants;
+ bool mConstrainConstantsDirty;
+ float mMotionConstrainScale;
+ float mMotionConstrainBias;
+ int32_t mNumBackstopConstraints;
+ nvidia::Array<PxVec4> mBackstopConstraints;
+
+ PxVec3 mScaledGravity;
+ float mLastTimestep;
+
+ nvidia::Array<cloth::PhaseConfig> mPhaseConfigs;
+
+ bool mLocalSpaceSim;
+
+ nvidia::Array<uint32_t> mSelfCollisionAttenuationPairs;
+ nvidia::Array<float> mSelfCollisionAttenuationValues;
+
+ PX_ALIGN(16, PxMat44 mGlobalPose);
+ PxMat44 mGlobalPosePrevious;
+ PxMat44 mGlobalPoseNormalized;
+ PxMat44 mGlobalPoseNormalizedInv;
+ float mActorScale;
+ float mTetherLimit;
+ bool mTeleported;
+ bool mIsStatic;
+};
+
+
+
+class ClothingSceneSimulateTask : public PxTask, public UserAllocated
+{
+public:
+ ClothingSceneSimulateTask(SceneIntl* apexScene, ClothingScene* scene, ModuleClothingImpl* module, profile::PxProfileZoneManager* manager);
+ virtual ~ClothingSceneSimulateTask();
+
+ void setWaitTask(PxBaseTask* waitForSolver);
+
+ void setDeltaTime(float simulationDelta);
+ float getDeltaTime();
+
+ // this must only be called from ClothingScene::getClothSolver() !!!
+ cloth::Solver* getSolver(ClothFactory factory);
+
+ void clearGpuSolver();
+
+ virtual void run();
+ virtual const char* getName() const;
+
+private:
+ static bool interCollisionFilter(void* user0, void* user1);
+
+ ModuleClothingImpl* mModule;
+ SceneIntl* mApexScene;
+ ClothingScene* mScene;
+ float mSimulationDelta;
+
+ cloth::Solver* mSolverGPU;
+ cloth::Solver* mSolverCPU;
+ PxProfileZone* mProfileSolverGPU;
+ PxProfileZone* mProfileSolverCPU;
+
+ PxBaseTask* mWaitForSolverTask;
+
+ profile::PxProfileZoneManager* mProfileManager;
+ bool mFailedGpuFactory;
+};
+
+
+class WaitForSolverTask : public PxTask, public UserAllocated
+{
+public:
+ WaitForSolverTask(ClothingScene* scene);
+
+ virtual void run();
+ virtual const char* getName() const;
+
+private:
+ ClothingScene* mScene;
+};
+
+
+}
+} // namespace nvidia
+
+#endif // SIMULATION_H
diff --git a/APEX_1.4/module/clothing/include/SimulationAbstract.h b/APEX_1.4/module/clothing/include/SimulationAbstract.h
new file mode 100644
index 00000000..6e750141
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/SimulationAbstract.h
@@ -0,0 +1,261 @@
+/*
+ * 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 SIMULATION_ABSTRACT_H
+#define SIMULATION_ABSTRACT_H
+
+#include "ApexUsingNamespace.h"
+#include "PsUserAllocated.h"
+
+#include "ApexDefs.h"
+
+#include "ClothingActorParam.h"
+
+// some params files
+#include "ClothingMaterialLibraryParameters.h"
+#include "ClothingAssetParameters.h"
+#include "ClothingPhysicalMeshParameters.h"
+
+#include "ApexPvdClient.h"
+
+namespace physx
+{
+#if APEX_UE4
+ class PxBaseTask;
+#endif
+
+ namespace pvdsdk
+ {
+ class PvdDataStream;
+ class PvdUserRenderer;
+ }
+}
+
+namespace nvidia
+{
+namespace apex
+{
+class ResourceList;
+class RenderDebugInterface;
+class ApexResourceInterface;
+class Actor;
+}
+namespace clothing
+{
+class ClothingScene;
+class ClothingDebugRenderParams;
+class ClothingCollisionImpl;
+
+
+struct GpuSimMemType
+{
+ enum Enum
+ {
+ UNDEFINED = -1,
+ GLOBAL = 0,
+ MIXED = 1,
+ SHARED = 2
+ };
+};
+
+
+struct SimulationType
+{
+ enum Enum
+ {
+ CLOTH2x,
+ SOFTBODY2x,
+ CLOTH3x
+ };
+};
+
+
+class SimulationAbstract : public UserAllocated
+{
+public:
+ typedef ClothingMaterialLibraryParametersNS::ClothingMaterial_Type tMaterial;
+ typedef ClothingActorParamNS::ClothDescTemplate_Type tClothingDescTemplate;
+ typedef ClothingActorParamNS::ActorDescTemplate_Type tActorDescTemplate;
+ typedef ClothingActorParamNS::ShapeDescTemplate_Type tShapeDescTemplate;
+ typedef ClothingAssetParametersNS::SimulationParams_Type tSimParams;
+ typedef ClothingAssetParametersNS::ActorEntry_Type tBoneActor;
+ typedef ClothingAssetParametersNS::BoneSphere_Type tBoneSphere;
+ typedef ClothingAssetParametersNS::BonePlane_Type tBonePlane;
+ typedef ClothingAssetParametersNS::BoneEntry_Type tBoneEntry;
+ typedef ClothingPhysicalMeshParametersNS::ConstrainCoefficient_Type tConstrainCoeffs;
+
+ SimulationAbstract(ClothingScene* clothingScene) : physicalMeshId(0xffffffff), submeshId(0xffffffff),
+ skinnedPhysicsPositions(NULL), skinnedPhysicsNormals(NULL),
+ sdkNumDeformableVertices(0), sdkWritebackPosition(NULL), sdkWritebackNormal(NULL), sdkNumDeformableIndices(0),
+ mRegisteredActor(NULL), mClothingScene(clothingScene), mUseCuda(false)
+ {
+ ::memset(&simulation, 0, sizeof(simulation));
+ }
+
+ virtual ~SimulationAbstract()
+ {
+ if (sdkWritebackPosition != NULL)
+ {
+ PX_FREE(sdkWritebackPosition);
+ sdkWritebackPosition = sdkWritebackNormal = NULL;
+ }
+
+ if (skinnedPhysicsPositions != NULL)
+ {
+ PX_FREE(skinnedPhysicsPositions);
+ skinnedPhysicsPositions = skinnedPhysicsNormals = NULL;
+ }
+
+ PX_ASSERT(mRegisteredActor == NULL);
+ }
+
+ void init(uint32_t numVertices, uint32_t numIndices, bool writebackNormals);
+ void initSimulation(const ClothingAssetParametersNS::SimulationParams_Type& s);
+
+ virtual bool needsExpensiveCreation() = 0;
+ virtual bool needsAdaptiveTargetFrequency() = 0;
+ virtual bool needsManualSubstepping() = 0;
+ virtual bool needsLocalSpaceGravity() = 0;
+ virtual SimulationType::Enum getType() const = 0;
+ virtual bool isGpuSim() const { return mUseCuda; }
+ virtual uint32_t getNumSolverIterations() const = 0;
+ virtual GpuSimMemType::Enum getGpuSimMemType() const { return GpuSimMemType::UNDEFINED; }
+ virtual bool setCookedData(NvParameterized::Interface* cookedData, float actorScale) = 0;
+ virtual bool initPhysics(uint32_t physicalMeshId, uint32_t* indices, PxVec3* restPositions, tMaterial* material, const PxMat44& globalPose, const PxVec3& scaledGravity, bool localSpaceSim) = 0;
+
+ // collision
+ virtual void initCollision( tBoneActor* boneActors, uint32_t numBoneActors,
+ tBoneSphere* boneSpheres, uint32_t numBoneSpheres,
+ uint16_t* spherePairIndices, uint32_t numSpherePairs,
+ tBonePlane* bonePlanes, uint32_t numBonePlanes,
+ uint32_t* convexes, uint32_t numConvexes,
+ tBoneEntry* bones, const PxMat44* boneTransforms,
+ ResourceList& actorPlanes,
+ ResourceList& actorConvexes,
+ ResourceList& actorSpheres,
+ ResourceList& actorCapsules,
+ ResourceList& actorTriangleMeshes,
+ const tActorDescTemplate& actorDesc, const tShapeDescTemplate& shapeDesc, float actorScale,
+ const PxMat44& globalPose, bool localSpaceSim) = 0;
+
+ virtual void updateCollision( tBoneActor* boneActors, uint32_t numBoneActors,
+ tBoneSphere* boneSpheres, uint32_t numBoneSpheres,
+ tBonePlane* bonePlanes, uint32_t numBonePlanes,
+ tBoneEntry* bones, const PxMat44* boneTransforms,
+ ResourceList& actorPlanes,
+ ResourceList& actorConvexes,
+ ResourceList& actorSpheres,
+ ResourceList& actorCapsules,
+ ResourceList& actorTriangleMeshes,
+ bool teleport) = 0;
+
+ virtual void updateCollisionDescs(const tActorDescTemplate& actorDesc, const tShapeDescTemplate& shapeDesc) = 0;
+ virtual void applyCollision() {};
+ virtual void releaseCollision(ClothingCollisionImpl& /*collision*/) {}
+
+ virtual void swapCollision(SimulationAbstract* /*oldSimulation*/) {}
+
+ virtual void registerPhysX(Actor* actor)
+ {
+ PX_ASSERT(mRegisteredActor == NULL);
+ mRegisteredActor = actor;
+
+ PX_ASSERT(physicalMeshId != 0xffffffff);
+ }
+
+ virtual void unregisterPhysX()
+ {
+ PX_ASSERT(mRegisteredActor != NULL);
+ mRegisteredActor = NULL;
+
+ PX_ASSERT(physicalMeshId != 0xffffffff);
+ }
+
+ virtual void disablePhysX(Actor* dummy) = 0;
+ virtual void reenablePhysX(Actor* newMaster, const PxMat44& globalPose) = 0;
+
+ virtual void fetchResults(bool computePhysicsMeshNormals) = 0;
+ virtual bool isSimulationMeshDirty() const = 0;
+ virtual void clearSimulationMeshDirt() = 0;
+
+ virtual void setStatic(bool on) = 0;
+ virtual bool applyPressure(float pressure) = 0;
+
+ virtual void setGlobalPose(const PxMat44& globalPose) = 0;
+ virtual void applyGlobalPose() {};
+
+ virtual bool raycast(const PxVec3& rayOrigin, const PxVec3& rayDirection, float& hitTime, PxVec3& hitNormal, uint32_t& vertexIndex) = 0;
+ virtual void attachVertexToGlobalPosition(uint32_t vertexIndex, const PxVec3& globalPosition) = 0;
+ virtual void freeVertex(uint32_t vertexIndex) = 0;
+
+ virtual NvParameterized::Interface* getCookedData() = 0;
+
+ // debugging and debug rendering
+ virtual void verifyTimeStep(float substepSize) = 0;
+ virtual void visualize(RenderDebugInterface& renderDebug, ClothingDebugRenderParams& clothingDebugParams) = 0;
+#ifndef WITHOUT_PVD
+ virtual void updatePvd(pvdsdk::PvdDataStream& /*pvdStream*/, pvdsdk::PvdUserRenderer& /*pvdRenderer*/, ApexResourceInterface* /*ClothingActorImpl*/, bool /*localSpaceSim*/) {};
+#endif
+
+ // R/W Access to simulation data
+ virtual void setPositions(PxVec3* positions) = 0;
+ virtual void setConstrainCoefficients(const tConstrainCoeffs* assetCoeffs, float maxDistanceBias, float maxDistanceScale, float maxDistanceDeform, float actorScale) = 0;
+ virtual void getVelocities(PxVec3* velocities) const = 0;
+ virtual void setVelocities(PxVec3* velocities) = 0;
+
+ virtual bool applyWind(PxVec3* velocities, const PxVec3* normals, const tConstrainCoeffs* assetCoeffs, const PxVec3& wind, float adaption, float dt) = 0;
+
+ // actually important
+ virtual void setTeleportWeight(float weight, bool reset, bool localSpaceSim) = 0;
+ virtual void setSolverIterations(uint32_t iterations) = 0;
+ virtual void updateConstrainPositions(bool isDirty) = 0;
+ virtual bool applyClothingMaterial(tMaterial* material, PxVec3 scaledGravity) = 0;
+ virtual void applyClothingDesc(tClothingDescTemplate& clothingTemplate) = 0;
+ virtual void setInterCollisionChannels(uint32_t /*channels*/) {};
+ virtual void setHalfPrecisionOption(bool /*isAllowed*/) {};
+
+ ClothingScene* getClothingScene() const
+ {
+ return mClothingScene;
+ }
+
+#if APEX_UE4
+ virtual void simulate(float) {}
+#endif
+
+ uint32_t physicalMeshId;
+ uint32_t submeshId;
+
+ PxVec3* skinnedPhysicsPositions;
+ PxVec3* skinnedPhysicsNormals;
+
+ // Results produced by PhysX SDK's Cloth simulation
+ uint32_t sdkNumDeformableVertices;
+ PxVec3* sdkWritebackPosition;
+ PxVec3* sdkWritebackNormal;
+
+ uint32_t sdkNumDeformableIndices;
+
+protected:
+ tSimParams simulation;
+
+ Actor* mRegisteredActor;
+
+ ClothingScene* mClothingScene;
+ bool mUseCuda;
+
+};
+
+}
+} // namespace nvidia
+
+
+#endif // SIMULATION_ABSTRACT_H
diff --git a/APEX_1.4/module/clothing/include/autogen/ClothingActorParam.h b/APEX_1.4/module/clothing/include/autogen/ClothingActorParam.h
new file mode 100644
index 00000000..db7ba860
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/autogen/ClothingActorParam.h
@@ -0,0 +1,351 @@
+// 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_ClothingActorParam_h
+#define HEADER_ClothingActorParam_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 clothing
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace ClothingActorParamNS
+{
+
+struct GroupsMask_Type;
+struct ClothDescTemplate_Type;
+struct ShapeDescFlags_Type;
+struct ShapeDescTemplate_Type;
+struct ActorDescTemplate_Type;
+struct WindParameters_Type;
+struct MaxDistanceScale_Type;
+struct ClothingActorFlags_Type;
+
+struct MAT44_DynamicArray1D_Type
+{
+ physx::PxMat44* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct VEC3_DynamicArray1D_Type
+{
+ physx::PxVec3* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct STRING_DynamicArray1D_Type
+{
+ NvParameterized::DummyStringStruct* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct ActorDescTemplate_Type
+{
+ uint64_t userData;
+ uint64_t name;
+};
+struct GroupsMask_Type
+{
+ uint32_t bits0;
+ uint32_t bits1;
+ uint32_t bits2;
+ uint32_t bits3;
+};
+struct ClothDescTemplate_Type
+{
+ float collisionResponseCoefficient;
+ uint16_t collisionGroup;
+ GroupsMask_Type groupsMask;
+ physx::PxBounds3 validBounds;
+ uint64_t compartment;
+ uint64_t userData;
+};
+struct MaxDistanceScale_Type
+{
+ float Scale;
+ bool Multipliable;
+};
+struct ClothingActorFlags_Type
+{
+ bool ParallelCpuSkinning;
+ bool RecomputeNormals;
+ bool RecomputeTangents;
+ bool Visualize;
+ bool CorrectSimulationNormals;
+ bool ComputeRenderData;
+ bool ComputePhysicsMeshNormals;
+};
+struct ShapeDescFlags_Type
+{
+ bool NX_SF_VISUALIZATION;
+ bool NX_SF_DISABLE_COLLISION;
+ bool NX_SF_DISABLE_RAYCASTING;
+ bool NX_SF_DYNAMIC_DYNAMIC_CCD;
+ bool NX_SF_DISABLE_SCENE_QUERIES;
+};
+struct ShapeDescTemplate_Type
+{
+ ShapeDescFlags_Type flags;
+ uint16_t collisionGroup;
+ GroupsMask_Type groupsMask;
+ uint16_t materialIndex;
+ uint64_t userData;
+ uint64_t name;
+};
+struct WindParameters_Type
+{
+ physx::PxVec3 Velocity;
+ float Adaption;
+};
+
+struct ParametersStruct
+{
+
+ physx::PxMat44 globalPose;
+ bool useHardwareCloth;
+ ClothingActorFlags_Type flags;
+ bool fallbackSkinning;
+ bool slowStart;
+ bool useInternalBoneOrder;
+ bool updateStateWithGlobalMatrices;
+ uint32_t uvChannelForTangentUpdate;
+ float maxDistanceBlendTime;
+ uint32_t clothingMaterialIndex;
+ WindParameters_Type windParams;
+ MaxDistanceScale_Type maxDistanceScale;
+ uint64_t userData;
+ MAT44_DynamicArray1D_Type boneMatrices;
+ ClothDescTemplate_Type clothDescTemplate;
+ ShapeDescTemplate_Type shapeDescTemplate;
+ ActorDescTemplate_Type actorDescTemplate;
+ float actorScale;
+ NvParameterized::Interface* runtimeCooked;
+ VEC3_DynamicArray1D_Type morphDisplacements;
+ VEC3_DynamicArray1D_Type morphPhysicalMeshNewPositions;
+ VEC3_DynamicArray1D_Type morphGraphicalMeshNewPositions;
+ bool allowAdaptiveTargetFrequency;
+ bool useVelocityClamping;
+ physx::PxBounds3 vertexVelocityClamp;
+ float pressure;
+ bool multiplyGlobalPoseIntoBones;
+ STRING_DynamicArray1D_Type overrideMaterialNames;
+ const char* simulationBackend;
+ bool freezeByLOD;
+ bool localSpaceSim;
+ int32_t teleportMode;
+
+};
+
+static const uint32_t checksum[] = { 0xf1063127, 0xe3a4d0e2, 0x61f25577, 0x4e838af4, };
+
+} // namespace ClothingActorParamNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class ClothingActorParam : public NvParameterized::NvParameters, public ClothingActorParamNS::ParametersStruct
+{
+public:
+ ClothingActorParam(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~ClothingActorParam();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("ClothingActorParam");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)18;
+
+ 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(ClothingActorParamNS::checksum);
+ return ClothingActorParamNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const ClothingActorParamNS::ParametersStruct& parameters(void) const
+ {
+ ClothingActorParam* tmpThis = const_cast<ClothingActorParam*>(this);
+ return *(static_cast<ClothingActorParamNS::ParametersStruct*>(tmpThis));
+ }
+
+ ClothingActorParamNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<ClothingActorParamNS::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 ClothingActorParamFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ ClothingActorParam::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(ClothingActorParam), ClothingActorParam::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, ClothingActorParam::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingActorParam");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(ClothingActorParam)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, ClothingActorParam)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, ClothingActorParam::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, ClothingActorParam::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingActorParam");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of ClothingActorParam 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 (ClothingActorParam*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (ClothingActorParam::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (ClothingActorParam::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (ClothingActorParam::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (ClothingActorParam::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace clothing
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/clothing/include/autogen/ClothingAssetParameters.h b/APEX_1.4/module/clothing/include/autogen/ClothingAssetParameters.h
new file mode 100644
index 00000000..5a56d6ec
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/autogen/ClothingAssetParameters.h
@@ -0,0 +1,374 @@
+// 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_ClothingAssetParameters_h
+#define HEADER_ClothingAssetParameters_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 clothing
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace ClothingAssetParametersNS
+{
+
+struct BoneEntry_Type;
+struct ActorEntry_Type;
+struct BoneSphere_Type;
+struct BonePlane_Type;
+struct CookedEntry_Type;
+struct SimulationParams_Type;
+
+struct REF_DynamicArray1D_Type
+{
+ NvParameterized::Interface** buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct BoneEntry_DynamicArray1D_Type
+{
+ BoneEntry_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct ActorEntry_DynamicArray1D_Type
+{
+ ActorEntry_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct VEC3_DynamicArray1D_Type
+{
+ physx::PxVec3* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct BoneSphere_DynamicArray1D_Type
+{
+ BoneSphere_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct U16_DynamicArray1D_Type
+{
+ uint16_t* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct BonePlane_DynamicArray1D_Type
+{
+ BonePlane_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct U32_DynamicArray1D_Type
+{
+ uint32_t* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct CookedEntry_DynamicArray1D_Type
+{
+ CookedEntry_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct BonePlane_Type
+{
+ int32_t boneIndex;
+ physx::PxVec3 n;
+ float d;
+};
+struct BoneSphere_Type
+{
+ int32_t boneIndex;
+ float radius;
+ physx::PxVec3 localPos;
+};
+struct SimulationParams_Type
+{
+ uint32_t hierarchicalLevels;
+ float thickness;
+ float virtualParticleDensity;
+ physx::PxVec3 gravityDirection;
+ float sleepLinearVelocity;
+ bool disableCCD;
+ bool untangling;
+ bool twowayInteraction;
+ float restLengthScale;
+};
+struct CookedEntry_Type
+{
+ float scale;
+ NvParameterized::Interface* cookedData;
+};
+struct BoneEntry_Type
+{
+ int32_t internalIndex;
+ int32_t externalIndex;
+ uint32_t numMeshReferenced;
+ uint32_t numRigidBodiesReferenced;
+ int32_t parentIndex;
+ physx::PxMat44 bindPose;
+ NvParameterized::DummyStringStruct name;
+};
+struct ActorEntry_Type
+{
+ int32_t boneIndex;
+ uint32_t convexVerticesStart;
+ uint32_t convexVerticesCount;
+ float capsuleRadius;
+ float capsuleHeight;
+ physx::PxMat44 localPose;
+};
+
+struct ParametersStruct
+{
+
+ REF_DynamicArray1D_Type physicalMeshes;
+ REF_DynamicArray1D_Type graphicalLods;
+ SimulationParams_Type simulation;
+ BoneEntry_DynamicArray1D_Type bones;
+ uint32_t bonesReferenced;
+ uint32_t bonesReferencedByMesh;
+ uint32_t rootBoneIndex;
+ ActorEntry_DynamicArray1D_Type boneActors;
+ VEC3_DynamicArray1D_Type boneVertices;
+ BoneSphere_DynamicArray1D_Type boneSpheres;
+ U16_DynamicArray1D_Type boneSphereConnections;
+ BonePlane_DynamicArray1D_Type bonePlanes;
+ U32_DynamicArray1D_Type collisionConvexes;
+ CookedEntry_DynamicArray1D_Type cookedData;
+ physx::PxBounds3 boundingBox;
+ NvParameterized::Interface* materialLibrary;
+ uint32_t materialIndex;
+ uint32_t interCollisionChannels;
+ NvParameterized::DummyStringStruct toolString;
+
+};
+
+static const uint32_t checksum[] = { 0x1095fcd4, 0x7327d8f7, 0xefaa63f8, 0x5bda9add, };
+
+} // namespace ClothingAssetParametersNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class ClothingAssetParameters : public NvParameterized::NvParameters, public ClothingAssetParametersNS::ParametersStruct
+{
+public:
+ ClothingAssetParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~ClothingAssetParameters();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("ClothingAssetParameters");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)14;
+
+ 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(ClothingAssetParametersNS::checksum);
+ return ClothingAssetParametersNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const ClothingAssetParametersNS::ParametersStruct& parameters(void) const
+ {
+ ClothingAssetParameters* tmpThis = const_cast<ClothingAssetParameters*>(this);
+ return *(static_cast<ClothingAssetParametersNS::ParametersStruct*>(tmpThis));
+ }
+
+ ClothingAssetParametersNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<ClothingAssetParametersNS::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 ClothingAssetParametersFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ ClothingAssetParameters::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(ClothingAssetParameters), ClothingAssetParameters::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, ClothingAssetParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingAssetParameters");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(ClothingAssetParameters)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, ClothingAssetParameters)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, ClothingAssetParameters::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, ClothingAssetParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingAssetParameters");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of ClothingAssetParameters 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 (ClothingAssetParameters*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (ClothingAssetParameters::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (ClothingAssetParameters::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (ClothingAssetParameters::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (ClothingAssetParameters::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace clothing
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/clothing/include/autogen/ClothingCookedParam.h b/APEX_1.4/module/clothing/include/autogen/ClothingCookedParam.h
new file mode 100644
index 00000000..c4306292
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/autogen/ClothingCookedParam.h
@@ -0,0 +1,297 @@
+// 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_ClothingCookedParam_h
+#define HEADER_ClothingCookedParam_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 clothing
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace ClothingCookedParamNS
+{
+
+struct CookedPhysicalMesh_Type;
+
+struct U8_DynamicArray1D_Type
+{
+ uint8_t* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct POINTER_DynamicArray1D_Type
+{
+ void** buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct CookedPhysicalMesh_DynamicArray1D_Type
+{
+ CookedPhysicalMesh_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct F32_DynamicArray1D_Type
+{
+ float* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct U32_DynamicArray1D_Type
+{
+ uint32_t* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct VEC3_DynamicArray1D_Type
+{
+ physx::PxVec3* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct CookedPhysicalMesh_Type
+{
+ uint32_t physicalMeshId;
+ uint32_t cookedDataOffset;
+ uint32_t cookedDataLength;
+ void* deformableMeshPointer;
+ uint32_t deformableInvParticleWeightsOffset;
+ uint32_t virtualParticleIndicesOffset;
+ uint32_t virtualParticleIndicesLength;
+};
+
+struct ParametersStruct
+{
+
+ float actorScale;
+ U8_DynamicArray1D_Type convexCookedData;
+ POINTER_DynamicArray1D_Type convexMeshPointers;
+ CookedPhysicalMesh_DynamicArray1D_Type cookedPhysicalMeshes;
+ U8_DynamicArray1D_Type deformableCookedData;
+ uint32_t cookedDataVersion;
+ F32_DynamicArray1D_Type deformableInvParticleWeights;
+ U32_DynamicArray1D_Type virtualParticleIndices;
+ VEC3_DynamicArray1D_Type virtualParticleWeights;
+
+};
+
+static const uint32_t checksum[] = { 0x140bacb3, 0x5ea948eb, 0x14dd612e, 0x6ad11b93, };
+
+} // namespace ClothingCookedParamNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class ClothingCookedParam : public NvParameterized::NvParameters, public ClothingCookedParamNS::ParametersStruct
+{
+public:
+ ClothingCookedParam(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~ClothingCookedParam();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("ClothingCookedParam");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)3;
+
+ static uint32_t staticVersion(void)
+ {
+ return ClassVersion;
+ }
+
+ uint32_t version(void) const
+ {
+ return(staticVersion());
+ }
+
+ static const uint32_t ClassAlignment = 8;
+
+ static const uint32_t* staticChecksum(uint32_t& bits)
+ {
+ bits = 8 * sizeof(ClothingCookedParamNS::checksum);
+ return ClothingCookedParamNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const ClothingCookedParamNS::ParametersStruct& parameters(void) const
+ {
+ ClothingCookedParam* tmpThis = const_cast<ClothingCookedParam*>(this);
+ return *(static_cast<ClothingCookedParamNS::ParametersStruct*>(tmpThis));
+ }
+
+ ClothingCookedParamNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<ClothingCookedParamNS::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 ClothingCookedParamFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ ClothingCookedParam::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(ClothingCookedParam), ClothingCookedParam::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, ClothingCookedParam::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingCookedParam");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(ClothingCookedParam)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, ClothingCookedParam)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, ClothingCookedParam::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, ClothingCookedParam::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingCookedParam");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of ClothingCookedParam 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 (ClothingCookedParam*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (ClothingCookedParam::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (ClothingCookedParam::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (ClothingCookedParam::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (ClothingCookedParam::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace clothing
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/clothing/include/autogen/ClothingCookedPhysX3Param.h b/APEX_1.4/module/clothing/include/autogen/ClothingCookedPhysX3Param.h
new file mode 100644
index 00000000..51dd9241
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/autogen/ClothingCookedPhysX3Param.h
@@ -0,0 +1,310 @@
+// 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_ClothingCookedPhysX3Param_h
+#define HEADER_ClothingCookedPhysX3Param_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 clothing
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace ClothingCookedPhysX3ParamNS
+{
+
+struct PhaseDesc_Type;
+struct SetDesc_Type;
+struct FabricGPU_Type;
+
+struct F32_DynamicArray1D_Type
+{
+ float* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct U32_DynamicArray1D_Type
+{
+ uint32_t* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct SetDesc_DynamicArray1D_Type
+{
+ SetDesc_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct PhaseDesc_DynamicArray1D_Type
+{
+ PhaseDesc_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct FabricGPU_DynamicArray1D_Type
+{
+ FabricGPU_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct SetDesc_Type
+{
+ uint32_t fiberEnd;
+ uint32_t longestFiber;
+ uint32_t shortestFiber;
+ uint32_t numEdges;
+ float avgEdgeLength;
+ uint32_t avgFiberLength;
+};
+struct PhaseDesc_Type
+{
+ uint32_t phaseType;
+ uint32_t setIndex;
+ uint32_t restValueOffset;
+};
+struct FabricGPU_Type
+{
+ void* fabricGPU;
+ void* factory;
+};
+
+struct ParametersStruct
+{
+
+ uint32_t physicalMeshId;
+ uint32_t numVertices;
+ F32_DynamicArray1D_Type deformableRestLengths;
+ U32_DynamicArray1D_Type deformableIndices;
+ U32_DynamicArray1D_Type selfCollisionIndices;
+ U32_DynamicArray1D_Type selfCollisionNormalIndices;
+ U32_DynamicArray1D_Type selfCollisionNormalSetSizes;
+ SetDesc_DynamicArray1D_Type deformableSets;
+ PhaseDesc_DynamicArray1D_Type deformablePhaseDescs;
+ U32_DynamicArray1D_Type tetherAnchors;
+ F32_DynamicArray1D_Type tetherLengths;
+ F32_DynamicArray1D_Type deformableInvVertexWeights;
+ U32_DynamicArray1D_Type virtualParticleIndices;
+ F32_DynamicArray1D_Type virtualParticleWeights;
+ uint32_t cookedDataVersion;
+ void* fabricCPU;
+ FabricGPU_DynamicArray1D_Type fabricGPU;
+ NvParameterized::Interface* nextCookedData;
+
+};
+
+static const uint32_t checksum[] = { 0x05292657, 0xc602622e, 0xa6989638, 0xf1f9e34f, };
+
+} // namespace ClothingCookedPhysX3ParamNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class ClothingCookedPhysX3Param : public NvParameterized::NvParameters, public ClothingCookedPhysX3ParamNS::ParametersStruct
+{
+public:
+ ClothingCookedPhysX3Param(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~ClothingCookedPhysX3Param();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("ClothingCookedPhysX3Param");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)5;
+
+ 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(ClothingCookedPhysX3ParamNS::checksum);
+ return ClothingCookedPhysX3ParamNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const ClothingCookedPhysX3ParamNS::ParametersStruct& parameters(void) const
+ {
+ ClothingCookedPhysX3Param* tmpThis = const_cast<ClothingCookedPhysX3Param*>(this);
+ return *(static_cast<ClothingCookedPhysX3ParamNS::ParametersStruct*>(tmpThis));
+ }
+
+ ClothingCookedPhysX3ParamNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<ClothingCookedPhysX3ParamNS::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 ClothingCookedPhysX3ParamFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ ClothingCookedPhysX3Param::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(ClothingCookedPhysX3Param), ClothingCookedPhysX3Param::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, ClothingCookedPhysX3Param::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingCookedPhysX3Param");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(ClothingCookedPhysX3Param)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, ClothingCookedPhysX3Param)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, ClothingCookedPhysX3Param::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, ClothingCookedPhysX3Param::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingCookedPhysX3Param");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of ClothingCookedPhysX3Param 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 (ClothingCookedPhysX3Param*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (ClothingCookedPhysX3Param::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (ClothingCookedPhysX3Param::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (ClothingCookedPhysX3Param::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (ClothingCookedPhysX3Param::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace clothing
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/clothing/include/autogen/ClothingDebugRenderParams.h b/APEX_1.4/module/clothing/include/autogen/ClothingDebugRenderParams.h
new file mode 100644
index 00000000..92a84a0e
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/autogen/ClothingDebugRenderParams.h
@@ -0,0 +1,270 @@
+// 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_ClothingDebugRenderParams_h
+#define HEADER_ClothingDebugRenderParams_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 clothing
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace ClothingDebugRenderParamsNS
+{
+
+
+
+struct ParametersStruct
+{
+
+ bool Actors;
+ float SkinnedPositions;
+ bool Backstop;
+ float BackstopPrecise;
+ bool MaxDistance;
+ bool MaxDistanceInwards;
+ bool SkinMapAll;
+ bool SkinMapBad;
+ bool SkinMapActual;
+ bool SkinMapInvalidBary;
+ float PhysicsMeshWire;
+ float PhysicsMeshSolid;
+ float PhysicsMeshNormals;
+ bool Skeleton;
+ float BoneFrames;
+ float BoneNames;
+ float Velocities;
+ float Wind;
+ bool GraphicalVertexBones;
+ bool PhysicalVertexBones;
+ bool CollisionShapes;
+ bool CollisionShapesWire;
+ bool LengthFibers;
+ bool CrossSectionFibers;
+ bool BendingFibers;
+ bool ShearingFibers;
+ bool ZerostretchFibers;
+ bool TethersActive;
+ bool TethersInactive;
+ bool VirtualCollision;
+ bool FiberRange;
+ bool ShowInLocalSpace;
+ bool GlobalPose;
+ bool RecomputeSubmeshes;
+ bool RecomputeVertices;
+ bool PhysicsMeshIndices;
+ bool MassScale;
+ bool SelfCollision;
+ bool SelfCollisionWire;
+ float SelfCollisionAttenuation;
+ bool SolverMode;
+
+};
+
+static const uint32_t checksum[] = { 0x0814367c, 0x9b811470, 0x122fd821, 0xd5717b8e, };
+
+} // namespace ClothingDebugRenderParamsNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class ClothingDebugRenderParams : public NvParameterized::NvParameters, public ClothingDebugRenderParamsNS::ParametersStruct
+{
+public:
+ ClothingDebugRenderParams(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~ClothingDebugRenderParams();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("ClothingDebugRenderParams");
+ }
+
+ 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(ClothingDebugRenderParamsNS::checksum);
+ return ClothingDebugRenderParamsNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const ClothingDebugRenderParamsNS::ParametersStruct& parameters(void) const
+ {
+ ClothingDebugRenderParams* tmpThis = const_cast<ClothingDebugRenderParams*>(this);
+ return *(static_cast<ClothingDebugRenderParamsNS::ParametersStruct*>(tmpThis));
+ }
+
+ ClothingDebugRenderParamsNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<ClothingDebugRenderParamsNS::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 ClothingDebugRenderParamsFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ ClothingDebugRenderParams::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(ClothingDebugRenderParams), ClothingDebugRenderParams::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, ClothingDebugRenderParams::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingDebugRenderParams");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(ClothingDebugRenderParams)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, ClothingDebugRenderParams)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, ClothingDebugRenderParams::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, ClothingDebugRenderParams::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingDebugRenderParams");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of ClothingDebugRenderParams 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 (ClothingDebugRenderParams*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (ClothingDebugRenderParams::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (ClothingDebugRenderParams::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (ClothingDebugRenderParams::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (ClothingDebugRenderParams::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace clothing
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/clothing/include/autogen/ClothingGraphicalLodParameters.h b/APEX_1.4/module/clothing/include/autogen/ClothingGraphicalLodParameters.h
new file mode 100644
index 00000000..596b8871
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/autogen/ClothingGraphicalLodParameters.h
@@ -0,0 +1,335 @@
+// 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_ClothingGraphicalLodParameters_h
+#define HEADER_ClothingGraphicalLodParameters_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 clothing
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace ClothingGraphicalLodParametersNS
+{
+
+struct SkinClothMapB_Type;
+struct SkinClothMapC_Type;
+struct SkinClothMapD_Type;
+struct TetraLink_Type;
+struct PhysicsMeshPartitioning_Type;
+
+struct STRING_DynamicArray1D_Type
+{
+ NvParameterized::DummyStringStruct* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct U32_DynamicArray1D_Type
+{
+ uint32_t* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct SkinClothMapB_DynamicArray1D_Type
+{
+ SkinClothMapB_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct SkinClothMapD_DynamicArray1D_Type
+{
+ SkinClothMapD_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct TetraLink_DynamicArray1D_Type
+{
+ TetraLink_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct PhysicsMeshPartitioning_DynamicArray1D_Type
+{
+ PhysicsMeshPartitioning_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct SkinClothMapC_Type
+{
+ physx::PxVec3 vertexBary;
+ uint32_t faceIndex0;
+ physx::PxVec3 normalBary;
+ uint32_t vertexIndexPlusOffset;
+};
+struct PhysicsMeshPartitioning_Type
+{
+ uint32_t graphicalSubmesh;
+ uint32_t numSimulatedVertices;
+ uint32_t numSimulatedVerticesAdditional;
+ uint32_t numSimulatedIndices;
+};
+struct SkinClothMapD_Type
+{
+ physx::PxVec3 vertexBary;
+ uint32_t vertexIndex0;
+ physx::PxVec3 normalBary;
+ uint32_t vertexIndex1;
+ physx::PxVec3 tangentBary;
+ uint32_t vertexIndex2;
+ uint32_t vertexIndexPlusOffset;
+};
+struct SkinClothMapB_Type
+{
+ physx::PxVec3 vtxTetraBary;
+ uint32_t vertexIndexPlusOffset;
+ physx::PxVec3 nrmTetraBary;
+ uint32_t faceIndex0;
+ uint32_t tetraIndex;
+ uint32_t submeshIndex;
+};
+struct TetraLink_Type
+{
+ physx::PxVec3 vertexBary;
+ uint32_t tetraIndex0;
+ physx::PxVec3 normalBary;
+ uint32_t _dummyForAlignment;
+};
+
+struct ParametersStruct
+{
+
+ STRING_DynamicArray1D_Type platforms;
+ uint32_t lod;
+ uint32_t physicalMeshId;
+ NvParameterized::Interface* renderMeshAsset;
+ void* renderMeshAssetPointer;
+ U32_DynamicArray1D_Type immediateClothMap;
+ SkinClothMapB_DynamicArray1D_Type skinClothMapB;
+ SkinClothMapD_DynamicArray1D_Type skinClothMap;
+ float skinClothMapThickness;
+ float skinClothMapOffset;
+ TetraLink_DynamicArray1D_Type tetraMap;
+ uint32_t renderMeshAssetSorting;
+ PhysicsMeshPartitioning_DynamicArray1D_Type physicsMeshPartitioning;
+
+};
+
+static const uint32_t checksum[] = { 0xb82a1fab, 0xfd43a015, 0x35b1be8a, 0x80ebc50f, };
+
+} // namespace ClothingGraphicalLodParametersNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class ClothingGraphicalLodParameters : public NvParameterized::NvParameters, public ClothingGraphicalLodParametersNS::ParametersStruct
+{
+public:
+ ClothingGraphicalLodParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~ClothingGraphicalLodParameters();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("ClothingGraphicalLodParameters");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)5;
+
+ 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(ClothingGraphicalLodParametersNS::checksum);
+ return ClothingGraphicalLodParametersNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const ClothingGraphicalLodParametersNS::ParametersStruct& parameters(void) const
+ {
+ ClothingGraphicalLodParameters* tmpThis = const_cast<ClothingGraphicalLodParameters*>(this);
+ return *(static_cast<ClothingGraphicalLodParametersNS::ParametersStruct*>(tmpThis));
+ }
+
+ ClothingGraphicalLodParametersNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<ClothingGraphicalLodParametersNS::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 ClothingGraphicalLodParametersFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ ClothingGraphicalLodParameters::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(ClothingGraphicalLodParameters), ClothingGraphicalLodParameters::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, ClothingGraphicalLodParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingGraphicalLodParameters");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(ClothingGraphicalLodParameters)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, ClothingGraphicalLodParameters)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, ClothingGraphicalLodParameters::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, ClothingGraphicalLodParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingGraphicalLodParameters");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of ClothingGraphicalLodParameters 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 (ClothingGraphicalLodParameters*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (ClothingGraphicalLodParameters::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (ClothingGraphicalLodParameters::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (ClothingGraphicalLodParameters::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (ClothingGraphicalLodParameters::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace clothing
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/clothing/include/autogen/ClothingMaterialLibraryParameters.h b/APEX_1.4/module/clothing/include/autogen/ClothingMaterialLibraryParameters.h
new file mode 100644
index 00000000..0edd6155
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/autogen/ClothingMaterialLibraryParameters.h
@@ -0,0 +1,277 @@
+// 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_ClothingMaterialLibraryParameters_h
+#define HEADER_ClothingMaterialLibraryParameters_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 clothing
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace ClothingMaterialLibraryParametersNS
+{
+
+struct StiffnessScaling_Type;
+struct ClothingMaterial_Type;
+
+struct ClothingMaterial_DynamicArray1D_Type
+{
+ ClothingMaterial_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct StiffnessScaling_Type
+{
+ float compressionRange;
+ float stretchRange;
+ float scale;
+};
+struct ClothingMaterial_Type
+{
+ NvParameterized::DummyStringStruct materialName;
+ float verticalStretchingStiffness;
+ float horizontalStretchingStiffness;
+ float bendingStiffness;
+ float shearingStiffness;
+ float tetherStiffness;
+ float tetherLimit;
+ bool orthoBending;
+ StiffnessScaling_Type verticalStiffnessScaling;
+ StiffnessScaling_Type horizontalStiffnessScaling;
+ StiffnessScaling_Type bendingStiffnessScaling;
+ StiffnessScaling_Type shearingStiffnessScaling;
+ float damping;
+ float stiffnessFrequency;
+ float drag;
+ bool comDamping;
+ float friction;
+ float massScale;
+ uint32_t solverIterations;
+ float solverFrequency;
+ float gravityScale;
+ float inertiaScale;
+ float hardStretchLimitation;
+ float maxDistanceBias;
+ uint32_t hierarchicalSolverIterations;
+ float selfcollisionThickness;
+ float selfcollisionSquashScale;
+ float selfcollisionStiffness;
+};
+
+struct ParametersStruct
+{
+
+ ClothingMaterial_DynamicArray1D_Type materials;
+
+};
+
+static const uint32_t checksum[] = { 0xf827ceb7, 0xd03d140a, 0x0c8ae038, 0x16333673, };
+
+} // namespace ClothingMaterialLibraryParametersNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class ClothingMaterialLibraryParameters : public NvParameterized::NvParameters, public ClothingMaterialLibraryParametersNS::ParametersStruct
+{
+public:
+ ClothingMaterialLibraryParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~ClothingMaterialLibraryParameters();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("ClothingMaterialLibraryParameters");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)14;
+
+ 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(ClothingMaterialLibraryParametersNS::checksum);
+ return ClothingMaterialLibraryParametersNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const ClothingMaterialLibraryParametersNS::ParametersStruct& parameters(void) const
+ {
+ ClothingMaterialLibraryParameters* tmpThis = const_cast<ClothingMaterialLibraryParameters*>(this);
+ return *(static_cast<ClothingMaterialLibraryParametersNS::ParametersStruct*>(tmpThis));
+ }
+
+ ClothingMaterialLibraryParametersNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<ClothingMaterialLibraryParametersNS::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 ClothingMaterialLibraryParametersFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ ClothingMaterialLibraryParameters::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(ClothingMaterialLibraryParameters), ClothingMaterialLibraryParameters::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, ClothingMaterialLibraryParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingMaterialLibraryParameters");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(ClothingMaterialLibraryParameters)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, ClothingMaterialLibraryParameters)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, ClothingMaterialLibraryParameters::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, ClothingMaterialLibraryParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingMaterialLibraryParameters");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of ClothingMaterialLibraryParameters 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 (ClothingMaterialLibraryParameters*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (ClothingMaterialLibraryParameters::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (ClothingMaterialLibraryParameters::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (ClothingMaterialLibraryParameters::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (ClothingMaterialLibraryParameters::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace clothing
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/clothing/include/autogen/ClothingModuleParameters.h b/APEX_1.4/module/clothing/include/autogen/ClothingModuleParameters.h
new file mode 100644
index 00000000..9f8142ed
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/autogen/ClothingModuleParameters.h
@@ -0,0 +1,240 @@
+// 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_ClothingModuleParameters_h
+#define HEADER_ClothingModuleParameters_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 clothing
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace ClothingModuleParametersNS
+{
+
+
+
+struct ParametersStruct
+{
+
+ uint32_t maxNumCompartments;
+ uint32_t maxUnusedPhysXResources;
+ bool allowAsyncCooking;
+ bool asyncFetchResults;
+ uint32_t avgSimFrequencyWindow;
+ bool allowApexWorkBetweenSubsteps;
+ float interCollisionDistance;
+ float interCollisionStiffness;
+ uint32_t interCollisionIterations;
+ bool sparseSelfCollision;
+ uint32_t maxTimeRenderProxyInPool;
+
+};
+
+static const uint32_t checksum[] = { 0x15043a9d, 0x77224355, 0x4c92d234, 0x3bbce77c, };
+
+} // namespace ClothingModuleParametersNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class ClothingModuleParameters : public NvParameterized::NvParameters, public ClothingModuleParametersNS::ParametersStruct
+{
+public:
+ ClothingModuleParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~ClothingModuleParameters();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("ClothingModuleParameters");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)1;
+
+ 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(ClothingModuleParametersNS::checksum);
+ return ClothingModuleParametersNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const ClothingModuleParametersNS::ParametersStruct& parameters(void) const
+ {
+ ClothingModuleParameters* tmpThis = const_cast<ClothingModuleParameters*>(this);
+ return *(static_cast<ClothingModuleParametersNS::ParametersStruct*>(tmpThis));
+ }
+
+ ClothingModuleParametersNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<ClothingModuleParametersNS::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 ClothingModuleParametersFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ ClothingModuleParameters::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(ClothingModuleParameters), ClothingModuleParameters::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, ClothingModuleParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingModuleParameters");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(ClothingModuleParameters)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, ClothingModuleParameters)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, ClothingModuleParameters::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, ClothingModuleParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingModuleParameters");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of ClothingModuleParameters 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 (ClothingModuleParameters*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (ClothingModuleParameters::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (ClothingModuleParameters::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (ClothingModuleParameters::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (ClothingModuleParameters::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace clothing
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/clothing/include/autogen/ClothingPhysicalMeshParameters.h b/APEX_1.4/module/clothing/include/autogen/ClothingPhysicalMeshParameters.h
new file mode 100644
index 00000000..0b282933
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/autogen/ClothingPhysicalMeshParameters.h
@@ -0,0 +1,373 @@
+// 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_ClothingPhysicalMeshParameters_h
+#define HEADER_ClothingPhysicalMeshParameters_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 clothing
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace ClothingPhysicalMeshParametersNS
+{
+
+struct SkinClothMapB_Type;
+struct SkinClothMapC_Type;
+struct SkinClothMapD_Type;
+struct TetraLink_Type;
+struct ConstrainCoefficient_Type;
+struct PhysicalMesh_Type;
+
+struct VEC3_DynamicArray1D_Type
+{
+ physx::PxVec3* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct ConstrainCoefficient_DynamicArray1D_Type
+{
+ ConstrainCoefficient_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct U16_DynamicArray1D_Type
+{
+ uint16_t* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct F32_DynamicArray1D_Type
+{
+ float* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct U8_DynamicArray1D_Type
+{
+ uint8_t* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct U32_DynamicArray1D_Type
+{
+ uint32_t* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct SkinClothMapB_DynamicArray1D_Type
+{
+ SkinClothMapB_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct SkinClothMapD_DynamicArray1D_Type
+{
+ SkinClothMapD_Type* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+struct SkinClothMapC_Type
+{
+ physx::PxVec3 vertexBary;
+ uint32_t faceIndex0;
+ physx::PxVec3 normalBary;
+ uint32_t vertexIndexPlusOffset;
+};
+struct ConstrainCoefficient_Type
+{
+ float maxDistance;
+ float collisionSphereRadius;
+ float collisionSphereDistance;
+};
+struct PhysicalMesh_Type
+{
+ uint32_t numVertices;
+ uint32_t numSimulatedVertices;
+ uint32_t numMaxDistance0Vertices;
+ uint32_t numIndices;
+ uint32_t numSimulatedIndices;
+ uint32_t numBonesPerVertex;
+ VEC3_DynamicArray1D_Type vertices;
+ VEC3_DynamicArray1D_Type normals;
+ VEC3_DynamicArray1D_Type skinningNormals;
+ ConstrainCoefficient_DynamicArray1D_Type constrainCoefficients;
+ U16_DynamicArray1D_Type boneIndices;
+ F32_DynamicArray1D_Type boneWeights;
+ U8_DynamicArray1D_Type optimizationData;
+ bool hasNegativeBackstop;
+ bool isClosed;
+ U32_DynamicArray1D_Type indices;
+ float maximumMaxDistance;
+ uint32_t physicalMeshSorting;
+ float shortestEdgeLength;
+ float averageEdgeLength;
+ bool isTetrahedralMesh;
+ bool flipNormals;
+};
+struct SkinClothMapD_Type
+{
+ physx::PxVec3 vertexBary;
+ uint32_t vertexIndex0;
+ physx::PxVec3 normalBary;
+ uint32_t vertexIndex1;
+ physx::PxVec3 tangentBary;
+ uint32_t vertexIndex2;
+ uint32_t vertexIndexPlusOffset;
+};
+struct SkinClothMapB_Type
+{
+ physx::PxVec3 vtxTetraBary;
+ uint32_t vertexIndexPlusOffset;
+ physx::PxVec3 nrmTetraBary;
+ uint32_t faceIndex0;
+ uint32_t tetraIndex;
+ uint32_t submeshIndex;
+};
+struct TetraLink_Type
+{
+ physx::PxVec3 vertexBary;
+ uint32_t tetraIndex0;
+ physx::PxVec3 normalBary;
+ uint32_t _dummyForAlignment;
+};
+
+struct ParametersStruct
+{
+
+ PhysicalMesh_Type physicalMesh;
+ SkinClothMapB_DynamicArray1D_Type transitionUpB;
+ SkinClothMapD_DynamicArray1D_Type transitionUp;
+ float transitionUpThickness;
+ float transitionUpOffset;
+ SkinClothMapB_DynamicArray1D_Type transitionDownB;
+ SkinClothMapD_DynamicArray1D_Type transitionDown;
+ float transitionDownThickness;
+ float transitionDownOffset;
+ uint32_t referenceCount;
+
+};
+
+static const uint32_t checksum[] = { 0x436eae3d, 0xbb86cc6f, 0xab9fa108, 0x26281bae, };
+
+} // namespace ClothingPhysicalMeshParametersNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class ClothingPhysicalMeshParameters : public NvParameterized::NvParameters, public ClothingPhysicalMeshParametersNS::ParametersStruct
+{
+public:
+ ClothingPhysicalMeshParameters(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~ClothingPhysicalMeshParameters();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("ClothingPhysicalMeshParameters");
+ }
+
+ const char* className(void) const
+ {
+ return(staticClassName());
+ }
+
+ static const uint32_t ClassVersion = ((uint32_t)0 << 16) + (uint32_t)11;
+
+ 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(ClothingPhysicalMeshParametersNS::checksum);
+ return ClothingPhysicalMeshParametersNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const ClothingPhysicalMeshParametersNS::ParametersStruct& parameters(void) const
+ {
+ ClothingPhysicalMeshParameters* tmpThis = const_cast<ClothingPhysicalMeshParameters*>(this);
+ return *(static_cast<ClothingPhysicalMeshParametersNS::ParametersStruct*>(tmpThis));
+ }
+
+ ClothingPhysicalMeshParametersNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<ClothingPhysicalMeshParametersNS::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 ClothingPhysicalMeshParametersFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ ClothingPhysicalMeshParameters::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(ClothingPhysicalMeshParameters), ClothingPhysicalMeshParameters::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, ClothingPhysicalMeshParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingPhysicalMeshParameters");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(ClothingPhysicalMeshParameters)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, ClothingPhysicalMeshParameters)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, ClothingPhysicalMeshParameters::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, ClothingPhysicalMeshParameters::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingPhysicalMeshParameters");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of ClothingPhysicalMeshParameters 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 (ClothingPhysicalMeshParameters*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (ClothingPhysicalMeshParameters::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (ClothingPhysicalMeshParameters::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (ClothingPhysicalMeshParameters::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (ClothingPhysicalMeshParameters::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace clothing
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/clothing/include/autogen/ClothingPreviewParam.h b/APEX_1.4/module/clothing/include/autogen/ClothingPreviewParam.h
new file mode 100644
index 00000000..a6b2093c
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/autogen/ClothingPreviewParam.h
@@ -0,0 +1,243 @@
+// 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_ClothingPreviewParam_h
+#define HEADER_ClothingPreviewParam_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 clothing
+{
+
+#if PX_VC
+#pragma warning(push)
+#pragma warning(disable: 4324) // structure was padded due to __declspec(align())
+#endif
+
+namespace ClothingPreviewParamNS
+{
+
+
+struct MAT44_DynamicArray1D_Type
+{
+ physx::PxMat44* buf;
+ bool isAllocated;
+ int32_t elementSize;
+ int32_t arraySizes[1];
+};
+
+
+struct ParametersStruct
+{
+
+ physx::PxMat44 globalPose;
+ bool fallbackSkinning;
+ bool useInternalBoneOrder;
+ bool updateStateWithGlobalMatrices;
+ uint64_t userData;
+ MAT44_DynamicArray1D_Type boneMatrices;
+
+};
+
+static const uint32_t checksum[] = { 0x614ffe9f, 0x273131aa, 0xa5bdd27c, 0xfe7fba5b, };
+
+} // namespace ClothingPreviewParamNS
+
+#ifndef NV_PARAMETERIZED_ONLY_LAYOUTS
+class ClothingPreviewParam : public NvParameterized::NvParameters, public ClothingPreviewParamNS::ParametersStruct
+{
+public:
+ ClothingPreviewParam(NvParameterized::Traits* traits, void* buf = 0, int32_t* refCount = 0);
+
+ virtual ~ClothingPreviewParam();
+
+ virtual void destroy();
+
+ static const char* staticClassName(void)
+ {
+ return("ClothingPreviewParam");
+ }
+
+ 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(ClothingPreviewParamNS::checksum);
+ return ClothingPreviewParamNS::checksum;
+ }
+
+ static void freeParameterDefinitionTable(NvParameterized::Traits* traits);
+
+ const uint32_t* checksum(uint32_t& bits) const
+ {
+ return staticChecksum(bits);
+ }
+
+ const ClothingPreviewParamNS::ParametersStruct& parameters(void) const
+ {
+ ClothingPreviewParam* tmpThis = const_cast<ClothingPreviewParam*>(this);
+ return *(static_cast<ClothingPreviewParamNS::ParametersStruct*>(tmpThis));
+ }
+
+ ClothingPreviewParamNS::ParametersStruct& parameters(void)
+ {
+ return *(static_cast<ClothingPreviewParamNS::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 ClothingPreviewParamFactory : public NvParameterized::Factory
+{
+ static const char* const vptr;
+
+public:
+
+ virtual void freeParameterDefinitionTable(NvParameterized::Traits* traits)
+ {
+ ClothingPreviewParam::freeParameterDefinitionTable(traits);
+ }
+
+ virtual NvParameterized::Interface* create(NvParameterized::Traits* paramTraits)
+ {
+ // placement new on this class using mParameterizedTraits
+
+ void* newPtr = paramTraits->alloc(sizeof(ClothingPreviewParam), ClothingPreviewParam::ClassAlignment);
+ if (!NvParameterized::IsAligned(newPtr, ClothingPreviewParam::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingPreviewParam");
+ paramTraits->free(newPtr);
+ return 0;
+ }
+
+ memset(newPtr, 0, sizeof(ClothingPreviewParam)); // always initialize memory allocated to zero for default values
+ return NV_PARAM_PLACEMENT_NEW(newPtr, ClothingPreviewParam)(paramTraits);
+ }
+
+ virtual NvParameterized::Interface* finish(NvParameterized::Traits* paramTraits, void* bufObj, void* bufStart, int32_t* refCount)
+ {
+ if (!NvParameterized::IsAligned(bufObj, ClothingPreviewParam::ClassAlignment)
+ || !NvParameterized::IsAligned(bufStart, ClothingPreviewParam::ClassAlignment))
+ {
+ NV_PARAM_TRAITS_WARNING(paramTraits, "Unaligned memory allocation for class ClothingPreviewParam");
+ return 0;
+ }
+
+ // Init NvParameters-part
+ // We used to call empty constructor of ClothingPreviewParam 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 (ClothingPreviewParam*)bufObj;
+ }
+
+ virtual const char* getClassName()
+ {
+ return (ClothingPreviewParam::staticClassName());
+ }
+
+ virtual uint32_t getVersion()
+ {
+ return (ClothingPreviewParam::staticVersion());
+ }
+
+ virtual uint32_t getAlignment()
+ {
+ return (ClothingPreviewParam::ClassAlignment);
+ }
+
+ virtual const uint32_t* getChecksum(uint32_t& bits)
+ {
+ return (ClothingPreviewParam::staticChecksum(bits));
+ }
+};
+#endif // NV_PARAMETERIZED_ONLY_LAYOUTS
+
+} // namespace clothing
+} // namespace nvidia
+
+#if PX_VC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/APEX_1.4/module/clothing/include/autogen/ModuleClothingRegistration.h b/APEX_1.4/module/clothing/include/autogen/ModuleClothingRegistration.h
new file mode 100644
index 00000000..4e8a5605
--- /dev/null
+++ b/APEX_1.4/module/clothing/include/autogen/ModuleClothingRegistration.h
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
+ *
+ * NVIDIA CORPORATION and its licensors retain all intellectual property
+ * and proprietary rights in and to this software, related documentation
+ * and any modifications thereto. Any use, reproduction, disclosure or
+ * distribution of this software and related documentation without an express
+ * license agreement from NVIDIA CORPORATION is strictly prohibited.
+ */
+
+#ifndef MODULE_MODULECLOTHINGREGISTRATIONH_H
+#define MODULE_MODULECLOTHINGREGISTRATIONH_H
+
+#include "PsAllocator.h"
+#include "NvRegistrationsForTraitsBase.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "PxAssert.h"
+#include <stdint.h>
+
+// INCLUDE GENERATED FACTORIES
+#include "ClothingActorParam.h"
+#include "ClothingAssetParameters.h"
+#include "ClothingCookedParam.h"
+#include "ClothingCookedPhysX3Param.h"
+#include "ClothingDebugRenderParams.h"
+#include "ClothingGraphicalLodParameters.h"
+#include "ClothingMaterialLibraryParameters.h"
+#include "ClothingModuleParameters.h"
+#include "ClothingPhysicalMeshParameters.h"
+#include "ClothingPreviewParam.h"
+
+
+// INCLUDE GENERATED CONVERSION
+
+
+namespace nvidia {
+namespace clothing {
+
+
+class ModuleClothingRegistration : public NvParameterized::RegistrationsForTraitsBase
+{
+public:
+ static void invokeRegistration(NvParameterized::Traits* parameterizedTraits)
+ {
+ if (parameterizedTraits)
+ {
+ ModuleClothingRegistration().registerAll(*parameterizedTraits);
+ }
+ }
+
+ static void invokeUnregistration(NvParameterized::Traits* parameterizedTraits)
+ {
+ if (parameterizedTraits)
+ {
+ ModuleClothingRegistration().unregisterAll(*parameterizedTraits);
+ }
+ }
+
+ void registerAvailableFactories(NvParameterized::Traits& parameterizedTraits)
+ {
+ ::NvParameterized::Factory* factoriesToRegister[] = {
+// REGISTER GENERATED FACTORIES
+ new nvidia::clothing::ClothingActorParamFactory(),
+ new nvidia::clothing::ClothingAssetParametersFactory(),
+ new nvidia::clothing::ClothingCookedParamFactory(),
+ new nvidia::clothing::ClothingCookedPhysX3ParamFactory(),
+ new nvidia::clothing::ClothingDebugRenderParamsFactory(),
+ new nvidia::clothing::ClothingGraphicalLodParametersFactory(),
+ new nvidia::clothing::ClothingMaterialLibraryParametersFactory(),
+ new nvidia::clothing::ClothingModuleParametersFactory(),
+ new nvidia::clothing::ClothingPhysicalMeshParametersFactory(),
+ new nvidia::clothing::ClothingPreviewParamFactory(),
+
+ };
+
+ 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::clothing::ClothingActorParamFactory(),
+ new nvidia::clothing::ClothingAssetParametersFactory(),
+ new nvidia::clothing::ClothingCookedParamFactory(),
+ new nvidia::clothing::ClothingCookedPhysX3ParamFactory(),
+ new nvidia::clothing::ClothingDebugRenderParamsFactory(),
+ new nvidia::clothing::ClothingGraphicalLodParametersFactory(),
+ new nvidia::clothing::ClothingMaterialLibraryParametersFactory(),
+ new nvidia::clothing::ClothingModuleParametersFactory(),
+ new nvidia::clothing::ClothingPhysicalMeshParametersFactory(),
+ new nvidia::clothing::ClothingPreviewParamFactory(),
+
+ };
+
+ 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::clothing
+
+#endif