Panda3D

Loading...
Searching...
No Matches
odeGeom.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 odeGeom.I
10 * @author joswilso
11 * @date 2006-12-27
12 */
13
14/**
15 * Returns true if the ID is 0, meaning the OdeGeom does not point to a valid
16 * geom. It is an error to call a method on an empty geom. Note that an
17 * empty OdeGeom also evaluates to False.
18 */
19INLINE bool OdeGeom::
20 is_empty() const {
21 return (_id == 0);
22}
23
24/**
25 * Returns the underlying dGeomID.
26 */
27INLINE dGeomID OdeGeom::
28 get_id() const {
29 return _id;
30}
31
32INLINE bool OdeGeom::
33has_body() const {
34 return (dGeomGetBody(_id) != nullptr);
35}
36
37INLINE OdeBody OdeGeom::
38get_body() const {
39 return OdeBody(dGeomGetBody(_id));
40}
41
42INLINE void OdeGeom::
43set_body(OdeBody &body) {
44 dGeomSetBody(_id, body.get_id());
45}
46
47/*
48 INLINE void OdeGeom::
49 set_data(void* data) {
50 dGeomSetData(_id, data);
51}
52*/
53
54INLINE void OdeGeom::
55set_position(dReal x, dReal y, dReal z) {
56 dGeomSetPosition(_id, x, y, z);
57}
58
59INLINE void OdeGeom::
60set_position(const LVecBase3f &pos) {
61 set_position(pos[0], pos[1], pos[2]);
62}
63
64INLINE void OdeGeom::
65set_rotation(const LMatrix3f &r) {
66 dMatrix3 rot = { r(0, 0), r(0, 1), r(0, 2), 0,
67 r(1, 0), r(1, 1), r(1, 2), 0,
68 r(2, 0), r(2, 1), r(2, 2), 0 };
69 dGeomSetRotation(_id, rot);
70}
71
72INLINE void OdeGeom::
73set_quaternion(const LQuaternionf &q) {
74 dQuaternion quat = { q[0], q[1], q[2], q[3] };
75 dGeomSetQuaternion(_id, quat);
76}
77
78INLINE LPoint3f OdeGeom::
79get_position() const {
80 const dReal *pos = dGeomGetPosition(_id);
81 return LPoint3f(pos[0], pos[1], pos[2]);
82}
83
84INLINE LMatrix3f OdeGeom::
85get_rotation() const {
86 const dReal *rot = dGeomGetRotation(_id);
87 return LMatrix3f(rot[0], rot[1], rot[2],
88 rot[4], rot[5], rot[6],
89 rot[8], rot[9], rot[10]);
90}
91
92INLINE LQuaternionf OdeGeom::
93get_quaternion() const {
94 dQuaternion res;
95 dGeomGetQuaternion(_id, res);
96 return LQuaternionf(res[0], res[1], res[2], res[3]);
97}
98
99INLINE void OdeGeom::
100get_AABB(LVecBase3f &min, LVecBase3f &max) const {
101 dReal result[6];
102 dGeomGetAABB(_id, result);
103 min.set(result[0], result[2], result[4]);
104 max.set(result[1], result[3], result[5]);
105}
106
107INLINE int OdeGeom::
108is_space() {
109 return dGeomIsSpace(_id);
110}
111
112INLINE int OdeGeom::
113get_class() const {
114 return dGeomGetClass(_id);
115}
116
117INLINE void OdeGeom::
118set_category_bits(const BitMask32 &bits) {
119 dGeomSetCategoryBits(_id, bits.get_word());
120}
121
122INLINE void OdeGeom::
123set_collide_bits(const BitMask32 &bits) {
124 dGeomSetCollideBits(_id, bits.get_word());
125}
126
127INLINE BitMask32 OdeGeom::
128get_category_bits() {
129 return BitMask32(dGeomGetCategoryBits(_id));
130}
131
132INLINE BitMask32 OdeGeom::
133get_collide_bits() {
134 return BitMask32(dGeomGetCollideBits(_id));
135}
136
137INLINE void OdeGeom::
138enable() {
139 dGeomEnable(_id);
140}
141
142INLINE void OdeGeom::
143disable() {
144 dGeomDisable(_id);
145}
146
147INLINE int OdeGeom::
148is_enabled() {
149 return dGeomIsEnabled(_id);
150}
151
152INLINE void OdeGeom::
153set_offset_position(dReal x, dReal y, dReal z) {
154 dGeomSetOffsetPosition(_id, x, y, z);
155}
156
157INLINE void OdeGeom::
158set_offset_position(const LVecBase3f &pos) {
159 set_offset_position(pos[0], pos[1], pos[2]);
160}
161
162INLINE void OdeGeom::
163set_offset_rotation(const LMatrix3f &r) {
164 dMatrix3 rot = { r(0, 0), r(0, 1), r(0, 2), 0,
165 r(1, 0), r(1, 1), r(1, 2), 0,
166 r(2, 0), r(2, 1), r(2, 2), 0 };
167 dGeomSetOffsetRotation(_id, rot);
168}
169
170INLINE void OdeGeom::
171set_offset_quaternion(const LQuaternionf &q) {
172 dQuaternion quat = { q[0], q[1], q[2], q[3] };
173 dGeomSetOffsetQuaternion(_id, quat);
174}
175
176INLINE void OdeGeom::
177set_offset_world_position(dReal x, dReal y, dReal z) {
178 dGeomSetOffsetWorldPosition(_id, x, y, z);
179}
180
181INLINE void OdeGeom::
182set_offset_world_position(const LVecBase3f &pos) {
183 set_offset_world_position(pos[0], pos[1], pos[2]);
184}
185
186INLINE void OdeGeom::
187set_offset_world_rotation(const LMatrix3f &r) {
188 dMatrix3 rot = { r(0, 0), r(0, 1), r(0, 2), 0,
189 r(1, 0), r(1, 1), r(1, 2), 0,
190 r(2, 0), r(2, 1), r(2, 2), 0 };
191 dGeomSetOffsetWorldRotation(_id, rot);
192}
193
194INLINE void OdeGeom::
195set_offset_world_quaternion(const LQuaternionf &q) {
196 dQuaternion quat = { q[0], q[1], q[2], q[3] };
197 dGeomSetOffsetWorldQuaternion(_id, quat);
198}
199
200INLINE void OdeGeom::
201clear_offset() {
202 dGeomClearOffset(_id);
203}
204
205INLINE int OdeGeom::
206is_offset() {
207 return dGeomIsOffset(_id);
208}
209
210INLINE LPoint3f OdeGeom::
211get_offset_position() const {
212 const dReal *pos = dGeomGetOffsetPosition(_id);
213 return LPoint3f(pos[0], pos[1], pos[2]);
214}
215
216INLINE LMatrix3f OdeGeom::
217get_offset_rotation() const {
218 const dReal *rot = dGeomGetOffsetRotation(_id);
219 return LMatrix3f(rot[0], rot[1], rot[2],
220 rot[4], rot[5], rot[6],
221 rot[8], rot[9], rot[10]);
222}
223
224INLINE LQuaternionf OdeGeom::
225get_offset_quaternion() const {
226 dQuaternion res;
227 dGeomGetOffsetQuaternion(_id, res);
228 return LQuaternionf(res[0], res[1], res[2], res[3]);
229}
230
231INLINE int OdeGeom::
232compare_to(const OdeGeom &other) const {
233 if (_id != other._id) {
234 return _id < other._id ? -1 : 1;
235 }
236 return 0;
237}
BitMask::get_word
WordType get_word() const
Returns the entire BitMask as a single word.
Definition bitMask.I:246
OdeBody
Definition odeBody.h:32
OdeBody::get_id
dBodyID get_id() const
Returns the underlying dBodyID.
Definition odeBody.I:28
OdeGeom
Definition odeGeom.h:45
OdeGeom::is_empty
bool is_empty() const
Returns true if the ID is 0, meaning the OdeGeom does not point to a valid geom.
Definition odeGeom.I:20
OdeGeom::get_id
dGeomID get_id() const
Returns the underlying dGeomID.
Definition odeGeom.I:28