64-bit hashes (#126)

- ContactEvent sample
- Improved shadows
- #120 
- Triangle collision fixes
This commit is contained in:
Erin Catto 2026-08-11 18:08:34 -07:00 • committed by GitHub
commit f42be210a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 19835 additions and 17544 deletions

View file

@ -3,8 +3,9 @@
// Dirk Gregorius contributed portions of this code
#include "algorithm.h"
#include "hull.h"
#include "algorithm.h"
#include "math_internal.h"
#include "shape.h"
@ -2258,7 +2259,7 @@ b3HullData* b3CreateHull( const b3Vec3* points, int pointCount, int maxVertexCou
}
hull->hash = 0;
hull->hash = b3NonZeroHash( b3Hash( B3_HASH_INIT, (uint8_t*)hull, hull->byteCount ) );
hull->hash = b3Hash64NonZero( (uint8_t*)hull, hull->byteCount );
return hull;
}
@ -2270,7 +2271,7 @@ b3HullData* b3CloneHull( const b3HullData* hull )
return NULL;
}
b3HullData* clone = (b3HullData*)b3Alloc( hull->byteCount );
b3HullData* clone = b3Alloc( hull->byteCount );
memcpy( clone, hull, hull->byteCount );
return clone;
@ -2278,9 +2279,7 @@ b3HullData* b3CloneHull( const b3HullData* hull )
uint64_t b3HashHullData( const b3HullData* hull )
{
// The baked content hash already covers byteCount. Spread the 32 bits across 64 so the table
// can use the high bits for its fast reject fragment.
return (uint64_t)hull->hash * 0x9E3779B97F4A7C15ull;
return hull->hash;
}
bool b3CompareHullData( const b3HullData* hull1, const b3HullData* hull2 )
@ -2301,7 +2300,7 @@ bool b3CompareHullData( const b3HullData* hull1, const b3HullData* hull2 )
// Hull identity covers every byte, so the structs carry explicit padding. These lock
// the layout, re-audit padding if a size changes.
_Static_assert( sizeof( b3HullData ) == 144, "unexpected hull data size" );
_Static_assert( sizeof( b3BoxHull ) == 648, "unexpected box hull size" );
_Static_assert( sizeof( b3BoxHull ) == 640, "unexpected box hull size" );
// Implement b3HullMap.
#define NAME b3HullMap
@ -2494,8 +2493,9 @@ b3HullData* b3CloneAndTransformHull( const b3HullData* original, b3Transform tra
return NULL;
}
// Must ensure the hash is 0 so it doesn't contribute to itself.
hull->hash = 0;
hull->hash = b3NonZeroHash( b3Hash( B3_HASH_INIT, (uint8_t*)hull, hull->byteCount ) );
hull->hash = b3Hash64NonZero( (uint8_t*)hull, hull->byteCount );
B3_VALIDATE( b3IsValidHull( hull ) );
@ -2863,8 +2863,9 @@ b3BoxHull b3MakeTransformedBoxHull( float hx, float hy, float hz, b3Transform tr
boxHull.nz[6] = 0.0f;
boxHull.nz[7] = 0.0f;
// Must ensure the hash is 0 so it doesn't contribute to itself.
boxHull.base.hash = 0;
boxHull.base.hash = b3NonZeroHash( b3Hash( B3_HASH_INIT, (uint8_t*)&boxHull, sizeof( b3BoxHull ) ) );
boxHull.base.hash = b3Hash64NonZero( (uint8_t*)&boxHull.base, boxHull.base.byteCount );
return boxHull;
}