A collision response oriented description of the intersection of two convex shapes. More...
#include <playrho/d2/Manifold.hpp>
Classes | |
struct | Conf |
Configuration data for manifold calculation. More... | |
struct | Point |
Data for a point of collision in a Manifold. More... | |
Public Types | |
using | CfIndex = ContactFeature::Index |
The contact feature index. | |
using | size_type = std::remove_const_t< decltype(MaxManifoldPoints)> |
Size type. | |
enum | Type : std::uint8_t { e_unset , e_circles , e_faceA , e_faceB } |
Manifold type. More... | |
Public Member Functions | |
Manifold ()=default | |
void | AddPoint (const Point &mp) noexcept |
constexpr ContactFeature | GetContactFeature (size_type index) const noexcept |
Gets the contact feature for the given index. More... | |
constexpr Momentum2 | GetImpulses (size_type index) const noexcept |
Gets the impulses for the given index. More... | |
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. More... | |
const Point & | GetPoint (size_type index) const noexcept |
Gets the point identified by the given index. More... | |
constexpr size_type | GetPointCount () const noexcept |
constexpr Type | GetType () const noexcept |
void | SetImpulses (size_type index, const Momentum2 &value) noexcept |
Sets the impulses for the given index. More... | |
void | SetImpulses (size_type index, Momentum n, Momentum t) noexcept |
Sets the impulses for the given index. More... | |
Static Public Member Functions | |
static Manifold | GetForCircles (const Length2 &vA, CfIndex iA, const Length2 &vB, CfIndex iB) noexcept |
static Manifold | GetForFaceA (const UnitVec &ln, const Length2 &lp, const Point &mp1) noexcept |
static Manifold | GetForFaceA (const UnitVec &ln, const Length2 &lp, const Point &mp1, const Point &mp2) noexcept |
static Manifold | GetForFaceA (const UnitVec &normalA, const Length2 &faceA) noexcept |
static Manifold | GetForFaceB (const UnitVec &ln, const Length2 &lp) noexcept |
static Manifold | GetForFaceB (const UnitVec &ln, const Length2 &lp, const Point &mp1) noexcept |
static Manifold | GetForFaceB (const UnitVec &ln, const Length2 &lp, const Point &mp1, const Point &mp2) noexcept |
Related Functions | |
(Note that these are not member functions.) | |
Manifold | CollideShapes (const DistanceProxy &shapeA, const Transformation &xfA, const DistanceProxy &shapeB, const Transformation &xfB, const Manifold::Conf &conf=GetDefaultManifoldConf()) |
Calculates the relevant collision manifold. More... | |
WorldManifold | GetWorldManifold (const Manifold &manifold, const Transformation &xfA, Length radiusA, const Transformation &xfB, Length radiusB) |
Gets the world manifold for the given data. More... | |
constexpr auto | IsValid (const d2::Manifold &value) noexcept -> bool |
Gets whether the given manifold is valid. | |
bool | operator!= (const Manifold &lhs, const Manifold &rhs) noexcept |
Manifold inequality operator. More... | |
bool | operator== (const Manifold &lhs, const Manifold &rhs) noexcept |
Manifold equality operator. 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 not defined, 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 not defined, and all other properties are invalid.
|
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.
GetType()
is not e_unset
. GetPointCount()
is less than MaxManifoldPoints
.
|
inlineconstexprnoexcept |
Gets the contact feature for the given index.
index
is less than GetPointCount()
.
|
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().
|
inlinestaticnoexcept |
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 impulses for the given index.
index
is less than GetPointCount()
.
|
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.
GetType() != e_unset
. Referenced by playrho::d2::GetPSM().
|
inlineconstexprnoexcept |
Gets the opposing point.
index
is less than GetPointCount()
. Gets the point identified by the given index.
index
is less than GetPointCount()
. 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()
function.
MaxManifoldPoints
. Referenced by GetContactFeature(), GetImpulses(), GetOpposingPoint(), GetPoint(), SetImpulses(), and playrho::GaussSeidel::SolvePositionConstraint().
|
inlineconstexprnoexcept |
Gets the type of this manifold.
IsValid
specialized template function for it. Referenced by GetLocalNormal(), GetLocalPoint(), playrho::d2::GetPSM(), and GetWorldManifold().
Sets the 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".
index
is less than GetPointCount()
. Sets the impulses for the given index.
index
is less than GetPointCount()
.
|
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.