mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
Bullet: exposing bounds for single shape and all shapes.
This commit is contained in:
parent
aaca66cdc1
commit
d658ba7254
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user