34 return (dGeomGetBody(_id) !=
nullptr);
39 return OdeBody(dGeomGetBody(_id));
44 dGeomSetBody(_id, body.
get_id());
55 set_position(dReal x, dReal y, dReal z) {
56 dGeomSetPosition(_id, x, y, z);
60 set_position(
const LVecBase3f &pos) {
61 set_position(pos[0], pos[1], pos[2]);
65 set_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);
73 set_quaternion(
const LQuaternionf &q) {
74 dQuaternion quat = { q[0], q[1], q[2], q[3] };
75 dGeomSetQuaternion(_id, quat);
78 INLINE LPoint3f OdeGeom::
79 get_position()
const {
80 const dReal *pos = dGeomGetPosition(_id);
81 return LPoint3f(pos[0], pos[1], pos[2]);
84 INLINE LMatrix3f OdeGeom::
85 get_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]);
92 INLINE LQuaternionf OdeGeom::
93 get_quaternion()
const {
95 dGeomGetQuaternion(_id, res);
96 return LQuaternionf(res[0], res[1], res[2], res[3]);
100 get_AABB(LVecBase3f &min, LVecBase3f &max)
const {
102 dGeomGetAABB(_id, result);
103 min.set(result[0], result[2], result[4]);
104 max.set(result[1], result[3], result[5]);
109 return dGeomIsSpace(_id);
114 return dGeomGetClass(_id);
117 INLINE
void OdeGeom::
118 set_category_bits(
const BitMask32 &bits) {
119 dGeomSetCategoryBits(_id, bits.
get_word());
122 INLINE
void OdeGeom::
123 set_collide_bits(
const BitMask32 &bits) {
124 dGeomSetCollideBits(_id, bits.
get_word());
128 get_category_bits() {
129 return BitMask32(dGeomGetCategoryBits(_id));
134 return BitMask32(dGeomGetCollideBits(_id));
137 INLINE
void OdeGeom::
142 INLINE
void OdeGeom::
149 return dGeomIsEnabled(_id);
152 INLINE
void OdeGeom::
153 set_offset_position(dReal x, dReal y, dReal z) {
154 dGeomSetOffsetPosition(_id, x, y, z);
157 INLINE
void OdeGeom::
158 set_offset_position(
const LVecBase3f &pos) {
159 set_offset_position(pos[0], pos[1], pos[2]);
162 INLINE
void OdeGeom::
163 set_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);
170 INLINE
void OdeGeom::
171 set_offset_quaternion(
const LQuaternionf &q) {
172 dQuaternion quat = { q[0], q[1], q[2], q[3] };
173 dGeomSetOffsetQuaternion(_id, quat);
176 INLINE
void OdeGeom::
177 set_offset_world_position(dReal x, dReal y, dReal z) {
178 dGeomSetOffsetWorldPosition(_id, x, y, z);
181 INLINE
void OdeGeom::
182 set_offset_world_position(
const LVecBase3f &pos) {
183 set_offset_world_position(pos[0], pos[1], pos[2]);
186 INLINE
void OdeGeom::
187 set_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);
194 INLINE
void OdeGeom::
195 set_offset_world_quaternion(
const LQuaternionf &q) {
196 dQuaternion quat = { q[0], q[1], q[2], q[3] };
197 dGeomSetOffsetWorldQuaternion(_id, quat);
200 INLINE
void OdeGeom::
202 dGeomClearOffset(_id);
207 return dGeomIsOffset(_id);
210 INLINE LPoint3f OdeGeom::
211 get_offset_position()
const {
212 const dReal *pos = dGeomGetOffsetPosition(_id);
213 return LPoint3f(pos[0], pos[1], pos[2]);
216 INLINE LMatrix3f OdeGeom::
217 get_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]);
224 INLINE LQuaternionf OdeGeom::
225 get_offset_quaternion()
const {
227 dGeomGetOffsetQuaternion(_id, res);
228 return LQuaternionf(res[0], res[1], res[2], res[3]);
232 compare_to(
const OdeGeom &other)
const {
233 if (_id != other._id) {
234 return _id < other._id ? -1 : 1;
bool is_empty() const
Returns true if the ID is 0, meaning the OdeGeom does not point to a valid geom.
dGeomID get_id() const
Returns the underlying dGeomID.
WordType get_word() const
Returns the entire BitMask as a single word.
dBodyID get_id() const
Returns the underlying dBodyID.