Box2D  3.0.0
A Real-Time-Oriented 2-D Physics Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
box2d::Manifold Class Reference

Manifold for two convex shapes. More...

#include <Manifold.hpp>

Classes

struct  Conf
 
struct  Point
 Point data for a manifold. More...
 

Public Types

enum  Type : std::uint8_t { e_unset, e_circles, e_faceA, e_faceB }
 Manifold type. More...
 
using size_type = std::remove_const< decltype(MaxManifoldPoints)>::type
 
using sidx_t = std::remove_const< decltype(MaxShapeVertices)>::type
 Shape index type. More...
 
using cf_t = ContactFeature::Type
 

Public Member Functions

 Manifold ()=default
 Default constructor. More...
 
 Manifold (const Manifold &copy)=default
 
constexpr Type GetType () const noexcept
 Gets the type of this manifold. More...
 
constexpr size_type GetPointCount () const noexcept
 Gets the manifold point count. More...
 
constexpr ContactFeature GetContactFeature (size_type index) const noexcept
 
constexpr ContactImpulses GetContactImpulses (size_type index) const noexcept
 
void SetContactImpulses (size_type index, ContactImpulses value) noexcept
 
const PointGetPoint (size_type index) const noexcept
 
void SetPointImpulses (size_type index, Momentum n, Momentum t)
 
void AddPoint (const Point &mp) noexcept
 Adds a new point. More...
 
void AddPoint (cf_t type, sidx_t index, Length2D point) noexcept
 
constexpr UnitVec2 GetLocalNormal () const noexcept
 Gets the local normal for a face-type manifold. More...
 
constexpr Length2D GetLocalPoint () const noexcept
 Gets the local point. More...
 
constexpr Length2D GetOpposingPoint (size_type index) const noexcept
 

Static Public Member Functions

static Manifold GetForCircles (Length2D vA, sidx_t iA, Length2D vB, sidx_t iB) noexcept
 Gets a circles-typed manifold with one point. More...
 
static Manifold GetForFaceA (UnitVec2 normalA, Length2D faceA) noexcept
 Gets a face A typed manifold. More...
 
static Manifold GetForFaceA (UnitVec2 ln, Length2D lp, const Point &mp1) noexcept
 Gets a face A typed manifold. More...
 
static Manifold GetForFaceA (UnitVec2 ln, Length2D lp, const Point &mp1, const Point &mp2) noexcept
 Gets a face A typed manifold. More...
 
static Manifold GetForFaceB (UnitVec2 ln, Length2D lp) noexcept
 Gets a face B typed manifold. More...
 
static Manifold GetForFaceB (UnitVec2 ln, Length2D lp, const Point &mp1) noexcept
 Gets a face B typed manifold. More...
 
static Manifold GetForFaceB (UnitVec2 ln, Length2D lp, const Point &mp1, const Point &mp2) noexcept
 Gets a face B typed manifold. More...
 
static Manifold GetForFaceA (UnitVec2 na, sidx_t ia, Length2D pa) noexcept
 
static Manifold GetForFaceB (UnitVec2 nb, sidx_t ib, Length2D pb) noexcept
 
static Manifold GetForFaceA (UnitVec2 na, sidx_t ia, Length2D pa, cf_t tb0, sidx_t ib0, Length2D pb0) noexcept
 
static Manifold GetForFaceB (UnitVec2 nb, sidx_t ib, Length2D pb, cf_t ta0, sidx_t ia0, Length2D pa0) noexcept
 
static Manifold GetForFaceA (UnitVec2 na, sidx_t ia, Length2D pa, cf_t tb0, sidx_t ib0, Length2D pb0, cf_t tb1, sidx_t ib1, Length2D pb1) noexcept
 
static Manifold GetForFaceB (UnitVec2 nb, sidx_t ib, Length2D pb, cf_t ta0, sidx_t ia0, Length2D pa0, cf_t ta1, sidx_t ia1, Length2D pa1) noexcept
 

Detailed Description

Manifold for two convex shapes.

This describes zero, one, or two points of contact for which impulses should be applied to most naturally resolve those contacts. Ideally the manifold is calculated at the earliest point in time of contact occuring. The further past that time, the less natural contact resolution of solid bodies will be - eventually resulting in oddities like tunneling.

Multiple types of contact are supported: clip point versus plane with radius, point versus point with radius (circles). Contacts are stored in this way so that position correction can account for movement, which is critical for continuous physics. All contact scenarios must be expressed in one of these types.

Note
The local point and local normal usage depends on the manifold type. For details, see the documentation associated with the different manifold types.
Every point adds computational overhead to the collision response calculation - so express collision manifolds with one point if possible instead of two.
This data structure is at least 58-bytes large (60-bytes on one 64-bit platform).
See also
Contact.
PositionConstraint.
VelocityConstraint.

