Panda3D
bulletManifoldPoint.cxx
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 bulletManifoldPoint.cxx
10  * @author enn0x
11  * @date 2010-03-07
12  */
13 
14 #include "bulletManifoldPoint.h"
15 
16 #include "bulletWorld.h"
17 
18 /**
19  *
20  */
21 BulletManifoldPoint::
22 BulletManifoldPoint(btManifoldPoint &pt)
23  : _pt(pt) {
24 
25 }
26 
27 /**
28  *
29  */
30 BulletManifoldPoint::
31 BulletManifoldPoint(const BulletManifoldPoint &other)
32  : _pt(other._pt) {
33 
34 }
35 
36 /**
37  *
38  */
39 BulletManifoldPoint& BulletManifoldPoint::
40 operator=(const BulletManifoldPoint& other) {
41 
42  this->_pt = other._pt;
43  return *this;
44 }
45 
46 /**
47  *
48  */
49 int BulletManifoldPoint::
50 get_life_time() const {
51  LightMutexHolder holder(BulletWorld::get_global_lock());
52 
53  return _pt.getLifeTime();
54 }
55 
56 /**
57  *
58  */
59 PN_stdfloat BulletManifoldPoint::
60 get_distance() const {
61  LightMutexHolder holder(BulletWorld::get_global_lock());
62 
63  return (PN_stdfloat)_pt.getDistance();
64 }
65 
66 /**
67  *
68  */
69 PN_stdfloat BulletManifoldPoint::
70 get_applied_impulse() const {
71  LightMutexHolder holder(BulletWorld::get_global_lock());
72 
73  return (PN_stdfloat)_pt.getAppliedImpulse();
74 }
75 
76 /**
77  *
78  */
79 LPoint3 BulletManifoldPoint::
80 get_position_world_on_a() const {
81  LightMutexHolder holder(BulletWorld::get_global_lock());
82 
83  return btVector3_to_LPoint3(_pt.getPositionWorldOnA());
84 }
85 
86 /**
87  *
88  */
89 LPoint3 BulletManifoldPoint::
90 get_position_world_on_b() const {
91  LightMutexHolder holder(BulletWorld::get_global_lock());
92 
93  return btVector3_to_LPoint3(_pt.getPositionWorldOnB());
94 }
95 
96 /**
97  *
98  */
99 LVector3 BulletManifoldPoint::
100 get_normal_world_on_b() const {
101  LightMutexHolder holder(BulletWorld::get_global_lock());
102 
103  return btVector3_to_LVector3(_pt.m_normalWorldOnB);
104 }
105 
106 /**
107  *
108  */
109 LPoint3 BulletManifoldPoint::
110 get_local_point_a() const {
111  LightMutexHolder holder(BulletWorld::get_global_lock());
112 
113  return btVector3_to_LPoint3(_pt.m_localPointA);
114 }
115 
116 /**
117  *
118  */
119 LPoint3 BulletManifoldPoint::
120 get_local_point_b() const {
121  LightMutexHolder holder(BulletWorld::get_global_lock());
122 
123  return btVector3_to_LPoint3(_pt.m_localPointB);
124 }
125 
126 /**
127  *
128  */
129 int BulletManifoldPoint::
130 get_part_id0() const {
131  LightMutexHolder holder(BulletWorld::get_global_lock());
132 
133  return _pt.m_partId0;
134 }
135 
136 /**
137  *
138  */
139 int BulletManifoldPoint::
140 get_part_id1() const {
141  LightMutexHolder holder(BulletWorld::get_global_lock());
142 
143  return _pt.m_partId1;
144 }
145 
146 /**
147  *
148  */
149 int BulletManifoldPoint::
150 get_index0() const {
151  LightMutexHolder holder(BulletWorld::get_global_lock());
152 
153  return _pt.m_index0;
154 }
155 
156 /**
157  *
158  */
159 int BulletManifoldPoint::
160 get_index1() const {
161  LightMutexHolder holder(BulletWorld::get_global_lock());
162 
163  return _pt.m_index1;
164 }
165 
166 /**
167  *
168  */
169 void BulletManifoldPoint::
170 set_lateral_friction_initialized(bool value) {
171  LightMutexHolder holder(BulletWorld::get_global_lock());
172 
173 #if BT_BULLET_VERSION >= 285
174  if (value) {
175  _pt.m_contactPointFlags |= BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED;
176  } else {
177  _pt.m_contactPointFlags &= ~BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED;
178  }
179 #else
180  _pt.m_lateralFrictionInitialized = value;
181 #endif
182 }
183 
184 /**
185  *
186  */
187 bool BulletManifoldPoint::
188 get_lateral_friction_initialized() const {
189  LightMutexHolder holder(BulletWorld::get_global_lock());
190 
191 #if BT_BULLET_VERSION >= 285
192  return (_pt.m_contactPointFlags & BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED) != 0;
193 #else
194  return _pt.m_lateralFrictionInitialized;
195 #endif
196 }
197 
198 /**
199  *
200  */
201 void BulletManifoldPoint::
202 set_lateral_friction_dir1(const LVecBase3 &dir) {
203  LightMutexHolder holder(BulletWorld::get_global_lock());
204 
205  _pt.m_lateralFrictionDir1 = LVecBase3_to_btVector3(dir);
206 }
207 
208 /**
209  *
210  */
211 LVector3 BulletManifoldPoint::
212 get_lateral_friction_dir1() const {
213  LightMutexHolder holder(BulletWorld::get_global_lock());
214 
215  return btVector3_to_LVector3(_pt.m_lateralFrictionDir1);
216 }
217 
218 /**
219  *
220  */
221 void BulletManifoldPoint::
222 set_lateral_friction_dir2(const LVecBase3 &dir) {
223  LightMutexHolder holder(BulletWorld::get_global_lock());
224 
225  _pt.m_lateralFrictionDir2 = LVecBase3_to_btVector3(dir);
226 }
227 
228 /**
229  *
230  */
231 LVector3 BulletManifoldPoint::
232 get_lateral_friction_dir2() const {
233  LightMutexHolder holder(BulletWorld::get_global_lock());
234 
235  return btVector3_to_LVector3(_pt.m_lateralFrictionDir2);
236 }
237 
238 /**
239  *
240  */
241 void BulletManifoldPoint::
242 set_contact_motion1(PN_stdfloat value) {
243  LightMutexHolder holder(BulletWorld::get_global_lock());
244 
245  _pt.m_contactMotion1 = (btScalar)value;
246 }
247 
248 /**
249  *
250  */
251 PN_stdfloat BulletManifoldPoint::
252 get_contact_motion1() const {
253  LightMutexHolder holder(BulletWorld::get_global_lock());
254 
255  return (PN_stdfloat)_pt.m_contactMotion1;
256 }
257 
258 /**
259  *
260  */
261 void BulletManifoldPoint::
262 set_contact_motion2(PN_stdfloat value) {
263  LightMutexHolder holder(BulletWorld::get_global_lock());
264 
265  _pt.m_contactMotion2 = (btScalar)value;
266 }
267 
268 /**
269  *
270  */
271 PN_stdfloat BulletManifoldPoint::
272 get_contact_motion2() const {
273  LightMutexHolder holder(BulletWorld::get_global_lock());
274 
275  return (PN_stdfloat)_pt.m_contactMotion2;
276 }
277 
278 /**
279  *
280  */
281 void BulletManifoldPoint::
282 set_combined_friction(PN_stdfloat value) {
283  LightMutexHolder holder(BulletWorld::get_global_lock());
284 
285  _pt.m_combinedFriction = (btScalar)value;
286 }
287 
288 /**
289  *
290  */
291 PN_stdfloat BulletManifoldPoint::
292 get_combined_friction() const {
293  LightMutexHolder holder(BulletWorld::get_global_lock());
294 
295  return (PN_stdfloat)_pt.m_combinedFriction;
296 }
297 
298 /**
299  *
300  */
301 void BulletManifoldPoint::
302 set_combined_restitution(PN_stdfloat value) {
303  LightMutexHolder holder(BulletWorld::get_global_lock());
304 
305  _pt.m_combinedRestitution = (btScalar)value;
306 }
307 
308 /**
309  *
310  */
311 PN_stdfloat BulletManifoldPoint::
312 get_combined_restitution() const {
313  LightMutexHolder holder(BulletWorld::get_global_lock());
314 
315  return (PN_stdfloat)_pt.m_combinedRestitution;
316 }
317 
318 /**
319  *
320  */
321 void BulletManifoldPoint::
322 set_applied_impulse(PN_stdfloat value) {
323  LightMutexHolder holder(BulletWorld::get_global_lock());
324 
325  _pt.m_appliedImpulse = (btScalar)value;
326 }
327 
328 /**
329  *
330  */
331 void BulletManifoldPoint::
332 set_applied_impulse_lateral1(PN_stdfloat value) {
333  LightMutexHolder holder(BulletWorld::get_global_lock());
334 
335  _pt.m_appliedImpulseLateral1 = (btScalar)value;
336 }
337 
338 /**
339  *
340  */
341 PN_stdfloat BulletManifoldPoint::
342 get_applied_impulse_lateral1() const {
343  LightMutexHolder holder(BulletWorld::get_global_lock());
344 
345  return (PN_stdfloat)_pt.m_appliedImpulseLateral1;
346 }
347 
348 /**
349  *
350  */
351 void BulletManifoldPoint::
352 set_applied_impulse_lateral2(PN_stdfloat value) {
353  LightMutexHolder holder(BulletWorld::get_global_lock());
354 
355  _pt.m_appliedImpulseLateral2 = (btScalar)value;
356 }
357 
358 /**
359  *
360  */
361 PN_stdfloat BulletManifoldPoint::
362 get_applied_impulse_lateral2() const {
363  LightMutexHolder holder(BulletWorld::get_global_lock());
364 
365  return (PN_stdfloat)_pt.m_appliedImpulseLateral2;
366 }
367 
368 /**
369  *
370  */
371 void BulletManifoldPoint::
372 set_contact_cfm1(PN_stdfloat value) {
373  LightMutexHolder holder(BulletWorld::get_global_lock());
374 
375 #if BT_BULLET_VERSION < 285
376  _pt.m_contactCFM1 = (btScalar)value;
377 #endif
378 }
379 
380 /**
381  *
382  */
383 PN_stdfloat BulletManifoldPoint::
384 get_contact_cfm1() const {
385  LightMutexHolder holder(BulletWorld::get_global_lock());
386 
387 #if BT_BULLET_VERSION < 285
388  return (PN_stdfloat)_pt.m_contactCFM1;
389 #else
390  return 0;
391 #endif
392 }
393 
394 /**
395  *
396  */
397 void BulletManifoldPoint::
398 set_contact_cfm2(PN_stdfloat value) {
399  LightMutexHolder holder(BulletWorld::get_global_lock());
400 
401 #if BT_BULLET_VERSION < 285
402  _pt.m_contactCFM2 = (btScalar)value;
403 #endif
404 }
405 
406 /**
407  *
408  */
409 PN_stdfloat BulletManifoldPoint::
410 get_contact_cfm2() const {
411  LightMutexHolder holder(BulletWorld::get_global_lock());
412 
413 #if BT_BULLET_VERSION < 285
414  return (PN_stdfloat)_pt.m_contactCFM2;
415 #else
416  return 0;
417 #endif
418 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Similar to MutexHolder, but for a light mutex.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.