mirror of
https://github.com/bulletphysics/bullet3
synced 2025-01-10 09:20:10 +00:00
deal with degenerate triangles in the btInternalEdgeUtility
thanks to scarrow, see http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=4603&start=15
This commit is contained in:
parent
04b7a7fff4
commit
a5f51905e8
@ -72,6 +72,17 @@ struct btConnectivityProcessor : public btTriangleCallback
|
||||
int sharedVertsA[3]={-1,-1,-1};
|
||||
int sharedVertsB[3]={-1,-1,-1};
|
||||
|
||||
///skip degenerate triangles
|
||||
btScalar crossBSqr = ((triangle[1]-triangle[0]).cross(triangle[2]-triangle[0])).length2();
|
||||
if (crossBSqr < m_triangleInfoMap->m_equalVertexThreshold)
|
||||
return;
|
||||
|
||||
|
||||
btScalar crossASqr = ((m_triangleVerticesA[1]-m_triangleVerticesA[0]).cross(m_triangleVerticesA[2]-m_triangleVerticesA[0])).length2();
|
||||
///skip degenerate triangles
|
||||
if (crossASqr< m_triangleInfoMap->m_equalVertexThreshold)
|
||||
return;
|
||||
|
||||
#if 0
|
||||
printf("triangle A[0] = (%f,%f,%f)\ntriangle A[1] = (%f,%f,%f)\ntriangle A[2] = (%f,%f,%f)\n",
|
||||
m_triangleVerticesA[0].getX(),m_triangleVerticesA[0].getY(),m_triangleVerticesA[0].getZ(),
|
||||
@ -94,8 +105,14 @@ struct btConnectivityProcessor : public btTriangleCallback
|
||||
sharedVertsA[numshared] = i;
|
||||
sharedVertsB[numshared] = j;
|
||||
numshared++;
|
||||
///degenerate case
|
||||
if(numshared >= 3)
|
||||
return;
|
||||
}
|
||||
}
|
||||
///degenerate case
|
||||
if(numshared >= 3)
|
||||
return;
|
||||
}
|
||||
switch (numshared)
|
||||
{
|
||||
|
@ -53,6 +53,8 @@ struct btTriangleInfoMap : public btInternalTriangleInfoMap
|
||||
btScalar m_planarEpsilon; ///used to determine if a triangle edge is planar with zero angle
|
||||
btScalar m_equalVertexThreshold; ///used to compute connectivity: if the distance between two vertices is smaller than m_equalVertexThreshold, they are considered to be 'shared'
|
||||
btScalar m_edgeDistanceThreshold; ///used to determine edge contacts: if the closest distance between a contact point and an edge is smaller than this distance threshold it is considered to "hit the edge"
|
||||
btScalar m_zeroAreaThreshold; ///used to determine if a triangle is degenerate (length squared of cross product of 2 triangle edges < threshold)
|
||||
|
||||
|
||||
btTriangleInfoMap()
|
||||
{
|
||||
@ -60,6 +62,7 @@ struct btTriangleInfoMap : public btInternalTriangleInfoMap
|
||||
m_planarEpsilon = 0.0001f;
|
||||
m_equalVertexThreshold = btScalar(0.0001)*btScalar(0.0001);
|
||||
m_edgeDistanceThreshold = btScalar(0.1);
|
||||
m_zeroAreaThreshold = btScalar(0.0001)*btScalar(0.0001);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user