hull neighbors

This commit is contained in:
Erin Catto 2026-10-31 11:43:25 -07:00
commit c201d06325
10 changed files with 213 additions and 73 deletions

View file

@ -23,43 +23,43 @@ cliff,0,0,box,0,2
cliff,0,0,capsule,0,2
cliff,0,0,upright,0,2
cliff,0,0,sphere,0,2
cliff,0,0,cylinder,2,2
cliff,0,1,box,2,2
cliff,0,0,cylinder,0,2
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,82,1
crest,0,0,box,15,1
cliff,0,1,cylinder,2,2
crest,0,0,box,0,2
crest,0,0,capsule,0,2
crest,0,0,upright,0,2
crest,0,0,sphere,0,2
crest,0,0,cylinder,12,1
crest,0,1,box,12,1
crest,0,0,cylinder,0,2
crest,0,1,box,0,2
crest,0,1,capsule,0,2
crest,0,1,upright,0,2
crest,0,1,sphere,0,2
crest,0,1,cylinder,14,0
bumps,0,0,box,602,0
crest,0,1,cylinder,0,2
bumps,0,0,box,0,1
bumps,0,0,capsule,0,1
bumps,0,0,upright,0,1
bumps,0,0,sphere,0,1
bumps,0,0,cylinder,91,0
bumps,0,1,box,10,0
bumps,0,0,cylinder,0,1
bumps,0,1,box,0,0
bumps,0,1,capsule,0,1
bumps,0,1,upright,0,1
bumps,0,1,sphere,0,1
bumps,0,1,cylinder,20,0
bumps,0,1,cylinder,0,0
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,11,2
tjunction,0,0,cylinder,9,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,12,2
seam,0,0,box,6,1
tjunction,0,1,cylinder,0,2
seam,0,0,box,4,1
seam,0,0,capsule,0,2
seam,0,0,upright,0,2
seam,0,0,sphere,0,2
@ -69,43 +69,43 @@ seam,0,1,capsule,0,2
seam,0,1,upright,0,2
seam,0,1,sphere,0,2
seam,0,1,cylinder,0,2
peel,0,0,box,6,2
peel,0,0,box,0,2
peel,0,0,capsule,0,2
peel,0,0,upright,0,2
peel,0,0,sphere,0,2
peel,0,0,cylinder,2,1
peel,0,1,box,2,2
peel,0,0,cylinder,0,2
peel,0,1,box,0,2
peel,0,1,capsule,0,2
peel,0,1,upright,0,2
peel,0,1,sphere,0,2
peel,0,1,cylinder,0,2
peel,1,0,box,4,2
peel,1,0,box,0,2
peel,1,0,capsule,0,2
peel,1,0,upright,0,2
peel,1,0,sphere,0,2
peel,1,0,cylinder,2,2
peel,1,1,box,2,2
peel,1,0,cylinder,0,2
peel,1,1,box,0,2
peel,1,1,capsule,0,2
peel,1,1,upright,0,2
peel,1,1,sphere,0,2
peel,1,1,cylinder,0,2
peel,2,0,box,8,1
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,36,1
peel,2,1,box,4,2
peel,2,0,cylinder,6,2
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,20,2
peel,3,0,box,9,1
peel,2,1,cylinder,2,2
peel,3,0,box,0,2
peel,3,0,capsule,0,2
peel,3,0,upright,0,2
peel,3,0,sphere,0,2
peel,3,0,cylinder,28,2
peel,3,1,box,6,2
peel,3,0,cylinder,0,2
peel,3,1,box,0,2
peel,3,1,capsule,0,2
peel,3,1,upright,0,2
peel,3,1,sphere,0,2
peel,3,1,cylinder,12,2
peel,3,1,cylinder,0,2

