Doxygen comments (#12)

- organized headers.
- added comments to headers.
- fixed a solver determinism bug.
- removed some un-used math functions
This commit is contained in:
Erin Catto 2026-06-10 13:21:14 -07:00 • committed by GitHub
commit d8fbeb444e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
53 changed files with 8973 additions and 1812 deletions

View file

@ -66,93 +66,6 @@ int b3GetPointSupport( const b3Vec3* points, int count, b3Vec3 axis )
return maxIndex;
}
// Similar to Real-time Collision Detection, p179.
// todo try https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-box-intersection.html
bool b3IntersectRayAndAABB( b3Vec3 lowerBound, b3Vec3 upperBound, b3Vec3 p1, b3Vec3 p2, float* minFraction,
float* maxFraction )
{
// Ray direction and length
b3Vec3 d = b3Sub( p2, p1 );
float rayLength = b3Length( d );
// Handle degenerate ray
if ( rayLength < FLT_EPSILON )
{
// Check if point is inside AABB
if ( p1.x >= lowerBound.x && p1.x <= upperBound.x && p1.y >= lowerBound.y && p1.y <= upperBound.y &&
p1.z >= lowerBound.z && p1.z <= upperBound.z )
{
*minFraction = 0.0f;
*maxFraction = 0.0f;
return true;
}
else
{
return false;
}
}
b3Vec3 rayDir = b3MulSV( 1.0f / rayLength, d );
// Slab method for ray-AABB intersection
float tMin = 0.0f;
float tMax = rayLength;
// Test each axis
for ( int i = 0; i < 3; ++i )
{
float rayComponent = b3GetByIndex( rayDir, i );
float rayStart = b3GetByIndex( p1, i );
float boxMin = b3GetByIndex( lowerBound, i );
float boxMax = b3GetByIndex( upperBound, i );
if ( b3AbsFloat( rayComponent ) < FLT_EPSILON )
{
// Ray is parallel to slab, check if ray origin is within slab
if ( rayStart < boxMin || rayStart > boxMax )
{
return false;
}
}
else
{
// Compute intersection distances
float t1 = ( boxMin - rayStart ) / rayComponent;
float t2 = ( boxMax - rayStart ) / rayComponent;
// Ensure t1 <= t2
if ( t1 > t2 )
{
float temp = t1;
t1 = t2;
t2 = temp;
}
// Update intersection interval
tMin = b3MaxFloat( tMin, t1 );
tMax = b3MinFloat( tMax, t2 );
// Check for no intersection
if ( tMin > tMax )
{
return false;
}
}
}
// Check if intersection is behind ray start
if ( tMax < 0.0f )
{
return false;
}
// Convert distances to fractions
*minFraction = b3ClampFloat( tMin / rayLength, 0.0f, 1.0f );
*maxFraction = b3ClampFloat( tMax / rayLength, 0.0f, 1.0f );
return true;
}
static void b3BarycentricCoordsEdge( float out[3], b3Vec3 a, b3Vec3 b )
{
b3Vec3 ab = b3Sub( b, a );