Panda3D
physxHeightField.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file physxHeightField.cxx
10  * @author enn0x
11  * @date 2009-10-15
12  */
13 
14 #include "physxHeightField.h"
15 
16 TypeHandle PhysxHeightField::_type_handle;
17 
18 /**
19  *
20  */
21 void PhysxHeightField::
22 link(NxHeightField *hfPtr) {
23 
24  PhysxManager::get_global_ptr()->_heightfields.add(this);
25  _ptr = hfPtr;
26  _error_type = ET_ok;
27 }
28 
29 /**
30  *
31  */
32 void PhysxHeightField::
33 unlink() {
34 
35  _error_type = ET_released;
36  PhysxManager::get_global_ptr()->_heightfields.remove(this);
37 }
38 
39 /**
40  *
41  */
42 void PhysxHeightField::
43 release() {
44 
45  nassertv(_error_type == ET_ok);
46 
47  unlink();
48  NxGetPhysicsSDK()->releaseHeightField(*_ptr);
49  _ptr = nullptr;
50 }
51 
52 /**
53  *
54  */
55 float PhysxHeightField::
56 get_height(float x, float y) const {
57 
58  nassertr(_error_type == ET_ok, 0.0f);
59  return _ptr->getHeight(x, y);
60 }
61 
62 /**
63  * Returns the reference count for shared meshes.
64  */
65 unsigned int PhysxHeightField::
67 
68  nassertr(_error_type == ET_ok, 0);
69  return _ptr->getReferenceCount();
70 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:81