Member Typedef Documentation

◆ cf_t

◆ sidx_t

using box2d::Manifold::sidx_t = std::remove_const<decltype(MaxShapeVertices)>::type

Shape index type.

◆ size_type

using box2d::Manifold::size_type = std::remove_const<decltype(MaxManifoldPoints)>::type

Member Enumeration Documentation

◆ Type

enum box2d::Manifold::Type : std::uint8_t

Manifold type.

Note
This is by design a 1-byte sized type.
Enumerator
e_unset 

Unset type.

Manifold is unset. For manifolds of this type: the point count is zero, point data is undefined, and all other properties are invalid.

e_circles 

Circles type.

Manifold is for circle-to-circle like collisions.

Note
For manifolds of this type: the local point is local center of "circle-A" (where shape A wasn't necessarily a circle but treating it as such is useful), the local normal is invalid (and unused) and, the point count will be zero or one where the contact feature will be ContactFeature{e_vertex, i, e_vertex, j} where i and j are indexes of the vertexes of shapes A and B respectively.
e_faceA 

Face-A type.

Indicates: local point is center of face A, local normal is normal on shape A, and the local points of Point instances are the local center of cirlce B or a clip point of polygon B where the contact feature will be ContactFeature{e_face, i, e_vertex, j} or ContactFeature{e_face, i, e_face, j} where i and j are indexes for the vertex or edge of shapes A and B respectively..

e_faceB 

Face-B type.

Indicates: local point is center of face B, local normal is normal on shape B, and the local points of Point instances are the local center of cirlce A or a clip point of polygon A where the contact feature will be ContactFeature{e_face, i, e_vertex, j} or ContactFeature{e_face, i, e_face, j} where i and j are indexes for the vertex or edge of shapes A and B respectively..

Constructor & Destructor Documentation

◆ Manifold() [1/2]

box2d::Manifold::Manifold ( )
default

Default constructor.

Constructs an unset-type manifold. For an unset-type manifold: point count is zero, point data is undefined, and all other properties are invalid.

◆ Manifold() [2/2]

box2d::Manifold::Manifold ( const Manifold copy)
default

Member Function Documentation

◆ AddPoint() [1/2]

void box2d::Manifold::AddPoint ( const Point mp)
inlinenoexcept

Adds a new point.

This can be called once for circle type manifolds, and up to twice for face-A or face-B type manifolds. GetPointCount() can be called to find out how many points have already been added.

Note
Behavior is undefined if this object's type is e_unset.
Behavior is undefined if this is called more than twice.

◆ AddPoint() [2/2]

void box2d::Manifold::AddPoint ( cf_t  type,
sidx_t  index,
Length2D  point 
)
inlinenoexcept

◆ GetContactFeature()

constexpr ContactFeature box2d::Manifold::GetContactFeature ( size_type  index) const
inlinenoexcept

◆ GetContactImpulses()

constexpr ContactImpulses box2d::Manifold::GetContactImpulses ( size_type  index) const
inlinenoexcept

◆ GetForCircles()

static Manifold box2d::Manifold::GetForCircles ( Length2D  vA,
sidx_t  iA,
Length2D  vB,
sidx_t  iB 
)
inlinestaticnoexcept

Gets a circles-typed manifold with one point.

Parameters
vALocal center of "circle" A.
iAIndex of vertex from shape A representing the local center of "circle" A.
vBLocal center of "circle" B.
iBIndex of vertex from shape B representing the local center of "circle" B.

◆ GetForFaceA() [1/6]

static Manifold box2d::Manifold::GetForFaceA ( UnitVec2  normalA,
Length2D  faceA 
)
inlinestaticnoexcept

Gets a face A typed manifold.

Parameters
normalALocal normal of the face from polygon A.
faceAAny point in local coordinates on the face whose normal was provided.

◆ GetForFaceA() [2/6]

static Manifold box2d::Manifold::GetForFaceA ( UnitVec2  ln,
Length2D  lp,
const Point mp1 
)
inlinestaticnoexcept

Gets a face A typed manifold.

Parameters
lnNormal on polygon A.
lpCenter of face A.
mp1Manifold point 1 (of 1).

◆ GetForFaceA() [3/6]

static Manifold box2d::Manifold::GetForFaceA ( UnitVec2  ln,
Length2D  lp,
const Point mp1,
const Point mp2 
)
inlinestaticnoexcept

Gets a face A typed manifold.

Parameters
lnNormal on polygon A.
lpCenter of face A.
mp1Manifold point 1 (of 2).
mp2Manifold point 2 (of 2).

◆ GetForFaceA() [4/6]

static Manifold box2d::Manifold::GetForFaceA ( UnitVec2  na,
sidx_t  ia,
Length2D  pa 
)
inlinestaticnoexcept

◆ GetForFaceA() [5/6]

static Manifold box2d::Manifold::GetForFaceA ( UnitVec2  na,
sidx_t  ia,
Length2D  pa,
cf_t  tb0,
sidx_t  ib0,
Length2D  pb0 
)
inlinestaticnoexcept

◆ GetForFaceA() [6/6]

static Manifold box2d::Manifold::GetForFaceA ( UnitVec2  na,
sidx_t  ia,
Length2D  pa,
cf_t  tb0,
sidx_t  ib0,
Length2D  pb0,
cf_t  tb1,
sidx_t  ib1,
Length2D  pb1 
)
inlinestaticnoexcept

◆ GetForFaceB() [1/6]

static Manifold box2d::Manifold::GetForFaceB ( UnitVec2  ln,
Length2D  lp 
)
inlinestaticnoexcept

Gets a face B typed manifold.

Parameters
lnNormal on polygon B.
lpCenter of face B.

◆ GetForFaceB() [2/6]

static Manifold box2d::Manifold::GetForFaceB ( UnitVec2  ln,
Length2D  lp,
const Point mp1 
)
inlinestaticnoexcept

Gets a face B typed manifold.

Parameters
lnNormal on polygon B.
lpCenter of face B.
mp1Manifold point 1.

◆ GetForFaceB() [3/6]

static Manifold box2d::Manifold::GetForFaceB ( UnitVec2  ln,
Length2D  lp,
const Point mp1,
const Point mp2 
)
inlinestaticnoexcept

Gets a face B typed manifold.

Parameters
lnNormal on polygon B.
lpCenter of face B.
mp1Manifold point 1 (of 2).
mp2Manifold point 2 (of 2).

◆ GetForFaceB() [4/6]

static Manifold box2d::Manifold::GetForFaceB ( UnitVec2  nb,
sidx_t  ib,
Length2D  pb 
)
inlinestaticnoexcept

◆ GetForFaceB() [5/6]

static Manifold box2d::Manifold::GetForFaceB ( UnitVec2  nb,
sidx_t  ib,
Length2D  pb,
cf_t  ta0,
sidx_t  ia0,
Length2D  pa0 
)
inlinestaticnoexcept

◆ GetForFaceB() [6/6]

static Manifold box2d::Manifold::GetForFaceB ( UnitVec2  nb,
sidx_t  ib,
Length2D  pb,
cf_t  ta0,
sidx_t  ia0,
Length2D  pa0,
cf_t  ta1,
sidx_t  ia1,
Length2D  pa1 
)
inlinestaticnoexcept

◆ GetLocalNormal()

constexpr UnitVec2 box2d::Manifold::GetLocalNormal ( ) const
inlinenoexcept

Gets the local normal for a face-type manifold.

Returns
Local normal if the manifold type is face A or face B, else invalid value.

◆ GetLocalPoint()

constexpr Length2D box2d::Manifold::GetLocalPoint ( ) const
inlinenoexcept

Gets the local point.

This is the: local center of "circle" A for circles-type manifolds, the center of face A for face-A-type manifolds, and the center of face B for face-B-type manifolds.

Note
Value invalid for unset (e_unset) type manifolds.
Returns
Local point.

◆ GetOpposingPoint()

constexpr Length2D box2d::Manifold::GetOpposingPoint ( size_type  index) const
inlinenoexcept

◆ GetPoint()

const Point& box2d::Manifold::GetPoint ( size_type  index) const
inlinenoexcept

◆ GetPointCount()

constexpr size_type box2d::Manifold::GetPointCount ( ) const
inlinenoexcept

Gets the manifold point count.

This is the count of contact points for this manifold. Only up to this many points can be validly accessed using the GetPoint() method.

Note
Non-zero values indicate that the two shapes are touching.
Returns
Value between 0 and MaxManifoldPoints.
See also
MaxManifoldPoints.
AddPoint().
GetPoint().

◆ GetType()

constexpr Type box2d::Manifold::GetType ( ) const
inlinenoexcept

Gets the type of this manifold.

Note
This must be a constant expression in order to use it in the context of the IsValid specialized template function for it.

◆ SetContactImpulses()

void box2d::Manifold::SetContactImpulses ( size_type  index,
ContactImpulses  value 
)
inlinenoexcept

◆ SetPointImpulses()

void box2d::Manifold::SetPointImpulses ( size_type  index,
Momentum  n,
Momentum  t 
)
inline

The documentation for this class was generated from the following file: