Panda3D
Loading...
Searching...
No Matches
physxHeightFieldDesc.I
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 physxHeightFieldDesc.I
10 * @author enn0x
11 * @date 2009-10-15
12 */
13
14/**
15 *
16 */
17INLINE PhysxHeightFieldDesc::
18PhysxHeightFieldDesc() {
19
20 _samples = nullptr;
21 _desc.setToDefault();
22}
23
24/**
25 *
26 */
27INLINE PhysxHeightFieldDesc::
28~PhysxHeightFieldDesc() {
29
30}
31
32/**
33 * (re)sets the structure to the default.
34 */
37
38 _desc.setToDefault();
39}
40
41/**
42 * Returns true if the descriptor is valid.
43 */
45is_valid() const {
46
47 return _desc.isValid();
48}
49
50/**
51 *
52 */
53INLINE void PhysxHeightFieldDesc::
54set_size(unsigned int num_rows, unsigned int num_columns) {
55
56 if (_samples) {
57 unset_size();
58 }
59
60 _desc.format = NX_HF_S16_TM;
61 _desc.nbRows = (NxU32) num_rows;
62 _desc.nbColumns = (NxU32) num_columns;
63 _desc.sampleStride = sizeof(NxU32);
64
65 _samples = new NxU32[_desc.nbColumns * _desc.nbRows];
66 _desc.samples = _samples;
67
68}
69
70/**
71 * Releases the memory allocated for the height field samples.
72 */
73INLINE void PhysxHeightFieldDesc::
74unset_size() {
75
76 if (_samples) {
77 _desc.nbRows = (NxU32) 0;
78 _desc.nbColumns = (NxU32) 0;
79 _desc.samples = nullptr;
80 delete[] _samples;
81 }
82}
bool is_valid() const
Returns true if the descriptor is valid.
void set_to_default()
(re)sets the structure to the default.