Panda3D
 All Classes Functions Variables Enumerations
bulletBodyNode.I
1 // Filename: bulletBodyNode.I
2 // Created by: enn0x (19Nov10)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: BulletBodyNode::Destructor
18 // Access: Published
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE BulletBodyNode::
22 ~BulletBodyNode() {
23 
24  if (_shape && (
25  _shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE ||
26  _shape->getShapeType() == EMPTY_SHAPE_PROXYTYPE)) {
27  delete _shape;
28  }
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: BulletBodyNode::set_into_collide_mask
33 // Access: Published
34 // Description:
35 ////////////////////////////////////////////////////////////////////
36 INLINE void BulletBodyNode::
37 set_into_collide_mask(CollideMask mask) {
38 
40 
41 /*
42  TODO: we would need a handle to the BulletWorld first
43  possible, but has to be set/cleared upon attach/remove to world
44 
45  if (!_world) return;
46 
47  btBroadphaseProxy* proxy = get_object()->getBroadphaseHandle();
48  if (proxy) {
49  btBroadphaseInterface *broadphase = _world->get_broadphase();
50  btDispatcher *dispatcher = _world->get_dispatcher();
51 
52  broadphase->getOverlappingPairCache()->cleanProxyFromPairs(proxy, dispatcher);
53  }
54 */
55 }
56 
57 ////////////////////////////////////////////////////////////////////
58 // Function: BulletBodyNode::notify_collisions
59 // Access: Published
60 // Description:
61 ////////////////////////////////////////////////////////////////////
62 INLINE void BulletBodyNode::
63 notify_collisions(bool value) {
64 
65  set_collision_flag(btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK, value);
66 }
67 
68 ////////////////////////////////////////////////////////////////////
69 // Function: BulletBodyNode::notifies_collisions
70 // Access: Published
71 // Description:
72 ////////////////////////////////////////////////////////////////////
73 INLINE bool BulletBodyNode::
74 notifies_collisions() const {
75 
76  return get_collision_flag(btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
77 }
78 
79 ////////////////////////////////////////////////////////////////////
80 // Function: BulletBodyNode::set_collision_response
81 // Access: Published
82 // Description:
83 ////////////////////////////////////////////////////////////////////
84 INLINE void BulletBodyNode::
85 set_collision_response(bool value) {
86 
87  set_collision_flag(btCollisionObject::CF_NO_CONTACT_RESPONSE, !value);
88 }
89 
90 ////////////////////////////////////////////////////////////////////
91 // Function: BulletBodyNode::get_collision_response
92 // Access: Published
93 // Description:
94 ////////////////////////////////////////////////////////////////////
95 INLINE bool BulletBodyNode::
96 get_collision_response() const {
97 
98  return !get_collision_flag(btCollisionObject::CF_NO_CONTACT_RESPONSE);
99 }
100 
101 ////////////////////////////////////////////////////////////////////
102 // Function: BulletBodyNode::set_collision_flag
103 // Access: Protected
104 // Description:
105 ////////////////////////////////////////////////////////////////////
106 INLINE void BulletBodyNode::
107 set_collision_flag(int flag, bool value) {
108 
109  int flags = get_object()->getCollisionFlags();
110 
111  if (value == true) {
112  flags |= flag;
113  }
114  else {
115  flags &= ~(flag);
116  }
117 
118  get_object()->setCollisionFlags(flags);
119 }
120 
121 ////////////////////////////////////////////////////////////////////
122 // Function: BulletBodyNode::get_collision_flag
123 // Access: Protected
124 // Description:
125 ////////////////////////////////////////////////////////////////////
126 INLINE bool BulletBodyNode::
127 get_collision_flag(int flag) const {
128 
129  return (get_object()->getCollisionFlags() & flag) ? true : false;
130 }
131 
132 ////////////////////////////////////////////////////////////////////
133 // Function: BulletBodyNode::is_static
134 // Access: Published
135 // Description:
136 ////////////////////////////////////////////////////////////////////
137 INLINE bool BulletBodyNode::
138 is_static() const {
139 
140  return get_object()->isStaticObject();
141 }
142 
143 ////////////////////////////////////////////////////////////////////
144 // Function: BulletBodyNode::is_kinematic
145 // Access: Published
146 // Description:
147 ////////////////////////////////////////////////////////////////////
148 INLINE bool BulletBodyNode::
149 is_kinematic() const {
150 
151  return get_object()->isKinematicObject();
152 }
153 
154 ////////////////////////////////////////////////////////////////////
155 // Function: BulletBodyNode::set_static
156 // Access: Published
157 // Description:
158 ////////////////////////////////////////////////////////////////////
159 INLINE void BulletBodyNode::
160 set_static(bool value) {
161 
162  set_collision_flag(btCollisionObject::CF_STATIC_OBJECT, value);
163 }
164 
165 ////////////////////////////////////////////////////////////////////
166 // Function: BulletBodyNode::set_kinematic
167 // Access: Published
168 // Description:
169 ////////////////////////////////////////////////////////////////////
170 INLINE void BulletBodyNode::
171 set_kinematic(bool value) {
172 
173  set_collision_flag(btCollisionObject::CF_KINEMATIC_OBJECT, value);
174 }
175 
176 ////////////////////////////////////////////////////////////////////
177 // Function: BulletBodyNode::get_restitution
178 // Access: Published
179 // Description:
180 ////////////////////////////////////////////////////////////////////
181 INLINE PN_stdfloat BulletBodyNode::
182 get_restitution() const {
183 
184  return get_object()->getRestitution();
185 }
186 
187 ////////////////////////////////////////////////////////////////////
188 // Function: BulletBodyNode::set_restitution
189 // Access: Published
190 // Description:
191 ////////////////////////////////////////////////////////////////////
192 INLINE void BulletBodyNode::
193 set_restitution(PN_stdfloat restitution) {
194 
195  return get_object()->setRestitution(restitution);
196 }
197 
198 ////////////////////////////////////////////////////////////////////
199 // Function: BulletBodyNode::get_friction
200 // Access: Published
201 // Description:
202 ////////////////////////////////////////////////////////////////////
203 INLINE PN_stdfloat BulletBodyNode::
204 get_friction() const {
205 
206  return get_object()->getFriction();
207 }
208 
209 ////////////////////////////////////////////////////////////////////
210 // Function: BulletBodyNode::set_friction
211 // Access: Published
212 // Description:
213 ////////////////////////////////////////////////////////////////////
214 INLINE void BulletBodyNode::
215 set_friction(PN_stdfloat friction) {
216 
217  return get_object()->setFriction(friction);
218 }
219 
220 #if BT_BULLET_VERSION >= 281
221 ////////////////////////////////////////////////////////////////////
222 // Function: BulletBodyNode::get_rolling_friction
223 // Access: Published
224 // Description:
225 ////////////////////////////////////////////////////////////////////
226 INLINE PN_stdfloat BulletBodyNode::
227 get_rolling_friction() const {
228 
229  return get_object()->getRollingFriction();
230 }
231 
232 ////////////////////////////////////////////////////////////////////
233 // Function: BulletBodyNode::set_rolling_friction
234 // Access: Published
235 // Description:
236 ////////////////////////////////////////////////////////////////////
237 INLINE void BulletBodyNode::
238 set_rolling_friction(PN_stdfloat friction) {
239 
240  return get_object()->setRollingFriction(friction);
241 }
242 #endif
243 
244 ////////////////////////////////////////////////////////////////////
245 // Function: BulletBodyNode::has_anisotropic_friction
246 // Access: Published
247 // Description:
248 ////////////////////////////////////////////////////////////////////
249 INLINE bool BulletBodyNode::
250 has_anisotropic_friction() const {
251 
252  return get_object()->hasAnisotropicFriction();
253 }
254 
255 ////////////////////////////////////////////////////////////////////
256 // Function: BulletBodyNode::get_num_shapes
257 // Access: Published
258 // Description:
259 ////////////////////////////////////////////////////////////////////
260 INLINE int BulletBodyNode::
261 get_num_shapes() const {
262 
263  return _shapes.size();
264 }
265 
266 ////////////////////////////////////////////////////////////////////
267 // Function: BulletBodyNode::get_shape
268 // Access: Published
269 // Description:
270 ////////////////////////////////////////////////////////////////////
271 INLINE BulletShape *BulletBodyNode::
272 get_shape(int idx) const {
273 
274  nassertr(idx >= 0 && idx < (int)_shapes.size(), NULL);
275  return _shapes[idx];
276 }
277 
278 ////////////////////////////////////////////////////////////////////
279 // Function: BulletBodyNode::set_debug_enabled
280 // Access: Published
281 // Description: Enables or disables the debug visualisation for
282 // this collision object. By default the debug
283 // visualisation is enabled.
284 ////////////////////////////////////////////////////////////////////
285 INLINE void BulletBodyNode::
286 set_debug_enabled(const bool enabled) {
287 
288  set_collision_flag(btCollisionObject::CF_DISABLE_VISUALIZE_OBJECT, !enabled);
289 }
290 
291 ////////////////////////////////////////////////////////////////////
292 // Function: BulletBodyNode::is_debug_enabled
293 // Access: Published
294 // Description: Returns TRUE if the debug visualisation is enabled
295 // for this collision object, and FALSE if the debug
296 // visualisation is disabled.
297 ////////////////////////////////////////////////////////////////////
298 INLINE bool BulletBodyNode::
300 
301  return !get_collision_flag(btCollisionObject::CF_DISABLE_VISUALIZE_OBJECT);
302 }
303 
bool is_debug_enabled() const
Returns TRUE if the debug visualisation is enabled for this collision object, and FALSE if the debug ...
void set_debug_enabled(const bool enabled)
Enables or disables the debug visualisation for this collision object.
void set_into_collide_mask(CollideMask mask)
Sets the &quot;into&quot; CollideMask.
Definition: pandaNode.cxx:2037
A general bitmask class.
Definition: bitMask.h:35