Box3D 0.1.0
A 3D physics engine for games
Loading...
Searching...
No Matches
Shape Collision

Collide pairs of shapes. More...

Data Structures

struct  b3ManifoldPoint
 A manifold point is a contact point belonging to a contact manifold. More...
struct  b3Manifold
 A contact manifold describes the contact points between colliding shapes. More...
struct  b3SATCache
 Separating axis test cache. Provides temporal acceleration of collision routines. More...
struct  b3FeaturePair
 Contact points are always the result of two edges intersecting. More...
struct  b3LocalManifoldPoint
 A local manifold point and normal in frame A. More...
struct  b3LocalManifold
 A local manifold with no dynamic information. Used by b3Collide functions. More...

Enumerations

enum  b3SeparatingFeature {
  b3_invalidAxis = 0 , b3_backsideAxis , b3_faceAxisA , b3_faceAxisB ,
  b3_edgePairAxis , b3_closestPointsAxis , b3_manualFaceAxisA , b3_manualFaceAxisB ,
  b3_manualEdgePairAxis
}
 Cached separating axis feature. More...
enum  b3TriangleFeature {
  b3_featureNone = 0 , b3_featureTriangleFace , b3_featureHullFace , b3_featureEdge1 ,
  b3_featureEdge2 , b3_featureEdge3 , b3_featureVertex1 , b3_featureVertex2 ,
  b3_featureVertex3
}
 Cached triangle feature. More...

Functions

void b3CollideSpheres (b3LocalManifold *manifold, int capacity, const b3Sphere *sphereA, const b3Sphere *sphereB, b3Transform transformBtoA)
 Collide two spheres.
void b3CollideCapsuleAndSphere (b3LocalManifold *manifold, int capacity, const b3Capsule *capsuleA, const b3Sphere *sphereB, b3Transform transformBtoA)
 Collide a capsule and a sphere.
void b3CollideHullAndSphere (b3LocalManifold *manifold, int capacity, const b3HullData *hullA, const b3Sphere *sphereB, b3Transform transformBtoA, b3SimplexCache *cache)
 Collide a hull and a sphere.
void b3CollideCapsules (b3LocalManifold *manifold, int capacity, const b3Capsule *capsuleA, const b3Capsule *capsuleB, b3Transform transformBtoA)
 Collide two capsules.
void b3CollideHullAndCapsule (b3LocalManifold *manifold, int capacity, const b3HullData *hullA, const b3Capsule *capsuleB, b3Transform transformBtoA, b3SimplexCache *cache)
 Collide a hull and a capsule.
void b3CollideHulls (b3LocalManifold *manifold, int capacity, const b3HullData *hullA, const b3HullData *hullB, b3Transform transformBtoA, b3SATCache *cache)
 Collide two hulls.
void b3CollideCapsuleAndTriangle (b3LocalManifold *manifold, int capacity, const b3Capsule *capsuleA, const b3Vec3 *triangleB, b3SimplexCache *cache)
 Collide a capsule and a triangle.
void b3CollideHullAndTriangle (b3LocalManifold *manifold, int capacity, const b3HullData *hullA, b3Vec3 v1, b3Vec3 v2, b3Vec3 v3, int triangleFlags, b3SATCache *cache)
 Collide a hull and a triangle.
void b3CollideSphereAndTriangle (b3LocalManifold *manifold, int capacity, const b3Sphere *sphereA, const b3Vec3 *triangleB)
 Collide a sphere and a triangle.

Detailed Description

Collide pairs of shapes.


Data Structure Documentation

◆ b3ManifoldPoint

struct b3ManifoldPoint

A manifold point is a contact point belonging to a contact manifold.

It holds details related to the geometry and dynamics of the contact points. Box3D uses speculative collision so some contact points may be separated. You may use the maxNormalImpulse to determine if there was an interaction during the time step.

