fixed GJK fallback bug

more point culling
chamfer test
This commit is contained in:
Erin Catto 2026-11-02 22:46:34 -08:00
commit 991f3f9758
15 changed files with 624 additions and 45 deletions

View file

@ -99,3 +99,7 @@ peel,3,1,capsule,0,2
peel,3,1,upright,0,2
peel,3,1,sphere,0,2
peel,3,1,cylinder,0,2
chamfer,0,0,box,0,2
chamfer,0,0,cylinder,0,2
chamfer,0,1,box,0,2
chamfer,0,1,cylinder,0,2

1 scene preset mirror body ghosts runs
99 peel 3 1 upright 0 2
100 peel 3 1 sphere 0 2
101 peel 3 1 cylinder 0 2
102 chamfer 0 0 box 0 2
103 chamfer 0 0 cylinder 0 2
104 chamfer 0 1 box 0 2
105 chamfer 0 1 cylinder 0 2

View file

@ -54,7 +54,7 @@ tjunction,0,0,capsule,0,2
tjunction,0,0,upright,0,2
tjunction,0,0,sphere,0,2
tjunction,0,0,cylinder,3,2
tjunction,0,1,box,2,0
tjunction,0,1,box,1,0
tjunction,0,1,capsule,0,2
tjunction,0,1,upright,0,2
tjunction,0,1,sphere,0,2
@ -99,3 +99,7 @@ peel,3,1,capsule,0,2
peel,3,1,upright,0,2
peel,3,1,sphere,0,2
peel,3,1,cylinder,0,2
chamfer,0,0,box,0,2
chamfer,0,0,cylinder,0,2
chamfer,0,1,box,0,2
chamfer,0,1,cylinder,0,2

1 scene preset mirror body ghosts runs
54 tjunction 0 0 upright 0 2
55 tjunction 0 0 sphere 0 2
56 tjunction 0 0 cylinder 3 2
57 tjunction 0 1 box 2 1 0
58 tjunction 0 1 capsule 0 2
59 tjunction 0 1 upright 0 2
60 tjunction 0 1 sphere 0 2
99 peel 3 1 upright 0 2
100 peel 3 1 sphere 0 2
101 peel 3 1 cylinder 0 2
102 chamfer 0 0 box 0 2
103 chamfer 0 0 cylinder 0 2
104 chamfer 0 1 box 0 2
105 chamfer 0 1 cylinder 0 2

View file

@ -18,7 +18,7 @@
#include <string.h>
// Command line and result file keys
static const char* s_sceneKeys[e_ghostSceneCount] = { "flat", "ramp", "cliff", "crest", "bumps", "tjunction", "peel" };
static const char* s_sceneKeys[e_ghostSceneCount] = { "flat", "ramp", "cliff", "crest", "bumps", "tjunction", "peel", "chamfer" };
static const char* s_bodyKeys[e_ghostBodyCount] = { "box", "capsule", "upright", "sphere", "cylinder" };
#define MAX_CONFIGS 256
@ -86,6 +86,14 @@ static void RunConfig( Config* config, GhostSettings settings, int stepCount, bo
settings.mirror = config->mirror;
settings.body = config->body;
// The s&box character is a fixed rotation hull without speculative contact. Speculative contact or
// rotation hide the ghost.
if ( config->scene == e_ghostChamfer )
{
settings.fixedRotation = true;
settings.speculative = false;
}
b3WorldDef worldDef = b3DefaultWorldDef();
b3WorldId worldId = b3CreateWorld( &worldDef );
GhostCollisionsData data = CreateGhostCollisions( worldId, settings );
@ -270,7 +278,8 @@ int main( int argc, char** argv )
{
printf( "Usage: ghost_scan [options]\n"
"Runs the Ghost Collisions sample headless and counts ghost manifolds per scene and body.\n"
" -s, --scene=<key|all> flat, ramp, cliff, crest, bumps, tjunction, peel (default all)\n"
" -s, --scene=<key|all> flat, ramp, cliff, crest, bumps, tjunction, peel, chamfer (default all)\n"
" chamfer runs only the box and cylinder, fixed rotation without speculative\n"
" -b, --body=<key|all> box, capsule, upright, sphere, cylinder (default all)\n"
" -m, --mirror=<0|1|all> mirrored mesh (default all)\n"
" -p, --preset=<0-3|all> PEEL preset (default all)\n"
@ -316,6 +325,12 @@ int main( int argc, char** argv )
continue;
}
// Only a flat bottom can rest on the chamfer edges
if ( scene == e_ghostChamfer && body != e_ghostBox && body != e_ghostCylinder )
{
continue;
}
configs[configCount++] = (Config){
.scene = (GhostScene)scene,
.preset = preset,
@ -365,6 +380,7 @@ int main( int argc, char** argv )
int totalGhosts = 0;
int grewCount = 0;
int shrankCount = 0;
int column = 0;
for ( int i = 0; i < configCount; ++i )
{
const Config* c = configs + i;
@ -375,8 +391,18 @@ int main( int argc, char** argv )
char row[64];
FormatRow( row, sizeof( row ), c );
printf( "%s%-18s", i == 0 ? "" : "\n", row );
column = 0;
}
// A scene that skips a body leaves its column empty
int bodyColumn = bodyFilter >= 0 ? 0 : (int)c->body;
while ( column < bodyColumn )
{
printf( "%10s", "-" );
column += 1;
}
column += 1;
char cell[32];
if ( c->baseGhostCount >= 0 && c->baseGhostCount != c->ghostCount )
{