1 scene preset mirror body ghosts runs
23 cliff 0 0 capsule 0 2
24 cliff 0 0 upright 0 2
25 cliff 0 0 sphere 0 2
26 cliff 0 0 cylinder 2 0 2
27 cliff 0 1 box 2 0 2
28 cliff 0 1 capsule 0 2
29 cliff 0 1 upright 0 2
30 cliff 0 1 sphere 0 2
31 cliff 0 1 cylinder 82 2 1 2
32 crest 0 0 box 15 0 1 2
33 crest 0 0 capsule 0 2
34 crest 0 0 upright 0 2
35 crest 0 0 sphere 0 2
36 crest 0 0 cylinder 12 0 1 2
37 crest 0 1 box 12 0 1 2
38 crest 0 1 capsule 0 2
39 crest 0 1 upright 0 2
40 crest 0 1 sphere 0 2
41 crest 0 1 cylinder 14 0 0 2
42 bumps 0 0 box 602 0 0 1
43 bumps 0 0 capsule 0 1
44 bumps 0 0 upright 0 1
45 bumps 0 0 sphere 0 1
46 bumps 0 0 cylinder 91 0 0 1
47 bumps 0 1 box 10 0 0
48 bumps 0 1 capsule 0 1
49 bumps 0 1 upright 0 1
50 bumps 0 1 sphere 0 1
51 bumps 0 1 cylinder 20 0 0
52 tjunction 0 0 box 0 2
53 tjunction 0 0 capsule 0 2
54 tjunction 0 0 upright 0 2
55 tjunction 0 0 sphere 0 2
56 tjunction 0 0 cylinder 11 9 2
57 tjunction 0 1 box 0 2
58 tjunction 0 1 capsule 0 2
59 tjunction 0 1 upright 0 2
60 tjunction 0 1 sphere 0 2
61 tjunction 0 1 cylinder 12 0 2
62 seam 0 0 box 6 4 1
63 seam 0 0 capsule 0 2
64 seam 0 0 upright 0 2
65 seam 0 0 sphere 0 2
69 seam 0 1 upright 0 2
70 seam 0 1 sphere 0 2
71 seam 0 1 cylinder 0 2
72 peel 0 0 box 6 0 2
73 peel 0 0 capsule 0 2
74 peel 0 0 upright 0 2
75 peel 0 0 sphere 0 2
76 peel 0 0 cylinder 2 0 1 2
77 peel 0 1 box 2 0 2
78 peel 0 1 capsule 0 2
79 peel 0 1 upright 0 2
80 peel 0 1 sphere 0 2
81 peel 0 1 cylinder 0 2
82 peel 1 0 box 4 0 2
83 peel 1 0 capsule 0 2
84 peel 1 0 upright 0 2
85 peel 1 0 sphere 0 2
86 peel 1 0 cylinder 2 0 2
87 peel 1 1 box 2 0 2
88 peel 1 1 capsule 0 2
89 peel 1 1 upright 0 2
90 peel 1 1 sphere 0 2
91 peel 1 1 cylinder 0 2
92 peel 2 0 box 8 0 1 2
93 peel 2 0 capsule 0 2
94 peel 2 0 upright 0 2
95 peel 2 0 sphere 0 2
96 peel 2 0 cylinder 36 6 1 2
97 peel 2 1 box 4 0 2
98 peel 2 1 capsule 0 2
99 peel 2 1 upright 0 2
100 peel 2 1 sphere 0 2
101 peel 2 1 cylinder 20 2 2
102 peel 3 0 box 9 0 1 2
103 peel 3 0 capsule 0 2
104 peel 3 0 upright 0 2
105 peel 3 0 sphere 0 2
106 peel 3 0 cylinder 28 0 2
107 peel 3 1 box 6 0 2
108 peel 3 1 capsule 0 2
109 peel 3 1 upright 0 2
110 peel 3 1 sphere 0 2
111 peel 3 1 cylinder 12 0 2

View file

