64-bit hashes (#126)
- ContactEvent sample - Improved shadows - #120 - Triangle collision fixes
This commit is contained in:
parent
3fc20f5b45
commit
f42be210a2
49 changed files with 19835 additions and 17544 deletions
|
|
@ -323,10 +323,10 @@ typedef struct b3RecPlayerInfo
|
|||
/// Replaying at a different count re-partitions the constraint graph, so the StateHash check
|
||||
/// becomes a cross-thread determinism test. Adjustable later with b3RecPlayer_SetWorkerCount.
|
||||
/// @return a new player, or NULL on bad header or deserialization failure
|
||||
B3_API b3RecPlayer* b3RecPlayer_Create( const void* data, int size, int workerCount );
|
||||
B3_API b3RecPlayer* b3CreatePlayer( const void* data, int size, int workerCount );
|
||||
|
||||
/// Destroy the player and free all memory. Restores the previous global length scale.
|
||||
B3_API void b3RecPlayer_Destroy( b3RecPlayer* player );
|
||||
B3_API void b3DestroyPlayer( b3RecPlayer* player );
|
||||
|
||||
/// Advance one frame. dispatch ops until the next Step completes.
|
||||
/// @return true when a frame was stepped, false at end-of-recording
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ B3_INLINE float b3DistanceSquared( b3Vec3 a, b3Vec3 b )
|
|||
}
|
||||
|
||||
/// Normalize a vector. Returns a zero vector if the input vector is very small.
|
||||
B3_INLINE b3Vec3 b3Normalize( b3Vec3 a )
|
||||
B3_FORCE_INLINE b3Vec3 b3Normalize( b3Vec3 a )
|
||||
{
|
||||
float lengthSquared = a.x * a.x + a.y * a.y + a.z * a.z;
|
||||
|
||||
|
|
@ -571,7 +571,7 @@ B3_INLINE float b3GetTwistAngle( b3Quat q )
|
|||
}
|
||||
|
||||
/// Swing angle used for cone limit
|
||||
B3_INLINE float b3GetSwingAngle( b3Quat q )
|
||||
B3_FORCE_INLINE float b3GetSwingAngle( b3Quat q )
|
||||
{
|
||||
// Polarity should not matter because all terms are squared.
|
||||
float x = sqrtf( q.v.z * q.v.z + q.s * q.s );
|
||||
|
|
@ -629,7 +629,7 @@ B3_INLINE b3Transform b3InvertTransform( b3Transform t )
|
|||
}
|
||||
|
||||
/// Transform a point.
|
||||
B3_INLINE b3Vec3 b3TransformPoint( b3Transform t, b3Vec3 v )
|
||||
B3_FORCE_INLINE b3Vec3 b3TransformPoint( b3Transform t, b3Vec3 v )
|
||||
{
|
||||
b3Vec3 rv = b3RotateVector( t.q, v );
|
||||
return b3Add( rv, t.p );
|
||||
|
|
@ -718,18 +718,8 @@ B3_INLINE b3Vec3 b3InvTransformWorldPoint( b3WorldTransform t, b3Pos p )
|
|||
return b3InvRotateVector( t.q, d );
|
||||
}
|
||||
|
||||
/// Relative transform of frame B in frame A. The narrow phase boundary.
|
||||
B3_INLINE b3Transform b3InvMulWorldTransforms( b3WorldTransform A, b3WorldTransform B )
|
||||
{
|
||||
b3Transform C;
|
||||
C.q = b3InvMulQuat( A.q, B.q );
|
||||
b3Vec3 d = { (float)( B.p.x - A.p.x ), (float)( B.p.y - A.p.y ), (float)( B.p.z - A.p.z ) };
|
||||
C.p = b3InvRotateVector( A.q, d );
|
||||
return C;
|
||||
}
|
||||
|
||||
/// Compose a world transform with a local transform.
|
||||
B3_INLINE b3WorldTransform b3MulWorldTransforms( b3WorldTransform A, b3Transform B )
|
||||
B3_FORCE_INLINE b3WorldTransform b3MulWorldTransforms( b3WorldTransform A, b3Transform B )
|
||||
{
|
||||
b3WorldTransform C;
|
||||
C.q = b3MulQuat( A.q, B.q );
|
||||
|
|
@ -738,6 +728,16 @@ B3_INLINE b3WorldTransform b3MulWorldTransforms( b3WorldTransform A, b3Transform
|
|||
return C;
|
||||
}
|
||||
|
||||
/// Relative transform of frame B in frame A. The narrow phase boundary.
|
||||
B3_FORCE_INLINE b3Transform b3InvMulWorldTransforms( b3WorldTransform A, b3WorldTransform B )
|
||||
{
|
||||
b3Transform C;
|
||||
C.q = b3InvMulQuat( A.q, B.q );
|
||||
b3Vec3 d = { (float)( B.p.x - A.p.x ), (float)( B.p.y - A.p.y ), (float)( B.p.z - A.p.z ) };
|
||||
C.p = b3InvRotateVector( A.q, d );
|
||||
return C;
|
||||
}
|
||||
|
||||
/// Shift a world transform into the frame of a base position.
|
||||
B3_INLINE b3Transform b3ToRelativeTransform( b3WorldTransform t, b3Pos base )
|
||||
{
|
||||
|
|
@ -872,7 +872,7 @@ B3_INLINE b3Matrix3 b3InvertMatrix( b3Matrix3 m )
|
|||
|
||||
/// Solve a matrix equation.
|
||||
/// @return inv(m) * a
|
||||
B3_INLINE b3Vec3 b3Solve3( b3Matrix3 m, b3Vec3 a )
|
||||
B3_FORCE_INLINE b3Vec3 b3Solve3( b3Matrix3 m, b3Vec3 a )
|
||||
{
|
||||
float det = b3Det( m );
|
||||
if ( b3AbsFloat( det ) > 1000.0f * FLT_MIN )
|
||||
|
|
@ -1037,7 +1037,7 @@ B3_INLINE bool b3AABB_Overlaps( b3AABB a, b3AABB b )
|
|||
/// Transform an axis-aligned bounding box. This can create a larger box
|
||||
/// than if you recomputed the AABB of the original shape with the transform
|
||||
/// applied.
|
||||
B3_INLINE b3AABB b3AABB_Transform( b3Transform transform, b3AABB a )
|
||||
B3_FORCE_INLINE b3AABB b3AABB_Transform( b3Transform transform, b3AABB a )
|
||||
{
|
||||
b3Vec3 center = b3TransformPoint( transform, b3AABB_Center( a ) );
|
||||
b3Matrix3 m = b3MakeMatrixFromQuat( transform.q );
|
||||
|
|
|
|||
|
|
@ -1968,7 +1968,7 @@ typedef struct b3HullFace
|
|||
} b3HullFace;
|
||||
|
||||
/// 64-bit hull version. Useful for validating serialized data.
|
||||
#define B3_HULL_VERSION 0xDA5150191B994C01ull
|
||||
#define B3_HULL_VERSION 0xE3BD07365000417Cull
|
||||
|
||||
/// A convex hull.
|
||||
/// @note This data structure has data hanging off the end and cannot be directly copied.
|
||||
|
|
@ -1977,11 +1977,8 @@ typedef struct b3HullData
|
|||
/// Version must be first and match B3_HULL_VERSION
|
||||
uint64_t version;
|
||||
|
||||
/// The total number of bytes for this hull.
|
||||
int byteCount;
|
||||
|
||||
/// Hash of this hull (this field is zero when the hash is computed).
|
||||
uint32_t hash;
|
||||
uint64_t hash;
|
||||
|
||||
/// Axis-aligned box in local space.
|
||||
b3AABB aabb;
|
||||
|
|
@ -2002,38 +1999,39 @@ typedef struct b3HullData
|
|||
b3Matrix3 centralInertia;
|
||||
|
||||
/// The vertex count.
|
||||
int vertexCount;
|
||||
int32_t vertexCount;
|
||||
|
||||
/// Offset of the vertex array in bytes from the struct address.
|
||||
int vertexOffset;
|
||||
int32_t vertexOffset;
|
||||
|
||||
/// Offset of the point array in bytes from the struct address.
|
||||
int pointOffset;
|
||||
int32_t pointOffset;
|
||||
|
||||
/// This is the half-edge count (double the edge count)
|
||||
int edgeCount;
|
||||
int32_t edgeCount;
|
||||
|
||||
/// Offset of the edge array in bytes from the struct address.
|
||||
int edgeOffset;
|
||||
int32_t edgeOffset;
|
||||
|
||||
/// The face count. Hulls faces are convex polygons.
|
||||
int faceCount;
|
||||
int32_t faceCount;
|
||||
|
||||
/// Offset of the face plane array in bytes from the struct address.
|
||||
int planeOffset;
|
||||
int32_t planeOffset;
|
||||
|
||||
/// Offset of the face array in bytes from the struct address.
|
||||
int faceOffset;
|
||||
int32_t faceOffset;
|
||||
|
||||
/// Offset of structure of array (SOA) vertices
|
||||
int soaVertexOffset;
|
||||
int32_t soaVertexOffset;
|
||||
|
||||
/// Offset of structure of array (SOA) unit normal vectors
|
||||
int soaNormalOffset;
|
||||
int32_t soaNormalOffset;
|
||||
|
||||
/// Explicit padding. Hull identity is a content hash and memcmp over raw bytes,
|
||||
/// so there must be no unnamed padding for struct copies to scramble.
|
||||
int padding;
|
||||
/// The total number of bytes for this hull.
|
||||
int32_t byteCount;
|
||||
|
||||
/// Any padding must be explicit.
|
||||
} b3HullData;
|
||||
|
||||
/// Efficient box hull
|
||||
|
|
@ -2046,7 +2044,7 @@ typedef struct b3BoxHull
|
|||
b3HullHalfEdge boxEdges[24]; ///< Box half-edges.
|
||||
b3Plane boxPlanes[6]; ///< Box face planes.
|
||||
b3HullFace boxFaces[6]; ///< Box faces.
|
||||
uint8_t padding[10]; ///< Explicit padding, see b3HullData::padding.
|
||||
uint8_t padding[2]; ///< Explicit padding.
|
||||
float vx[8]; ///< vertex x
|
||||
float vy[8]; ///< vertex y
|
||||
float vz[8]; ///< vertex z
|
||||
|
|
@ -2063,10 +2061,11 @@ typedef struct b3BoxHull
|
|||
* @{
|
||||
*/
|
||||
|
||||
/// This is used to create a re-usable collision mesh.
|
||||
/// This is used to create a re-usable collision mesh. No pointers
|
||||
/// are held to this data in b3MeshData. So all this data can be temporary.
|
||||
typedef struct b3MeshDef
|
||||
{
|
||||
/// Triangle vertices
|
||||
/// Triangle vertices.
|
||||
b3Vec3* vertices;
|
||||
|
||||
/// Triangle vertex indices. 3 for each triangle. CCW winding.
|
||||
|
|
@ -2098,7 +2097,7 @@ typedef struct b3MeshDef
|
|||
} b3MeshDef;
|
||||
|
||||
/// 64-bit mesh version. Useful for validating serialized data.
|
||||
#define B3_MESH_VERSION 0xABD11AB62A6E886Dull
|
||||
#define B3_MESH_VERSION 0xA661B13E6655156Full
|
||||
|
||||
/// Triangle mesh edge flags.
|
||||
typedef enum b3MeshEdgeFlags
|
||||
|
|
@ -2172,11 +2171,11 @@ typedef struct b3MeshData
|
|||
/// Version must be first.
|
||||
uint64_t version;
|
||||
|
||||
/// The total number of bytes for this mesh.
|
||||
int byteCount;
|
||||
|
||||
/// Hash of this mesh (this field is zero when the hash is computed)
|
||||
uint32_t hash;
|
||||
uint64_t hash;
|
||||
|
||||
/// The total number of bytes for this mesh.
|
||||
int32_t byteCount;
|
||||
|
||||
/// Local axis-aligned box.
|
||||
b3AABB bounds;
|
||||
|
|
@ -2185,37 +2184,40 @@ typedef struct b3MeshData
|
|||
float surfaceArea;
|
||||
|
||||
/// The height of the bounding volume hierarchy.
|
||||
int treeHeight;
|
||||
int32_t treeHeight;
|
||||
|
||||
/// The number of degenerate triangles. Diagnostic.
|
||||
int degenerateCount;
|
||||
int32_t degenerateCount;
|
||||
|
||||
/// Offset of the node array in bytes from the struct address.
|
||||
int nodeOffset;
|
||||
int32_t nodeOffset;
|
||||
|
||||
/// The number of BVH nodes.
|
||||
int nodeCount;
|
||||
int32_t nodeCount;
|
||||
|
||||
/// Offset of the vertex array in bytes from the struct address.
|
||||
int vertexOffset;
|
||||
int32_t vertexOffset;
|
||||
|
||||
/// The number of vertices.
|
||||
int vertexCount;
|
||||
int32_t vertexCount;
|
||||
|
||||
/// Offset of the triangle array in bytes from the struct address.
|
||||
int triangleOffset;
|
||||
int32_t triangleOffset;
|
||||
|
||||
/// The number of triangles.
|
||||
int triangleCount;
|
||||
int32_t triangleCount;
|
||||
|
||||
/// Offset of the material array in bytes from the struct address.
|
||||
int materialOffset;
|
||||
int32_t materialOffset;
|
||||
|
||||
/// The number of materials.
|
||||
int materialCount;
|
||||
int32_t materialCount;
|
||||
|
||||
/// Offset of the triangle flag array in bytes from the struct address.
|
||||
int flagsOffset;
|
||||
int32_t flagsOffset;
|
||||
|
||||
/// Explicit padding.
|
||||
int32_t padding;
|
||||
} b3MeshData;
|
||||
|
||||
/// This allows mesh data to be re-used with different scales.
|
||||
|
|
@ -2237,7 +2239,7 @@ typedef struct b3Mesh
|
|||
* @{
|
||||
*/
|
||||
|
||||
/// Data used to create a height field
|
||||
/// Data used to create a height field. No pointers are held to this data.
|
||||
typedef struct b3HeightFieldDef
|
||||
{
|
||||
/// Grid point heights
|
||||
|
|
@ -2276,7 +2278,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 0x8B18CBD138A6BC84ull
|
||||
#define B3_HEIGHT_FIELD_VERSION 0x9FEE70DB5A860835ull
|
||||
|
||||
/// A height field with compressed storage.
|
||||
/// @note This data structure has data hanging off the end and cannot be directly copied.
|
||||
|
|
@ -2285,12 +2287,12 @@ typedef struct b3HeightFieldData
|
|||
/// Version must be first and match B3_HEIGHT_FIELD_VERSION
|
||||
uint64_t version;
|
||||
|
||||
/// Hash of this height field (this field is zero when the hash is computed).
|
||||
uint64_t hash;
|
||||
|
||||
/// The total number of bytes for this height field.
|
||||
int byteCount;
|
||||
|
||||
/// Hash of this height field (this field is zero when the hash is computed).
|
||||
uint32_t hash;
|
||||
|
||||
/// The local axis-aligned bounding box.
|
||||
b3AABB aabb;
|
||||
|
||||
|
|
@ -2307,29 +2309,28 @@ typedef struct b3HeightFieldData
|
|||
b3Vec3 scale;
|
||||
|
||||
/// The number of grid columns along the local x-axis.
|
||||
int columnCount;
|
||||
int32_t columnCount;
|
||||
|
||||
/// The number of grid rows along the local z-axis.
|
||||
int rowCount;
|
||||
int32_t rowCount;
|
||||
|
||||
/// Offset of the compressed height array in bytes from the struct address.
|
||||
/// uint16_t, one per grid point.
|
||||
int heightsOffset;
|
||||
int32_t heightsOffset;
|
||||
|
||||
/// Offset of the material index array in bytes from the struct address.
|
||||
/// uint8_t, one per cell.
|
||||
int materialOffset;
|
||||
int32_t materialOffset;
|
||||
|
||||
/// Offset of the flag array in bytes from the struct address.
|
||||
/// uint8_t, one per triangle.
|
||||
int flagsOffset;
|
||||
int32_t flagsOffset;
|
||||
|
||||
/// Triangle winding.
|
||||
bool clockwise;
|
||||
uint8_t clockwise;
|
||||
|
||||
/// Explicit padding. Identity is a content hash over raw bytes, so there must
|
||||
/// be no unnamed padding for struct copies to scramble.
|
||||
uint8_t padding[3];
|
||||
/// Explicit padding.
|
||||
uint8_t padding[7];
|
||||
} b3HeightFieldData;
|
||||
|
||||
/**@}*/ // height_field
|
||||
|
|
@ -2973,7 +2974,7 @@ typedef struct b3DebugShape
|
|||
typedef struct b3DebugDraw
|
||||
{
|
||||
/// Draws a user shape. The userShape pointer is owned by the application and is known to Box3D as
|
||||
/// an opaque pointer returned from b3CreateDebugShapeCallback. When this is called the drawn shape has
|
||||
/// an opaque pointer returned from b3CreateDebugShapeCallback. When this is called the drawn shape has
|
||||
/// passed a culling test against drawingBounds below.
|
||||
void ( *DrawShapeFcn )( void* userShape, b3WorldTransform transform, b3HexColor color, void* context );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue