Reduce ghosts (#212)
Full ghost collision handling for sphere, capsule, and hull versus a single mesh or heightfield. This requires mesh to be built with edge identification. Optimized mesh builder. Removed B3_MAX_MESH_CONTACT_TRIANGLES. You will still hit performance problems for dense meshes. Fixes #184
This commit is contained in:
parent
3362633204
commit
38f2ae1e19
61 changed files with 17756 additions and 1492 deletions
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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,6 +345,28 @@ 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.
|
||||
B3_INLINE const int8_t* b3GetMeshEdgeAngles( const b3MeshData* mesh )
|
||||
{
|
||||
if ( mesh->edgeAngleOffset == 0 )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (const int8_t*)( (intptr_t)mesh + mesh->edgeAngleOffset );
|
||||
}
|
||||
|
||||
/// Get read only vertex flags.
|
||||
B3_INLINE const uint8_t* b3GetMeshVertexFlags( const b3MeshData* mesh )
|
||||
{
|
||||
if ( mesh->vertexFlagOffset == 0 )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (const uint8_t*)( (intptr_t)mesh + mesh->vertexFlagOffset );
|
||||
}
|
||||
|
||||
/// Create a grid mesh along the x and z axes.
|
||||
/// @param xCount the number of rows in the x direction
|
||||
/// @param zCount the number of rows in the z direction
|
||||
|
|
@ -422,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 );
|
||||
|
|
@ -522,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 );
|
||||
|
|
@ -580,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.
|
||||
|
|
@ -630,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,
|
||||
|
|
@ -650,24 +681,46 @@ 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,
|
||||
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,
|
||||
const b3Sphere* sphereB );
|
||||
|
||||
/// Collide a mesh and hull for testing.
|
||||
B3_API int b3CollideMeshAndHull( b3Manifold* manifolds, int capacity, const b3Mesh* mesh, const b3HullData* hull,
|
||||
b3Transform transformBtoA, bool enableSpeculative, bool handleGhosts );
|
||||
|
||||
/// Collide a mesh and sphere for testing.
|
||||
B3_API int b3CollideMeshAndSphere( b3Manifold* manifolds, int capacity, const b3Mesh* mesh, const b3Sphere* sphere,
|
||||
b3Transform transformBtoA, bool enableSpeculative, bool handleGhosts );
|
||||
|
||||
/// This is used for computing 2D hulls in service of contact manifold simplification.
|
||||
/// Placed here for testing. Internal.
|
||||
typedef struct b3Point2D
|
||||
{
|
||||
b3Vec2 p; // 2D point
|
||||
float separation; // separation of the associated contact point
|
||||
int originalIndex; // original index of the associated contact point
|
||||
b3Vec2 p; ///< 2D point
|
||||
float separation; ///< separation of the associated contact point
|
||||
int originalIndex; ///< original index of the associated contact point
|
||||
} b3Point2D;
|
||||
|
||||
/// Options for how a 2D hull is built.
|
||||
typedef enum b3Hull2DFlags
|
||||
{
|
||||
/// Keep collinear points.
|
||||
b3_hull2DKeepCollinear = 0x01,
|
||||
|
||||
/// Only merge identical points.
|
||||
b3_hull2DExactMerge = 0x02,
|
||||
|
||||
/// Order the output points by the input order.
|
||||
b3_hull2DIndexOrder = 0x04,
|
||||
} b3Hull2DFlags;
|
||||
|
||||
/// Compute a 2D hull. Used internally for contact manifold simplification. Here for testing.
|
||||
B3_API int b3Hull2D( b3Point2D* pts, int count, b3Point2D* hull );
|
||||
B3_API int b3Hull2D( b3Point2D* pts, int count, b3Point2D* hull, int flags );
|
||||
|
||||
/// Simplify a 2D hull. Used internally for contact manifold simplification. Here for testing.
|
||||
B3_API int b3SimplifyHull2D( b3Point2D* hull, int count, int target );
|
||||
|
|
|
|||
|
|
@ -137,10 +137,3 @@ B3_API float b3GetLengthUnitsPerMeter( void );
|
|||
#define B3_CHILD_POWER ( 64 - 2 * B3_SHAPE_POWER )
|
||||
#define B3_MAX_SHAPES ( 1 << B3_SHAPE_POWER )
|
||||
#define B3_MAX_CHILD_SHAPES ( 1 << B3_CHILD_POWER )
|
||||
|
||||
/// This is the limit on how many mesh or heightfield triangles a single convex shape can collide with.
|
||||
/// Increasing this will increase stack usage, so be careful. I recommend to simplify your collision data
|
||||
/// before increasing this. For example, using render mesh for collision often leads to poor performance.
|
||||
#ifndef B3_MAX_MESH_CONTACT_TRIANGLES
|
||||
#define B3_MAX_MESH_CONTACT_TRIANGLES 512
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -189,7 +189,48 @@ B3_INLINE float b3LerpFloat( float a, float b, float alpha )
|
|||
/// This is hand coded for cross-platform determinism. The atan2f
|
||||
/// function in the standard library is not cross-platform deterministic.
|
||||
/// Accurate to around 0.0023 degrees.
|
||||
B3_API float b3Atan2( float y, float x );
|
||||
/// https://stackoverflow.com/questions/46210708/atan2-approximation-with-11bits-in-mantissa-on-x86with-sse2-and-armwith-vfpv4
|
||||
B3_INLINE float b3Atan2( float y, float x )
|
||||
{
|
||||
// Added check for (0,0) to match atan2f and avoid NaN
|
||||
if ( x == 0.0f && y == 0.0f )
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
float ax = b3AbsFloat( x );
|
||||
float ay = b3AbsFloat( y );
|
||||
float mx = b3MaxFloat( ay, ax );
|
||||
float mn = b3MinFloat( ay, ax );
|
||||
float a = mn / mx;
|
||||
|
||||
// Minimax polynomial approximation to atan(a) on [0,1]
|
||||
float s = a * a;
|
||||
float c = s * a;
|
||||
float q = s * s;
|
||||
float r = 0.024840285f * q + 0.18681418f;
|
||||
float t = -0.094097948f * q - 0.33213072f;
|
||||
r = r * s + t;
|
||||
r = r * c + a;
|
||||
|
||||
// Map to full circle
|
||||
if ( ay > ax )
|
||||
{
|
||||
r = 1.57079637f - r;
|
||||
}
|
||||
|
||||
if ( x < 0 )
|
||||
{
|
||||
r = 3.14159274f - r;
|
||||
}
|
||||
|
||||
if ( y < 0 )
|
||||
{
|
||||
r = -r;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/// Compute the cosine and sine of an angle in radians. Implemented
|
||||
/// for cross-platform determinism.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -1628,7 +1625,6 @@ typedef struct b3SimplexCache
|
|||
/// Value use to compare length, area, volume of two simplexes.
|
||||
float metric;
|
||||
|
||||
// todo use an index of 0xFF as a sentinel and remove the count
|
||||
/// The number of stored simplex points
|
||||
uint16_t count;
|
||||
|
||||
|
|
@ -1650,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
|
||||
|
|
@ -1905,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
|
||||
|
||||
|
|
@ -2009,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
|
||||
|
|
@ -2260,7 +2252,7 @@ typedef struct b3MeshDef
|
|||
} b3MeshDef;
|
||||
|
||||
/// 64-bit mesh version. Useful for validating serialized data.
|
||||
#define B3_MESH_VERSION 0xAAAB9A00F1A8AAF7ull
|
||||
#define B3_MESH_VERSION 0x24AA0BF74682501Dull
|
||||
|
||||
/// Triangle mesh edge flags.
|
||||
typedef enum b3MeshEdgeFlags
|
||||
|
|
@ -2291,6 +2283,16 @@ typedef struct b3MeshTriangle
|
|||
int32_t index3; ///< Index of vertex 3.
|
||||
} b3MeshTriangle;
|
||||
|
||||
/// Indicates an isolated edge (treated as a cliff).
|
||||
#define B3_BOUNDARY_EDGE_ANGLE ( -128 )
|
||||
|
||||
/// Mesh vertex flags. Used for ghost collision handling.
|
||||
typedef enum b3MeshVertexFlags
|
||||
{
|
||||
b3_flatVertex = 0x01, ///< All edges are flat.
|
||||
b3_concaveVertex = 0x02, ///< Any edge is concave.
|
||||
} b3MeshVertexFlags;
|
||||
|
||||
/// A mesh BVH node.
|
||||
typedef struct b3MeshNode
|
||||
{
|
||||
|
|
@ -2327,7 +2329,8 @@ typedef struct b3MeshNode
|
|||
uint32_t triangleOffset;
|
||||
} b3MeshNode;
|
||||
|
||||
/// This is a sorted triangle collision bounding volume hierarchy.
|
||||
/// This is a sorted triangle collision bounding volume hierarchy. Offsets are a byte
|
||||
/// count offset from the struct address.
|
||||
/// @note This struct has data hanging off the end and cannot be directly copied.
|
||||
typedef struct b3MeshData
|
||||
{
|
||||
|
|
@ -2352,35 +2355,41 @@ typedef struct b3MeshData
|
|||
/// The number of degenerate triangles. Diagnostic.
|
||||
int32_t degenerateCount;
|
||||
|
||||
/// Offset of the node array in bytes from the struct address.
|
||||
/// Offset of the node array.
|
||||
int32_t nodeOffset;
|
||||
|
||||
/// The number of BVH nodes.
|
||||
int32_t nodeCount;
|
||||
|
||||
/// Offset of the vertex array in bytes from the struct address.
|
||||
/// Offset of the vertex array.
|
||||
int32_t vertexOffset;
|
||||
|
||||
/// The number of vertices.
|
||||
int32_t vertexCount;
|
||||
|
||||
/// Offset of the triangle array in bytes from the struct address.
|
||||
/// Offset of the triangle array.
|
||||
int32_t triangleOffset;
|
||||
|
||||
/// The number of triangles.
|
||||
int32_t triangleCount;
|
||||
|
||||
/// Offset of the material array in bytes from the struct address.
|
||||
/// Offset of the material array.
|
||||
int32_t materialOffset;
|
||||
|
||||
/// The number of materials.
|
||||
int32_t materialCount;
|
||||
|
||||
/// Offset of the triangle flag array in bytes from the struct address.
|
||||
/// Offset of the triangle flag array.
|
||||
int32_t flagsOffset;
|
||||
|
||||
/// Explicit padding.
|
||||
int32_t padding;
|
||||
// Offset to the edge neighbor angles.
|
||||
int32_t edgeAngleOffset;
|
||||
|
||||
/// Offset of the vertex flag array.
|
||||
int32_t vertexFlagOffset;
|
||||
|
||||
/// Offset the vertex neighbor angle ring.
|
||||
int32_t vertexRingOffset;
|
||||
} b3MeshData;
|
||||
|
||||
/// This allows mesh data to be re-used with different scales.
|
||||
|
|
@ -2441,7 +2450,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.
|
||||
|
|
@ -2489,11 +2498,15 @@ typedef struct b3HeightFieldData
|
|||
/// uint8_t, one per triangle.
|
||||
int32_t flagsOffset;
|
||||
|
||||
/// Offset to the vertex ghost collision flag. Array of bits.
|
||||
int32_t vertexFlagOffset;
|
||||
|
||||
/// Triangle winding.
|
||||
uint8_t clockwise;
|
||||
|
||||
/// Explicit padding.
|
||||
uint8_t padding[7];
|
||||
uint8_t padding[3];
|
||||
|
||||
} b3HeightFieldData;
|
||||
|
||||
/**@}*/ // height_field
|
||||
|
|
@ -2797,6 +2810,12 @@ typedef struct b3ManifoldPoint
|
|||
|
||||
/// Did this contact point exist in the previous step?
|
||||
bool persisted;
|
||||
|
||||
// b3TriangleFeature
|
||||
uint8_t triangleFeature;
|
||||
|
||||
// b3MeshContactFlags
|
||||
uint8_t meshFlags;
|
||||
} b3ManifoldPoint;
|
||||
|
||||
/// A contact manifold describes the contact points between colliding shapes.
|
||||
|
|
@ -2824,7 +2843,7 @@ typedef struct b3Manifold
|
|||
} b3Manifold;
|
||||
|
||||
/// Cached separating axis feature.
|
||||
typedef enum
|
||||
typedef enum b3SeparatingFeature
|
||||
{
|
||||
b3_invalidAxis = 0,
|
||||
b3_backsideAxis,
|
||||
|
|
@ -2840,7 +2859,7 @@ typedef enum
|
|||
} b3SeparatingFeature;
|
||||
|
||||
/// Cached triangle feature.
|
||||
typedef enum
|
||||
typedef enum b3TriangleFeature
|
||||
{
|
||||
b3_featureNone = 0,
|
||||
b3_featureTriangleFace,
|
||||
|
|
@ -2856,6 +2875,14 @@ typedef enum
|
|||
b3_featureVertex3
|
||||
} b3TriangleFeature;
|
||||
|
||||
/// This gives debug information about how a contact point was generated.
|
||||
typedef enum b3MeshContactFlags
|
||||
{
|
||||
b3_meshContactHullFace = 0x01, ///< Normal is a hull face normal.
|
||||
b3_meshContactSnapped = 0x02, ///< The normal is snapped to the triangle normal.
|
||||
b3_meshContactDeep = 0x04, ///< The contact is considered deep (2 * linear slop).
|
||||
} b3MeshContactFlags;
|
||||
|
||||
/// Separating axis test cache. Provides temporal acceleration of collision routines.
|
||||
typedef struct
|
||||
{
|
||||
|
|
@ -2907,6 +2934,12 @@ typedef struct b3LocalManifoldPoint
|
|||
|
||||
/// The triangle index when collide with a mesh or height-field.
|
||||
int triangleIndex;
|
||||
|
||||
// b3TriangleFeature
|
||||
uint8_t triangleFeature;
|
||||
|
||||
// b3MeshContactFlags
|
||||
uint8_t meshFlags;
|
||||
} b3LocalManifoldPoint;
|
||||
|
||||
/// A local manifold with no dynamic information. Used by b3Collide functions.
|
||||
|
|
@ -2927,18 +2960,8 @@ typedef struct b3LocalManifold
|
|||
/// The index of the triangle.
|
||||
int triangleIndex;
|
||||
|
||||
int i1; ///< Vertex 1 index.
|
||||
int i2; ///< Vertex 2 index.
|
||||
int i3; ///< Vertex 3 index.
|
||||
|
||||
/// The squared distance of a sphere from a triangle. For ghost collision reduction.
|
||||
float squaredDistance;
|
||||
|
||||
/// The triangle feature involved.
|
||||
b3TriangleFeature feature;
|
||||
|
||||
/// b3MeshEdgeFlags.
|
||||
int triangleFlags;
|
||||
} b3LocalManifold;
|
||||
|
||||
/**@}*/ // collision
|
||||
|
|
@ -3157,8 +3180,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 );
|
||||
|
|
@ -3173,15 +3195,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 );
|
||||
|
|
|
|||
Loading…
Reference in a new issue