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

Distance Proxy. More...

#include <DistanceProxy.hpp>

Public Types

using size_type = std::remove_const< decltype(MaxShapeVertices)>::type
 Size type. More...
 

Public Member Functions

 DistanceProxy ()=default
 
constexpr DistanceProxy (const DistanceProxy &copy) noexcept
 
constexpr DistanceProxy (const Length vertexRadius, const size_type count, const Length2D *vertices, const UnitVec2 *normals) noexcept
 Initializing constructor. More...
 
auto GetVertexRadius () const noexcept
 Gets the vertexRadius of the vertices of the associated shape. More...
 
auto GetVertexCount () const noexcept
 Gets the vertex count. More...
 
auto GetVertex (size_type index) const noexcept
 Gets a vertex by index. More...
 
auto GetNormal (size_type index) const noexcept
 
Span< const Length2DGetVertices () const noexcept
 
Span< const UnitVec2GetNormals () const noexcept
 

Static Public Attributes

static constexpr size_type InvalidIndex = static_cast<size_type>(-1)
 

Detailed Description

Distance Proxy.

A distance proxy aggragates a convex set of vertices and a vertexRadius of those vertices. This can be visualized as a convex N-gon with rounded corners. It's meant to represent any single portion of a shape identified by its child-index. These are used by the GJK algorithm: "a method for determining the minimium distance between two convex sets".

Note
This data structure is 24-bytes.
See also
https://en.wikipedia.org/wiki/Gilbert%2DJohnson%2DKeerthi_distance_algorithm

Member Typedef Documentation

◆ size_type

using box2d::DistanceProxy::size_type = std::remove_const<decltype(MaxShapeVertices)>::type

Size type.

Must be big enough to hold max posible count of vertices.

Constructor & Destructor Documentation

◆ DistanceProxy() [1/3]

box2d::DistanceProxy::DistanceProxy ( )
default

◆ DistanceProxy() [2/3]

constexpr box2d::DistanceProxy::DistanceProxy ( const DistanceProxy copy)
inlinenoexcept

◆ DistanceProxy() [3/3]

constexpr box2d::DistanceProxy::DistanceProxy ( const Length  vertexRadius,
const size_type  count,
const Length2D vertices,
const UnitVec2 normals 
)
inlinenoexcept

Initializing constructor.

Constructs a distance proxy for n-point shape (like a polygon).

Parameters
vertexRadiusRadius of the given vertices.
countCount of elements of the vertices and normals arrays.
verticesCollection of vertices of the shape (relative to the shape's origin).
normalsCollection of normals of the shape.
Note
The vertices collection must have more than zero elements and no more than MaxShapeVertices elements.
Warning
Behavior is undefined if the vertices collection has less than one element or more than MaxShapeVertices elements.

Member Function Documentation

◆ GetNormal()

auto box2d::DistanceProxy::GetNormal ( size_type  index) const
inlinenoexcept

◆ GetNormals()

Span<const UnitVec2> box2d::DistanceProxy::GetNormals ( ) const
inlinenoexcept

◆ GetVertex()

auto box2d::DistanceProxy::GetVertex ( size_type  index) const
inlinenoexcept

Gets a vertex by index.

Parameters
indexIndex value less than the count of vertices represented by this proxy.
Note
Behavior is undefined if the index given is not less than the count of vertices represented by this proxy.
Behavior is undefined if InvalidIndex is given as the index value.
Returns
2D vector position (relative to the shape's origin) at the given index.
See also
Distance.

◆ GetVertexCount()

auto box2d::DistanceProxy::GetVertexCount ( ) const
inlinenoexcept

Gets the vertex count.

This is the count of valid vertex elements that this object provides.

Returns
Value between 0 and MaxShapeVertices.
Note
This only returns 0 if this proxy was default constructed.

◆ GetVertexRadius()

auto box2d::DistanceProxy::GetVertexRadius ( ) const
inlinenoexcept

Gets the vertexRadius of the vertices of the associated shape.

Returns
Non-negative distance.

◆ GetVertices()

Span<const Length2D> box2d::DistanceProxy::GetVertices ( ) const
inlinenoexcept

Member Data Documentation

◆ InvalidIndex

constexpr size_type box2d::DistanceProxy::InvalidIndex = static_cast<size_type>(-1)
static

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