Bug fixes and minor features (#2)
- API to query compounds directly. - Fix some uninitialized stuff (thanks MSAN). - Fix for store impulses on overflow. - AABB margin reduced for small shapes - body contact recycling option - angular threshold for contact recycling - reduce AABB margin on smaller shapes - fix for hull vs tri when axis aligned - fully locked rotation uses zero inverse inertia
This commit is contained in:
parent
d7816a0a58
commit
7216822064
50 changed files with 759 additions and 360 deletions
|
|
@ -783,6 +783,7 @@ B3_API b3MeshData* b3CreateWaveMesh( int xCount, int zCount, float cellWidth, fl
|
|||
float columnFrequency );
|
||||
B3_API b3MeshData* b3CreateTorusMesh( int radialResolution, int tubularResolution, float radius, float thickness );
|
||||
B3_API b3MeshData* b3CreateBoxMesh( b3Vec3 center, b3Vec3 extent, bool identifyEdges );
|
||||
B3_API b3MeshData* b3CreatePlatformMesh( b3Vec3 center, float height, float topWidth, float bottomWidth );
|
||||
B3_API b3MeshData* b3CreateMesh( const b3MeshDef* def, int* degenerateTriangleIndices, int degenerateCapacity );
|
||||
B3_API void b3DestroyMesh( b3MeshData* mesh );
|
||||
B3_API int b3GetHeight( const b3MeshData* mesh );
|
||||
|
|
|
|||
|
|
@ -64,16 +64,26 @@ B3_API float b3GetLengthUnitsPerMeter( void );
|
|||
/// The default contact recycling distance.
|
||||
#define B3_CONTACT_RECYCLE_DISTANCE ( 10.0f * B3_LINEAR_SLOP )
|
||||
|
||||
/// The default contact recycling world angle threshold. For performance this value
|
||||
/// is cos(angle/2)^2. This value corresponds to 10 degrees.
|
||||
#define B3_CONTACT_RECYCLE_ANGULAR_DISTANCE ( 0.99240388f )
|
||||
|
||||
// This is used to fatten AABBs in the dynamic tree. This allows proxies
|
||||
// to move by a small amount without triggering a tree adjustment. This is in meters.
|
||||
// @warning modifying this can have a significant impact on performance
|
||||
#define B3_AABB_MARGIN ( 0.05f * b3GetLengthUnitsPerMeter() )
|
||||
#define B3_MAX_AABB_MARGIN ( 0.05f * b3GetLengthUnitsPerMeter() )
|
||||
|
||||
// Per-shape AABB margin is a fraction of the shape extent (capped by B3_MAX_AABB_MARGIN).
|
||||
// Small shapes get small margins; large shapes are clamped to the cap.
|
||||
#define B3_AABB_MARGIN_FRACTION 0.125f
|
||||
|
||||
// The time that a body must be still before it will go to sleep. In seconds.
|
||||
#define B3_TIME_TO_SLEEP 0.5f
|
||||
|
||||
// Body and shape name lengths
|
||||
#define B3_NAME_LENGTH 64
|
||||
/// Maximum length of the body name. Must be at least 1. Includes null termination.
|
||||
#ifndef B3_NAME_LENGTH
|
||||
#define B3_NAME_LENGTH 18
|
||||
#endif
|
||||
|
||||
// These generous limits allow for easy hashing. See b3ShapePairKey.
|
||||
#define B3_SHAPE_POWER 22
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ typedef struct b3BodyDef
|
|||
/// Sleep speed threshold, default is 0.05 meters per second
|
||||
float sleepThreshold;
|
||||
|
||||
/// Optional body name for debugging. Up to 31 characters (excluding null termination)
|
||||
/// Optional body name for debugging. Up to B3_NAME_LENGTH characters (including null termination)
|
||||
const char* name;
|
||||
|
||||
/// Use this to store application specific body data.
|
||||
|
|
@ -258,10 +258,20 @@ typedef struct b3BodyDef
|
|||
/// Is this body initially awake or sleeping?
|
||||
bool isAwake;
|
||||
|
||||
/// Treat this body as high speed object that performs continuous collision detection
|
||||
/// Treat this body as a high speed object that performs continuous collision detection
|
||||
/// against dynamic and kinematic bodies, but not other bullet bodies.
|
||||
/// @warning Bullets should be used sparingly. They are not a solution for general dynamic-versus-dynamic
|
||||
/// continuous collision.
|
||||
/// continuous collision. They do not guarantee accurate collision if both bodies are fast moving because
|
||||
/// the bullet does a continuous check after all non-bullet bodies have moved. You could get unlucky and have
|
||||
/// the bullet body end a time step very close to a non-bullet body and the non-bullet body then moves over
|
||||
/// the bullet body. In continuous collision, initial overlap is ignored to avoid freezing bodies in place.
|
||||
/// I do not recommend using them for game projectiles if precise collision timing is needed. Instead consider
|
||||
/// using a ray or shape cast. You can use a marching ray or shape cast for projectile that moves over time.
|
||||
/// If you want a fast moving projectile to collide with a fast moving target, you need to consider the relative
|
||||
/// movement in your ray or shape cast. This is out of the scope of Box3D.
|
||||
/// So what are good use cases for bullets? Pinball games or games with dynamic containers that hold other objects.
|
||||
/// It should be a use case where it doesn't break the game if there is a collision missed, but having them
|
||||
/// captured improves the quality of the game.
|
||||
bool isBullet;
|
||||
|
||||
/// Used to disable a body. A disabled body does not move or collide.
|
||||
|
|
@ -271,10 +281,9 @@ typedef struct b3BodyDef
|
|||
/// for circular objects, like wheels.
|
||||
bool allowFastRotation;
|
||||
|
||||
/// Enable continuous collision. This is true by default and should only be disabled for application reasons, such
|
||||
/// as wheels on a vehicle.
|
||||
/// todo not hooked up yet
|
||||
bool enableContinuousCollision;
|
||||
/// Enable contact recycling. True by default. Leaving this enabled improves performance
|
||||
/// but may lead to ghost collision that should be avoided on characters.
|
||||
bool enableContactRecycling;
|
||||
|
||||
/// Used internally to detect a valid definition. DO NOT SET.
|
||||
int internalValue;
|
||||
|
|
@ -1266,6 +1275,29 @@ typedef struct b3BodyPlaneResult
|
|||
b3PlaneResult result;
|
||||
} b3BodyPlaneResult;
|
||||
|
||||
typedef struct b3ChildShape
|
||||
{
|
||||
union
|
||||
{
|
||||
b3Capsule capsule;
|
||||
const b3Hull* hull;
|
||||
b3Mesh mesh;
|
||||
b3Sphere sphere;
|
||||
};
|
||||
|
||||
b3Transform transform;
|
||||
|
||||
// Index 0 is used for convex shapes.
|
||||
// todo limit to 64K?
|
||||
int materialIndices[B3_MAX_COMPOUND_MESH_MATERIALS];
|
||||
b3ShapeType type;
|
||||
} b3ChildShape;
|
||||
|
||||
typedef bool b3CompoundQueryFcn( const b3Compound* compound, int childIndex, void* context );
|
||||
|
||||
B3_API b3ChildShape b3GetCompoundChild( const b3Compound* compound, int childIndex );
|
||||
B3_API void b3QueryCompound( const b3Compound* compound, b3AABB aabb, b3CompoundQueryFcn* fcn, void* context );
|
||||
|
||||
/// These colors are used for debug draw and mostly match the named SVG colors.
|
||||
/// See https://www.rapidtables.com/web/color/index.html
|
||||
/// https://johndecember.com/html/spec/colorsvg.html
|
||||
|
|
|
|||
Loading…
Reference in a new issue