aboutsummaryrefslogtreecommitdiff
path: root/APEX_1.4/module/clothing/include/ModuleClothingImpl.h
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/ModuleClothingImpl.h
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/ModuleClothingImpl.h')
-rw-r--r--APEX_1.4/module/clothing/include/ModuleClothingImpl.h268
1 files changed, 268 insertions, 0 deletions
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