Panda3D
 All Classes Functions Variables Enumerations
physxTriangleMesh.cxx
1 // Filename: physxTriangleMesh.cxx
2 // Created by: enn0x (14Oct09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "physxTriangleMesh.h"
16 #include "physxMeshPool.h"
17 
18 TypeHandle PhysxTriangleMesh::_type_handle;
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: PhysxTriangleMesh::link
22 // Access: Public
23 // Description:
24 ////////////////////////////////////////////////////////////////////
25 void PhysxTriangleMesh::
26 link(NxTriangleMesh *meshPtr) {
27 
28  // Link self
29  PhysxManager::get_global_ptr()->_triangle_meshes.add(this);
30  _ptr = meshPtr;
31  _error_type = ET_ok;
32 }
33 
34 ////////////////////////////////////////////////////////////////////
35 // Function: PhysxTriangleMesh::unlink
36 // Access: Public
37 // Description:
38 ////////////////////////////////////////////////////////////////////
39 void PhysxTriangleMesh::
40 unlink() {
41 
42  // Unlink self
43  _error_type = ET_released;
44  PhysxManager::get_global_ptr()->_triangle_meshes.remove(this);
45 }
46 
47 ////////////////////////////////////////////////////////////////////
48 // Function: PhysxTriangleMesh::release
49 // Access: Published
50 // Description:
51 ////////////////////////////////////////////////////////////////////
52 void PhysxTriangleMesh::
53 release() {
54 
55  nassertv(_error_type == ET_ok);
56 
57  unlink();
58  NxGetPhysicsSDK()->releaseTriangleMesh(*_ptr);
59  _ptr = NULL;
60 
61  PhysxMeshPool::release_triangle_mesh(this);
62 }
63 
64 ////////////////////////////////////////////////////////////////////
65 // Function: PhysxTriangleMesh::get_reference_count
66 // Access: Published
67 // Description: Returns the reference count for shared meshes.
68 ////////////////////////////////////////////////////////////////////
69 unsigned int PhysxTriangleMesh::
71 
72  nassertr(_error_type == ET_ok, 0);
73 
74  return _ptr->getReferenceCount();
75 }
76 
static PhysxManager * get_global_ptr()
Returns a pointer to the global PhysxManager object.
unsigned int get_reference_count() const
Returns the reference count for shared meshes.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85