Box2D 3.1.0
A 2D physics engine for games
 
Loading...
Searching...
No Matches
Collision

Functions for colliding pairs of shapes. More...

Data Structures

struct  b2ManifoldPoint
 A manifold point is a contact point belonging to a contact manifold. More...
 
struct  b2Manifold
 A contact manifold describes the contact points between colliding shapes. More...
 

Functions

b2Manifold b2CollideCircles (const b2Circle *circleA, b2Transform xfA, const b2Circle *circleB, b2Transform xfB)
 Compute the contact manifold between two circles.
 
b2Manifold b2CollideCapsuleAndCircle (const b2Capsule *capsuleA, b2Transform xfA, const b2Circle *circleB, b2Transform xfB)
 Compute the contact manifold between a capsule and circle.
 
b2Manifold b2CollideSegmentAndCircle (const b2Segment *segmentA, b2Transform xfA, const b2Circle *circleB, b2Transform xfB)
 Compute the contact manifold between an segment and a circle.
 
b2Manifold b2CollidePolygonAndCircle (const b2Polygon *polygonA, b2Transform xfA, const b2Circle *circleB, b2Transform xfB)
 Compute the contact manifold between a polygon and a circle.
 
b2Manifold b2CollideCapsules (const b2Capsule *capsuleA, b2Transform xfA, const b2Capsule *capsuleB, b2Transform xfB)
 Compute the contact manifold between a capsule and circle.
 
b2Manifold b2CollideSegmentAndCapsule (const b2Segment *segmentA, b2Transform xfA, const b2Capsule *capsuleB, b2Transform xfB)
 Compute the contact manifold between an segment and a capsule.
 
b2Manifold b2CollidePolygonAndCapsule (const b2Polygon *polygonA, b2Transform xfA, const b2Capsule *capsuleB, b2Transform xfB)
 Compute the contact manifold between a polygon and capsule.
 
b2Manifold b2CollidePolygons (const b2Polygon *polygonA, b2Transform xfA, const b2Polygon *polygonB, b2Transform xfB)
 Compute the contact manifold between two polygons.
 
b2Manifold b2CollideSegmentAndPolygon (const b2Segment *segmentA, b2Transform xfA, const b2Polygon *polygonB, b2Transform xfB)
 Compute the contact manifold between an segment and a polygon.
 
b2Manifold b2CollideChainSegmentAndCircle (const b2ChainSegment *segmentA, b2Transform xfA, const b2Circle *circleB, b2Transform xfB)
 Compute the contact manifold between a chain segment and a circle.
 
b2Manifold b2CollideChainSegmentAndCapsule (const b2ChainSegment *segmentA, b2Transform xfA, const b2Capsule *capsuleB, b2Transform xfB, b2SimplexCache *cache)
 Compute the contact manifold between a chain segment and a capsule.
 
b2Manifold b2CollideChainSegmentAndPolygon (const b2ChainSegment *segmentA, b2Transform xfA, const b2Polygon *polygonB, b2Transform xfB, b2SimplexCache *cache)
 Compute the contact manifold between a chain segment and a rounded polygon.
 

Detailed Description

Functions for colliding pairs of shapes.


Data Structure Documentation

◆ b2ManifoldPoint

struct b2ManifoldPoint

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. Box2D uses speculative collision so some contact points may be separated. You may use the totalNormalImpulse to determine if there was an interaction during the time step.

Collaboration diagram for b2ManifoldPoint:
Data Fields
b2Vec2 anchorA Location of the contact point relative to shapeA's origin in world space.
Note
When used internally to the Box2D solver, this is relative to the body center of mass.
b2Vec2 anchorB Location of the contact point relative to shapeB's origin in world space.
Note
When used internally to the Box2D solver, this is relative to the body center of mass.
uint16_t id Uniquely identifies a contact point between two shapes.
float normalImpulse The impulse along the manifold normal vector.
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 the previous step?
b2Vec2 point Location of the contact point in world space.

Subject to precision loss at large coordinates.

Note
Should only be used for debugging.
float separation The separation of the contact point, negative if penetrating.
float tangentImpulse The friction impulse.
float totalNormalImpulse The total normal impulse applied across sub-stepping and restitution.

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

◆ b2Manifold

struct b2Manifold

A contact manifold describes the contact points between colliding shapes.

Note
Box2D uses speculative collision so some contact points may be separated.
Collaboration diagram for b2Manifold:
Data Fields
b2Vec2 normal The unit normal vector in world space, points from shape A to bodyB.
int pointCount The number of contacts points, will be 0, 1, or 2.
b2ManifoldPoint points[2] The manifold points, up to two are possible in 2D.
float rollingImpulse Angular impulse applied for rolling resistance. N * m * s = kg * m^2 / s.