@ -118,7 +118,7 @@ static void RunConfig( Config* config, GhostSettings settings, int stepCount, bo
static void FormatRow( char* buffer, size_t size, const Config* config )
{
if ( config->scene == e_ghostInternalEdges )
if ( config->scene == e_ghostInternal )
{
snprintf( buffer, size, "%s %d%s", s_sceneKeys[config->scene], config->preset, config->mirror ? " mirror" : "" );
}
@ -289,10 +289,10 @@ int main( int argc, char** argv )
continue;
}
int presetCount = scene == e_ghostInternalEdges ? GHOST_PEEL_PRESET_COUNT : 1;
int presetCount = scene == e_ghostInternal ? GHOST_PEEL_PRESET_COUNT : 1;
for ( int preset = 0; preset < presetCount; ++preset )
{
if ( scene == e_ghostInternalEdges && presetFilter >= 0 && preset != presetFilter )
if ( scene == e_ghostInternal && presetFilter >= 0 && preset != presetFilter )
{
continue;
}

View file

@ -1,9 +1,9 @@
filter,base,generations,shape,tunnels,awake,depth4,depth8,depth16,depth32
all,12345,1000,box,0,0,1386,213,2,0
all,12345,1000,box,0,0,1536,214,2,0
all,12345,1000,capsule,0,0,14474,3477,28,0
all,12345,1000,cylinder,0,0,10741,2305,35,0
all,12345,1000,cylinder,0,0,11200,2338,36,0
all,12345,1000,sphere,0,0,56,0,0,0
all,12345,16000,box,0,0,21423,3126,42,0
all,12345,16000,box,0,0,23701,3164,43,0
all,12345,16000,capsule,0,0,231138,54408,513,0
all,12345,16000,cylinder,0,0,172961,36766,453,0
all,12345,16000,cylinder,0,0,179066,37366,473,0
all,12345,16000,sphere,0,0,989,0,0,0

1 filter base generations shape tunnels awake depth4 depth8 depth16 depth32
2 all 12345 1000 box 0 0 1386 1536 213 214 2 0
3 all 12345 1000 capsule 0 0 14474 3477 28 0
4 all 12345 1000 cylinder 0 0 10741 11200 2305 2338 35 36 0
5 all 12345 1000 sphere 0 0 56 0 0 0
6 all 12345 16000 box 0 0 21423 23701 3126 3164 42 43 0
7 all 12345 16000 capsule 0 0 231138 54408 513 0
8 all 12345 16000 cylinder 0 0 172961 179066 36766 37366 453 473 0
9 all 12345 16000 sphere 0 0 989 0 0 0

View file

@ -1688,7 +1688,7 @@ public:
settings.scene = (GhostScene)scene;
rebuild = true;
if ( settings.scene == e_ghostInternalEdges )
if ( settings.scene == e_ghostInternal )
{
m_camera->SetView( 60.0f, 20.0f, 160.0f, { 0.0f, 30.0f, 0.0f } );
}
@ -1698,7 +1698,7 @@ public:
}
}
if ( settings.scene == e_ghostInternalEdges )
if ( settings.scene == e_ghostInternal )
{
rebuild |= ImGui::Combo( "Preset", &settings.peelPreset, g_ghostPeelPresetNames, GHOST_PEEL_PRESET_COUNT );
}

View file