Collaboration diagram for b3ManifoldPoint:
Data Fields
b3Vec3 anchorA Location of the contact point relative to the bodyA center of mass in world space.
b3Vec3 anchorB Location of the contact point relative to the bodyB center of mass in world space.
float baseSeparation Cached separation used for contact recycling.
uint32_t featureId Local point for matching Uniquely identifies a contact point between two shapes.
float normalImpulse The impulse along the manifold normal vector.

Since Box3D uses sub-stepping, this is result from the final sub-step.

float normalVelocity Relative normal velocity pre-solve.

Used for hit events. If the normal impulse is zero then there was no hit. Negative means shapes are approaching.

bool persisted Did this contact point exist in the previous step?
float separation The separation of the contact point, negative if penetrating.
float totalNormalImpulse The total normal impulse applied during sub-stepping.

This is important to identify speculative contact points that had an interaction in the time step.

int triangleIndex Triangle index if one of the shapes is a mesh or height field.

◆ b3Manifold

struct b3Manifold

A contact manifold describes the contact points between colliding shapes.

Note
Box3D uses speculative collision so some contact points may be separated.
Collaboration diagram for b3Manifold:
Data Fields
b3Vec3 frictionImpulse Central friction linear impulse.
b3Vec3 normal The unit normal vector in world space, points from shape A to shape B.
int pointCount The number of contact points, will be 0 to 4.
b3ManifoldPoint points[B3_MAX_MANIFOLD_POINTS] The manifold points. There may be 1 to 4 valid points.
b3Vec3 rollingImpulse Rolling resistance angular impulse.
float twistImpulse Central friction angular impulse (applied about the normal).

◆ b3SATCache

struct b3SATCache

Separating axis test cache. Provides temporal acceleration of collision routines.

Data Fields
uint8_t hit Was the cache re-used?
uint8_t indexA Index of the feature on shape A.
uint8_t indexB Index of the feature on shape B.
float separation The separation when the cache is populated. Negative for overlap.
uint8_t type b3SeparatingFeature.

◆ b3FeaturePair

struct b3FeaturePair

Contact points are always the result of two edges intersecting.

It can be two edges of the same shape, which is just a shape vertex. Or a contact point can be the result of two edges crossing from different shapes. This is designed to support hull versus hull, but it is adapted to work with all shape types. The feature pair is used to identify contact points for temporal coherence and warm starting.

Data Fields
uint8_t index1 Incoming edge index (into associated shape array).
uint8_t index2 Outgoing edge index (into associated shape array).
uint8_t owner1 Incoming type (either edge on shape A or shape B).
uint8_t owner2 Outgoing type (either edge on shape A or shape B).

◆ b3LocalManifoldPoint

struct b3LocalManifoldPoint

A local manifold point and normal in frame A.

Collaboration diagram for b3LocalManifoldPoint:
Data Fields
b3FeaturePair pair The feature pair for this point.
b3Vec3 point Local point in frame A.
float separation The contact point separation. Negative for overlap.
int triangleIndex The triangle index when collide with a mesh or height-field.

◆ b3LocalManifold

struct b3LocalManifold

A local manifold with no dynamic information. Used by b3Collide functions.

Collaboration diagram for b3LocalManifold:
Data Fields
b3TriangleFeature feature The triangle feature involved.
int i1 Vertex 1 index.
int i2 Vertex 2 index.
int i3 Vertex 3 index.
b3Vec3 normal Local normal in frame A.
int pointCount The number of manifold points. Only bounded by the buffer capacity.
b3LocalManifoldPoint * points The manifold points. From a point buffer.
float squaredDistance The squared distance of a sphere from a triangle. For ghost collision reduction.
int triangleFlags b3MeshEdgeFlags.
int triangleIndex The index of the triangle.
b3Vec3 triangleNormal The triangle normal.

Enumeration Type Documentation

◆ b3SeparatingFeature

Cached separating axis feature.

Enumerator
b3_manualFaceAxisA 

These are for testing.

◆ b3TriangleFeature

Cached triangle feature.

Enumerator
b3_featureEdge1 

v1-v2

b3_featureEdge2 

v2-v3

b3_featureEdge3 

v3-v1