Panda3D
bulletPersistentManifold.cxx
1 // Filename: bulletPersistentManifold.cxx
2 // Created by: enn0x (07Mar10)
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 #include "bulletPersistentManifold.h"
16 #include "bulletManifoldPoint.h"
17 
18 ////////////////////////////////////////////////////////////////////
19 // Function: BulletPersistentManifold::Constructor
20 // Access: Public
21 // Description:
22 ////////////////////////////////////////////////////////////////////
23 BulletPersistentManifold::
24 BulletPersistentManifold(btPersistentManifold *manifold) : _manifold(manifold) {
25 
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: BulletPersistentManifold::get_contact_breaking_threshold
30 // Access: Published
31 // Description:
32 ////////////////////////////////////////////////////////////////////
33 PN_stdfloat BulletPersistentManifold::
34 get_contact_breaking_threshold() const {
35 
36  return (PN_stdfloat)_manifold->getContactBreakingThreshold();
37 }
38 
39 ////////////////////////////////////////////////////////////////////
40 // Function: BulletPersistentManifold::get_contact_processing_threshold
41 // Access: Published
42 // Description:
43 ////////////////////////////////////////////////////////////////////
44 PN_stdfloat BulletPersistentManifold::
45 get_contact_processing_threshold() const {
46 
47  return (PN_stdfloat)_manifold->getContactProcessingThreshold();
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function: BulletPersistentManifold::set_suspension_stiffness
52 // Access: Published
53 // Description:
54 ////////////////////////////////////////////////////////////////////
55 void BulletPersistentManifold::
56 clear_manifold() {
57 
58  _manifold->clearManifold();
59 }
60 
61 ////////////////////////////////////////////////////////////////////
62 // Function: BulletPersistentManifold::get_node0
63 // Access: Published
64 // Description:
65 ////////////////////////////////////////////////////////////////////
66 const PandaNode *BulletPersistentManifold::
67 get_node0() {
68 
69 #if BT_BULLET_VERSION >= 281
70  const btCollisionObject *obj = _manifold->getBody0();
71 #else
72  const btCollisionObject *obj = (btCollisionObject *)_manifold->getBody0();
73 #endif
74 
75  return (obj) ? (const PandaNode *)obj->getUserPointer(): NULL;
76 }
77 
78 ////////////////////////////////////////////////////////////////////
79 // Function: BulletPersistentManifold::get_node1
80 // Access: Published
81 // Description:
82 ////////////////////////////////////////////////////////////////////
83 const PandaNode *BulletPersistentManifold::
84 get_node1() {
85 
86 #if BT_BULLET_VERSION >= 281
87  const btCollisionObject *obj = _manifold->getBody1();
88 #else
89  const btCollisionObject *obj = (btCollisionObject *)_manifold->getBody1();
90 #endif
91 
92  return (obj) ? (const PandaNode *)obj->getUserPointer(): NULL;
93 }
94 
95 ////////////////////////////////////////////////////////////////////
96 // Function: BulletPersistentManifold::get_num_manifold_points
97 // Access: Published
98 // Description:
99 ////////////////////////////////////////////////////////////////////
100 int BulletPersistentManifold::
101 get_num_manifold_points() const {
102 
103  return _manifold->getNumContacts();
104 }
105 
106 ////////////////////////////////////////////////////////////////////
107 // Function: BulletPersistentManifold::get_manifold_point
108 // Access: Published
109 // Description:
110 ////////////////////////////////////////////////////////////////////
111 BulletManifoldPoint *BulletPersistentManifold::
112 get_manifold_point(int idx) const {
113 
114  nassertr(idx < _manifold->getNumContacts(), NULL)
115 
116  return new BulletManifoldPoint(_manifold->getContactPoint(idx));
117 }
118 
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72