Browse Source

Exposing BulletShape.getBounds

enn0x 11 years ago
parent
commit
aaca66cdc1
2 changed files with 31 additions and 0 deletions
  1. 28 0
      panda/src/bullet/bulletShape.cxx
  2. 3 0
      panda/src/bullet/bulletShape.h

+ 28 - 0
panda/src/bullet/bulletShape.cxx

@@ -73,3 +73,31 @@ set_local_scale(const LVecBase3 &scale) {
   ptr()->setLocalScaling(LVecBase3_to_btVector3(scale));
   ptr()->setLocalScaling(LVecBase3_to_btVector3(scale));
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: BulletShape::get_bounds
+//       Access: Published
+//  Description: Returns the current bounds of this collision shape.
+////////////////////////////////////////////////////////////////////
+BoundingSphere BulletShape::
+get_bounds() const {
+
+/*
+  btTransform tr;
+  tr.setIdentity();
+  btVector3 aabbMin,aabbMax;
+  ptr()->getAabb(tr,aabbMin,aabbMax);
+  btVector3 o = tr.getOrigin();
+cout << "aabbMin " << aabbMin.x() << " " << aabbMin.y() << " " << aabbMin.z() << endl;
+cout << "aabbMax " << aabbMax.x() << " " << aabbMax.y() << " " << aabbMax.z() << endl;
+cout << "origin " << aabbMin.x() << " " << aabbMin.y() << " " << aabbMin.z() << endl;
+*/
+
+  btVector3 center;
+  btScalar radius;
+
+  ptr()->getBoundingSphere(center, radius);
+  BoundingSphere bounds(btVector3_to_LPoint3(center), (PN_stdfloat)radius);
+
+  return bounds;
+}
+

+ 3 - 0
panda/src/bullet/bulletShape.h

@@ -20,6 +20,7 @@
 #include "bullet_includes.h"
 #include "bullet_includes.h"
 
 
 #include "typedReferenceCount.h"
 #include "typedReferenceCount.h"
+#include "boundingSphere.h"
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //       Class : BulletShape
 //       Class : BulletShape
@@ -43,6 +44,8 @@ PUBLISHED:
 
 
   PN_stdfloat get_margin() const;
   PN_stdfloat get_margin() const;
 
 
+  BoundingSphere get_bounds() const;
+
 public:
 public:
   virtual btCollisionShape *ptr() const = 0;
   virtual btCollisionShape *ptr() const = 0;