An n-vertex convex polygon shaped part eligible for use with a Shape
.
More...
#include <playrho/d2/PolygonShapeConf.hpp>
Public Member Functions | |
PolygonShapeConf (Length hx, Length hy, const PolygonShapeConf &conf=GetDefaultConf()) | |
Initializing constructor for a 4-sided box polygon. More... | |
PolygonShapeConf (Span< const Length2 > points, const PolygonShapeConf &conf=GetDefaultConf()) | |
Creates a convex hull from the given array of local points. More... | |
UnitVec | GetNormal (VertexCounter index) const |
Span< const UnitVec > | GetNormals () const noexcept |
Gets the span of normals. | |
Length2 | GetVertex (VertexCounter index) const |
VertexCounter | GetVertexCount () const noexcept |
Span< const Length2 > | GetVertices () const noexcept |
PolygonShapeConf & | Rotate (const UnitVec &value) |
Rotates all the vertices by the given amount. | |
PolygonShapeConf & | Scale (const Vec2 &value) |
Scales all the vertices by the given amount. | |
PolygonShapeConf & | Set (const VertexSet &points) |
Sets the vertices to a convex hull of the given ones. More... | |
PolygonShapeConf & | Set (Span< const Length2 > points) |
Sets the vertices to a convex hull of the given ones. More... | |
PolygonShapeConf & | SetAsBox (Length hx, Length hy) |
Sets the vertices to represent an axis-aligned box centered on the local origin. More... | |
PolygonShapeConf & | SetAsBox (Length hx, Length hy, const Length2 ¢er, Angle angle) |
Sets the vertices for the described box. | |
PolygonShapeConf & | Transform (const Mat22 &m) |
Transforms the vertices by the given transformation matrix. More... | |
PolygonShapeConf & | Transform (const Transformation &xfm) |
Transforms the vertices by the given transformation. | |
PolygonShapeConf & | Translate (const Length2 &value) |
Translates all the vertices by the given amount. | |
PolygonShapeConf & | UseVertexRadius (NonNegative< Length > value) noexcept |
Uses the given vertex radius. | |
PolygonShapeConf & | UseVertices (const Span< const Length2 > &verts) |
Uses the given vertices. | |
Public Member Functions inherited from playrho::d2::ShapeBuilder< PolygonShapeConf > | |
constexpr PolygonShapeConf & | UseDensity (NonNegative< AreaDensity > value) noexcept |
Uses the given density. | |
constexpr PolygonShapeConf & | UseFilter (Filter value) noexcept |
Uses the given filter. | |
constexpr PolygonShapeConf & | UseFriction (NonNegative< Real > value) noexcept |
Uses the given friction. | |
constexpr PolygonShapeConf & | UseIsSensor (bool value) noexcept |
Uses the given is-sensor value. | |
constexpr PolygonShapeConf & | UseRestitution (Finite< Real > value) noexcept |
Uses the given restitution. | |
Static Public Member Functions | |
static PolygonShapeConf | GetDefaultConf () noexcept |
Gets the default configuration for a PolygonShapeConf . | |
static constexpr NonNegative< Length > | GetDefaultVertexRadius () noexcept |
Gets the default vertex radius for the PolygonShapeConf . More... | |
Public Attributes | |
NgonWithFwdNormals | ngon |
N-gon data. | |
NonNegativeFF< Length > | vertexRadius = GetDefaultVertexRadius() |
Vertex radius. More... | |
Public Attributes inherited from playrho::d2::BaseShapeConf | |
NonNegative< AreaDensity > | density = DefaultDensity |
Area density of the associated shape. More... | |
Filter | filter = DefaultFilter |
Filtering data for contacts. | |
NonNegative< Real > | friction = DefaultFriction |
Friction coefficient. More... | |
bool | isSensor = DefaultIsSensor |
A sensor shape collects contact information but never generates a collision response. | |
Finite< Real > | restitution = DefaultRestitution |
Restitution (elasticity) of the associated shape. More... | |
Static Public Attributes | |
static constexpr auto | DefaultVertexRadius = NonNegative<Length>{DefaultLinearSlop * 2} |
Default vertex radius. | |
Static Public Attributes inherited from playrho::d2::BaseShapeConf | |
static constexpr auto | DefaultDensity = NonNegative<AreaDensity>{0_kgpm2} |
Default density value. | |
static constexpr auto | DefaultFilter = Filter{} |
Default filter value. | |
static constexpr auto | DefaultFriction = NonNegative<Real>{Real{2} / Real{10}} |
Default friction value. | |
static constexpr auto | DefaultIsSensor = false |
Default is-sensor value. | |
static const auto | DefaultRestitution = Finite<Real>{} |
Default restitution value. | |
Friends | |
bool | operator!= (const PolygonShapeConf &lhs, const PolygonShapeConf &rhs) noexcept |
Inequality operator. | |
bool | operator== (const PolygonShapeConf &lhs, const PolygonShapeConf &rhs) noexcept |
Equality operator. | |
Related Functions | |
(Note that these are not member functions.) | |
DistanceProxy | GetChild (const PolygonShapeConf &arg, ChildCounter index) |
Gets the "child" shape for the given shape configuration. | |
constexpr ChildCounter | GetChildCount (const PolygonShapeConf &) noexcept |
Gets the "child" count for the given shape configuration. More... | |
MassData | GetMassData (const PolygonShapeConf &arg) |
Gets the mass data for the given shape configuration. | |
NonNegative< Length > | GetVertexRadius (const PolygonShapeConf &arg) noexcept |
Gets the vertex radius of the given shape configuration. | |
NonNegative< Length > | GetVertexRadius (const PolygonShapeConf &arg, ChildCounter) noexcept |
Gets the vertex radius of the given shape configuration. | |
void | Transform (PolygonShapeConf &arg, const Mat22 &m) |
Transforms the given polygon configuration's vertices by the given transformation matrix. More... | |
Related Functions inherited from playrho::d2::BaseShapeConf | |
constexpr NonNegative< AreaDensity > | GetDensity (const BaseShapeConf &arg) noexcept |
Gets the density of the given shape configuration. | |
constexpr Filter | GetFilter (const BaseShapeConf &arg) noexcept |
Gets the filter of the given shape configuration. | |
constexpr NonNegativeFF< Real > | GetFriction (const BaseShapeConf &arg) noexcept |
Gets the friction of the given shape. | |
constexpr Finite< Real > | GetRestitution (const BaseShapeConf &arg) noexcept |
Gets the restitution of the given shape. | |
constexpr bool | IsSensor (const BaseShapeConf &arg) noexcept |
Gets the is-sensor state of the given shape configuration. | |
void | SetDensity (BaseShapeConf &arg, NonNegative< AreaDensity > value) |
Sets the density of the given shape configuration. | |
void | SetFilter (BaseShapeConf &arg, Filter value) |
Sets the filter of the given shape configuration. | |
void | SetFriction (BaseShapeConf &arg, NonNegative< Real > value) |
Sets the friction of the given shape. | |
void | SetRestitution (BaseShapeConf &arg, Real value) noexcept |
Sets the restitution of the given shape. | |
void | SetSensor (BaseShapeConf &arg, bool value) |
Sets the is-sensor state of the given shape configuration. | |
An n-vertex convex polygon shaped part eligible for use with a Shape
.
MaxShapeVertices
. If all you want is a rectangular part (that will only ever have 4-vertices) you may want to consider using a rectangular playrho::d2::part::Compositor
instead. playrho::d2::PolygonShapeConf::PolygonShapeConf | ( | Length | hx, |
Length | hy, | ||
const PolygonShapeConf & | conf = GetDefaultConf() |
||
) |
Initializing constructor for a 4-sided box polygon.
hx | Half of the width. |
hy | Half of the height. |
conf | Additional configuration information. |
|
explicit |
Creates a convex hull from the given array of local points.
MaxShapeVertices
].
|
inlinestaticconstexprnoexcept |
Gets the default vertex radius for the PolygonShapeConf
.
DefaultVertexRadius
directly. DefaultVertexRadius
.
|
inline |
Gets a normal by index.
These are 90-degree clockwise-rotated (outward-facing) unit-vectors of the edges defined by consecutive pairs of vertices starting with vertex 0.
index | Index of the normal to get. |
|
inline |
Gets a vertex by index.
Vertices go counter-clockwise.
|
inlinenoexcept |
Gets the vertex count.
MaxShapeVertices
inclusive. Referenced by GetChild(), GetNormal(), and GetVertex().
Gets the span of vertices.
Vertices go counter-clockwise.
Referenced by GetChild(), and GetMassData().
PolygonShapeConf & playrho::d2::PolygonShapeConf::Set | ( | const VertexSet & | points | ) |
Sets the vertices to a convex hull of the given ones.
MaxShapeVertices
]. PolygonShapeConf & playrho::d2::PolygonShapeConf::Set | ( | Span< const Length2 > | points | ) |
Sets the vertices to a convex hull of the given ones.
MaxShapeVertices
]. Referenced by PolygonShapeConf(), Rotate(), Scale(), Transform(), Translate(), and UseVertices().
PolygonShapeConf & playrho::d2::PolygonShapeConf::SetAsBox | ( | Length | hx, |
Length | hy | ||
) |
Sets the vertices to represent an axis-aligned box centered on the local origin.
hx | the half-width. |
hy | the half-height. |
Referenced by SetAsBox().
PolygonShapeConf & playrho::d2::PolygonShapeConf::Transform | ( | const Mat22 & | m | ) |
Transforms the vertices by the given transformation matrix.
|
related |
Gets the "child" count for the given shape configuration.
|
related |
Transforms the given polygon configuration's vertices by the given transformation matrix.
Referenced by playrho::d2::GetManifold().
NonNegativeFF<Length> playrho::d2::PolygonShapeConf::vertexRadius = GetDefaultVertexRadius() |
Vertex radius.
This is the radius from the vertex that the shape's "skin" should extend outward by. While any edges — line segments between multiple vertices — are straight, corners between them (the vertices) are rounded and treated as rounded. Shapes with larger vertex radiuses compared to edge lengths therefore will be more prone to rolling or having other shapes more prone to roll off of them.
Referenced by GetChild(), and GetMassData().