Move some code (mainly constructors) into header files.
Add parameter to optionally compute local AABB for ConvexPointCloudShape Add setter and getter for cached local AABB in PolyhedralConvexShape
This commit is contained in:
@@ -17,30 +17,13 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#include "LinearMath/btQuaternion.h"
|
#include "LinearMath/btQuaternion.h"
|
||||||
|
|
||||||
btConvexPointCloudShape::btConvexPointCloudShape (btVector3* points,int numPoints) : btPolyhedralConvexShape ()
|
|
||||||
{
|
|
||||||
m_shapeType = CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE;
|
|
||||||
m_points = points;
|
|
||||||
m_numPoints = numPoints;
|
|
||||||
|
|
||||||
recalcLocalAabb();
|
|
||||||
}
|
|
||||||
|
|
||||||
void btConvexPointCloudShape::setPoints (btVector3* points, int numPoints)
|
|
||||||
{
|
|
||||||
m_points = points;
|
|
||||||
m_numPoints = numPoints;
|
|
||||||
|
|
||||||
recalcLocalAabb();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void btConvexPointCloudShape::setLocalScaling(const btVector3& scaling)
|
void btConvexPointCloudShape::setLocalScaling(const btVector3& scaling)
|
||||||
{
|
{
|
||||||
m_localScaling = scaling;
|
m_localScaling = scaling;
|
||||||
recalcLocalAabb();
|
recalcLocalAabb();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __SPU__
|
||||||
btVector3 btConvexPointCloudShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
|
btVector3 btConvexPointCloudShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
|
||||||
{
|
{
|
||||||
btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));
|
btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
@@ -124,7 +107,7 @@ btVector3 btConvexPointCloudShape::localGetSupportingVertex(const btVector3& vec
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,24 @@ ATTRIBUTE_ALIGNED16(class) btConvexPointCloudShape : public btPolyhedralConvexSh
|
|||||||
public:
|
public:
|
||||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
btConvexPointCloudShape(btVector3* points,int numPoints);
|
btConvexPointCloudShape(btVector3* points,int numPoints, bool computeAabb = true)
|
||||||
|
{
|
||||||
|
m_shapeType = CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE;
|
||||||
|
m_points = points;
|
||||||
|
m_numPoints = numPoints;
|
||||||
|
|
||||||
void setPoints (btVector3* points, int numPoints);
|
if (computeAabb)
|
||||||
|
recalcLocalAabb();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPoints (btVector3* points, int numPoints, bool computeAabb = true)
|
||||||
|
{
|
||||||
|
m_points = points;
|
||||||
|
m_numPoints = numPoints;
|
||||||
|
|
||||||
|
if (computeAabb)
|
||||||
|
recalcLocalAabb();
|
||||||
|
}
|
||||||
|
|
||||||
btPoint3* getPoints()
|
btPoint3* getPoints()
|
||||||
{
|
{
|
||||||
@@ -47,9 +62,11 @@ public:
|
|||||||
return m_numPoints;
|
return m_numPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __SPU__
|
||||||
virtual btVector3 localGetSupportingVertex(const btVector3& vec)const;
|
virtual btVector3 localGetSupportingVertex(const btVector3& vec)const;
|
||||||
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
|
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
|
||||||
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
|
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//debugging
|
//debugging
|
||||||
|
|||||||
@@ -15,18 +15,6 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h"
|
#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h"
|
||||||
|
|
||||||
btPolyhedralConvexShape::btPolyhedralConvexShape()
|
|
||||||
:btConvexInternalShape(),
|
|
||||||
m_localAabbMin(1,1,1),
|
|
||||||
m_localAabbMax(-1,-1,-1),
|
|
||||||
m_isLocalAabbValid(false),
|
|
||||||
m_optionalHull(0)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
btVector3 btPolyhedralConvexShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
|
btVector3 btPolyhedralConvexShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -31,18 +31,41 @@ protected:
|
|||||||
btVector3 m_localAabbMax;
|
btVector3 m_localAabbMax;
|
||||||
bool m_isLocalAabbValid;
|
bool m_isLocalAabbValid;
|
||||||
|
|
||||||
btPolyhedralConvexShape();
|
btPolyhedralConvexShape() :btConvexInternalShape(),
|
||||||
|
m_localAabbMin(1,1,1),
|
||||||
|
m_localAabbMax(-1,-1,-1),
|
||||||
|
m_isLocalAabbValid(false),
|
||||||
|
m_optionalHull(0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//brute force implementations
|
//brute force implementations
|
||||||
|
|
||||||
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
|
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
|
||||||
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
|
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
|
||||||
|
|
||||||
|
|
||||||
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const;
|
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const;
|
||||||
|
|
||||||
|
|
||||||
|
void setCachedLocalAabb (const btVector3& aabbMin, const btVector3& aabbMax)
|
||||||
|
{
|
||||||
|
m_isLocalAabbValid = true;
|
||||||
|
m_localAabbMin = aabbMin;
|
||||||
|
m_localAabbMax = aabbMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void getCachedLocalAabb (btVector3& aabbMin, btVector3& aabbMax) const
|
||||||
|
{
|
||||||
|
btAssert(m_isLocalAabbValid);
|
||||||
|
aabbMin = m_localAabbMin;
|
||||||
|
aabbMax = m_localAabbMax;
|
||||||
|
}
|
||||||
|
|
||||||
inline void getNonvirtualAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax, btScalar margin) const
|
inline void getNonvirtualAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax, btScalar margin) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,6 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#include "LinearMath/btQuaternion.h"
|
#include "LinearMath/btQuaternion.h"
|
||||||
|
|
||||||
|
|
||||||
btSphereShape ::btSphereShape (btScalar radius) : btConvexInternalShape ()
|
|
||||||
{
|
|
||||||
m_shapeType = SPHERE_SHAPE_PROXYTYPE;
|
|
||||||
m_implicitShapeDimensions.setX(radius);
|
|
||||||
m_collisionMargin = radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
btVector3 btSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
|
btVector3 btSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
|
||||||
{
|
{
|
||||||
(void)vec;
|
(void)vec;
|
||||||
|
|||||||
@@ -27,8 +27,12 @@ ATTRIBUTE_ALIGNED16(class) btSphereShape : public btConvexInternalShape
|
|||||||
public:
|
public:
|
||||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
btSphereShape (btScalar radius);
|
btSphereShape (btScalar radius) : btConvexInternalShape ()
|
||||||
|
{
|
||||||
|
m_shapeType = SPHERE_SHAPE_PROXYTYPE;
|
||||||
|
m_implicitShapeDimensions.setX(radius);
|
||||||
|
m_collisionMargin = radius;
|
||||||
|
}
|
||||||
|
|
||||||
virtual btVector3 localGetSupportingVertex(const btVector3& vec)const;
|
virtual btVector3 localGetSupportingVertex(const btVector3& vec)const;
|
||||||
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
|
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
|
||||||
|
|||||||
Reference in New Issue
Block a user