Define cloth classes/methods only if PhysX cloth API is defined (Not yet tested).

This commit is contained in:
enn0x 2010-03-28 19:01:03 +00:00
parent 3d82f01530
commit b7eb84762f
12 changed files with 77 additions and 12 deletions

View File

@ -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");
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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<PhysxHeightField> _heightfields;
PhysxObjectCollection<PhysxConvexMesh> _convex_meshes;
PhysxObjectCollection<PhysxTriangleMesh> _triangle_meshes;
#if NX_USE_CLOTH_API
PhysxObjectCollection<PhysxClothMesh> _cloth_meshes;
#endif
INLINE static NxVec3 vec3_to_nxVec3(const LVector3f &v);
INLINE static LVector3f nxVec3_to_vec3(const NxVec3 &v);

View File

@ -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
}

View File

@ -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<Filename, PT(PhysxConvexMesh)> ConvexMeshes;
typedef pmap<Filename, PT(PhysxTriangleMesh)> TriangleMeshes;
typedef pmap<Filename, PT(PhysxClothMesh)> ClothMeshes;
//typedef pmap<Filename, PT(PhysxSoftBodyMesh)> SoftbodyMeshes;
static ConvexMeshes _convex_meshes;
typedef pmap<Filename, PT(PhysxTriangleMesh)> TriangleMeshes;
static TriangleMeshes _triangle_meshes;
#if NX_USE_CLOTH_API
typedef pmap<Filename, PT(PhysxClothMesh)> ClothMeshes;
static ClothMeshes _cloth_meshes;
#endif
//typedef pmap<Filename, PT(PhysxSoftBodyMesh)> SoftbodyMeshes;
//static SoftbodyMeshes _softbody_meshes;
};

View File

@ -112,6 +112,5 @@
#include "physxWheelDesc.cxx"
#include "physxWheelShape.cxx"
#include "physxWheelShapeDesc.cxx"
#include "physxClothMesh.cxx"
#include "physxClothMeshDesc.cxx"