23PhysxMeshPool::ConvexMeshes PhysxMeshPool::_convex_meshes;
24PhysxMeshPool::TriangleMeshes PhysxMeshPool::_triangle_meshes;
25PhysxMeshPool::ClothMeshes PhysxMeshPool::_cloth_meshes;
26PhysxMeshPool::SoftbodyMeshes PhysxMeshPool::_softbody_meshes;
35 physx_cat.error() <<
"File does not exists: " << fn << std::endl;
40 physx_cat.error() <<
"Not a regular file: " << fn << std::endl;
51load_convex_mesh(
const Filename &fn) {
53 if (!check_filename(fn))
return nullptr;
55 PhysxConvexMesh *mesh;
57 ConvexMeshes::iterator it = _convex_meshes.find(fn);
58 if (it == _convex_meshes.end()) {
60 NxConvexMesh *meshPtr;
61 PhysxFileStream stream = PhysxFileStream(fn,
true);
63 mesh =
new PhysxConvexMesh();
64 nassertr_always(mesh,
nullptr);
66 NxPhysicsSDK *sdk = NxGetPhysicsSDK();
67 nassertr_always(sdk,
nullptr);
69 meshPtr = sdk->createConvexMesh(stream);
70 nassertr_always(meshPtr,
nullptr);
74 _convex_meshes.insert(ConvexMeshes::value_type(fn, mesh));
88load_triangle_mesh(
const Filename &fn) {
90 if (!check_filename(fn))
return nullptr;
92 PhysxTriangleMesh *mesh;
94 TriangleMeshes::iterator it = _triangle_meshes.find(fn);
95 if (it == _triangle_meshes.end()) {
97 NxTriangleMesh *meshPtr;
98 PhysxFileStream stream = PhysxFileStream(fn,
true);
100 mesh =
new PhysxTriangleMesh();
101 nassertr_always(mesh,
nullptr);
103 NxPhysicsSDK *sdk = NxGetPhysicsSDK();
104 nassertr_always(sdk,
nullptr);
106 meshPtr = sdk->createTriangleMesh(stream);
107 nassertr_always(meshPtr,
nullptr);
111 _triangle_meshes.insert(TriangleMeshes::value_type(fn, mesh));
125load_cloth_mesh(
const Filename &fn) {
127 if (!check_filename(fn))
return nullptr;
129 PhysxClothMesh *mesh;
131 ClothMeshes::iterator it = _cloth_meshes.find(fn);
132 if (it == _cloth_meshes.end()) {
134 NxClothMesh *meshPtr;
135 PhysxFileStream stream = PhysxFileStream(fn,
true);
137 mesh =
new PhysxClothMesh();
138 nassertr_always(mesh,
nullptr);
140 NxPhysicsSDK *sdk = NxGetPhysicsSDK();
141 nassertr_always(sdk,
nullptr);
143 meshPtr = sdk->createClothMesh(stream);
144 nassertr_always(meshPtr,
nullptr);
148 _cloth_meshes.insert(ClothMeshes::value_type(fn, mesh));
162load_soft_body_mesh(
const Filename &fn) {
164 if (!check_filename(fn))
return nullptr;
166 PhysxSoftBodyMesh *mesh;
168 SoftbodyMeshes::iterator it = _softbody_meshes.find(fn);
169 if (it == _softbody_meshes.end()) {
171 NxSoftBodyMesh *meshPtr;
172 PhysxFileStream stream = PhysxFileStream(fn,
true);
174 mesh =
new PhysxSoftBodyMesh();
175 nassertr_always(mesh,
nullptr);
177 NxPhysicsSDK *sdk = NxGetPhysicsSDK();
178 nassertr_always(sdk,
nullptr);
180 meshPtr = sdk->createSoftBodyMesh(stream);
181 nassertr_always(meshPtr,
nullptr);
185 _softbody_meshes.insert(SoftbodyMeshes::value_type(fn, mesh));
201 ConvexMeshes::iterator it;
202 for (it=_convex_meshes.begin(); it != _convex_meshes.end(); ++it) {
203 if (mesh == (*it).second) {
204 _convex_meshes.erase(it);
218 TriangleMeshes::iterator it;
219 for (it=_triangle_meshes.begin(); it != _triangle_meshes.end(); ++it) {
220 if (mesh == (*it).second) {
221 _triangle_meshes.erase(it);
235 ClothMeshes::iterator it;
236 for (it=_cloth_meshes.begin(); it != _cloth_meshes.end(); ++it) {
237 if (mesh == (*it).second) {
238 _cloth_meshes.erase(it);
252 SoftbodyMeshes::iterator it;
253 for (it=_softbody_meshes.begin(); it != _softbody_meshes.end(); ++it) {
254 if (mesh == (*it).second) {
255 _softbody_meshes.erase(it);
275list_contents(std::ostream &out) {
277 out <<
"PhysX mesh pool contents:\n";
281 ConvexMeshes::const_iterator it;
282 for (it=_convex_meshes.begin(); it != _convex_meshes.end(); ++it) {
283 Filename fn = (*it).first;
284 PhysxConvexMesh *mesh = (*it).second;
287 <<
" (convex mesh, " << mesh->ptr()->getReferenceCount()
288 <<
" references)" << std::endl;
294 TriangleMeshes::const_iterator it;
295 for (it=_triangle_meshes.begin(); it != _triangle_meshes.end(); ++it) {
296 Filename fn = (*it).first;
297 PhysxTriangleMesh *mesh = (*it).second;
300 <<
" (triangle mesh, " << mesh->ptr()->getReferenceCount()
307 ClothMeshes::const_iterator it;
308 for (it=_cloth_meshes.begin(); it != _cloth_meshes.end(); ++it) {
309 Filename fn = (*it).first;
310 PhysxClothMesh *mesh = (*it).second;
313 <<
" (cloth mesh, " << mesh->ptr()->getReferenceCount()
320 SoftbodyMeshes::const_iterator it;
321 for (it=_softbody_meshes.begin(); it != _softbody_meshes.end(); ++it) {
322 Filename fn = (*it).first;
323 PhysxSoftBodyMesh *mesh = (*it).second;
326 <<
" (soft body mesh, " << mesh->ptr()->getReferenceCount()
332 NxPhysicsSDK *sdk = NxGetPhysicsSDK();
334 out <<
" Total number of convex meshes: " << sdk->getNbConvexMeshes()
335 <<
" created, " << _convex_meshes.size() <<
" registred\n";
337 out <<
" Total number of triangle meshes: " << sdk->getNbTriangleMeshes()
338 <<
" created, " << _triangle_meshes.size() <<
" registred\n";
340 out <<
" Total number of cloth meshes: " << sdk->getNbClothMeshes()
341 <<
" created, " << _cloth_meshes.size() <<
" registred\n";
343 out <<
" Total number of soft body meshes: " << sdk->getNbSoftBodyMeshes()
344 <<
" created, " << _softbody_meshes.size() <<
" registred\n";
The name of a file, such as a texture file or an Egg file.
std::string get_fullpath() const
Returns the entire filename: directory, basename, extension.
static VirtualFileSystem * get_global_ptr()
Returns the default global VirtualFileSystem.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.