more work on hashed pairmanager. growing doesn't work yet, so need to allocate enough room for the overlapping pairs in advance.
boxbox reports contact point in B, rather then average point box, cylinder use halfextents corrected for scaling and margin. made the margin in this halfextents explicit in the 'getHalfExtentsWithMargin' and 'getHalfExtentsWithoutMargin' integrated changed for ODE quickstep solver replaced inline with SIMD_FORCE_INLINE some minor optimizations in the btSequentialImpulseConstraintSolver added cone drawing (for X,Y,Z cones)
This commit is contained in:
@@ -15,16 +15,13 @@ subject to the following restrictions:
|
||||
|
||||
#include "btBoxShape.h"
|
||||
|
||||
btVector3 btBoxShape::getHalfExtents() const
|
||||
{
|
||||
return m_implicitShapeDimensions * m_localScaling;
|
||||
}
|
||||
|
||||
//{
|
||||
|
||||
|
||||
void btBoxShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
|
||||
{
|
||||
btVector3 halfExtents = getHalfExtents();
|
||||
const btVector3& halfExtents = getHalfExtentsWithoutMargin();
|
||||
|
||||
btMatrix3x3 abs_b = t.getBasis().absolute();
|
||||
btPoint3 center = t.getOrigin();
|
||||
@@ -43,7 +40,7 @@ void btBoxShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabb
|
||||
void btBoxShape::calculateLocalInertia(btScalar mass,btVector3& inertia)
|
||||
{
|
||||
//btScalar margin = btScalar(0.);
|
||||
btVector3 halfExtents = getHalfExtents();
|
||||
btVector3 halfExtents = getHalfExtentsWithMargin();
|
||||
|
||||
btScalar lx=btScalar(2.)*(halfExtents.x());
|
||||
btScalar ly=btScalar(2.)*(halfExtents.y());
|
||||
|
||||
@@ -31,25 +31,37 @@ class btBoxShape: public btPolyhedralConvexShape
|
||||
|
||||
public:
|
||||
|
||||
btVector3 getHalfExtents() const;
|
||||
|
||||
btVector3 getHalfExtentsWithMargin() const
|
||||
{
|
||||
btVector3 halfExtents = getHalfExtentsWithoutMargin();
|
||||
btVector3 margin(getMargin(),getMargin(),getMargin());
|
||||
halfExtents += margin;
|
||||
return halfExtents;
|
||||
}
|
||||
|
||||
const btVector3& getHalfExtentsWithoutMargin() const
|
||||
{
|
||||
return m_implicitShapeDimensions;//changed in Bullet 2.63: assume the scaling and margin are included
|
||||
}
|
||||
|
||||
|
||||
virtual int getShapeType() const { return BOX_SHAPE_PROXYTYPE;}
|
||||
|
||||
virtual btVector3 localGetSupportingVertex(const btVector3& vec) const
|
||||
{
|
||||
btVector3 halfExtents = getHalfExtents();
|
||||
btVector3 halfExtents = getHalfExtentsWithoutMargin();
|
||||
btVector3 margin(getMargin(),getMargin(),getMargin());
|
||||
halfExtents += margin;
|
||||
|
||||
return btVector3(btFsels(vec.x(), halfExtents.x(), -halfExtents.x()),
|
||||
btFsels(vec.y(), halfExtents.y(), -halfExtents.y()),
|
||||
btFsels(vec.z(), halfExtents.z(), -halfExtents.z()));
|
||||
}
|
||||
|
||||
virtual inline btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const
|
||||
SIMD_FORCE_INLINE btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const
|
||||
{
|
||||
btVector3 halfExtents = getHalfExtents();
|
||||
btVector3 margin(getMargin(),getMargin(),getMargin());
|
||||
halfExtents -= margin;
|
||||
|
||||
const btVector3& halfExtents = getHalfExtentsWithoutMargin();
|
||||
|
||||
return btVector3(btFsels(vec.x(), halfExtents.x(), -halfExtents.x()),
|
||||
btFsels(vec.y(), halfExtents.y(), -halfExtents.y()),
|
||||
btFsels(vec.z(), halfExtents.z(), -halfExtents.z()));
|
||||
@@ -57,11 +69,8 @@ public:
|
||||
|
||||
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
|
||||
{
|
||||
btVector3 halfExtents = getHalfExtents();
|
||||
btVector3 margin(getMargin(),getMargin(),getMargin());
|
||||
halfExtents -= margin;
|
||||
|
||||
|
||||
const btVector3& halfExtents = getHalfExtentsWithoutMargin();
|
||||
|
||||
for (int i=0;i<numVectors;i++)
|
||||
{
|
||||
const btVector3& vec = vectors[i];
|
||||
@@ -75,9 +84,33 @@ public:
|
||||
|
||||
btBoxShape( const btVector3& boxHalfExtents)
|
||||
{
|
||||
m_implicitShapeDimensions = boxHalfExtents;
|
||||
btVector3 margin(getMargin(),getMargin(),getMargin());
|
||||
m_implicitShapeDimensions = (boxHalfExtents * m_localScaling) - margin;
|
||||
};
|
||||
|
||||
|
||||
virtual void setMargin(btScalar collisionMargin)
|
||||
{
|
||||
//correct the m_implicitShapeDimensions for the margin
|
||||
btVector3 oldMargin(getMargin(),getMargin(),getMargin());
|
||||
btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
|
||||
|
||||
btConvexInternalShape::setMargin(collisionMargin);
|
||||
btVector3 newMargin(getMargin(),getMargin(),getMargin());
|
||||
m_implicitShapeDimensions = implicitShapeDimensionsWithMargin - newMargin;
|
||||
|
||||
}
|
||||
virtual void setLocalScaling(const btVector3& scaling)
|
||||
{
|
||||
btVector3 oldMargin(getMargin(),getMargin(),getMargin());
|
||||
btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
|
||||
btVector3 unScaledImplicitShapeDimensionsWithMargin = implicitShapeDimensionsWithMargin / m_localScaling;
|
||||
|
||||
btConvexInternalShape::setLocalScaling(scaling);
|
||||
|
||||
m_implicitShapeDimensions = (unScaledImplicitShapeDimensionsWithMargin * m_localScaling) - oldMargin;
|
||||
|
||||
}
|
||||
|
||||
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
|
||||
|
||||
|
||||
@@ -112,7 +145,7 @@ public:
|
||||
|
||||
virtual void getVertex(int i,btVector3& vtx) const
|
||||
{
|
||||
btVector3 halfExtents = getHalfExtents();
|
||||
btVector3 halfExtents = getHalfExtentsWithoutMargin();
|
||||
|
||||
vtx = btVector3(
|
||||
halfExtents.x() * (1-(i&1)) - halfExtents.x() * (i&1),
|
||||
@@ -123,7 +156,7 @@ public:
|
||||
|
||||
virtual void getPlaneEquation(btVector4& plane,int i) const
|
||||
{
|
||||
btVector3 halfExtents = getHalfExtents();
|
||||
btVector3 halfExtents = getHalfExtentsWithoutMargin();
|
||||
|
||||
switch (i)
|
||||
{
|
||||
@@ -230,7 +263,7 @@ public:
|
||||
|
||||
virtual bool isInside(const btPoint3& pt,btScalar tolerance) const
|
||||
{
|
||||
btVector3 halfExtents = getHalfExtents();
|
||||
btVector3 halfExtents = getHalfExtentsWithoutMargin();
|
||||
|
||||
//btScalar minDist = 2*tolerance;
|
||||
|
||||
|
||||
@@ -49,26 +49,26 @@ public:
|
||||
|
||||
#ifndef __SPU__
|
||||
|
||||
inline bool isPolyhedral() const
|
||||
SIMD_FORCE_INLINE bool isPolyhedral() const
|
||||
{
|
||||
return btBroadphaseProxy::isPolyhedral(getShapeType());
|
||||
}
|
||||
|
||||
inline bool isConvex() const
|
||||
SIMD_FORCE_INLINE bool isConvex() const
|
||||
{
|
||||
return btBroadphaseProxy::isConvex(getShapeType());
|
||||
}
|
||||
inline bool isConcave() const
|
||||
SIMD_FORCE_INLINE bool isConcave() const
|
||||
{
|
||||
return btBroadphaseProxy::isConcave(getShapeType());
|
||||
}
|
||||
inline bool isCompound() const
|
||||
SIMD_FORCE_INLINE bool isCompound() const
|
||||
{
|
||||
return btBroadphaseProxy::isCompound(getShapeType());
|
||||
}
|
||||
|
||||
///isInfinite is used to catch simulation error (aabb check)
|
||||
inline bool isInfinite() const
|
||||
SIMD_FORCE_INLINE bool isInfinite() const
|
||||
{
|
||||
return btBroadphaseProxy::isInfinite(getShapeType());
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ void btCylinderShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3&
|
||||
}
|
||||
|
||||
|
||||
inline btVector3 CylinderLocalSupportX(const btVector3& halfExtents,const btVector3& v)
|
||||
SIMD_FORCE_INLINE btVector3 CylinderLocalSupportX(const btVector3& halfExtents,const btVector3& v)
|
||||
{
|
||||
const int cylinderUpAxis = 0;
|
||||
const int XX = 1;
|
||||
@@ -163,24 +163,24 @@ const int ZZ = 1;
|
||||
|
||||
btVector3 btCylinderShapeX::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
|
||||
{
|
||||
return CylinderLocalSupportX(getHalfExtents(),vec);
|
||||
return CylinderLocalSupportX(getHalfExtentsWithoutMargin(),vec);
|
||||
}
|
||||
|
||||
|
||||
btVector3 btCylinderShapeZ::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
|
||||
{
|
||||
return CylinderLocalSupportZ(getHalfExtents(),vec);
|
||||
return CylinderLocalSupportZ(getHalfExtentsWithoutMargin(),vec);
|
||||
}
|
||||
btVector3 btCylinderShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
|
||||
{
|
||||
return CylinderLocalSupportY(getHalfExtents(),vec);
|
||||
return CylinderLocalSupportY(getHalfExtentsWithoutMargin(),vec);
|
||||
}
|
||||
|
||||
void btCylinderShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
|
||||
{
|
||||
for (int i=0;i<numVectors;i++)
|
||||
{
|
||||
supportVerticesOut[i] = CylinderLocalSupportY(getHalfExtents(),vectors[i]);
|
||||
supportVerticesOut[i] = CylinderLocalSupportY(getHalfExtentsWithoutMargin(),vectors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ void btCylinderShapeZ::batchedUnitVectorGetSupportingVertexWithoutMargin(const b
|
||||
{
|
||||
for (int i=0;i<numVectors;i++)
|
||||
{
|
||||
supportVerticesOut[i] = CylinderLocalSupportZ(getHalfExtents(),vectors[i]);
|
||||
supportVerticesOut[i] = CylinderLocalSupportZ(getHalfExtentsWithoutMargin(),vectors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ void btCylinderShapeX::batchedUnitVectorGetSupportingVertexWithoutMargin(const b
|
||||
{
|
||||
for (int i=0;i<numVectors;i++)
|
||||
{
|
||||
supportVerticesOut[i] = CylinderLocalSupportX(getHalfExtents(),vectors[i]);
|
||||
supportVerticesOut[i] = CylinderLocalSupportX(getHalfExtentsWithoutMargin(),vectors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
|
||||
virtual btScalar getRadius() const
|
||||
{
|
||||
return getHalfExtents().getX();
|
||||
return getHalfExtentsWithMargin().getX();
|
||||
}
|
||||
|
||||
//debugging
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
|
||||
virtual btScalar getRadius() const
|
||||
{
|
||||
return getHalfExtents().getY();
|
||||
return getHalfExtentsWithMargin().getY();
|
||||
}
|
||||
|
||||
};
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
|
||||
virtual btScalar getRadius() const
|
||||
{
|
||||
return getHalfExtents().getX();
|
||||
return getHalfExtentsWithMargin().getX();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -285,7 +285,7 @@ protected:
|
||||
#define USE_BANCHLESS 1
|
||||
#ifdef USE_BANCHLESS
|
||||
//This block replaces the block below and uses no branches, and replaces the 8 bit return with a 32 bit return for improved performance (~3x on XBox 360)
|
||||
inline unsigned testQuantizedAabbAgainstQuantizedAabb(unsigned short int* aabbMin1,unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) const
|
||||
SIMD_FORCE_INLINE unsigned testQuantizedAabbAgainstQuantizedAabb(unsigned short int* aabbMin1,unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) const
|
||||
{
|
||||
return btSelect((unsigned)((aabbMin1[0] <= aabbMax2[0]) & (aabbMax1[0] >= aabbMin2[0])
|
||||
& (aabbMin1[2] <= aabbMax2[2]) & (aabbMax1[2] >= aabbMin2[2])
|
||||
@@ -293,7 +293,7 @@ protected:
|
||||
1, 0);
|
||||
}
|
||||
#else
|
||||
inline bool testQuantizedAabbAgainstQuantizedAabb(unsigned short int* aabbMin1,unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) const
|
||||
SIMD_FORCE_INLINE bool testQuantizedAabbAgainstQuantizedAabb(unsigned short int* aabbMin1,unsigned short int* aabbMax1,const unsigned short int* aabbMin2,const unsigned short int* aabbMax2) const
|
||||
{
|
||||
bool overlap = true;
|
||||
overlap = (aabbMin1[0] > aabbMax2[0] || aabbMax1[0] < aabbMin2[0]) ? false : overlap;
|
||||
@@ -316,7 +316,7 @@ public:
|
||||
|
||||
void reportSphereOverlappingNodex(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const;
|
||||
|
||||
inline void quantizeWithClamp(unsigned short* out, const btVector3& point) const
|
||||
SIMD_FORCE_INLINE void quantizeWithClamp(unsigned short* out, const btVector3& point) const
|
||||
{
|
||||
|
||||
btAssert(m_useQuantization);
|
||||
@@ -347,12 +347,12 @@ public:
|
||||
void updateBvhNodes(btStridingMeshInterface* meshInterface,int firstNode,int endNode,int index);
|
||||
|
||||
|
||||
inline QuantizedNodeArray& getQuantizedNodeArray()
|
||||
SIMD_FORCE_INLINE QuantizedNodeArray& getQuantizedNodeArray()
|
||||
{
|
||||
return m_quantizedContiguousNodes;
|
||||
}
|
||||
|
||||
inline BvhSubtreeInfoArray& getSubtreeInfoArray()
|
||||
SIMD_FORCE_INLINE BvhSubtreeInfoArray& getSubtreeInfoArray()
|
||||
{
|
||||
return m_SubtreeHeaders;
|
||||
}
|
||||
@@ -368,7 +368,7 @@ public:
|
||||
|
||||
static unsigned int getAlignmentSerializationPadding();
|
||||
|
||||
inline bool isQuantized()
|
||||
SIMD_FORCE_INLINE bool isQuantized()
|
||||
{
|
||||
return m_useQuantization;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user