forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathodeGeom.I
More file actions
243 lines (206 loc) · 5.76 KB
/
odeGeom.I
File metadata and controls
243 lines (206 loc) · 5.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
// Filename: odeGeom.I
// Created by: joswilso (27Dec06)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: OdeGeom::is_empty
// Access: Published
// Description: Returns true if the ID is 0, meaning the OdeGeom
// does not point to a valid geom. It is an error to
// call a method on an empty geom.
// Note that an empty OdeGeom also evaluates to False.
////////////////////////////////////////////////////////////////////
INLINE bool OdeGeom::
is_empty() const {
return (_id == 0);
}
////////////////////////////////////////////////////////////////////
// Function: OdeGeom::get_id
// Access: Published
// Description: Returns the underlying dGeomID.
////////////////////////////////////////////////////////////////////
INLINE dGeomID OdeGeom::
get_id() const {
return _id;
}
INLINE bool OdeGeom::
has_body() const {
return (dGeomGetBody(_id) != NULL);
}
INLINE OdeBody OdeGeom::
get_body() const {
return OdeBody(dGeomGetBody(_id));
}
INLINE void OdeGeom::
set_body(OdeBody &body) {
dGeomSetBody(_id, body.get_id());
}
/*
INLINE void OdeGeom::
set_data(void* data) {
dGeomSetData(_id, data);
}
*/
INLINE void OdeGeom::
set_position(dReal x, dReal y, dReal z) {
dGeomSetPosition(_id, x, y, z);
}
INLINE void OdeGeom::
set_position(const LVecBase3f &pos) {
set_position(pos[0], pos[1], pos[2]);
}
INLINE void OdeGeom::
set_rotation(const LMatrix3f &r) {
dMatrix3 rot = { r(0, 0), r(0, 1), r(0, 2), 0,
r(1, 0), r(1, 1), r(1, 2), 0,
r(2, 0), r(2, 1), r(2, 2), 0 };
dGeomSetRotation(_id, rot);
}
INLINE void OdeGeom::
set_quaternion(const LQuaternionf &q) {
dQuaternion quat = { q[0], q[1], q[2], q[3] };
dGeomSetQuaternion(_id, quat);
}
INLINE LPoint3f OdeGeom::
get_position() const {
const dReal *pos = dGeomGetPosition(_id);
return LPoint3f(pos[0], pos[1], pos[2]);
}
INLINE LMatrix3f OdeGeom::
get_rotation() const {
const dReal *rot = dGeomGetRotation(_id);
return LMatrix3f(rot[0], rot[1], rot[2],
rot[4], rot[5], rot[6],
rot[8], rot[9], rot[10]);
}
INLINE LQuaternionf OdeGeom::
get_quaternion() const {
dQuaternion res;
dGeomGetQuaternion(_id, res);
return LQuaternionf(res[0], res[1], res[2], res[3]);
}
INLINE void OdeGeom::
get_AABB(LVecBase3f &min, LVecBase3f &max) const {
dReal result[6];
dGeomGetAABB(_id, result);
min.set(result[0], result[2], result[4]);
max.set(result[1], result[3], result[5]);
}
INLINE int OdeGeom::
is_space() {
return dGeomIsSpace(_id);
}
INLINE int OdeGeom::
get_class() const {
return dGeomGetClass(_id);
}
INLINE void OdeGeom::
set_category_bits(const BitMask32 &bits) {
dGeomSetCategoryBits(_id, bits.get_word());
}
INLINE void OdeGeom::
set_collide_bits(const BitMask32 &bits) {
dGeomSetCollideBits(_id, bits.get_word());
}
INLINE BitMask32 OdeGeom::
get_category_bits() {
return BitMask32(dGeomGetCategoryBits(_id));
}
INLINE BitMask32 OdeGeom::
get_collide_bits() {
return BitMask32(dGeomGetCollideBits(_id));
}
INLINE void OdeGeom::
enable() {
dGeomEnable(_id);
}
INLINE void OdeGeom::
disable() {
dGeomDisable(_id);
}
INLINE int OdeGeom::
is_enabled() {
return dGeomIsEnabled(_id);
}
INLINE void OdeGeom::
set_offset_position(dReal x, dReal y, dReal z) {
dGeomSetOffsetPosition(_id, x, y, z);
}
INLINE void OdeGeom::
set_offset_position(const LVecBase3f &pos) {
set_offset_position(pos[0], pos[1], pos[2]);
}
INLINE void OdeGeom::
set_offset_rotation(const LMatrix3f &r) {
dMatrix3 rot = { r(0, 0), r(0, 1), r(0, 2), 0,
r(1, 0), r(1, 1), r(1, 2), 0,
r(2, 0), r(2, 1), r(2, 2), 0 };
dGeomSetOffsetRotation(_id, rot);
}
INLINE void OdeGeom::
set_offset_quaternion(const LQuaternionf &q) {
dQuaternion quat = { q[0], q[1], q[2], q[3] };
dGeomSetOffsetQuaternion(_id, quat);
}
INLINE void OdeGeom::
set_offset_world_position(dReal x, dReal y, dReal z) {
dGeomSetOffsetWorldPosition(_id, x, y, z);
}
INLINE void OdeGeom::
set_offset_world_position(const LVecBase3f &pos) {
set_offset_world_position(pos[0], pos[1], pos[2]);
}
INLINE void OdeGeom::
set_offset_world_rotation(const LMatrix3f &r) {
dMatrix3 rot = { r(0, 0), r(0, 1), r(0, 2), 0,
r(1, 0), r(1, 1), r(1, 2), 0,
r(2, 0), r(2, 1), r(2, 2), 0 };
dGeomSetOffsetWorldRotation(_id, rot);
}
INLINE void OdeGeom::
set_offset_world_quaternion(const LQuaternionf &q) {
dQuaternion quat = { q[0], q[1], q[2], q[3] };
dGeomSetOffsetWorldQuaternion(_id, quat);
}
INLINE void OdeGeom::
clear_offset() {
dGeomClearOffset(_id);
}
INLINE int OdeGeom::
is_offset() {
return dGeomIsOffset(_id);
}
INLINE LPoint3f OdeGeom::
get_offset_position() const {
const dReal *pos = dGeomGetOffsetPosition(_id);
return LPoint3f(pos[0], pos[1], pos[2]);
}
INLINE LMatrix3f OdeGeom::
get_offset_rotation() const {
const dReal *rot = dGeomGetOffsetRotation(_id);
return LMatrix3f(rot[0], rot[1], rot[2],
rot[4], rot[5], rot[6],
rot[8], rot[9], rot[10]);
}
INLINE LQuaternionf OdeGeom::
get_offset_quaternion() const {
dQuaternion res;
dGeomGetOffsetQuaternion(_id, res);
return LQuaternionf(res[0], res[1], res[2], res[3]);
}
INLINE int OdeGeom::
compare_to(const OdeGeom &other) const {
if (_id != other._id) {
return _id < other._id ? -1 : 1;
}
return 0;
}