diff --git a/panda/src/bullet/bulletBodyNode.cxx b/panda/src/bullet/bulletBodyNode.cxx index f0bea49a05..ef1a68df96 100644 --- a/panda/src/bullet/bulletBodyNode.cxx +++ b/panda/src/bullet/bulletBodyNode.cxx @@ -668,3 +668,35 @@ set_transform_dirty() { transform_changed(); } +//////////////////////////////////////////////////////////////////// +// Function: BulletBodyNode::get_shape_bounds +// Access: Published +// Description: Returns the current bounds of all collision shapes +// owned by this body. +//////////////////////////////////////////////////////////////////// +BoundingSphere BulletBodyNode:: +get_shape_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; + + if (_shape) { + _shape->getBoundingSphere(center, radius); + } + + BoundingSphere bounds(btVector3_to_LPoint3(center), (PN_stdfloat)radius); + + return bounds; +} + diff --git a/panda/src/bullet/bulletBodyNode.h b/panda/src/bullet/bulletBodyNode.h index c5be54eb47..59c1ecb32c 100644 --- a/panda/src/bullet/bulletBodyNode.h +++ b/panda/src/bullet/bulletBodyNode.h @@ -24,6 +24,7 @@ #include "collideMask.h" #include "collisionNode.h" #include "transformState.h" +#include "boundingSphere.h" class BulletShape; @@ -47,6 +48,7 @@ PUBLISHED: LPoint3 get_shape_pos(int idx) const; LMatrix4 get_shape_mat(int idx) const; + BoundingSphere get_shape_bounds() const; void add_shapes_from_collision_solids(CollisionNode *cnode); diff --git a/panda/src/bullet/bulletShape.cxx b/panda/src/bullet/bulletShape.cxx index 77871b2c34..c0398e3922 100644 --- a/panda/src/bullet/bulletShape.cxx +++ b/panda/src/bullet/bulletShape.cxx @@ -74,12 +74,12 @@ set_local_scale(const LVecBase3 &scale) { } //////////////////////////////////////////////////////////////////// -// Function: BulletShape::get_bounds +// Function: BulletShape::get_shape_bounds // Access: Published // Description: Returns the current bounds of this collision shape. //////////////////////////////////////////////////////////////////// BoundingSphere BulletShape:: -get_bounds() const { +get_shape_bounds() const { /* btTransform tr; diff --git a/panda/src/bullet/bulletShape.h b/panda/src/bullet/bulletShape.h index afdd35f947..de98ebf1eb 100644 --- a/panda/src/bullet/bulletShape.h +++ b/panda/src/bullet/bulletShape.h @@ -44,7 +44,7 @@ PUBLISHED: PN_stdfloat get_margin() const; - BoundingSphere get_bounds() const; + BoundingSphere get_shape_bounds() const; public: virtual btCollisionShape *ptr() const = 0;