fix saddle tunnel

This commit is contained in:
Erin Catto 2026-11-08 09:56:24 -08:00
commit a2adbafec0
6 changed files with 1569 additions and 1126 deletions

View file

@ -3212,7 +3212,7 @@ int b3Hull2D( b3Point2D* pts, int count, b3Point2D* hull, int flags )
}
else
{
b3Weld2D( pts, count );
count1 = b3Weld2D( pts, count );
}
bool keepCollinear = ( flags & b3_hull2DKeepCollinear ) != 0;

View file

@ -759,19 +759,19 @@ static b3NeighborResult b3TestNeighbors( const b3Shape* shape, int triangleIndex
return b3IsInVertexRegion( vertices, vertexIndex, normal ) ? b3_neighborSkip : b3_neighborSnap;
}
// Check vertex area first to avoid a saddle tunnel.
if ( vertexIndex != B3_NULL_INDEX && b3IsInVertexRegion( vertices, vertexIndex, normal ) &&
b3IsInVertexCone( shape, triangleIndex, vertexIndex, meshToLocal, normal ) )
{
return b3_neighborAdmit;
}
if ( convex )
{
// todo comment
return *ownerEdge == B3_NULL_INDEX ? b3_neighborDrop : b3_neighborSkip;
}
// Check vertex.
if ( vertexIndex != B3_NULL_INDEX &&
b3AdmitsVertexNormal( shape, triangleIndex, vertices, vertexIndex, meshToLocal, normal ) )
{
return b3_neighborAdmit;
}
return b3_neighborSnap;
}