@ -28,16 +28,16 @@ static const PeelPreset s_peelPresets[GHOST_PEEL_PRESET_COUNT] = {
};
const char* g_ghostSceneNames[e_ghostSceneCount] = {
"Flat", "Concave Ramp", "Cliff", "Crest", "Bumps", "T-Junction", "Shape Seam", "PEEL Internal Edges",
"Flat", "Concave", "Cliff", "Crest", "Bumps", "T-Junction", "Seam", "Internal",
};
const char* g_ghostBodyNames[e_ghostBodyCount] = { "Box", "Capsule", "Upright Capsule", "Sphere", "Cylinder" };
const char* g_ghostBodyNames[e_ghostBodyCount] = { "Box", "H Capsule", "V Capsule", "Sphere", "Cylinder" };
const char* g_ghostPeelPresetNames[GHOST_PEEL_PRESET_COUNT] = {
"4 x 0.1, start -55",
"4 x 0.1, start -54",
"4 x 0.01, start -55",
"16 x 0.01, start -54",
"4.1:-55",
"4.1:-54",
"4.01:-55",
"16.01:-54",
};
GhostSettings GetDefaultGhostSettings( void )
@ -207,7 +207,7 @@ void CreateGhostGround( b3WorldId worldId, GhostCollisionsData* data )
switch ( settings->scene )
{
case e_ghostConcaveRamp:
case e_ghostConcave:
{
float slope = 8.0f * B3_PI / 180.0f;
PushProfile( data, -h, h * tanf( slope ) );
@ -241,7 +241,7 @@ void CreateGhostGround( b3WorldId worldId, GhostCollisionsData* data )
}
break;
case e_ghostInternalEdges:
case e_ghostInternal:
// PEEL's curved mesh: 32 rows 4 m apart, each step up 1.25 times the last, sliding toward +x
for ( int i = 31; i >= 0; --i )
{
@ -268,7 +268,7 @@ void CreateGhostGround( b3WorldId worldId, GhostCollisionsData* data )
AddStrip( &builder, right, 2, cellSize, cellSize, mirror );
AddMesh( data, &builder, false );
}
else if ( settings->scene == e_ghostShapeSeam )
else if ( settings->scene == e_ghostSeam )
{
// Two mesh shapes meeting at x = 0, so the seam spans two contacts
AddStrip( &builder, left, 2, cellSize, cellSize, mirror );
@ -276,7 +276,7 @@ void CreateGhostGround( b3WorldId worldId, GhostCollisionsData* data )
AddStrip( &builder, right, 2, cellSize, cellSize, mirror );
AddMesh( data, &builder, false );
}
else if ( settings->scene == e_ghostInternalEdges )
else if ( settings->scene == e_ghostInternal )
{
// The mesh has no friction and the ground plane under it does, as in PEEL
PeelPreset preset = s_peelPresets[settings->peelPreset];
@ -309,7 +309,7 @@ void LaunchGhostBody( b3WorldId worldId, GhostCollisionsData* data )
const GhostSettings* settings = &data->settings;
// PEEL drops its bodies from rest, sized in meters rather than tenths
bool peel = settings->scene == e_ghostInternalEdges;
bool peel = settings->scene == e_ghostInternal;
float boxHalf = peel ? 1.0f : 0.2f;
float capsuleRadius = peel ? 1.0f : 0.2f;
float capsuleHalf = peel ? 2.0f : 0.4f;
@ -348,7 +348,7 @@ void LaunchGhostBody( b3WorldId worldId, GhostCollisionsData* data )
{
lift = sphereRadius;
}
else if ( settings->body == e_ghostUprightCapsule )
else if ( settings->body == e_ghostVCapsule )
{
lift = capsuleHalf + capsuleRadius;
}
@ -380,14 +380,14 @@ void LaunchGhostBody( b3WorldId worldId, GhostCollisionsData* data )
}
break;
case e_ghostCapsule:
case e_ghostHCapsule:
{
b3Capsule capsule = { { 0.0f, 0.0f, -capsuleHalf }, { 0.0f, 0.0f, capsuleHalf }, capsuleRadius };
data->shapeId = b3CreateCapsuleShape( data->bodyId, &shapeDef, &capsule );
}
break;
case e_ghostUprightCapsule:
case e_ghostVCapsule:
{
b3Capsule capsule = { { 0.0f, -capsuleHalf, 0.0f }, { 0.0f, capsuleHalf, 0.0f }, capsuleRadius };
data->shapeId = b3CreateCapsuleShape( data->bodyId, &shapeDef, &capsule );
@ -406,6 +406,7 @@ void LaunchGhostBody( b3WorldId worldId, GhostCollisionsData* data )
break;
}
data->contactBounds = b3Shape_GetAABB( data->shapeId );
data->runGhostCount = 0;
data->runSteps = 0;
}
@ -467,7 +468,7 @@ int UpdateGhostCollisions( b3WorldId worldId, GhostCollisionsData* data, GhostRe
{
b3Pos center = b3Body_GetWorldCenter( data->bodyId );
bool done = center.x > GHOST_HALF_LENGTH - 1.0f || center.y < -3.0f;
if ( data->settings.scene == e_ghostInternalEdges )
if ( data->settings.scene == e_ghostInternal )
{
// Run out onto the ground plane, or give up on a body knocked off the side
done = center.x > 100.0f || center.y < -3.0f || data->runSteps > 900;
@ -482,9 +483,10 @@ int UpdateGhostCollisions( b3WorldId worldId, GhostCollisionsData* data, GhostRe
data->runSteps += 1;
b3AABB bounds = b3Shape_GetAABB( data->shapeId );
b3AABB bounds = data->contactBounds;
float xMin = (float)bounds.lowerBound.x - 0.1f;
float xMax = (float)bounds.upperBound.x + 0.1f;
data->contactBounds = b3Shape_GetAABB( data->shapeId );
int ghostCount = 0;
b3ContactData contacts[8];

View file

@ -22,21 +22,21 @@ extern "C"
typedef enum GhostScene
{
e_ghostFlat,
e_ghostConcaveRamp,
e_ghostConcave,
e_ghostCliff,
e_ghostCrest,
e_ghostBumps,
e_ghostTJunction,
e_ghostShapeSeam,
e_ghostInternalEdges,
e_ghostSeam,
e_ghostInternal,
e_ghostSceneCount
} GhostScene;
typedef enum GhostBody
{
e_ghostBox,
e_ghostCapsule,
e_ghostUprightCapsule,
e_ghostHCapsule,
e_ghostVCapsule,
e_ghostSphere,
e_ghostCylinder,
e_ghostBodyCount
@ -92,6 +92,10 @@ typedef struct GhostCollisionsData
b3BodyId bodyId;
b3ShapeId shapeId;
// Body bounds at the start of the step, where the contacts were computed. A fast body can cross a fold
// within a step, so the bounds after the step can miss the face a contact came from.
b3AABB contactBounds;
// Steps in the current run
int runSteps;

View file

@ -54,6 +54,9 @@ void b3CollideHullsAtWidth( b3LocalManifold* manifold, int capacity, const b3Hul
void b3BuildTriangleAndCapsuleFaceContact( b3LocalManifold* manifold, const b3Vec3* triangle, b3Plane plane,
const b3Capsule* capsule );
void b3BuildTriangleAndHullFaceContact( b3LocalManifold* manifold, int capacity, const b3Vec3* triangle, int triangleFlags,
const b3HullData* hull, bool enableSpeculative );
b3AxisQuery b3ComputeSeparatingAxisW4( const b3HullData* hullA, const b3HullData* hullB, b3Transform xfB, bool earlyReturn );
b3AxisQuery b3ComputeSeparatingAxisW8( const b3HullData* hullA, const b3HullData* hullB, b3Transform xfB, bool earlyReturn );

View file

@ -636,6 +636,86 @@ static b3NeighborResult b3TestNeighbors( const b3Shape* shape, int triangleIndex
return convex ? b3_neighborSkip : b3_neighborSnap;
}
// Voronoi test of neighbors based on deepest point.
static b3NeighborResult b3TestHullFaceNeighbors( const b3Shape* shape, int triangleIndex,
const b3Vec3* vertices, b3Matrix3 meshToLocal,
const b3LocalManifold* manifold )
{
b3Vec3 normal = manifold->normal;
b3Vec3 triangleNormal = b3MakeNormalFromPoints( vertices[0], vertices[1], vertices[2] );
float tolerance = B3_NEIGHBOR_TOLERANCE;
if ( b3Dot( normal, triangleNormal ) > 0.0f &&
b3Length( b3Cross( normal, triangleNormal ) ) <= tolerance )
{
return b3_neighborAdmit;
}
int deepest = 0;
for ( int i = 1; i < manifold->pointCount; ++i )
{
if ( manifold->points[i].separation < manifold->points[deepest].separation )
{
deepest = i;
}
}
// Clip points were moved onto the hull face, step back along the normal to the triangle.
const b3LocalManifoldPoint* deepestPoint = manifold->points + deepest;
b3Vec3 point = b3MulSub( deepestPoint->point, deepestPoint->separation, normal );
float linearSlop = B3_LINEAR_SLOP;
int nearEdges[3];
int nearCount = 0;
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 ) );
if ( b3Dot( inward, b3Sub( point, vertex ) ) <= linearSlop )
{
nearEdges[nearCount] = i;
nearCount += 1;
}
}
b3TriangleFeature feature;
if ( nearCount == 0 )
{
// A tilted hull face over the triangle interior, the triangle face owns the normal.
return b3_neighborSnap;
}
else if ( nearCount == 1 )
{
b3TriangleFeature edgeFeatures[3] = { b3_featureEdge1, b3_featureEdge2, b3_featureEdge3 };
feature = edgeFeatures[nearEdges[0]];
}
else if ( nearCount == 2 )
{
if ( nearEdges[0] == 0 && nearEdges[1] == 1 )
{
feature = b3_featureVertex2;
}
else if ( nearEdges[0] == 1 )
{
feature = b3_featureVertex3;
}
else
{
feature = b3_featureVertex1;
}
}
else
{
return b3_neighborUnknown;
}
// Never skip a hull face, its normal can miss the whole vertex cone so every triangle would
// skip, the face contact is empty when the hull is off this triangle.
b3NeighborResult result =
b3TestNeighbors( shape, triangleIndex, vertices, meshToLocal, feature, normal );
return result == b3_neighborSkip ? b3_neighborSnap : result;
}
bool b3ComputeMeshManifolds( b3World* world, int workerIndex, b3Contact* contact,
const b3Shape* shapeA, const uint16_t* materialMap,
b3WorldTransform xfA, const b3Shape* shapeB, b3WorldTransform xfB,
@ -838,8 +918,7 @@ bool b3ComputeMeshManifolds( b3World* world, int workerIndex, b3Contact* contact
b3LocalManifold* manifoldBuffer = b3Bump( &arena, survivorCount * sizeof( b3LocalManifold ) );
int manifoldCount = 0;
bool validateNeighbors = B3_VALIDATE_NEIGHBOR_NORMALS && B3_FORCE_GHOST_COLLISIONS == 0 &&
( shapeB->type == b3_sphereShape || shapeB->type == b3_capsuleShape );
bool validateNeighbors = B3_VALIDATE_NEIGHBOR_NORMALS && B3_FORCE_GHOST_COLLISIONS == 0;
for ( int survivorIndex = 0;
survivorIndex < survivorCount && totalPointCount + 3 < pointBufferCapacity;
@ -903,10 +982,14 @@ bool b3ComputeMeshManifolds( b3World* world, int workerIndex, b3Contact* contact
manifold->feature != b3_featureTriangleFace )
{
b3NeighborResult result =
b3TestNeighbors( shapeA, triangleIndex, vertices, relativeMatrix, manifold->feature,
manifold->normal );
manifold->feature == b3_featureHullFace
? b3TestHullFaceNeighbors( shapeA, triangleIndex, vertices, relativeMatrix,
manifold )
: b3TestNeighbors( shapeA, triangleIndex, vertices, relativeMatrix,
manifold->feature, manifold->normal );
if ( result == b3_neighborSkip )
bool deep = false;
if ( result == b3_neighborSkip || result == b3_neighborSnap )
{
float minSeparation = manifold->points[0].separation;
for ( int i = 1; i < manifold->pointCount; ++i )
@ -914,12 +997,25 @@ bool b3ComputeMeshManifolds( b3World* world, int workerIndex, b3Contact* contact
minSeparation = b3MinFloat( minSeparation, manifold->points[i].separation );
}
if ( minSeparation < -2.0f * linearSlop )
{
// In deep overlap the owning neighbor may apply backside culling. Experiments
// show the that in this case the neighbor should snap the normal.
result = shapeB->type == b3_capsuleShape ? b3_neighborSnap : b3_neighborUnknown;
}
deep = minSeparation < -2.0f * linearSlop;
}
if ( result == b3_neighborSkip && deep )
{
// In deep overlap the owning neighbor may apply backside culling. Experiments
// show the that in this case the neighbor should snap the normal.
result = shapeB->type == b3_sphereShape ? b3_neighborUnknown : b3_neighborSnap;
}
b3LocalManifold deepManifold = { 0 };
b3LocalManifoldPoint deepPoints[B3_MAX_CLIP_POINTS];
bool keepDeep = deep && result == b3_neighborSnap && shapeB->type == b3_hullShape;
if ( keepDeep )
{
B3_ASSERT( manifold->pointCount <= B3_MAX_CLIP_POINTS );
deepManifold = *manifold;
memcpy( deepPoints, manifold->points,
manifold->pointCount * sizeof( b3LocalManifoldPoint ) );
}
if ( result == b3_neighborSkip || result == b3_neighborSnap )
@ -934,6 +1030,19 @@ bool b3ComputeMeshManifolds( b3World* world, int workerIndex, b3Contact* contact
b3Plane plane = b3MakePlaneFromPoints( vertices[0], vertices[1], vertices[2] );
b3BuildTriangleAndCapsuleFaceContact( manifold, vertices, plane, &shapeB->capsule );
}
else if ( result == b3_neighborSnap && shapeB->type == b3_hullShape )
{
b3BuildTriangleAndHullFaceContact( manifold, pointCapacity, vertices,
triangle.flags, hullB, enableSpeculative );
if ( keepDeep && manifold->pointCount == 0 )
{
// A deep hull off the triangle face keeps its own manifold.
*manifold = deepManifold;
memcpy( manifold->points, deepPoints,
manifold->pointCount * sizeof( b3LocalManifoldPoint ) );
}
}
}
int manifoldPointCount = manifold->pointCount;

View file

@ -954,6 +954,28 @@ static void b3CollideTriangleAndHullEdges( b3LocalManifold* manifold, int capaci
manifold->feature = edgesFeatures[query.indexA];
}
// Triangle face contact wrapper.
void b3BuildTriangleAndHullFaceContact( b3LocalManifold* manifold, int capacity, const b3Vec3* triangle, int triangleFlags,
const b3HullData* hull, bool enableSpeculative )
{
manifold->pointCount = 0;
b3TriangleData triangleData = {
.v1 = triangle[0],
.v2 = triangle[1],
.v3 = triangle[2],
.e1 = b3Sub( triangle[1], triangle[0] ),
.e2 = b3Sub( triangle[2], triangle[1] ),
.e3 = b3Sub( triangle[0], triangle[2] ),
.plane = b3MakePlaneFromPoints( triangle[0], triangle[1], triangle[2] ),
.flags = triangleFlags,
};
b3SeparatingAxis query = b3QueryTriangleFace( &triangleData, hull );
b3SATCache cache = { 0 };
b3CollideTriangleFace( manifold, capacity, &triangleData, hull, query, &cache, enableSpeculative );
}
b3AtomicInt b3_triangleConvexCalls;
b3AtomicInt b3_triangleCacheHits;

View file

@ -32,14 +32,14 @@
#else
#define RAGDOLL_SLEEP_STEP 346
#define RAGDOLL_HASH 0x27E7E059
#define WAVE_PILE_SLEEP_STEP 297
#define WAVE_PILE_HASH 0xC357A993
#define WAVE_PILE_SLEEP_STEP 309
#define WAVE_PILE_HASH 0xC57E6388
#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 226
#define MESH_DROP_HASH 0xD2FF069D
#define MESH_DROP_SLEEP_STEP 197
#define MESH_DROP_HASH 0xA498DD53
#endif
// The goldens above pin exact values for the default four point manifold. A build that