Panda3D
bulletShape.cxx
1 // Filename: bulletShape.cxx
2 // Created by: enn0x (23Jan10)
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 "bulletShape.h"
16 #include "bullet_utils.h"
17 
18 TypeHandle BulletShape::_type_handle;
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: BulletShape::get_name
22 // Access: Published
23 // Description:
24 ////////////////////////////////////////////////////////////////////
25 const char *BulletShape::
26 get_name() const {
27 
28  return ptr()->getName();
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: BulletShape::get_margin
33 // Access: Published
34 // Description:
35 ////////////////////////////////////////////////////////////////////
36 PN_stdfloat BulletShape::
37 get_margin() const {
38 
39  return ptr()->getMargin();
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: BulletShape::set_margin
44 // Access: Published
45 // Description:
46 ////////////////////////////////////////////////////////////////////
47 void BulletShape::
48 set_margin(PN_stdfloat margin) {
49 
50  ptr()->setMargin(margin);
51 }
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function: BulletShape::get_local_scale
55 // Access: Public
56 // Description:
57 ////////////////////////////////////////////////////////////////////
58 LVecBase3 BulletShape::
59 get_local_scale() const {
60 
61  return btVector3_to_LVecBase3(ptr()->getLocalScaling());
62 }
63 
64 ////////////////////////////////////////////////////////////////////
65 // Function: BulletShape::set_local_scale
66 // Access: Public
67 // Description:
68 ////////////////////////////////////////////////////////////////////
69 void BulletShape::
70 set_local_scale(const LVecBase3 &scale) {
71 
72  nassertv(!scale.is_nan());
73  ptr()->setLocalScaling(LVecBase3_to_btVector3(scale));
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function: BulletShape::get_shape_bounds
78 // Access: Published
79 // Description: Returns the current bounds of this collision shape.
80 ////////////////////////////////////////////////////////////////////
83 
84 /*
85  btTransform tr;
86  tr.setIdentity();
87  btVector3 aabbMin,aabbMax;
88  ptr()->getAabb(tr,aabbMin,aabbMax);
89  btVector3 o = tr.getOrigin();
90 cout << "aabbMin " << aabbMin.x() << " " << aabbMin.y() << " " << aabbMin.z() << endl;
91 cout << "aabbMax " << aabbMax.x() << " " << aabbMax.y() << " " << aabbMax.z() << endl;
92 cout << "origin " << aabbMin.x() << " " << aabbMin.y() << " " << aabbMin.z() << endl;
93 */
94 
95  btVector3 center;
96  btScalar radius;
97 
98  ptr()->getBoundingSphere(center, radius);
99  BoundingSphere bounds(btVector3_to_LPoint3(center), (PN_stdfloat)radius);
100 
101  return bounds;
102 }
103 
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
BoundingSphere get_shape_bounds() const
Returns the current bounds of this collision shape.
Definition: bulletShape.cxx:82
This defines a bounding sphere, consisting of a center and a radius.
bool is_nan() const
Returns true if any component of the vector is not-a-number, false otherwise.
Definition: lvecBase3.h:464
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85