+ Internal improvements for collision shapes
1) add AabbCaching versions of btPolyhedralConvexShape and btMultiSphereShape (this speeds up btMultiSphereShape 'getAabb', and reduces size of btBoxShape) 2) btCylinderShape doesn't derive from btBoxShape anymore + Minor fixes in drawing for btMultiSphereShape, btBoxShape. + Don't re-generate btDebugFont every frame + Disabled velocity prediction for btDbvtBroadphase. Previous default can be restored using btDbvtBroadphase->setVelocityPrediction(1./2.);
This commit is contained in:
@@ -35,6 +35,7 @@ void btConvexInternalShape::setLocalScaling(const btVector3& scaling)
|
||||
void btConvexInternalShape::getAabbSlow(const btTransform& trans,btVector3&minAabb,btVector3&maxAabb) const
|
||||
{
|
||||
|
||||
//use localGetSupportingVertexWithoutMargin?
|
||||
btScalar margin = getMargin();
|
||||
for (int i=0;i<3;i++)
|
||||
{
|
||||
@@ -79,3 +80,71 @@ btVector3 btConvexInternalShape::localGetSupportingVertex(const btVector3& vec)c
|
||||
}
|
||||
|
||||
|
||||
btConvexInternalAabbCachingShape::btConvexInternalAabbCachingShape()
|
||||
: btConvexInternalShape(),
|
||||
m_localAabbMin(1,1,1),
|
||||
m_localAabbMax(-1,-1,-1),
|
||||
m_isLocalAabbValid(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void btConvexInternalAabbCachingShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
|
||||
{
|
||||
getNonvirtualAabb(trans,aabbMin,aabbMax,getMargin());
|
||||
}
|
||||
|
||||
void btConvexInternalAabbCachingShape::setLocalScaling(const btVector3& scaling)
|
||||
{
|
||||
btConvexInternalShape::setLocalScaling(scaling);
|
||||
recalcLocalAabb();
|
||||
}
|
||||
|
||||
|
||||
void btConvexInternalAabbCachingShape::recalcLocalAabb()
|
||||
{
|
||||
m_isLocalAabbValid = true;
|
||||
|
||||
#if 1
|
||||
static const btVector3 _directions[] =
|
||||
{
|
||||
btVector3( 1., 0., 0.),
|
||||
btVector3( 0., 1., 0.),
|
||||
btVector3( 0., 0., 1.),
|
||||
btVector3( -1., 0., 0.),
|
||||
btVector3( 0., -1., 0.),
|
||||
btVector3( 0., 0., -1.)
|
||||
};
|
||||
|
||||
btVector3 _supporting[] =
|
||||
{
|
||||
btVector3( 0., 0., 0.),
|
||||
btVector3( 0., 0., 0.),
|
||||
btVector3( 0., 0., 0.),
|
||||
btVector3( 0., 0., 0.),
|
||||
btVector3( 0., 0., 0.),
|
||||
btVector3( 0., 0., 0.)
|
||||
};
|
||||
|
||||
batchedUnitVectorGetSupportingVertexWithoutMargin(_directions, _supporting, 6);
|
||||
|
||||
for ( int i = 0; i < 3; ++i )
|
||||
{
|
||||
m_localAabbMax[i] = _supporting[i][i] + m_collisionMargin;
|
||||
m_localAabbMin[i] = _supporting[i + 3][i] - m_collisionMargin;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
for (int i=0;i<3;i++)
|
||||
{
|
||||
btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||
vec[i] = btScalar(1.);
|
||||
btVector3 tmp = localGetSupportingVertex(vec);
|
||||
m_localAabbMax[i] = tmp[i]+m_collisionMargin;
|
||||
vec[i] = btScalar(-1.);
|
||||
tmp = localGetSupportingVertex(vec);
|
||||
m_localAabbMin[i] = tmp[i]-m_collisionMargin;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user