diff --git a/benchmark/ghost_baseline.csv b/benchmark/ghost_baseline.csv index 7d997b8..e5edfd5 100644 --- a/benchmark/ghost_baseline.csv +++ b/benchmark/ghost_baseline.csv @@ -28,7 +28,7 @@ cliff,0,1,box,0,2 cliff,0,1,capsule,0,2 cliff,0,1,upright,0,2 cliff,0,1,sphere,0,2 -cliff,0,1,cylinder,2,2 +cliff,0,1,cylinder,0,2 crest,0,0,box,0,2 crest,0,0,capsule,0,2 crest,0,0,upright,0,2 @@ -44,26 +44,26 @@ bumps,0,0,capsule,0,1 bumps,0,0,upright,0,1 bumps,0,0,sphere,0,1 bumps,0,0,cylinder,0,1 -bumps,0,1,box,0,0 +bumps,0,1,box,0,1 bumps,0,1,capsule,0,1 bumps,0,1,upright,0,1 bumps,0,1,sphere,0,1 -bumps,0,1,cylinder,0,0 +bumps,0,1,cylinder,0,1 tjunction,0,0,box,0,2 tjunction,0,0,capsule,0,2 tjunction,0,0,upright,0,2 tjunction,0,0,sphere,0,2 -tjunction,0,0,cylinder,9,2 +tjunction,0,0,cylinder,6,2 tjunction,0,1,box,0,2 tjunction,0,1,capsule,0,2 tjunction,0,1,upright,0,2 tjunction,0,1,sphere,0,2 tjunction,0,1,cylinder,0,2 -seam,0,0,box,4,1 +seam,0,0,box,2,1 seam,0,0,capsule,0,2 seam,0,0,upright,0,2 seam,0,0,sphere,0,2 -seam,0,0,cylinder,6,1 +seam,0,0,cylinder,4,1 seam,0,1,box,0,2 seam,0,1,capsule,0,2 seam,0,1,upright,0,2 @@ -93,12 +93,12 @@ peel,2,0,box,0,2 peel,2,0,capsule,0,2 peel,2,0,upright,0,2 peel,2,0,sphere,0,2 -peel,2,0,cylinder,6,2 +peel,2,0,cylinder,4,1 peel,2,1,box,0,2 peel,2,1,capsule,0,2 peel,2,1,upright,0,2 peel,2,1,sphere,0,2 -peel,2,1,cylinder,2,2 +peel,2,1,cylinder,0,2 peel,3,0,box,0,2 peel,3,0,capsule,0,2 peel,3,0,upright,0,2 diff --git a/src/mesh_contact.c b/src/mesh_contact.c index 8a7a530..bb41653 100644 --- a/src/mesh_contact.c +++ b/src/mesh_contact.c @@ -666,26 +666,37 @@ static b3NeighborResult b3TestHullFaceNeighbors( const b3Shape* shape, int trian float linearSlop = B3_LINEAR_SLOP; int nearEdges[3]; int nearCount = 0; + bool inwardTilt = false; + bool alongEdge = false; for ( int i = 0; i < 3; ++i ) { b3Vec3 vertex = vertices[i]; - b3Vec3 edge = b3Sub( vertices[i < 2 ? i + 1 : 0], vertex ); - b3Vec3 inward = b3Normalize( b3Cross( triangleNormal, edge ) ); + b3Vec3 edge = b3Normalize( b3Sub( vertices[i < 2 ? i + 1 : 0], vertex ) ); + b3Vec3 inward = b3Cross( triangleNormal, edge ); if ( b3Dot( inward, b3Sub( point, vertex ) ) <= linearSlop ) { nearEdges[nearCount] = i; nearCount += 1; + + // An edge or vertex normal cone tilts outward from the triangle and an edge cone is perpendicular to the edge, a hull face normal need be neither. + inwardTilt = inwardTilt || b3Dot( normal, inward ) > tolerance; + alongEdge = alongEdge || b3AbsFloat( b3Dot( normal, edge ) ) > tolerance; } } b3TriangleFeature feature; - if ( nearCount == 0 ) + if ( nearCount == 0 || inwardTilt ) { // A tilted hull face over the triangle interior, the triangle face owns the normal. return b3_neighborSnap; } else if ( nearCount == 1 ) { + if ( alongEdge ) + { + return b3_neighborSnap; + } + b3TriangleFeature edgeFeatures[3] = { b3_featureEdge1, b3_featureEdge2, b3_featureEdge3 }; feature = edgeFeatures[nearEdges[0]]; } diff --git a/test/test_determinism.c b/test/test_determinism.c index ba738ac..b7c3bea 100644 --- a/test/test_determinism.c +++ b/test/test_determinism.c @@ -32,14 +32,14 @@ #else #define RAGDOLL_SLEEP_STEP 346 #define RAGDOLL_HASH 0x27E7E059 -#define WAVE_PILE_SLEEP_STEP 309 -#define WAVE_PILE_HASH 0xC57E6388 +#define WAVE_PILE_SLEEP_STEP 328 +#define WAVE_PILE_HASH 0x865EC3F3 #define QUERY_SPAWN_SLEEP_STEP 242 #define QUERY_SPAWN_HASH 0xF3AD9BA6 #define QUERY_SPAWN_HIT_COUNT 59 #define QUERY_SPAWN_QUERY_HASH 0xE3271F3D #define MESH_DROP_SLEEP_STEP 197 -#define MESH_DROP_HASH 0xA498DD53 +#define MESH_DROP_HASH 0xD30DB1AE #endif // The goldens above pin exact values for the default four point manifold. A build that