diff --git a/panda/src/bullet/bulletShape.cxx b/panda/src/bullet/bulletShape.cxx index 769f46ff39..77871b2c34 100644 --- a/panda/src/bullet/bulletShape.cxx +++ b/panda/src/bullet/bulletShape.cxx @@ -73,3 +73,31 @@ set_local_scale(const LVecBase3 &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; +} + diff --git a/panda/src/bullet/bulletShape.h b/panda/src/bullet/bulletShape.h index a42c3cb71c..afdd35f947 100644 --- a/panda/src/bullet/bulletShape.h +++ b/panda/src/bullet/bulletShape.h @@ -20,6 +20,7 @@ #include "bullet_includes.h" #include "typedReferenceCount.h" +#include "boundingSphere.h" //////////////////////////////////////////////////////////////////// // Class : BulletShape @@ -43,6 +44,8 @@ PUBLISHED: PN_stdfloat get_margin() const; + BoundingSphere get_bounds() const; + public: virtual btCollisionShape *ptr() const = 0;