A collision response oriented description of the intersection of two convex shapes. More...
#include <Manifold.hpp>
Classes | |
struct | Conf |
Configuration data for manifold calculation. More... | |
struct | Point |
Data for a point of collision in a Manifold. More... | |
struct | PointArray |
Point array structure. 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 |
Size type. | |
using | CfIndex = ContactFeature::Index |
Contact feature index. | |
using | CfType = ContactFeature::Type |
Contact feature type. | |
Public Member Functions | |
Manifold ()=default | |
Default constructor. More... | |
Manifold (const Manifold ©)=default | |
Copy constructor. | |
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 |
Gets the contact feature for the given index. | |
constexpr Momentum2 | GetContactImpulses (size_type index) const noexcept |
Gets the contact impulses for the given index. More... | |
void | SetContactImpulses (size_type index, Momentum2 value) noexcept |
Sets the contact impulses for the given index. More... | |
const Point & | GetPoint (size_type index) const noexcept |
Gets the point identified by the given index. | |
void | SetPointImpulses (size_type index, Momentum n, Momentum t) |
Sets the point impulses for the given index. | |
void | AddPoint (const Point &mp) noexcept |
Adds a new point. More... | |
void | AddPoint (CfType type, CfIndex index, Length2 point) noexcept |
Adds a new point with the given data. | |
constexpr UnitVec | GetLocalNormal () const noexcept |
Gets the local normal for a face-type manifold. More... | |
constexpr Length2 | GetLocalPoint () const noexcept |
Gets the local point. More... | |
constexpr Length2 | GetOpposingPoint (size_type index) const noexcept |
Gets the opposing point. | |
Static Public Member Functions | |
static Manifold | GetForCircles (Length2 vA, CfIndex iA, Length2 vB, CfIndex iB) noexcept |
Gets a circles-typed manifold with one point. More... | |
static Manifold | GetForFaceA (UnitVec normalA, Length2 faceA) noexcept |
Gets a face A typed manifold. More... | |
static Manifold | GetForFaceA (UnitVec ln, Length2 lp, const Point &mp1) noexcept |
Gets a face A typed manifold. More... | |
static Manifold | GetForFaceA (UnitVec ln, Length2 lp, const Point &mp1, const Point &mp2) noexcept |
Gets a face A typed manifold. More... | |
static Manifold | GetForFaceB (UnitVec ln, Length2 lp) noexcept |
Gets a face B typed manifold. More... | |
static Manifold | GetForFaceB (UnitVec ln, Length2 lp, const Point &mp1) noexcept |
Gets a face B typed manifold. More... | |
static Manifold | GetForFaceB (UnitVec ln, Length2 lp, const Point &mp1, const Point &mp2) noexcept |
Gets a face B typed manifold. More... | |
static Manifold | GetForFaceA (UnitVec na, CfIndex ia, Length2 pa) noexcept |
Gets the face A manifold for the given data. | |
static Manifold | GetForFaceB (UnitVec nb, CfIndex ib, Length2 pb) noexcept |
Gets the face B manifold for the given data. | |
static Manifold | GetForFaceA (UnitVec na, CfIndex ia, Length2 pa, CfType tb0, CfIndex ib0, Length2 pb0) noexcept |
Gets the face A manifold for the given data. | |
static Manifold | GetForFaceB (UnitVec nb, CfIndex ib, Length2 pb, CfType ta0, CfIndex ia0, Length2 pa0) noexcept |
Gets the face B manifold for the given data. | |
static Manifold | GetForFaceA (UnitVec na, CfIndex ia, Length2 pa, CfType tb0, CfIndex ib0, Length2 pb0, CfType tb1, CfIndex ib1, Length2 pb1) noexcept |
Gets the face A manifold for the given data. | |
static Manifold | GetForFaceB (UnitVec nb, CfIndex ib, Length2 pb, CfType ta0, CfIndex ia0, Length2 pa0, CfType ta1, CfIndex ia1, Length2 pa1) noexcept |
Gets the face B manifold for the given data. | |
Private Member Functions | |
constexpr | Manifold (Type t, UnitVec ln, Length2 lp, size_type n, const PointArray &mpa) noexcept |
Constructs manifold with array of points using the given values. More... | |
Private Attributes | |
Type | m_type = e_unset |
Type of collision this manifold is associated with (1-byte). | |
size_type | m_pointCount = 0 |
Number of defined manifold points (1-byte). | |
UnitVec | m_localNormal = GetInvalid<decltype(m_localNormal)>() |
Local normal. More... | |
Length2 | m_localPoint = GetInvalid<Length2>() |
Local point. More... | |
PointArray | m_points |
Points of contact (at least 40-bytes). More... | |
Related Functions | |
(Note that these are not member functions.) | |
bool | operator== (const Manifold &lhs, const Manifold &rhs) noexcept |
Manifold equality operator. More... | |
bool | operator!= (const Manifold &lhs, const Manifold &rhs) noexcept |
Manifold inequality operator. More... | |
Manifold | CollideShapes (const DistanceProxy &shapeA, const Transformation &xfA, const DistanceProxy &shapeB, const Transformation &xfB, Manifold::Conf conf=GetDefaultManifoldConf()) |
Calculates the relevant collision manifold. More... | |
template<> | |
constexpr bool | IsValid (const d2::Manifold &value) noexcept |
Gets whether the given manifold is valid. | |
WorldManifold | GetWorldManifold (const Manifold &manifold, Transformation xfA, Length radiusA, Transformation xfB, Length radiusB) |
Gets the world manifold for the given data. More... | |
A collision response oriented description of the intersection of 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 occurring. 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.
Conceptually, a manifold represents the intersection of two convex sets (which is itself a convex set) and a solution for moving the sets away from each other to eliminate the intersection.
enum playrho::d2::Manifold::Type : std::uint8_t |
Manifold 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.
|
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 circle B or a clip point of polygon B where the contact feature will be |
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 circle A or a clip point of polygon A where the contact feature will be |
|
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.
|
constexprprivatenoexcept |
|
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.
|
inlineconstexprnoexcept |
Gets the contact impulses for the given index.
|
inlinestaticnoexcept |
Gets a circles-typed manifold with one point.
vA | Local center of "circle" A. |
iA | Index of vertex from shape A representing the local center of "circle" A. |
vB | Local center of "circle" B. |
iB | Index of vertex from shape B representing the local center of "circle" B. |
Referenced by playrho::d2::GetManifold().
|
inlinestaticnoexcept |
Gets a face A typed manifold.
ln | Normal on polygon A. |
lp | Center of face A. |
mp1 | Manifold point 1 (of 1). |
|
inlinestaticnoexcept |
Gets a face A typed manifold.
normalA | Local normal of the face from polygon A. |
faceA | Any point in local coordinates on the face whose normal was provided. |
Referenced by playrho::d2::GetManifold().
Gets a face B typed manifold.
ln | Normal on polygon B. |
lp | Center of face B. |
Referenced by playrho::d2::GetManifold().
|
inlinestaticnoexcept |
Gets a face B typed manifold.
ln | Normal on polygon B. |
lp | Center of face B. |
mp1 | Manifold point 1. |
|
inlineconstexprnoexcept |
Gets the local normal for a face-type manifold.
Referenced by playrho::d2::GetPSM().
|
inlineconstexprnoexcept |
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; or the center of face B for face-B-type manifolds.
Referenced by playrho::d2::GetPSM().
|
inlineconstexprnoexcept |
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.
MaxManifoldPoints
.
|
inlineconstexprnoexcept |
Gets the type of this manifold.
IsValid
specialized template function for it. Referenced by playrho::d2::GetPSM(), playrho::d2::GetWorldManifold(), and playrho::IsValid().
Sets the contact impulses for the given index.
Sets the contact impulses for the given index where the first impulse is the "normal impulse" and the second impulse is the "tangent impulse".
|
related |
Calculates the relevant collision manifold.
TestOverlap
function. This is not always the case however especially when the separation or overlap distance is closer to zero.
|
related |
Gets the world manifold for the given data.
manifold | Manifold to use. Uses the manifold's type, local point, local normal, point-count, and the indexed-points' local point data. |
xfA | Transformation A. |
radiusA | Radius of shape A. |
xfB | Transformation B. |
radiusB | Radius of shape B. |
Manifold inequality operator.
Determines whether the two given manifolds are not equal.
Manifold equality operator.
|
private |
Local normal.
Exact usage depends on manifold type (8-bytes).
Referenced by GetLocalNormal().
|
private |
Local point.
Exact usage depends on manifold type (8-bytes).
Referenced by GetLocalPoint().
|
private |
Points of contact (at least 40-bytes).
Referenced by GetContactFeature(), GetContactImpulses(), GetOpposingPoint(), GetPoint(), SetContactImpulses(), and SetPointImpulses().