use dihedral for edge

This commit is contained in:
Erin Catto 2026-11-06 14:45:29 -08:00
commit f533aa5a70
7 changed files with 296 additions and 138 deletions

View file

@ -12,7 +12,7 @@ BraceWrapping:
AfterUnion: true
BeforeWhile: true
ColumnLimit: 100
ColumnLimit: 120
PointerAlignment: Left
UseTab: Always
BreakConstructorInitializers: BeforeComma

View file

@ -34,6 +34,7 @@ typedef struct Config
// From the compare file, -1 when absent
int baseGhostCount;
int baseRunCount;
} Config;
static const char* MatchValue( const char* arg, const char* shortName, const char* longName )
@ -136,25 +137,65 @@ static void FormatRow( char* buffer, size_t size, const Config* config )
}
}
static bool WriteResults( const char* path, const Config* configs, int configCount )
static bool SameConfig( const Config* a, const Config* b )
{
FILE* file = fopen( path, "w" );
if ( file == NULL )
return a->scene == b->scene && a->preset == b->preset && a->mirror == b->mirror && a->body == b->body;
}
// Filters are -1 for all
static int BuildConfigs( Config* configs, int sceneFilter, int presetFilter, int mirrorFilter, int bodyFilter )
{
int configCount = 0;
for ( int scene = 0; scene < e_ghostSceneCount; ++scene )
{
printf( "cannot write %s\n", path );
return false;
if ( sceneFilter >= 0 && scene != sceneFilter )
{
continue;
}
int presetCount = scene == e_ghostInternal ? GHOST_PEEL_PRESET_COUNT : 1;
for ( int preset = 0; preset < presetCount; ++preset )
{
if ( scene == e_ghostInternal && presetFilter >= 0 && preset != presetFilter )
{
continue;
}
for ( int mirror = 0; mirror < 2; ++mirror )
{
if ( mirrorFilter >= 0 && mirror != mirrorFilter )
{
continue;
}
for ( int body = 0; body < e_ghostBodyCount; ++body )
{
if ( bodyFilter >= 0 && body != bodyFilter )
{
continue;
}
// Only a flat bottom can rest on the chamfer edges
if ( scene == e_ghostChamfer && body != e_ghostBox && body != e_ghostCylinder )
{
continue;
}
B3_ASSERT( configCount < MAX_CONFIGS );
configs[configCount++] = (Config){
.scene = (GhostScene)scene,
.preset = preset,
.mirror = mirror != 0,
.body = (GhostBody)body,
.baseGhostCount = -1,
.baseRunCount = -1,
};
}
}
}
}
fprintf( file, "scene,preset,mirror,body,ghosts,runs\n" );
for ( int i = 0; i < configCount; ++i )
{
const Config* c = configs + i;
fprintf( file, "%s,%d,%d,%s,%d,%d\n", s_sceneKeys[c->scene], c->preset, c->mirror ? 1 : 0, s_bodyKeys[c->body], c->ghostCount,
c->runCount );
}
fclose( file );
return true;
return configCount;
}
static bool ReadBaseline( const char* path, Config* configs, int configCount )
@ -184,6 +225,7 @@ static bool ReadBaseline( const char* path, Config* configs, int configCount )
if ( (int)c->scene == scene && c->preset == preset && c->mirror == ( mirror != 0 ) && (int)c->body == body )
{
c->baseGhostCount = ghosts;
c->baseRunCount = runs;
}
}
}
@ -192,6 +234,58 @@ static bool ReadBaseline( const char* path, Config* configs, int configCount )
return true;
}
// Replaces only the rows of this run and keeps the rest of an existing file, in canonical order
static bool WriteResults( const char* path, const Config* configs, int configCount )
{
Config allConfigs[MAX_CONFIGS];
int allCount = BuildConfigs( allConfigs, -1, -1, -1, -1 );
FILE* existing = fopen( path, "r" );
if ( existing != NULL )
{
fclose( existing );
if ( ReadBaseline( path, allConfigs, allCount ) == false )
{
return false;
}
}
FILE* file = fopen( path, "w" );
if ( file == NULL )
{
printf( "cannot write %s\n", path );
return false;
}
fprintf( file, "scene,preset,mirror,body,ghosts,runs\n" );
for ( int i = 0; i < allCount; ++i )
{
const Config* c = allConfigs + i;
int ghostCount = c->baseGhostCount;
int runCount = c->baseRunCount;
for ( int j = 0; j < configCount; ++j )
{
if ( SameConfig( c, configs + j ) )
{
ghostCount = configs[j].ghostCount;
runCount = configs[j].runCount;
break;
}
}
if ( ghostCount < 0 )
{
continue;
}
fprintf( file, "%s,%d,%d,%s,%d,%d\n", s_sceneKeys[c->scene], c->preset, c->mirror ? 1 : 0, s_bodyKeys[c->body], ghostCount,
runCount );
}
fclose( file );
return true;
}
int main( int argc, char** argv )
{
int sceneFilter = -1;
@ -278,70 +372,24 @@ 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, chamfer (default all)\n"
" -s, --scene=<key|all> flat, ramp, cliff, crest, bumps, tjunction, peel, chamfer, rail (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"
" -n, --steps=<int> steps per config (default 900)\n"
" -w, --write=<file> write results as csv\n"
" -c, --compare=<file> compare with a written csv, fail if any count grew\n"
" -w, --write=<file> write results as csv, replacing only the rows of this run\n"
" -c, --compare=<file> compare with a written csv, fail if any count grew or has no row\n"
" --speed=, --yaw=, --friction=, --cell=, --fixed-rotation, --no-speculative\n"
" --height-field height field ground, the t-junction becomes a fine and coarse tile seam\n"
" -v, --verbose print every ghost\n"
"Exit code is 1 when a compared count grew, 0 otherwise.\n" );
"Exit code is 1 when a compared count grew or has no row, 0 otherwise.\n" );
return 2;
}
}
Config configs[MAX_CONFIGS];
int configCount = 0;
for ( int scene = 0; scene < e_ghostSceneCount; ++scene )
{
if ( sceneFilter >= 0 && scene != sceneFilter )
{
continue;
}
int presetCount = scene == e_ghostInternal ? GHOST_PEEL_PRESET_COUNT : 1;
for ( int preset = 0; preset < presetCount; ++preset )
{
if ( scene == e_ghostInternal && presetFilter >= 0 && preset != presetFilter )
{
continue;
}
for ( int mirror = 0; mirror < 2; ++mirror )
{
if ( mirrorFilter >= 0 && mirror != mirrorFilter )
{
continue;
}
for ( int body = 0; body < e_ghostBodyCount; ++body )
{
if ( bodyFilter >= 0 && body != bodyFilter )
{
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,
.mirror = mirror != 0,
.body = (GhostBody)body,
.baseGhostCount = -1,
};
}
}
}
}
int configCount = BuildConfigs( configs, sceneFilter, presetFilter, mirrorFilter, bodyFilter );
if ( comparePath != NULL && ReadBaseline( comparePath, configs, configCount ) == false )
{
@ -380,6 +428,7 @@ int main( int argc, char** argv )
int totalGhosts = 0;
int grewCount = 0;
int shrankCount = 0;
int missingCount = 0;
int column = 0;
for ( int i = 0; i < configCount; ++i )
{
@ -404,7 +453,11 @@ int main( int argc, char** argv )
column += 1;
char cell[32];
if ( c->baseGhostCount >= 0 && c->baseGhostCount != c->ghostCount )
if ( comparePath != NULL && c->baseGhostCount < 0 )
{
snprintf( cell, sizeof( cell ), "?>%d", c->ghostCount );
}
else if ( c->baseGhostCount >= 0 && c->baseGhostCount != c->ghostCount )
{
snprintf( cell, sizeof( cell ), "%d>%d", c->baseGhostCount, c->ghostCount );
}
@ -417,6 +470,7 @@ int main( int argc, char** argv )
totalGhosts += c->ghostCount;
grewCount += c->baseGhostCount >= 0 && c->ghostCount > c->baseGhostCount;
shrankCount += c->baseGhostCount >= 0 && c->ghostCount < c->baseGhostCount;
missingCount += c->baseGhostCount < 0;
}
printf( "\n\ntotal ghosts %d, time %.1f s\n", totalGhosts, seconds );
@ -428,9 +482,10 @@ int main( int argc, char** argv )
if ( comparePath != NULL )
{
printf( "compared with %s: %d grew, %d shrank\n", comparePath, grewCount, shrankCount );
printf( grewCount == 0 ? "PASS\n" : "FAIL\n" );
return grewCount == 0 ? 0 : 1;
bool pass = grewCount == 0 && missingCount == 0;
printf( "compared with %s: %d grew, %d shrank, %d missing\n", comparePath, grewCount, shrankCount, missingCount );
printf( pass ? "PASS\n" : "FAIL\n" );
return pass ? 0 : 1;
}
return 0;

View file

@ -25,8 +25,6 @@
#define MAX_REPORTED_FAILURES 32
#define MAX_THREADS 64
#define MAX_BASELINE_ROWS 64
#define BASELINE_ROW_SIZE 512
typedef enum FailureKind
{
@ -261,25 +259,17 @@ static void WriteBaseline( const Soak* soak, const char* path )
GetBaselineKey( soak, key, sizeof( key ) );
size_t keyLength = strlen( key );
char* rows = malloc( MAX_BASELINE_ROWS * BASELINE_ROW_SIZE );
int rowCount = 0;
FILE* file = fopen( path, "r" );
// Read the whole file so neither a row count nor a row length can drop a row
char* text = NULL;
FILE* file = fopen( path, "rb" );
if ( file != NULL )
{
char line[BASELINE_ROW_SIZE];
bool header = true;
while ( fgets( line, sizeof( line ), file ) != NULL )
{
if ( header == false && strncmp( line, key, keyLength ) != 0 && rowCount < MAX_BASELINE_ROWS )
{
snprintf( rows + rowCount * BASELINE_ROW_SIZE, BASELINE_ROW_SIZE, "%s", line );
rowCount += 1;
}
header = false;
}
fseek( file, 0, SEEK_END );
long textLength = ftell( file );
fseek( file, 0, SEEK_SET );
text = malloc( textLength + 1 );
textLength = (long)fread( text, 1, textLength, file );
text[textLength] = '\0';
fclose( file );
}
@ -287,7 +277,7 @@ static void WriteBaseline( const Soak* soak, const char* path )
if ( file == NULL )
{
printf( "cannot write %s\n", path );
free( rows );
free( text );
return;
}
@ -298,12 +288,30 @@ static void WriteBaseline( const Soak* soak, const char* path )
}
fprintf( file, "\n" );
for ( int i = 0; i < rowCount; ++i )
if ( text != NULL )
{
fputs( rows + i * BASELINE_ROW_SIZE, file );
}
bool header = true;
char* line = text;
while ( *line != '\0' )
{
char* next = strchr( line, '\n' );
size_t lineLength = next != NULL ? (size_t)( next - line ) : strlen( line );
if ( lineLength > 0 && line[lineLength - 1] == '\r' )
{
lineLength -= 1;
}
free( rows );
if ( header == false && lineLength > 0 && strncmp( line, key, keyLength ) != 0 )
{
fprintf( file, "%.*s\n", (int)lineLength, line );
}
header = false;
line = next != NULL ? next + 1 : line + strlen( line );
}
free( text );
}
for ( int shape = 0; shape < e_meshDropShapeCount; ++shape )
{

View file

@ -2453,7 +2453,7 @@ typedef struct b3HeightFieldDef
#define B3_HEIGHT_FIELD_HOLE 0xFF
/// 64-bit height-field version. Useful for validating serialized data.
#define B3_HEIGHT_FIELD_VERSION 0x8E41E5FB084848F8ull
#define B3_HEIGHT_FIELD_VERSION 0x5A69A297D7ACE1CDull
/// A height field with compressed storage.
/// @note This data structure has data hanging off the end and cannot be directly copied.

View file

@ -1966,14 +1966,14 @@ public:
// m_triangle[1] = { 1.00000000, 0, 0.00000000 };
// m_triangle[2] = { 0.00000000, 0, 0.00000000 };
m_triangle[0] = { 0.299769998f, -1.01549578f, -0.744717002f };
m_triangle[1] = { 0.299769998f, -1.01549578f, 1.28728306f };
m_triangle[2] = { 0.299769998f, -0.913895786f, 0.271283031f };
// Deep overlap where the hull face normal crosses the triangle edge, so SAT tries the edge pair,
// but the edge closest points fall outside the segments. Only the hull face clip keeps a contact,
// GJK sees overlap and returns nothing.
m_triangle[0] = { 0.259390f, -0.178787f, -0.292602f };
m_triangle[1] = { 0.861452f, 0.228978f, 0.393873f };
m_triangle[2] = { -0.539058f, 0.127502f, 0.225728f };
float bodyHalfWidth = 0.304800004f;
float bodyHalfHeight = 0.914399981f;
m_boxHull = b3MakeBoxHull( bodyHalfWidth, bodyHalfHeight, bodyHalfWidth );
m_boxHull = b3MakeBoxHull( 0.4f, 0.2f, 0.4f );
m_transformA = b3WorldTransform_identity;
m_transformB = b3WorldTransform_identity;

View file

@ -452,7 +452,9 @@ static bool b3IsInVertexRegion( const b3Vec3* vertices, int vertexIndex, b3Vec3
b3Vec3 vertex = vertices[vertexIndex];
b3Vec3 next = vertices[vertexIndex < 2 ? vertexIndex + 1 : 0];
b3Vec3 previous = vertices[vertexIndex > 0 ? vertexIndex - 1 : 2];
return b3Dot( normal, b3Sub( next, vertex ) ) <= 0.0f && b3Dot( normal, b3Sub( previous, vertex ) ) <= 0.0f;
b3Vec3 e1 = b3Sub( next, vertex );
b3Vec3 e2 = b3Sub( previous, vertex );
return b3Dot( normal, e1 ) <= 0.0f && b3Dot( normal, e2 ) <= 0.0f;
}
// Check the vertex flags to determined if this normal is admissible.
@ -461,6 +463,7 @@ static bool b3AdmitsVertexNormal( const b3Shape* shape, int triangleIndex, const
{
if ( b3IsInVertexRegion( vertices, vertexIndex, normal ) == false )
{
// Not in the vertex region so this vertex cannot admit the normal.
return false;
}
@ -567,6 +570,7 @@ static b3NeighborResult b3TestHullFaceNeighbors( const b3Shape* shape, int trian
float cosAngle = b3Dot( normal, triangleNormal );
if ( cosAngle > 0.0f && cosAngle * cosAngle >= 1.0f - tolerance * tolerance )
{
// Face normal (flipped to point from A to B) is parallel to triangle normal.
return b3_neighborAdmit;
}
@ -579,13 +583,27 @@ static b3NeighborResult b3TestHullFaceNeighbors( const b3Shape* shape, int trian
}
}
// Test vertices.
if ( manifold->points[deepest].separation < 0.0f )
// 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;
// If the hull overlaps this triangle then determine if the deepest point
// is close to a vertex.
if ( deepestPoint->separation < 0.0f )
{
for ( int i = 0; i < 3; ++i )
{
if ( b3AdmitsVertexNormal( shape, triangleIndex, vertices, i, normal ) )
if ( b3DistanceSquared( point, vertices[i] ) > linearSlop * linearSlop )
{
continue;
}
bool admit = b3AdmitsVertexNormal( shape, triangleIndex, vertices, i, normal );
if ( admit )
{
// This vertex tentatively accepts the normal.
b3TriangleFeature vertexFeatures[3] = { b3_featureVertex1, b3_featureVertex2, b3_featureVertex3 };
*nearFeature = vertexFeatures[i];
return b3_neighborAdmit;
@ -593,11 +611,6 @@ static b3NeighborResult b3TestHullFaceNeighbors( const b3Shape* shape, int trian
}
}
// 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;
bool inwardTilt = false;
@ -728,7 +741,10 @@ static b3Vec3 b3GetFeaturePoint( const b3LocalManifold* manifold, const b3Vec3*
typedef struct b3BlockTarget
{
// Triangle normal
b3Vec3 normal;
// Tolerance scaled by maximum edge length.
float distanceTolerance;
} b3BlockTarget;
@ -757,7 +773,8 @@ static bool b3ShouldBlockNormal( const b3Vec3* vertices, b3BlockTarget target, b
float distanceTolerance = target.distanceTolerance;
B3_ASSERT( b3AbsFloat( b3Dot( triangleNormal, b3Sub( point, vertices[0] ) ) ) <= distanceTolerance );
if ( b3Dot( normal, triangleNormal ) < -0.01f )
float normalDot = b3Dot( normal, triangleNormal );
if ( normalDot < -0.01f )
{
return false;
}
@ -1216,8 +1233,12 @@ static int b3CollideMeshTriangles( b3Cluster** clustersOut, const b3Shape* shape
if ( blockSourceCount > 0 )
{
bool* usedAsBlocker = b3Bump( arena, manifoldCount * sizeof( bool ) );
memset( usedAsBlocker, 0, manifoldCount * sizeof( bool ) );
int* survivorSources = b3Bump( arena, survivorCount * sizeof( int ) );
memset( survivorSources, 0xFF, survivorCount * sizeof( int ) );
for ( int i = 0; i < blockSourceCount; ++i )
{
survivorSources[blockSources[i].survivorIndex] = i;
}
b3BlockTarget* blockTargets = b3Bump( arena, survivorCount * sizeof( b3BlockTarget ) );
for ( int i = 0; i < survivorCount; ++i )
@ -1237,15 +1258,21 @@ static int b3CollideMeshTriangles( b3Cluster** clustersOut, const b3Shape* shape
continue;
}
// todo explain this better
// Compute the distance of the block source point from the target plane.
const b3Vec3* targetVertices = survivorVertices + 3 * j;
float planeDistance = b3Dot( blockTargets[j].normal, b3Sub( source->point, targetVertices[0] ) );
// Is the absolute plane distance greater than the target tolerance?
if ( b3AbsFloat( planeDistance ) > blockTargets[j].distanceTolerance )
{
continue;
}
if ( b3ShouldBlockNormal( targetVertices, blockTargets[j], source->point, normal ) )
// The source point is in the plane of the target.
//
bool shouldBlock =
b3ShouldBlockNormal( targetVertices, blockTargets[j], source->point, normal );
if ( shouldBlock )
{
// todo explain this better
float alignment = b3Dot( normal, blockTargets[j].normal );
@ -1256,14 +1283,95 @@ static int b3CollideMeshTriangles( b3Cluster** clustersOut, const b3Shape* shape
}
}
}
}
if ( source->blockerIndex != B3_NULL_INDEX )
bool* separated = b3Bump( arena, blockSourceCount * sizeof( bool ) );
for ( int i = 0; i < blockSourceCount; ++i )
{
const b3LocalManifold* manifold = manifoldBuffer + blockSources[i].manifoldIndex;
float minSeparation = manifold->points[0].separation;
for ( int j = 1; j < manifold->pointCount; ++j )
{
int blockerManifold = survivorManifolds[source->blockerIndex];
if ( blockerManifold != B3_NULL_INDEX )
minSeparation = b3MinFloat( minSeparation, manifold->points[j].separation );
}
separated[i] = minSeparation >= restOffset;
}
// From Bepu, drop when the blocker has its own contact unless the two block each
// other as when wedged in a crease, otherwise correct to the blocker face normal if touching.
// todo comment
enum
{
b3_blockUnvisited,
b3_blockOnPath,
b3_blockResolved,
};
uint8_t* states = b3Bump( arena, blockSourceCount * sizeof( uint8_t ) );
memset( states, b3_blockUnvisited, blockSourceCount * sizeof( uint8_t ) );
bool* dropped = b3Bump( arena, blockSourceCount * sizeof( bool ) );
int* path = b3Bump( arena, blockSourceCount * sizeof( int ) );
for ( int i = 0; i < blockSourceCount; ++i )
{
int pathCount = 0;
int k = i;
while ( k != B3_NULL_INDEX && states[k] == b3_blockUnvisited )
{
states[k] = b3_blockOnPath;
path[pathCount++] = k;
int blocker = blockSources[k].blockerIndex;
if ( blocker == B3_NULL_INDEX )
{
usedAsBlocker[blockerManifold] = true;
dropped[k] = false;
states[k] = b3_blockResolved;
k = B3_NULL_INDEX;
}
else if ( survivorManifolds[blocker] == B3_NULL_INDEX )
{
dropped[k] = separated[k];
states[k] = b3_blockResolved;
k = B3_NULL_INDEX;
}
else if ( survivorSources[blocker] == B3_NULL_INDEX )
{
dropped[k] = true;
states[k] = b3_blockResolved;
k = B3_NULL_INDEX;
}
else
{
k = survivorSources[blocker];
}
}
// todo comment
if ( k != B3_NULL_INDEX && states[k] == b3_blockOnPath )
{
int m = k;
do
{
dropped[m] = separated[m];
states[m] = b3_blockResolved;
m = survivorSources[blockSources[m].blockerIndex];
}
while ( m != k );
}
for ( int p = pathCount - 1; p >= 0; --p )
{
int s = path[p];
if ( states[s] == b3_blockResolved )
{
continue;
}
int next = survivorSources[blockSources[s].blockerIndex];
B3_ASSERT( states[next] == b3_blockResolved );
dropped[s] = separated[s] || dropped[next] == false;
states[s] = b3_blockResolved;
}
}
@ -1276,17 +1384,7 @@ static int b3CollideMeshTriangles( b3Cluster** clustersOut, const b3Shape* shape
}
b3LocalManifold* manifold = manifoldBuffer + source->manifoldIndex;
float minSeparation = manifold->points[0].separation;
for ( int j = 1; j < manifold->pointCount; ++j )
{
minSeparation = b3MinFloat( minSeparation, manifold->points[j].separation );
}
// From Bepu, drop when the blocker has its own contact unless the two block each
// other as when wedged in a crease, otherwise correct to the blocker face normal if touching.
bool blockerHasManifold = survivorManifolds[source->blockerIndex] != B3_NULL_INDEX;
bool wedged = usedAsBlocker[source->manifoldIndex];
if ( ( blockerHasManifold && wedged == false ) || minSeparation >= restOffset )
if ( dropped[i] )
{
manifold->pointCount = 0;
}
@ -1307,7 +1405,9 @@ static int b3CollideMeshTriangles( b3Cluster** clustersOut, const b3Shape* shape
if ( hullB != NULL && validateNeighbors )
{
// Cull contacts below hull face when it rests on a triangle.
// Cull triangles fully below the hull face when it rests on a triangle and has
// a tilted manifold normal. This helps when a box slides across a chamfered
// channel.
float tolerance = B3_NEIGHBOR_TOLERANCE;
float cosSquaredTolerance = 1.0f - tolerance * tolerance;
const b3LocalManifold* resting = NULL;
@ -1487,10 +1587,6 @@ bool b3ComputeMeshManifolds( b3World* world, int workerIndex, b3Contact* contact
bool isFast, b3Arena arena )
{
B3_ASSERT( shapeA->type == b3_meshShape || shapeA->type == b3_heightShape );
B3_UNUSED( workerIndex );
B3_UNUSED( isFast );
B3_UNUSED( materialMap );
b3TaskContext* context = b3Array_Get( world->taskContexts, workerIndex );
b3RefreshCache( contact, shapeA, xfA, &shapeB->aabb, arena );

View file

@ -13,7 +13,6 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
// cosine of hull normal versus edge axis tolerance.
#define B3_CROSSING_TOLERANCE 0.1f