some minor comment-renames, and moved some data from box/sphere into common convex.

This commit is contained in:
ejcoumans
2006-09-28 20:14:10 +00:00
parent 839c9b01c0
commit 21482e4cab
13 changed files with 39 additions and 29 deletions

View File

@@ -17,7 +17,7 @@ subject to the following restrictions:
btVector3 btBoxShape::getHalfExtents() const
{
return m_boxHalfExtents1 * m_localScaling;
return m_implicitShapeDimensions * m_localScaling;
}
//{

View File

@@ -22,21 +22,17 @@ subject to the following restrictions:
#include "LinearMath/btPoint3.h"
#include "LinearMath/btSimdMinMax.h"
///BoxShape implements both a feature based (vertex/edge/plane) and implicit (getSupportingVertex) Box
///btBoxShape implements both a feature based (vertex/edge/plane) and implicit (getSupportingVertex) Box
class btBoxShape: public btPolyhedralConvexShape
{
btVector3 m_boxHalfExtents1;
//btVector3 m_boxHalfExtents1; //use m_implicitShapeDimensions instead
public:
btVector3 getHalfExtents() const;
//{ return m_boxHalfExtents1 * m_localScaling;}
//const btVector3& getHalfExtents() const{ return m_boxHalfExtents1;}
virtual int getShapeType() const { return BOX_SHAPE_PROXYTYPE;}
virtual btVector3 localGetSupportingVertex(const btVector3& vec) const
@@ -81,7 +77,10 @@ public:
}
btBoxShape( const btVector3& boxHalfExtents) : m_boxHalfExtents1(boxHalfExtents){};
btBoxShape( const btVector3& boxHalfExtents)
{
m_implicitShapeDimensions = boxHalfExtents;
};
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;

View File

@@ -33,6 +33,16 @@ struct btConvexCastResult;
/// used in combination with GJK or btConvexCast
class btConvexShape : public btCollisionShape
{
protected:
//local scaling. collisionMargin is not scaled !
btVector3 m_localScaling;
btVector3 m_implicitShapeDimensions;
btScalar m_collisionMargin;
public:
btConvexShape();
@@ -42,7 +52,10 @@ public:
//notice that the vectors should be unit length
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const= 0;
// testing for hullnode code
const btVector3& getImplicitShapeDimensions() const
{
return m_implicitShapeDimensions;
}
///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
@@ -70,11 +83,7 @@ public:
{
return m_collisionMargin;
}
private:
btScalar m_collisionMargin;
//local scaling. collisionMargin is not scaled !
protected:
btVector3 m_localScaling;
};

View File

@@ -21,7 +21,7 @@ subject to the following restrictions:
#define MAX_NUM_SPHERES 5
///MultiSphereShape represents implicit convex hull of a collection of spheres (using getSupportingVertex)
///btMultiSphereShape represents implicit convex hull of a collection of spheres (using getSupportingVertex)
class btMultiSphereShape : public btConvexShape
{

View File

@@ -20,8 +20,8 @@ subject to the following restrictions:
btSphereShape ::btSphereShape (btScalar radius)
: m_radius(radius)
{
{
m_implicitShapeDimensions.setX(radius);
}
btVector3 btSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const

View File

@@ -19,11 +19,10 @@ subject to the following restrictions:
#include "btConvexShape.h"
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
///SphereShape implements an implicit (getSupportingVertex) Sphere
///btSphereShape implements an implicit (getSupportingVertex) Sphere
class btSphereShape : public btConvexShape
{
btScalar m_radius;
public:
btSphereShape (btScalar radius);
@@ -41,7 +40,7 @@ public:
virtual int getShapeType() const { return SPHERE_SHAPE_PROXYTYPE; }
btScalar getRadius() const { return m_radius;}
btScalar getRadius() const { return m_implicitShapeDimensions.getX();}
//debugging
virtual char* getName()const {return "SPHERE";}
@@ -54,7 +53,7 @@ public:
{
//to improve gjk behaviour, use radius+margin as the full margin, so never get into the penetration case
//this means, non-uniform scaling is not supported anymore
return m_localScaling[0] * m_radius + btConvexShape::getMargin();
return m_localScaling.getX() * getRadius() + btConvexShape::getMargin();
}