Panda3D
 All Classes Functions Variables Enumerations
physxHeightField.cxx
1 // Filename: physxHeightField.cxx
2 // Created by: enn0x (15Oct09)
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 "physxHeightField.h"
16 
17 TypeHandle PhysxHeightField::_type_handle;
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function: PhysxHeightField::link
21 // Access: Public
22 // Description:
23 ////////////////////////////////////////////////////////////////////
24 void PhysxHeightField::
25 link(NxHeightField *hfPtr) {
26 
27  PhysxManager::get_global_ptr()->_heightfields.add(this);
28  _ptr = hfPtr;
29  _error_type = ET_ok;
30 }
31 
32 ////////////////////////////////////////////////////////////////////
33 // Function: PhysxHeightField::unlink
34 // Access: Public
35 // Description:
36 ////////////////////////////////////////////////////////////////////
37 void PhysxHeightField::
38 unlink() {
39 
40  _error_type = ET_released;
41  PhysxManager::get_global_ptr()->_heightfields.remove(this);
42 }
43 
44 ////////////////////////////////////////////////////////////////////
45 // Function: PhysxHeightField::release
46 // Access: Public
47 // Description:
48 ////////////////////////////////////////////////////////////////////
49 void PhysxHeightField::
50 release() {
51 
52  nassertv(_error_type == ET_ok);
53 
54  unlink();
55  NxGetPhysicsSDK()->releaseHeightField(*_ptr);
56  _ptr = NULL;
57 }
58 
59 ////////////////////////////////////////////////////////////////////
60 // Function: PhysxHeightField::get_height
61 // Access: Published
62 // Description:
63 ////////////////////////////////////////////////////////////////////
64 float PhysxHeightField::
65 get_height(float x, float y) const {
66 
67  nassertr(_error_type == ET_ok, 0.0f);
68  return _ptr->getHeight(x, y);
69 }
70 
71 ////////////////////////////////////////////////////////////////////
72 // Function: PhysxHeightField::get_reference_count
73 // Access: Published
74 // Description: Returns the reference count for shared meshes.
75 ////////////////////////////////////////////////////////////////////
76 unsigned int PhysxHeightField::
78 
79  nassertr(_error_type == ET_ok, 0);
80  return _ptr->getReferenceCount();
81 }
82 
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