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

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...
struct  b2LocalManifoldPoint
 Contact manifold point in local coordinates (frame A). More...
struct  b2LocalManifold
 Contact manifold in local coordinates (frame A). More...

Functions

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

Detailed Description

Functions for colliding pairs of shapes.

Each function takes the shapes in their own local frames and the transform of shape B in shape A's frame (b2InvMulWorldTransforms( worldA, worldB )). The manifold is returned in frame A.


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.

Data Fields
b2Vec2 anchorA Location of the contact point relative to bodyA's center of mass in world space.

This can be converted to a world point using: b2Pos worldPointA = b2OffsetPos(b2Body_GetWorldCenter(myBodyIdA), anchorA);

b2Vec2 anchorB Similar for body B.
float baseSeparation Cached separation used for contact recycling.
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.

Negative when approaching. This is only computed if hit events are enabled. It may be computed otherwise as a side effect of SIMD bundling, but that is not guaranteed.

bool persisted Did this contact point exist the previous step?
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. This includes the warm starting impulse, the sub-step delta impulse, and the restitution impulse.

◆ 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.
Data Fields
b2Vec2 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, 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.

◆ b2LocalManifoldPoint

struct b2LocalManifoldPoint

Contact manifold point in local coordinates (frame A).

Data Fields
uint16_t id Uniquely identifies a contact point between two shapes.
b2Vec2 point Contact point in frame A.
float separation The separation of the contact point, negative if penetrating. May be positive or negative.

◆ b2LocalManifold

struct b2LocalManifold

Contact manifold in local coordinates (frame A).

Data Fields
b2Vec2 normal The unit normal vector in frame A, points from shape A to shape B.
int pointCount The number of contact points, will be 0, 1, or 2.
b2LocalManifoldPoint points[2] The manifold points, up to two are possible in 2D.