comments and formatting

This commit is contained in:
Erin Catto 2026-11-09 09:23:45 -08:00
commit 40b3b2ddd5
5 changed files with 104 additions and 132 deletions

View file

@ -80,14 +80,13 @@ B3_API b3ContactEvents b3World_GetContactEvents( b3WorldId worldId );
B3_API b3JointEvents b3World_GetJointEvents( b3WorldId worldId );
/// Overlap test for all shapes that *potentially* overlap the provided AABB
B3_API b3TreeStats b3World_OverlapAABB( b3WorldId worldId, b3AABB aabb, b3QueryFilter filter,
b3OverlapResultFcn* fcn, void* context );
B3_API b3TreeStats b3World_OverlapAABB( b3WorldId worldId, b3AABB aabb, b3QueryFilter filter, b3OverlapResultFcn* fcn,
void* context );
/// Overlap test for all shapes that overlap the provided shape proxy. The proxy points are relative
/// to the world origin, which lets the query stay precise far from the world origin.
B3_API b3TreeStats b3World_OverlapShape( b3WorldId worldId, b3Pos origin, const b3ShapeProxy* proxy,
b3QueryFilter filter, b3OverlapResultFcn* fcn,
void* context );
b3QueryFilter filter, b3OverlapResultFcn* fcn, void* context );
/// Cast a ray into the world to collect shapes in the path of the ray.
/// Your callback function controls whether you get the closest point, any point, or n-points.
@ -100,23 +99,21 @@ B3_API b3TreeStats b3World_OverlapShape( b3WorldId worldId, b3Pos origin, const
/// @param fcn A user implemented callback function
/// @param context A user context that is passed along to the callback function
/// @return traversal performance counters
B3_API b3TreeStats b3World_CastRay( b3WorldId worldId, b3Pos origin, b3Vec3 translation,
b3QueryFilter filter, b3CastResultFcn* fcn, void* context );
B3_API b3TreeStats b3World_CastRay( b3WorldId worldId, b3Pos origin, b3Vec3 translation, b3QueryFilter filter,
b3CastResultFcn* fcn, void* context );
/// Cast a ray into the world to collect the closest hit. This is a convenience function. Ignores
/// initial overlap. This is less general than b3World_CastRay() and does not allow for custom
/// filtering. Ignores back-side collision on meshes and height-fields.
B3_API b3RayResult b3World_CastRayClosest( b3WorldId worldId, b3Pos origin, b3Vec3 translation,
b3QueryFilter filter );
B3_API b3RayResult b3World_CastRayClosest( b3WorldId worldId, b3Pos origin, b3Vec3 translation, b3QueryFilter filter );
/// Cast a shape through the world. Similar to a cast ray except that a shape is cast instead of a
/// point. The proxy points are relative to the origin and the hit points come back as world
/// positions, so the cast stays precise far from the world origin. Ignores back-side collision on
/// meshes and height-fields.
/// @see b3World_CastRay
B3_API b3TreeStats b3World_CastShape( b3WorldId worldId, b3Pos origin, const b3ShapeProxy* proxy,
b3Vec3 translation, b3QueryFilter filter,
b3CastResultFcn* fcn, void* context );
B3_API b3TreeStats b3World_CastShape( b3WorldId worldId, b3Pos origin, const b3ShapeProxy* proxy, b3Vec3 translation,
b3QueryFilter filter, b3CastResultFcn* fcn, void* context );
/// Cast a capsule mover through the world. This is a special shape cast that handles sliding along
/// other shapes while reducing clipping. This is not a good source of information about what the
@ -130,15 +127,14 @@ B3_API b3TreeStats b3World_CastShape( b3WorldId worldId, b3Pos origin, const b3S
/// @param fcn Optional callback for custom shape filtering
/// @param context A user context that is passed along to the callback function
/// @return the translation fraction
B3_API float b3World_CastMover( b3WorldId worldId, b3Pos origin, const b3Capsule* mover,
b3Vec3 translation, b3QueryFilter filter, b3MoverFilterFcn* fcn,
void* context );
B3_API float b3World_CastMover( b3WorldId worldId, b3Pos origin, const b3Capsule* mover, b3Vec3 translation,
b3QueryFilter filter, b3MoverFilterFcn* fcn, void* context );
/// Collide a capsule mover with the world, gathering collision planes that can be fed to
/// b3SolvePlanes. Useful for kinematic character movement. The mover and the returned planes are
/// relative to the origin. Ignores back-side collision on meshes and height-fields.
B3_API void b3World_CollideMover( b3WorldId worldId, b3Pos origin, const b3Capsule* mover,
b3QueryFilter filter, b3PlaneResultFcn* fcn, void* context );
B3_API void b3World_CollideMover( b3WorldId worldId, b3Pos origin, const b3Capsule* mover, b3QueryFilter filter,
b3PlaneResultFcn* fcn, void* context );
/// Enable/disable sleep. If your application does not need sleeping, you can gain some performance
/// by disabling sleep completely at the world level.
@ -187,8 +183,7 @@ B3_API void b3World_SetHitEventThreshold( b3WorldId worldId, float value );
B3_API float b3World_GetHitEventThreshold( b3WorldId worldId );
/// Register the custom filter callback. This is optional.
B3_API void b3World_SetCustomFilterCallback( b3WorldId worldId, b3CustomFilterFcn* fcn,
void* context );
B3_API void b3World_SetCustomFilterCallback( b3WorldId worldId, b3CustomFilterFcn* fcn, void* context );
/// Register the pre-solve callback. This is optional.
B3_API void b3World_SetPreSolveCallback( b3WorldId worldId, b3PreSolveFcn* fcn, void* context );
@ -212,8 +207,7 @@ B3_API void b3World_Explode( b3WorldId worldId, const b3ExplosionDef* explosionD
/// @param dampingRatio The contact bounciness with 1 being critical damping (non-dimensional)
/// @param contactSpeed The maximum contact constraint push out speed (meters per second)
/// @note Advanced feature
B3_API void b3World_SetContactTuning( b3WorldId worldId, float hertz, float dampingRatio,
float contactSpeed );
B3_API void b3World_SetContactTuning( b3WorldId worldId, float hertz, float dampingRatio, float contactSpeed );
/// Set the contact point recycling distance. Setting this to zero disables contact point recycling.
/// Usually in meters.
@ -421,8 +415,7 @@ B3_API void b3RecPlayer_SetWorkerCount( b3RecPlayer* player, int count );
/// @param minIntervalFrames finest spacing between keyframes, in frames
/// A zero budget or a non-positive interval keeps that value. Clears the existing ring, so call
/// b3RecPlayer_Restart afterward to repopulate it under the new policy.
B3_API void b3RecPlayer_SetKeyframePolicy( b3RecPlayer* player, size_t budgetBytes,
int minIntervalFrames );
B3_API void b3RecPlayer_SetKeyframePolicy( b3RecPlayer* player, size_t budgetBytes, int minIntervalFrames );
/// @return the keyframe memory budget in bytes
B3_API size_t b3RecPlayer_GetKeyframeBudget( const b3RecPlayer* player );
@ -453,10 +446,8 @@ B3_API b3BodyId b3RecPlayer_GetBodyId( const b3RecPlayer* player, int index );
/// @param createDebugShape called when a replayed shape is added; returns a user draw handle
/// @param destroyDebugShape called when a replayed shape is removed; may be NULL
/// @param context user context passed to both callbacks
B3_API void b3RecPlayer_SetDebugShapeCallbacks( b3RecPlayer* player,
b3CreateDebugShapeCallback* createDebugShape,
b3DestroyDebugShapeCallback* destroyDebugShape,
void* context );
B3_API void b3RecPlayer_SetDebugShapeCallbacks( b3RecPlayer* player, b3CreateDebugShapeCallback* createDebugShape,
b3DestroyDebugShapeCallback* destroyDebugShape, void* context );
/// Draw the spatial queries recorded during the most recently replayed frame, layered on top of the
/// world. Call after b3World_Draw. NULL draw function pointers are skipped.
@ -465,8 +456,7 @@ B3_API void b3RecPlayer_SetDebugShapeCallbacks( b3RecPlayer* player,
/// @param queryIndex index of the frame query to draw, or -1 to draw all of them
/// @param selectedIndex index of the query to emphasize (reserved color plus a label), or -1 for
/// none
B3_API void b3RecPlayer_DrawFrameQueries( b3RecPlayer* player, b3DebugDraw* draw, int queryIndex,
int selectedIndex );
B3_API void b3RecPlayer_DrawFrameQueries( b3RecPlayer* player, b3DebugDraw* draw, int queryIndex, int selectedIndex );
/// The kind of a recorded spatial query, matching the public query and cast functions.
typedef enum b3RecQueryType
@ -510,8 +500,7 @@ B3_API int b3RecPlayer_GetFrameQueryCount( const b3RecPlayer* player );
B3_API b3RecQueryInfo b3RecPlayer_GetFrameQuery( const b3RecPlayer* player, int index );
/// Get one result of a recorded query from the most recently replayed frame.
B3_API b3RecQueryHit b3RecPlayer_GetFrameQueryHit( const b3RecPlayer* player, int queryIndex,
int hitIndex );
B3_API b3RecQueryHit b3RecPlayer_GetFrameQueryHit( const b3RecPlayer* player, int queryIndex, int hitIndex );
/**@}*/ // recording
@ -601,8 +590,7 @@ B3_API void b3Body_SetAngularVelocity( b3BodyId bodyId, b3Vec3 angularVelocity )
/// The result will be close but maybe not exact. This is meant for kinematic bodies.
/// The target is not applied if the velocity would be below the sleep threshold.
/// This will optionally wake the body if asleep, but only if the movement is significant.
B3_API void b3Body_SetTargetTransform( b3BodyId bodyId, b3WorldTransform target, float timeStep,
bool wake );
B3_API void b3Body_SetTargetTransform( b3BodyId bodyId, b3WorldTransform target, float timeStep, bool wake );
/// Get the linear velocity of a local point attached to a body. Usually in meters per second.
B3_API b3Vec3 b3Body_GetLocalPointVelocity( b3BodyId bodyId, b3Vec3 localPoint );
@ -828,35 +816,30 @@ B3_API float b3Body_GetClosestPoint( b3BodyId bodyId, b3Vec3* result, b3Vec3 tar
/// Cast a ray at a specific body using a specified body transform.
/// Ignores back-side collision on meshes and height-fields.
B3_API b3BodyCastResult b3Body_CastRay( b3BodyId bodyId, b3Pos origin, b3Vec3 translation,
b3QueryFilter filter, float maxFraction,
b3WorldTransform bodyTransform );
B3_API b3BodyCastResult b3Body_CastRay( b3BodyId bodyId, b3Pos origin, b3Vec3 translation, b3QueryFilter filter,
float maxFraction, b3WorldTransform bodyTransform );
/// Cast a shape at a specific body using a specified body transform.
/// Ignores back-side collision on meshes and height-fields.
B3_API b3BodyCastResult b3Body_CastShape( b3BodyId bodyId, b3Pos origin, const b3ShapeProxy* proxy,
b3Vec3 translation, b3QueryFilter filter,
float maxFraction, bool canEncroach,
B3_API b3BodyCastResult b3Body_CastShape( b3BodyId bodyId, b3Pos origin, const b3ShapeProxy* proxy, b3Vec3 translation,
b3QueryFilter filter, float maxFraction, bool canEncroach,
b3WorldTransform bodyTransform );
/// Overlap a shape with a specific body using a specified body transform.
B3_API bool b3Body_OverlapShape( b3BodyId bodyId, b3Pos origin, const b3ShapeProxy* proxy,
b3QueryFilter filter, b3WorldTransform bodyTransform );
B3_API bool b3Body_OverlapShape( b3BodyId bodyId, b3Pos origin, const b3ShapeProxy* proxy, b3QueryFilter filter,
b3WorldTransform bodyTransform );
/// Collide a character mover with a specific body using a specified body transform.
/// Only considers convex shapes on the body.
B3_API int b3Body_CollideMover( b3BodyId bodyId, b3BodyPlaneResult* bodyPlanes, int planeCapacity,
b3Pos origin, const b3Capsule* mover, b3QueryFilter filter,
b3WorldTransform bodyTransform );
B3_API int b3Body_CollideMover( b3BodyId bodyId, b3BodyPlaneResult* bodyPlanes, int planeCapacity, b3Pos origin,
const b3Capsule* mover, b3QueryFilter filter, b3WorldTransform bodyTransform );
/// Perform a time of impact between a character mover and a body using specified sweep transforms.
/// Initial overlap of any shape on the body is ignored. A non-overlapped shape can still be hit.
/// Only considers convex shapes on the body.
B3_API b3BodyTOIResult b3Body_TimeOfImpactMover( b3BodyId bodyId, b3Pos origin,
const b3Capsule* mover, b3Vec3 moverTranslation,
b3QueryFilter filter,
b3WorldTransform bodyTransform1,
b3WorldTransform bodyTransform2 );
B3_API b3BodyTOIResult b3Body_TimeOfImpactMover( b3BodyId bodyId, b3Pos origin, const b3Capsule* mover,
b3Vec3 moverTranslation, b3QueryFilter filter,
b3WorldTransform bodyTransform1, b3WorldTransform bodyTransform2 );
/** @} */ // body
@ -875,29 +858,25 @@ B3_API b3BodyTOIResult b3Body_TimeOfImpactMover( b3BodyId bodyId, b3Pos origin,
/// Create a circle shape and attach it to a body. The shape definition and geometry are fully
/// cloned. Contacts are not created until the next time step.
/// @return the shape id for accessing the shape
B3_API b3ShapeId b3CreateSphereShape( b3BodyId bodyId, const b3ShapeDef* def,
const b3Sphere* sphere );
B3_API b3ShapeId b3CreateSphereShape( b3BodyId bodyId, const b3ShapeDef* def, const b3Sphere* sphere );
/// Create a capsule shape and attach it to a body. The shape definition and geometry are fully
/// cloned. Contacts are not created until the next time step.
/// @return the shape id for accessing the shape
B3_API b3ShapeId b3CreateCapsuleShape( b3BodyId bodyId, const b3ShapeDef* def,
const b3Capsule* capsule );
B3_API b3ShapeId b3CreateCapsuleShape( b3BodyId bodyId, const b3ShapeDef* def, const b3Capsule* capsule );
/// Create a convex hull shape and attach it to a body. The shape definition is fully cloned.
/// Contacts are not created until the next time step.
/// @return the shape id for accessing the shape
B3_API b3ShapeId b3CreateHullShape( b3BodyId bodyId, const b3ShapeDef* def,
const b3HullData* hull );
B3_API b3ShapeId b3CreateHullShape( b3BodyId bodyId, const b3ShapeDef* def, const b3HullData* hull );
/// Create a convex hull shape and attach it to a body. The hull is cloned then transformed with
/// scale applied first. Use this for non-uniform or mirrored scale or a baked local transform. The
/// baked result is shared through the world hull database. The shape definition and geometry are
/// fully cloned. Contacts are not created until the next time step.
/// @return the shape id for accessing the shape
B3_API b3ShapeId b3CreateTransformedHullShape( b3BodyId bodyId, const b3ShapeDef* def,
const b3HullData* hull, b3Transform transform,
b3Vec3 scale );
B3_API b3ShapeId b3CreateTransformedHullShape( b3BodyId bodyId, const b3ShapeDef* def, const b3HullData* hull,
b3Transform transform, b3Vec3 scale );
/// Create a mesh hull shape and attach it to a body. The shape definition is fully cloned but the
/// mesh is not. Contacts are not created until the next time step. Mesh collision only creates
@ -905,8 +884,7 @@ B3_API b3ShapeId b3CreateTransformedHullShape( b3BodyId bodyId, const b3ShapeDef
/// @warning this holds reference to the input mesh data which must remain valid for the lifetime of
/// this shape
/// @return the shape id for accessing the shape
B3_API b3ShapeId b3CreateMeshShape( b3BodyId bodyId, const b3ShapeDef* def, const b3MeshData* mesh,
b3Vec3 scale );
B3_API b3ShapeId b3CreateMeshShape( b3BodyId bodyId, const b3ShapeDef* def, const b3MeshData* mesh, b3Vec3 scale );
/// Create a height-field shape and attach it to a body. The shape definition is fully cloned but
/// the height field is not. Contacts are not created until the next time step. Height field is only
@ -920,8 +898,7 @@ B3_API b3ShapeId b3CreateHeightFieldShape( b3BodyId bodyId, const b3ShapeDef* de
/// Baked compound shapes are only allowed on static bodies.
/// Note: runtime compounds are achieved by adding multiple shapes to a body.
/// Runtime compounds can be dynamic and/or kinematic.
B3_API b3ShapeId b3CreateBakedCompoundShape( b3BodyId bodyId, b3ShapeDef* def,
const b3CompoundData* compound );
B3_API b3ShapeId b3CreateBakedCompoundShape( b3BodyId bodyId, b3ShapeDef* def, const b3CompoundData* compound );
/// Destroy a shape. You may defer the body mass update which can improve performance if several
/// shapes on a
@ -987,8 +964,7 @@ B3_API b3SurfaceMaterial b3Shape_GetSurfaceMaterial( b3ShapeId shapeId );
B3_API int b3Shape_GetMeshMaterialCount( b3ShapeId shapeId );
/// Set a surface material for a mesh shape.
B3_API void b3Shape_SetMeshMaterial( b3ShapeId shapeId, b3SurfaceMaterial surfaceMaterial,
int index );
B3_API void b3Shape_SetMeshMaterial( b3ShapeId shapeId, b3SurfaceMaterial surfaceMaterial, int index );
/// Get a surface material for a mesh shape
B3_API b3SurfaceMaterial b3Shape_GetMeshSurfaceMaterial( b3ShapeId shapeId, int index );
@ -1121,8 +1097,7 @@ B3_API b3Vec3 b3Shape_GetClosestPoint( b3ShapeId shapeId, b3Vec3 target );
/// @param maxSpeed the maximum relative speed. Speed cap is necessary for stability. Typically
/// 10m/s or less.
/// @param wake should this wake the body
B3_API void b3Shape_ApplyWind( b3ShapeId shapeId, b3Vec3 wind, float drag, float lift,
float maxSpeed, bool wake );
B3_API void b3Shape_ApplyWind( b3ShapeId shapeId, b3Vec3 wind, float drag, float lift, float maxSpeed, bool wake );
/** @} */ // shape
@ -1271,12 +1246,10 @@ B3_API void b3DistanceJoint_EnableSpring( b3JointId jointId, bool enableSpring )
B3_API bool b3DistanceJoint_IsSpringEnabled( b3JointId jointId );
/// Set the force range for the spring.
B3_API void b3DistanceJoint_SetSpringForceRange( b3JointId jointId, float lowerForce,
float upperForce );
B3_API void b3DistanceJoint_SetSpringForceRange( b3JointId jointId, float lowerForce, float upperForce );
/// Get the force range for the spring.
B3_API void b3DistanceJoint_GetSpringForceRange( b3JointId jointId, float* lowerForce,
float* upperForce );
B3_API void b3DistanceJoint_GetSpringForceRange( b3JointId jointId, float* lowerForce, float* upperForce );
/// Set the spring stiffness in Hertz
B3_API void b3DistanceJoint_SetSpringHertz( b3JointId jointId, float hertz );
@ -1651,8 +1624,7 @@ B3_API float b3RevoluteJoint_GetLowerLimit( b3JointId jointId );
B3_API float b3RevoluteJoint_GetUpperLimit( b3JointId jointId );
/// Set the revolute joint limits in radians
B3_API void b3RevoluteJoint_SetLimits( b3JointId jointId, float lowerLimitRadians,
float upperLimitRadians );
B3_API void b3RevoluteJoint_SetLimits( b3JointId jointId, float lowerLimitRadians, float upperLimitRadians );
/// Enable/disable a revolute joint motor
B3_API void b3RevoluteJoint_EnableMotor( b3JointId jointId, bool enableMotor );
@ -1718,8 +1690,7 @@ B3_API float b3SphericalJoint_GetLowerTwistLimit( b3JointId jointId );
B3_API float b3SphericalJoint_GetUpperTwistLimit( b3JointId jointId );
/// Set the spherical joint limits in radians
B3_API void b3SphericalJoint_SetTwistLimits( b3JointId jointId, float lowerLimitRadians,
float upperLimitRadians );
B3_API void b3SphericalJoint_SetTwistLimits( b3JointId jointId, float lowerLimitRadians, float upperLimitRadians );
/// Get the spherical joint current twist angle in radians.
B3_API float b3SphericalJoint_GetTwistAngle( b3JointId jointId );
@ -1924,8 +1895,7 @@ B3_API float b3WheelJoint_GetLowerSteeringLimit( b3JointId jointId );
B3_API float b3WheelJoint_GetUpperSteeringLimit( b3JointId jointId );
/// Set the wheel joint steering limits in radians.
B3_API void b3WheelJoint_SetSteeringLimits( b3JointId jointId, float lowerRadians,
float upperRadians );
B3_API void b3WheelJoint_SetSteeringLimits( b3JointId jointId, float lowerRadians, float upperRadians );
/// Set the wheel joint target steering angle in radians.
B3_API void b3WheelJoint_SetTargetSteeringAngle( b3JointId jointId, float radians );

View file

@ -39,25 +39,28 @@ B3_API void b3DynamicTree_SetCategoryBits( b3DynamicTree* tree, int proxyId, uin
/// Get the category bits on a proxy.
B3_API uint64_t b3DynamicTree_GetCategoryBits( b3DynamicTree* tree, int proxyId );
/// Query an AABB for overlapping proxies. The callback function is called for each proxy that overlaps the supplied AABB.
/// Query an AABB for overlapping proxies. The callback function is called for each proxy that overlaps the supplied
/// AABB.
/// @return performance data
B3_API b3TreeStats b3DynamicTree_Query( const b3DynamicTree* tree, b3AABB aabb, uint64_t maskBits, bool requireAllBits,
b3TreeQueryCallbackFcn* callback, void* context );
/// Query an AABB for the closest object. The callback function is called for each proxy that might be closest to the supplied
/// point.
/// Query an AABB for the closest object. The callback function is called for each proxy that might be closest to the
/// supplied point.
/// @param tree the dynamic tree to query
/// @param point the query point
/// @param maskBits proxies are skipped if the bit-wise AND with the proxy category bits is zero
/// @param requireAllBits proxies are skipped if the bit-wise AND with the proxy category bits does not equal the maskBits
/// @param requireAllBits proxies are skipped if the bit-wise AND with the proxy category bits does not equal the
/// maskBits
/// @param callback a user provided instance of b3TreeQueryClosestCallbackFcn
/// @param context a user context object that is provided to the callback
/// @param minDistanceSqr the initial and final minimum squared distance. Provide a small initial to restrict the search and
/// improve performance. If the value is large this query has performance that scales linearly with the number of proxies and
/// would be slower than a brute force search.
/// @param minDistanceSqr the initial and final minimum squared distance. Provide a small initial to restrict the search
/// and improve performance. If the value is large this query has performance that scales linearly with the number of
/// proxies and would be slower than a brute force search.
/// @return performance data
B3_API b3TreeStats b3DynamicTree_QueryClosest( const b3DynamicTree* tree, b3Vec3 point, uint64_t maskBits, bool requireAllBits,
b3TreeQueryClosestCallbackFcn* callback, void* context, float* minDistanceSqr );
B3_API b3TreeStats b3DynamicTree_QueryClosest( const b3DynamicTree* tree, b3Vec3 point, uint64_t maskBits,
bool requireAllBits, b3TreeQueryClosestCallbackFcn* callback,
void* context, float* minDistanceSqr );
/// Ray cast against the proxies in the tree. This relies on the callback
/// to perform an exact ray cast in the case where the proxy contains a shape.
@ -342,7 +345,7 @@ B3_INLINE const uint8_t* b3GetMeshFlags( const b3MeshData* mesh )
return (const uint8_t*)( (intptr_t)mesh + mesh->flagsOffset );
}
// Get read only quantized angles between neighboring triangle normals.
/// Get read only quantized angles between neighboring triangle normals.
B3_INLINE const int8_t* b3GetMeshEdgeAngles( const b3MeshData* mesh )
{
if ( mesh->edgeAngleOffset == 0 )
@ -353,7 +356,7 @@ B3_INLINE const int8_t* b3GetMeshEdgeAngles( const b3MeshData* mesh )
return (const int8_t*)( (intptr_t)mesh + mesh->edgeAngleOffset );
}
// Get read only vertex flags.
/// Get read only vertex flags.
B3_INLINE const uint8_t* b3GetMeshVertexFlags( const b3MeshData* mesh )
{
if ( mesh->vertexFlagOffset == 0 )
@ -444,8 +447,8 @@ B3_API b3HeightFieldData* b3CreateHeightField( const b3HeightFieldDef* data );
B3_API b3HeightFieldData* b3CreateGrid( int rowCount, int columnCount, b3Vec3 scale, bool makeHoles );
/// Create a wave grid as a height field.
B3_API b3HeightFieldData* b3CreateWave( int rowCount, int columnCount, b3Vec3 scale, float rowFrequency, float columnFrequency,
bool makeHoles );
B3_API b3HeightFieldData* b3CreateWave( int rowCount, int columnCount, b3Vec3 scale, float rowFrequency,
float columnFrequency, bool makeHoles );
/// Destroy a height field.
B3_API void b3DestroyHeightField( b3HeightFieldData* heightField );
@ -544,7 +547,8 @@ B3_API bool b3OverlapCapsule( const b3Capsule* shape, b3Transform shapeTransform
B3_API bool b3OverlapCompound( const b3CompoundData* shape, b3Transform shapeTransform, const b3ShapeProxy* proxy );
/// Overlap shape versus height field
B3_API bool b3OverlapHeightField( const b3HeightFieldData* shape, b3Transform shapeTransform, const b3ShapeProxy* proxy );
B3_API bool b3OverlapHeightField( const b3HeightFieldData* shape, b3Transform shapeTransform,
const b3ShapeProxy* proxy );
/// Overlap shape versus hull
B3_API bool b3OverlapHull( const b3HullData* shape, b3Transform shapeTransform, const b3ShapeProxy* proxy );
@ -602,29 +606,34 @@ B3_API b3CastOutput b3ShapeCastHeightField( const b3HeightFieldData* shape, cons
/// Query callback.
typedef bool b3MeshQueryFcn( b3Vec3 a, b3Vec3 b, b3Vec3 c, int triangleIndex, void* context );
/// Query a mesh for triangles overlapping a bounding box in local space. May have false positives. Useful for debug draw.
/// Query a mesh for triangles overlapping a bounding box in local space. May have false positives. Useful for debug
/// draw.
/// @param mesh the mesh to query, includes scale
/// @param bounds the bounding box in local space
/// @param fcn a user function to collect triangles
/// @param context the context sent to the user function.
B3_API void b3QueryMesh( const b3Mesh* mesh, const b3AABB bounds, b3MeshQueryFcn* fcn, void* context );
/// Query a height field for triangles overlapping a bounding box in local space. May have false positives. Useful for debug draw.
/// Query a height field for triangles overlapping a bounding box in local space. May have false positives. Useful for
/// debug draw.
/// @param heightField the height field to query
/// @param bounds the bounding box in local space
/// @param fcn a user function to collect triangles
/// @param context the context sent to the user function.
B3_API void b3QueryHeightField( const b3HeightFieldData* heightField, b3AABB bounds, b3MeshQueryFcn* fcn, void* context );
B3_API void b3QueryHeightField( const b3HeightFieldData* heightField, b3AABB bounds, b3MeshQueryFcn* fcn,
void* context );
/// Compute the closest points between two shapes represented as point clouds.
/// b3SimplexCache cache is input/output. On the first call set b3SimplexCache.count to zero.
/// The query runs in frame A, so the witness points and normal are returned in frame A.
/// The underlying GJK algorithm may be debugged by passing in debug simplexes and capacity. You may pass in NULL and 0 for these.
/// The underlying GJK algorithm may be debugged by passing in debug simplexes and capacity. You may pass in NULL and 0
/// for these.
B3_API b3DistanceOutput b3ShapeDistance( const b3DistanceInput* input, b3SimplexCache* cache, b3Simplex* simplexes,
int simplexCapacity );
/// Perform a linear shape cast of shape B moving and shape A fixed. Determines the hit point, normal, and translation fraction.
/// The query runs in frame A, so the hit point and normal are returned in frame A. Initially touching shapes are a miss.
/// Perform a linear shape cast of shape B moving and shape A fixed. Determines the hit point, normal, and translation
/// fraction. The query runs in frame A, so the hit point and normal are returned in frame A. Initially touching shapes
/// are a miss.
B3_API b3CastOutput b3ShapeCast( const b3ShapeCastPairInput* input );
/// Evaluate the transform sweep at a specific time.
@ -652,16 +661,16 @@ B3_API void b3CollideCapsuleAndSphere( b3LocalManifold* manifold, int capacity,
const b3Sphere* sphereB, b3Transform transformBtoA );
/// Collide a hull and a sphere.
B3_API void b3CollideHullAndSphere( b3LocalManifold* manifold, int capacity, const b3HullData* hullA, const b3Sphere* sphereB,
b3Transform transformBtoA, b3SimplexCache* cache );
B3_API void b3CollideHullAndSphere( b3LocalManifold* manifold, int capacity, const b3HullData* hullA,
const b3Sphere* sphereB, b3Transform transformBtoA, b3SimplexCache* cache );
/// Collide two capsules.
B3_API void b3CollideCapsules( b3LocalManifold* manifold, int capacity, const b3Capsule* capsuleA, const b3Capsule* capsuleB,
b3Transform transformBtoA );
B3_API void b3CollideCapsules( b3LocalManifold* manifold, int capacity, const b3Capsule* capsuleA,
const b3Capsule* capsuleB, b3Transform transformBtoA );
/// Collide a hull and a capsule.
B3_API void b3CollideHullAndCapsule( b3LocalManifold* manifold, int capacity, const b3HullData* hullA, const b3Capsule* capsuleB,
b3Transform transformBtoA, b3SimplexCache* cache );
B3_API void b3CollideHullAndCapsule( b3LocalManifold* manifold, int capacity, const b3HullData* hullA,
const b3Capsule* capsuleB, b3Transform transformBtoA, b3SimplexCache* cache );
/// Collide two hulls.
B3_API void b3CollideHulls( b3LocalManifold* manifold, int capacity, const b3HullData* hullA, const b3HullData* hullB,
@ -672,8 +681,9 @@ B3_API void b3CollideTriangleAndCapsule( b3LocalManifold* manifold, int capacity
const b3Capsule* capsuleB, b3SimplexCache* cache );
/// Collide a triangle and hull. Normal points from triangle to hull.
B3_API void b3CollideTriangleAndHull( b3LocalManifold* manifold, int capacity, b3Vec3 v1, b3Vec3 v2, b3Vec3 v3, int triangleFlags,
const b3HullData* hullB, b3SATCache* cache, bool enableSpeculative );
B3_API void b3CollideTriangleAndHull( b3LocalManifold* manifold, int capacity, b3Vec3 v1, b3Vec3 v2, b3Vec3 v3,
int triangleFlags, const b3HullData* hullB, b3SATCache* cache,
bool enableSpeculative );
/// Collide a triangle and sphere. Normal points from triangle to sphere.
B3_API void b3CollideTriangleAndSphere( b3LocalManifold* manifold, int capacity, const b3Vec3* triangleA,

View file

@ -31,8 +31,7 @@ typedef void b3TaskCallback( void* taskContext );
/// @param userContext the scheduler context object that is opaque to Box3D
/// @param taskName the Box3D task name that the scheduler can use for diagnostics
/// @ingroup world
typedef void* b3EnqueueTaskCallback( b3TaskCallback* task, void* taskContext, void* userContext,
const char* taskName );
typedef void* b3EnqueueTaskCallback( b3TaskCallback* task, void* taskContext, void* userContext, const char* taskName );
/// Finishes a user task object that wraps a Box3D task. This must block until the task has
/// completed. The step blocks here on the tasks it spawned, so b3World_Step holds its stack across
@ -64,8 +63,8 @@ typedef float b3FrictionCallback( float frictionA, uint64_t userMaterialIdA, flo
/// this is called from a worker thread.
/// @warning This function should not attempt to modify Box3D state or user application state.
/// @ingroup world
typedef float b3RestitutionCallback( float restitutionA, uint64_t userMaterialIdA,
float restitutionB, uint64_t userMaterialIdB );
typedef float b3RestitutionCallback( float restitutionA, uint64_t userMaterialIdA, float restitutionB,
uint64_t userMaterialIdB );
/// Prototype for a contact filter callback.
/// This is called when a contact pair is considered for collision. This allows you to
@ -93,8 +92,7 @@ typedef bool b3CustomFilterFcn( b3ShapeId shapeIdA, b3ShapeId shapeIdB, void* co
/// full contact manifold.
/// @warning Do not attempt to modify the world inside this callback
/// @ingroup world
typedef bool b3PreSolveFcn( b3ShapeId shapeIdA, b3ShapeId shapeIdB, b3Pos point, b3Vec3 normal,
void* context );
typedef bool b3PreSolveFcn( b3ShapeId shapeIdA, b3ShapeId shapeIdB, b3Pos point, b3Vec3 normal, void* context );
/// Prototype callback for overlap queries.
/// Called for each shape found in the query.
@ -122,9 +120,8 @@ typedef bool b3OverlapResultFcn( b3ShapeId shapeId, void* context );
/// @return -1 to filter, 0 to terminate, fraction to clip the ray for closest hit, 1 to continue
/// @see b3World_CastRay
/// @ingroup world
typedef float b3CastResultFcn( b3ShapeId shapeId, b3Pos point, b3Vec3 normal, float fraction,
uint64_t userMaterialId, int triangleIndex, int childIndex,
void* context );
typedef float b3CastResultFcn( b3ShapeId shapeId, b3Pos point, b3Vec3 normal, float fraction, uint64_t userMaterialId,
int triangleIndex, int childIndex, void* context );
/// Optional world capacities that can be use to avoid run-time allocations
/// @ingroup world
@ -1649,7 +1646,7 @@ typedef struct b3ShapeCastPairInput
b3Transform transform; ///< Transform of shape B in shape A's frame, the relative pose B in A
b3Vec3 translationB; ///< The translation of shape B, in A's frame
float maxFraction; ///< The fraction of the translation to consider, typically 1
bool canEncroach; ///< Allows shapes with a radius to move slightly closer if already touching
bool canEncroach; ///< Allows shapes with a radius to move slightly closer if already touching
} b3ShapeCastPairInput;
/// Input for b3ShapeDistance
@ -1904,24 +1901,21 @@ typedef bool b3TreeQueryCallbackFcn( int proxyId, uint64_t userData, void* conte
/// This function receives the minimum distance squared so far and proxy to check in the closest
/// query.
/// @return minimum distance squared to user objects in the proxy
typedef float b3TreeQueryClosestCallbackFcn( float distanceSqrMin, int proxyId, uint64_t userData,
void* context );
typedef float b3TreeQueryClosestCallbackFcn( float distanceSqrMin, int proxyId, uint64_t userData, void* context );
/// This function receives clipped AABB cast input for a proxy. The function returns the new cast
/// fraction.
/// - return a value of 0 to terminate the cast
/// - return a value less than input->maxFraction to clip the cast
/// - return a value of input->maxFraction to continue the cast without clipping
typedef float b3TreeBoxCastCallbackFcn( const b3BoxCastInput* input, int proxyId, uint64_t userData,
void* context );
typedef float b3TreeBoxCastCallbackFcn( const b3BoxCastInput* input, int proxyId, uint64_t userData, void* context );
/// This function receives clipped ray cast input for a proxy. The function
/// returns the new ray fraction.
/// - return a value of 0 to terminate the ray cast
/// - return a value less than input->maxFraction to clip the ray
/// - return a value of input->maxFraction to continue the ray cast without clipping
typedef float b3TreeRayCastCallbackFcn( const b3RayCastInput* input, int proxyId, uint64_t userData,
void* context );
typedef float b3TreeRayCastCallbackFcn( const b3RayCastInput* input, int proxyId, uint64_t userData, void* context );
/**@}*/ // tree
@ -2008,8 +2002,7 @@ typedef struct b3BodyTOIResult
/// Used to collect collision planes for character movers.
/// Return true to continue gathering planes.
typedef bool b3PlaneResultFcn( b3ShapeId shapeId, const b3PlaneResult* plane, int planeCount,
void* context );
typedef bool b3PlaneResultFcn( b3ShapeId shapeId, const b3PlaneResult* plane, int planeCount, void* context );
/// Used to filter shapes for shape casting character movers.
/// Return true to accept the collision
@ -2290,14 +2283,14 @@ typedef struct b3MeshTriangle
int32_t index3; ///< Index of vertex 3.
} b3MeshTriangle;
// Indicates an isolated edge.
/// Indicates an isolated edge (treated as a cliff).
#define B3_BOUNDARY_EDGE_ANGLE ( -128 )
// Mesh vertex flags. Used for ghost collision handling.
/// Mesh vertex flags. Used for ghost collision handling.
typedef enum b3MeshVertexFlags
{
b3_flatVertex = 0x01,
b3_concaveVertex = 0x02,
b3_flatVertex = 0x01, ///< All edges are flat.
b3_concaveVertex = 0x02, ///< Any edge is concave.
} b3MeshVertexFlags;
/// A mesh BVH node.
@ -3188,8 +3181,7 @@ 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 passed a culling test against drawingBounds below.
void ( *DrawShapeFcn )( void* userShape, b3WorldTransform transform, b3HexColor color,
void* context );
void ( *DrawShapeFcn )( void* userShape, b3WorldTransform transform, b3HexColor color, void* context );
/// Draw a line segment.
void ( *DrawSegmentFcn )( b3Pos p1, b3Pos p2, b3HexColor color, void* context );
@ -3204,15 +3196,13 @@ typedef struct b3DebugDraw
void ( *DrawSphereFcn )( b3Pos p, float radius, b3HexColor color, float alpha, void* context );
/// Draw a capsule.
void ( *DrawCapsuleFcn )( b3Pos p1, b3Pos p2, float radius, b3HexColor color, float alpha,
void* context );
void ( *DrawCapsuleFcn )( b3Pos p1, b3Pos p2, float radius, b3HexColor color, float alpha, void* context );
/// Draw a bounding box.
void ( *DrawBoundsFcn )( b3AABB aabb, b3HexColor color, void* context );
/// Draw an oriented box.
void ( *DrawBoxFcn )( b3Vec3 extents, b3WorldTransform transform, b3HexColor color,
void* context );
void ( *DrawBoxFcn )( b3Vec3 extents, b3WorldTransform transform, b3HexColor color, void* context );
/// Draw a string in world space
void ( *DrawStringFcn )( b3Pos p, const char* s, b3HexColor color, void* context );

View file

@ -1505,7 +1505,8 @@ int b3GetMeshVertexFlag( const b3Mesh* mesh, int triangleIndex, int vertexIndex
}
b3MeshTriangle triangle = b3GetMeshTriangles( data )[triangleIndex];
return vertexFlags[b3GetMeshVertexIndex( mesh, triangle, vertexIndex )];
int index = b3GetMeshVertexIndex( mesh, triangle, vertexIndex );
return vertexFlags[index];
}
// Is the candidate manifold normal in vertex Voronoi region?

View file

@ -209,6 +209,7 @@ static inline bool b3IsConvexVertex( const b3Shape* shape, int triangleIndex, in
{
if ( shape->type == b3_meshShape )
{
// todo should this handle reflection?
int flags = b3GetMeshVertexFlag( &shape->mesh, triangleIndex, vertexIndex );
return ( flags & ( b3_flatVertex | b3_concaveVertex ) ) == 0;
}