Exposing BulletShape.getBounds

This commit is contained in:
enn0x 2014-08-04 22:41:31 +00:00
parent 3d19752dc0
commit aaca66cdc1
2 changed files with 31 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;