Planar triangle meshes with zero extends (in any direction) could cause quantization failures (division by zero).

Added a positive value to quantization AABB (doesn't affect performance).
This commit is contained in:
ejcoumans 2007-05-23 20:09:46 +00:00
parent cf2337ed7b
commit c1250cd26a
2 changed files with 6 additions and 4 deletions

View File

@ -326,10 +326,12 @@ void btOptimizedBvh::updateBvhNodes(btStridingMeshInterface* meshInterface,int f
}
void btOptimizedBvh::setQuantizationValues(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax)
void btOptimizedBvh::setQuantizationValues(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax,btScalar quantizationMargin)
{
m_bvhAabbMin = bvhAabbMin;
m_bvhAabbMax = bvhAabbMax;
//enlarge the AABB to avoid division by zero when initializing the quantization values
btVector3 clampValue(quantizationMargin,quantizationMargin,quantizationMargin);
m_bvhAabbMin = bvhAabbMin - clampValue;
m_bvhAabbMax = bvhAabbMax + clampValue;
btVector3 aabbSize = m_bvhAabbMax - m_bvhAabbMin;
m_bvhQuantization = btVector3(btScalar(65535.0),btScalar(65535.0),btScalar(65535.0)) / aabbSize;
}

View File

@ -205,7 +205,7 @@ ATTRIBUTE_ALIGNED16(class) btOptimizedBvh
}
void setQuantizationValues(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax);
void setQuantizationValues(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax,btScalar quantizationMargin=btScalar(1.0));
void setInternalNodeEscapeIndex(int nodeIndex, int escapeIndex)
{