Panda3D
bulletShape.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 bulletShape.cxx
10  * @author enn0x
11  * @date 2010-01-23
12  */
13 
14 #include "bulletShape.h"
15 
16 #include "bulletWorld.h"
17 
18 #include "bullet_utils.h"
19 
20 TypeHandle BulletShape::_type_handle;
21 
22 /**
23  *
24  */
25 const char *BulletShape::
26 get_name() const {
27  LightMutexHolder holder(BulletWorld::get_global_lock());
28 
29  return ptr()->getName();
30 }
31 
32 /**
33  *
34  */
35 PN_stdfloat BulletShape::
36 get_margin() const {
37  LightMutexHolder holder(BulletWorld::get_global_lock());
38 
39  return ptr()->getMargin();
40 }
41 
42 /**
43  *
44  */
45 void BulletShape::
46 set_margin(PN_stdfloat margin) {
47  LightMutexHolder holder(BulletWorld::get_global_lock());
48 
49  ptr()->setMargin(margin);
50 }
51 
52 /**
53  *
54  */
55 LVecBase3 BulletShape::
56 get_local_scale() const {
57  LightMutexHolder holder(BulletWorld::get_global_lock());
58 
59  return btVector3_to_LVecBase3(ptr()->getLocalScaling());
60 }
61 
62 /**
63  * Assumes the lock(bullet global lock) is held by the caller
64  */
65 void BulletShape::
66 do_set_local_scale(const LVecBase3 &scale) {
67 
68  nassertv(!scale.is_nan());
69  ptr()->setLocalScaling(LVecBase3_to_btVector3(scale));
70 }
71 
72 /**
73  *
74  */
75 void BulletShape::
76 set_local_scale(const LVecBase3 &scale) {
77  LightMutexHolder holder(BulletWorld::get_global_lock());
78 
79  do_set_local_scale(scale);
80 }
81 
82 /**
83  * Returns the current bounds of this collision shape.
84  */
85 BoundingSphere BulletShape::
86 get_shape_bounds() const {
87  LightMutexHolder holder(BulletWorld::get_global_lock());
88 
89 /*
90  btTransform tr;
91  tr.setIdentity();
92  btVector3 aabbMin,aabbMax;
93  ptr()->getAabb(tr,aabbMin,aabbMax);
94  btVector3 o = tr.getOrigin();
95 cout << "aabbMin " << aabbMin.x() << " " << aabbMin.y() << " " << aabbMin.z() << endl;
96 cout << "aabbMax " << aabbMax.x() << " " << aabbMax.y() << " " << aabbMax.z() << endl;
97 cout << "origin " << aabbMin.x() << " " << aabbMin.y() << " " << aabbMin.z() << endl;
98 */
99 
100  btVector3 center;
101  btScalar radius;
102 
103  ptr()->getBoundingSphere(center, radius);
104  BoundingSphere bounds(btVector3_to_LPoint3(center), (PN_stdfloat)radius);
105 
106  return bounds;
107 }
108 
109 /**
110  *
111  */
112 bool BulletShape::
113 is_polyhedral() const {
114  LightMutexHolder holder(BulletWorld::get_global_lock());
115 
116  return ptr()->isPolyhedral();
117 }
118 
119 /**
120  *
121  */
122 bool BulletShape::
123 is_convex() const {
124  LightMutexHolder holder(BulletWorld::get_global_lock());
125 
126  return ptr()->isConvex();
127 }
128 
129 /**
130  *
131  */
132 bool BulletShape::
133 is_convex_2d() const {
134  LightMutexHolder holder(BulletWorld::get_global_lock());
135 
136  return ptr()->isConvex2d();
137 }
138 
139 /**
140  *
141  */
142 bool BulletShape::
143 is_concave() const {
144  LightMutexHolder holder(BulletWorld::get_global_lock());
145 
146  return ptr()->isConcave();
147 }
148 
149 /**
150  *
151  */
152 bool BulletShape::
153 is_infinite() const {
154  LightMutexHolder holder(BulletWorld::get_global_lock());
155 
156  return ptr()->isInfinite();
157 }
158 
159 /**
160  *
161  */
162 bool BulletShape::
163 is_non_moving() const {
164  LightMutexHolder holder(BulletWorld::get_global_lock());
165 
166  return ptr()->isNonMoving();
167 }
168 
169 /**
170  *
171  */
172 bool BulletShape::
173 is_soft_body() const {
174  LightMutexHolder holder(BulletWorld::get_global_lock());
175 
176  return ptr()->isSoftBody();
177 }
This defines a bounding sphere, consisting of a center and a radius.
Similar to MutexHolder, but for a light mutex.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
void do_set_local_scale(const LVecBase3 &scale)
Assumes the lock(bullet global lock) is held by the caller.
Definition: bulletShape.cxx:66