diff --git a/panda/src/physx/config_physx.cxx b/panda/src/physx/config_physx.cxx index 072145ca42..92a8ab5038 100644 --- a/panda/src/physx/config_physx.cxx +++ b/panda/src/physx/config_physx.cxx @@ -22,7 +22,6 @@ #include "physxCapsuleController.h" #include "physxCapsuleForceFieldShape.h" #include "physxCapsuleShape.h" -#include "physxClothMesh.h" #include "physxContactPair.h" #include "physxContactPoint.h" #include "physxController.h" @@ -59,6 +58,10 @@ #include "physxWheel.h" #include "physxWheelShape.h" +#if NX_USE_CLOTH_API +#include "physxClothMesh.h" +#endif + ConfigureDef(config_physx); NotifyCategoryDef(physx, ""); @@ -118,7 +121,6 @@ init_libphysx() { PhysxCapsuleController::init_type(); PhysxCapsuleForceFieldShape::init_type(); PhysxCapsuleShape::init_type(); - PhysxClothMesh::init_type(); PhysxContactPair::init_type(); PhysxContactPoint::init_type(); PhysxController::init_type(); @@ -155,6 +157,10 @@ init_libphysx() { PhysxWheel::init_type(); PhysxWheelShape::init_type(); +#if NX_USE_CLOTH_API + PhysxClothMesh::init_type(); +#endif + PandaSystem *ps = PandaSystem::get_global_ptr(); ps->add_system("PhysX"); } diff --git a/panda/src/physx/physxClothMesh.cxx b/panda/src/physx/physxClothMesh.cxx index 242bf75d5c..85f2a8f746 100644 --- a/panda/src/physx/physxClothMesh.cxx +++ b/panda/src/physx/physxClothMesh.cxx @@ -15,6 +15,8 @@ #include "physxClothMesh.h" #include "physxMeshPool.h" +#if NX_USE_CLOTH_API + TypeHandle PhysxClothMesh::_type_handle; //////////////////////////////////////////////////////////////////// @@ -74,3 +76,5 @@ get_reference_count() const { return _ptr->getReferenceCount(); } +#endif + diff --git a/panda/src/physx/physxClothMesh.h b/panda/src/physx/physxClothMesh.h index bf96fa7ab5..dbd90fbe56 100644 --- a/panda/src/physx/physxClothMesh.h +++ b/panda/src/physx/physxClothMesh.h @@ -20,6 +20,7 @@ #include "physxObject.h" #include "physx_includes.h" +#if NX_USE_CLOTH_API //////////////////////////////////////////////////////////////////// // Class : PhysxClothMesh // Description : @@ -71,5 +72,6 @@ private: }; #include "physxClothMesh.I" +#endif #endif // PHYSXCLOTHMESH_H diff --git a/panda/src/physx/physxClothMeshDesc.cxx b/panda/src/physx/physxClothMeshDesc.cxx index b7aa3c4a91..c9a61d637f 100644 --- a/panda/src/physx/physxClothMeshDesc.cxx +++ b/panda/src/physx/physxClothMeshDesc.cxx @@ -19,6 +19,8 @@ #include "geomNode.h" #include "geomVertexReader.h" +#if NX_USE_CLOTH_API + //////////////////////////////////////////////////////////////////// // Function: PhysxClothMeshDesc::set_num_vertices // Access: Published @@ -221,3 +223,5 @@ set_from_node_path(const NodePath &np) { _desc.triangles = _triangles; } +#endif + diff --git a/panda/src/physx/physxClothMeshDesc.h b/panda/src/physx/physxClothMeshDesc.h index 536170578a..78829d603a 100644 --- a/panda/src/physx/physxClothMeshDesc.h +++ b/panda/src/physx/physxClothMeshDesc.h @@ -22,6 +22,7 @@ #include "physx_includes.h" +#if NX_USE_CLOTH_API //////////////////////////////////////////////////////////////////// // Class : PhysxClothMeshDesc // Description : @@ -53,5 +54,6 @@ private: }; #include "physxClothMeshDesc.I" +#endif #endif // PHYSXCLOTHMESHDESC_H diff --git a/panda/src/physx/physxKitchen.cxx b/panda/src/physx/physxKitchen.cxx index 1472abf1bb..708761d022 100644 --- a/panda/src/physx/physxKitchen.cxx +++ b/panda/src/physx/physxKitchen.cxx @@ -17,12 +17,15 @@ #include "physxConvexMeshDesc.h" #include "physxTriangleMesh.h" #include "physxTriangleMeshDesc.h" -#include "physxClothMesh.h" -#include "physxClothMeshDesc.h" #include "physxFileStream.h" #include "physxMemoryReadBuffer.h" #include "physxMemoryWriteBuffer.h" +#if NX_USE_CLOTH_API +#include "physxClothMesh.h" +#include "physxClothMeshDesc.h" +#endif + //////////////////////////////////////////////////////////////////// // Function: PhysxKitchen::set_cooking_params // Access: Published @@ -85,6 +88,7 @@ cook_triangle_mesh(const PhysxTriangleMeshDesc &meshDesc, const Filename &filena return _cooking->NxCookTriangleMesh(meshDesc.get_desc(), stream); } +#if NX_USE_CLOTH_API //////////////////////////////////////////////////////////////////// // Function: PhysxKitchen::cook_cloth_mesh // Access: Published @@ -93,6 +97,7 @@ cook_triangle_mesh(const PhysxTriangleMeshDesc &meshDesc, const Filename &filena bool PhysxKitchen:: cook_cloth_mesh(const PhysxClothMeshDesc &meshDesc, const Filename &filename) { + nassertr_always(!filename.empty(), false); nassertr_always(filename.touch(), false); nassertr_always(meshDesc.is_valid(), false); @@ -100,6 +105,7 @@ cook_cloth_mesh(const PhysxClothMeshDesc &meshDesc, const Filename &filename) { PhysxFileStream stream = PhysxFileStream(filename, false); return _cooking->NxCookClothMesh(meshDesc.get_desc(), stream); } +#endif //////////////////////////////////////////////////////////////////// // Function: PhysxKitchen::cook_convex_mesh @@ -157,6 +163,7 @@ cook_triangle_mesh(const PhysxTriangleMeshDesc &meshDesc) { return mesh; } +#if NX_USE_CLOTH_API //////////////////////////////////////////////////////////////////// // Function: PhysxKitchen::cook_cloth_mesh // Access: Published @@ -184,4 +191,5 @@ cook_cloth_mesh(const PhysxClothMeshDesc &meshDesc) { return mesh; } +#endif diff --git a/panda/src/physx/physxKitchen.h b/panda/src/physx/physxKitchen.h index bc601f1754..174cd5326e 100644 --- a/panda/src/physx/physxKitchen.h +++ b/panda/src/physx/physxKitchen.h @@ -24,8 +24,11 @@ class PhysxConvexMesh; class PhysxConvexMeshDesc; class PhysxTriangleMesh; class PhysxTriangleMeshDesc; + +#if NX_USE_CLOTH_API class PhysxClothMesh; class PhysxClothMeshDesc; +#endif //////////////////////////////////////////////////////////////////// // Class : PhysxKitchen @@ -40,12 +43,15 @@ PUBLISHED: void set_cooking_params(float skinWidth, bool hintCollisionSpeed); bool cook_convex_mesh(const PhysxConvexMeshDesc &meshDesc, const Filename &filename); - bool cook_triangle_mesh(const PhysxTriangleMeshDesc &meshDesc, const Filename &filename); - bool cook_cloth_mesh(const PhysxClothMeshDesc &meshDesc, const Filename &filename); - PhysxConvexMesh *cook_convex_mesh(const PhysxConvexMeshDesc &meshDesc); + + bool cook_triangle_mesh(const PhysxTriangleMeshDesc &meshDesc, const Filename &filename); PhysxTriangleMesh *cook_triangle_mesh(const PhysxTriangleMeshDesc &meshDesc); + +#if NX_USE_CLOTH_API + bool cook_cloth_mesh(const PhysxClothMeshDesc &meshDesc, const Filename &filename); PhysxClothMesh *cook_cloth_mesh(const PhysxClothMeshDesc &meshDesc); +#endif private: NxCookingInterface *_cooking; diff --git a/panda/src/physx/physxManager.cxx b/panda/src/physx/physxManager.cxx index b775962379..434f6f8b25 100644 --- a/panda/src/physx/physxManager.cxx +++ b/panda/src/physx/physxManager.cxx @@ -271,6 +271,7 @@ get_triangle_mesh(unsigned int idx) { return (PhysxTriangleMesh *)_triangle_meshes[idx]; } +#if NX_USE_CLOTH_API //////////////////////////////////////////////////////////////////// // Function: PhysxManager::get_num_cloth_meshes // Access: Published @@ -294,6 +295,7 @@ get_cloth_mesh(unsigned int idx) { return (PhysxClothMesh *)_cloth_meshes[idx]; } +#endif //////////////////////////////////////////////////////////////////// // Function: PhysxManager::is_hardware_available diff --git a/panda/src/physx/physxManager.h b/panda/src/physx/physxManager.h index ae7fb5b936..f68322b6e3 100644 --- a/panda/src/physx/physxManager.h +++ b/panda/src/physx/physxManager.h @@ -71,9 +71,11 @@ PUBLISHED: PhysxTriangleMesh *get_triangle_mesh(unsigned int idx); MAKE_SEQ(get_triangle_meshes, get_num_triangle_meshes, get_triangle_mesh); +#if NX_USE_CLOTH_API unsigned int get_num_cloth_meshes(); PhysxClothMesh *get_cloth_mesh(unsigned int idx); MAKE_SEQ(get_cloth_meshes, get_num_cloth_meshes, get_cloth_mesh); +#endif INLINE void ls() const; INLINE void ls(ostream &out, int indent_level=0) const; @@ -85,7 +87,10 @@ public: PhysxObjectCollection _heightfields; PhysxObjectCollection _convex_meshes; PhysxObjectCollection _triangle_meshes; + +#if NX_USE_CLOTH_API PhysxObjectCollection _cloth_meshes; +#endif INLINE static NxVec3 vec3_to_nxVec3(const LVector3f &v); INLINE static LVector3f nxVec3_to_vec3(const NxVec3 &v); diff --git a/panda/src/physx/physxMeshPool.cxx b/panda/src/physx/physxMeshPool.cxx index 301fc46573..b56918e26a 100644 --- a/panda/src/physx/physxMeshPool.cxx +++ b/panda/src/physx/physxMeshPool.cxx @@ -15,13 +15,21 @@ #include "physxMeshPool.h" #include "physxConvexMesh.h" #include "physxTriangleMesh.h" + +#if NX_USE_CLOTH_API #include "physxClothMesh.h" +#endif + #include "physxFileStream.h" #include "virtualFileSystem.h" PhysxMeshPool::ConvexMeshes PhysxMeshPool::_convex_meshes; PhysxMeshPool::TriangleMeshes PhysxMeshPool::_triangle_meshes; + +#if NX_USE_CLOTH_API PhysxMeshPool::ClothMeshes PhysxMeshPool::_cloth_meshes; +#endif + //PhysxMeshPool::SoftbodyMeshes PhysxMeshPool::_softbody_meshes; //////////////////////////////////////////////////////////////////// @@ -123,6 +131,7 @@ load_triangle_mesh(const Filename &fn) { return mesh; } +#if NX_USE_CLOTH_API //////////////////////////////////////////////////////////////////// // Function: PhysxMeshPool::load_cloth_mesh // Access: Published @@ -161,6 +170,7 @@ load_cloth_mesh(const Filename &fn) { return mesh; } +#endif //////////////////////////////////////////////////////////////////// // Function: PhysxMeshPool::release_convex_mesh @@ -200,6 +210,7 @@ release_triangle_mesh(PhysxTriangleMesh *mesh) { return false; } +#if NX_USE_CLOTH_API //////////////////////////////////////////////////////////////////// // Function: PhysxMeshPool::release_cloth_mesh // Access: Published @@ -218,6 +229,7 @@ release_cloth_mesh(PhysxClothMesh *mesh) { return false; } +#endif //////////////////////////////////////////////////////////////////// // Function: PhysxMeshPool::list_content @@ -265,6 +277,7 @@ list_contents(ostream &out) { } } +#if NX_USE_CLOTH_API // Cloth meshes { ClothMeshes::const_iterator it; @@ -277,6 +290,7 @@ list_contents(ostream &out) { << " references)\n"; } } +#endif // Summary NxPhysicsSDK *sdk = NxGetPhysicsSDK(); @@ -287,7 +301,9 @@ list_contents(ostream &out) { out << " Total number of triangle meshes: " << sdk->getNbTriangleMeshes() << " created, " << _triangle_meshes.size() << " registred\n"; +#if NX_USE_CLOTH_API out << " Total number of cloth meshes: " << sdk->getNbClothMeshes() << " created, " << _cloth_meshes.size() << " registred\n"; +#endif } diff --git a/panda/src/physx/physxMeshPool.h b/panda/src/physx/physxMeshPool.h index abd9022405..16f6b1783d 100644 --- a/panda/src/physx/physxMeshPool.h +++ b/panda/src/physx/physxMeshPool.h @@ -25,7 +25,10 @@ class PhysxConvexMesh; class PhysxTriangleMesh; + +#if NX_USE_CLOTH_API class PhysxClothMesh; +#endif //////////////////////////////////////////////////////////////////// // Class : PhysxMeshPool @@ -43,12 +46,16 @@ PUBLISHED: static PhysxConvexMesh *load_convex_mesh(const Filename &filename); static PhysxTriangleMesh *load_triangle_mesh(const Filename &filename); +#if NX_USE_CLOTH_API static PhysxClothMesh *load_cloth_mesh(const Filename &filename); +#endif //static PhysxSoftBodyMesh *load_softbody_mesh(const Filename &filename); static bool release_convex_mesh(PhysxConvexMesh *mesh); static bool release_triangle_mesh(PhysxTriangleMesh *mesh); +#if NX_USE_CLOTH_API static bool release_cloth_mesh(PhysxClothMesh *mesh); +#endif //static bool release_softbody_mesh(PhysxSoftBodyMesh *mesh); static void list_contents(); @@ -58,13 +65,17 @@ private: static bool check_filename(const Filename &fn); typedef pmap ConvexMeshes; - typedef pmap TriangleMeshes; - typedef pmap ClothMeshes; - //typedef pmap SoftbodyMeshes; - static ConvexMeshes _convex_meshes; + + typedef pmap TriangleMeshes; static TriangleMeshes _triangle_meshes; + +#if NX_USE_CLOTH_API + typedef pmap ClothMeshes; static ClothMeshes _cloth_meshes; +#endif + + //typedef pmap SoftbodyMeshes; //static SoftbodyMeshes _softbody_meshes; }; diff --git a/panda/src/physx/physx_composite.cxx b/panda/src/physx/physx_composite.cxx index fd7fa4163d..4dd14356ed 100644 --- a/panda/src/physx/physx_composite.cxx +++ b/panda/src/physx/physx_composite.cxx @@ -112,6 +112,5 @@ #include "physxWheelDesc.cxx" #include "physxWheelShape.cxx" #include "physxWheelShapeDesc.cxx" - #include "physxClothMesh.cxx" #include "physxClothMeshDesc.cxx"