Panda3D
bulletPersistentManifold.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 bulletPersistentManifold.cxx
10  * @author enn0x
11  * @date 2010-03-07
12  */
13 
15 
16 #include "bulletManifoldPoint.h"
17 #include "bulletWorld.h"
18 
19 /**
20  *
21  */
22 BulletPersistentManifold::
23 BulletPersistentManifold(btPersistentManifold *manifold) : _manifold(manifold) {
24 
25 }
26 
27 /**
28  *
29  */
30 PN_stdfloat BulletPersistentManifold::
31 get_contact_breaking_threshold() const {
32  LightMutexHolder holder(BulletWorld::get_global_lock());
33 
34  return (PN_stdfloat)_manifold->getContactBreakingThreshold();
35 }
36 
37 /**
38  *
39  */
40 PN_stdfloat BulletPersistentManifold::
41 get_contact_processing_threshold() const {
42  LightMutexHolder holder(BulletWorld::get_global_lock());
43 
44  return (PN_stdfloat)_manifold->getContactProcessingThreshold();
45 }
46 
47 /**
48  *
49  */
50 void BulletPersistentManifold::
51 clear_manifold() {
52  LightMutexHolder holder(BulletWorld::get_global_lock());
53 
54  _manifold->clearManifold();
55 }
56 
57 /**
58  *
59  */
60 PandaNode *BulletPersistentManifold::
61 get_node0() {
62  LightMutexHolder holder(BulletWorld::get_global_lock());
63 
64 #if BT_BULLET_VERSION >= 281
65  const btCollisionObject *obj = _manifold->getBody0();
66 #else
67  const btCollisionObject *obj = (btCollisionObject *)_manifold->getBody0();
68 #endif
69 
70  return (obj) ? (PandaNode *)obj->getUserPointer(): nullptr;
71 }
72 
73 /**
74  *
75  */
76 PandaNode *BulletPersistentManifold::
77 get_node1() {
78  LightMutexHolder holder(BulletWorld::get_global_lock());
79 
80 #if BT_BULLET_VERSION >= 281
81  const btCollisionObject *obj = _manifold->getBody1();
82 #else
83  const btCollisionObject *obj = (btCollisionObject *)_manifold->getBody1();
84 #endif
85 
86  return (obj) ? (PandaNode *)obj->getUserPointer(): nullptr;
87 }
88 
89 /**
90  *
91  */
92 int BulletPersistentManifold::
93 get_num_manifold_points() const {
94  LightMutexHolder holder(BulletWorld::get_global_lock());
95 
96  return _manifold->getNumContacts();
97 }
98 
99 /**
100  *
101  */
102 BulletManifoldPoint *BulletPersistentManifold::
103 get_manifold_point(int idx) const {
104  LightMutexHolder holder(BulletWorld::get_global_lock());
105 
106  nassertr(idx < _manifold->getNumContacts(), nullptr)
107 
108  return new BulletManifoldPoint(_manifold->getContactPoint(idx));
109 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Similar to MutexHolder, but for a light mutex.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.