#include <playrho/d2/Shape.hpp>
Public Member Functions | |
Shape () noexcept=default | |
Default constructor. More... | |
Shape (const Shape &other) | |
Copy constructor. | |
Shape (Shape &&other) noexcept=default | |
Move constructor. | |
template<typename T , typename Tp = DecayedTypeIfNotSame<T, Shape>, typename = std::enable_if_t<std::is_constructible_v<Tp, T>>> | |
Shape (T &&arg) | |
Initializing constructor for alternative types. More... | |
bool | has_value () const noexcept |
Checks whether this instance contains a value. | |
Shape & | operator= (const Shape &other) |
Copy assignment. | |
Shape & | operator= (Shape &&other)=default |
Move assignment operator. | |
template<typename T , typename Tp = DecayedTypeIfNotSame<T, Shape>, typename = std::enable_if_t<std::is_constructible_v<Tp, T>>> | |
Shape & | operator= (T &&arg) |
Move assignment operator for alternative types. More... | |
void | swap (Shape &other) noexcept |
Swap support. | |
Static Public Attributes | |
static constexpr auto | DefaultDensity = NonNegative<AreaDensity>{0_kgpm2} |
Default density of a default-constructed, or otherwise value-less, shape. | |
Friends | |
DistanceProxy | GetChild (const Shape &shape, ChildCounter index) |
Gets the "child" for the given index. More... | |
ChildCounter | GetChildCount (const Shape &shape) noexcept |
Gets the number of child primitives of the shape. More... | |
const void * | GetData (const Shape &shape) noexcept |
Gets a pointer to the underlying data. More... | |
NonNegative< AreaDensity > | GetDensity (const Shape &shape) noexcept |
Gets the density of the given shape. More... | |
Filter | GetFilter (const Shape &shape) noexcept |
Gets the filter value for the given shape. More... | |
NonNegativeFF< Real > | GetFriction (const Shape &shape) noexcept |
Gets the coefficient of friction. More... | |
MassData | GetMassData (const Shape &shape) |
Gets the mass properties of this shape using its dimensions and density. More... | |
Real | GetRestitution (const Shape &shape) noexcept |
Gets the coefficient of restitution value of the given shape. More... | |
TypeID | GetType (const Shape &shape) noexcept |
Gets the type info of the use of the given shape. More... | |
NonNegative< Length > | GetVertexRadius (const Shape &shape, ChildCounter idx) |
Gets the vertex radius of the indexed child of the given shape. More... | |
bool | IsSensor (const Shape &shape) noexcept |
Gets whether or not the given shape is a sensor. More... | |
bool | operator!= (const Shape &lhs, const Shape &rhs) noexcept |
Inequality operator for shape to shape comparisons. | |
bool | operator== (const Shape &lhs, const Shape &rhs) noexcept |
Equality operator for shape to shape comparisons. | |
void | Rotate (Shape &shape, const UnitVec &value) |
Rotates all of the given shape's vertices by the given amount. More... | |
void | Scale (Shape &shape, const Vec2 &value) |
Scales all of the given shape's vertices by the given amount. More... | |
void | SetDensity (Shape &shape, NonNegative< AreaDensity > value) |
Sets the density of the given shape. More... | |
void | SetFilter (Shape &shape, Filter value) |
Sets the filter value for the given shape. More... | |
void | SetFriction (Shape &shape, NonNegative< Real > value) |
Sets the coefficient of friction. More... | |
void | SetRestitution (Shape &shape, Real value) |
Sets the coefficient of restitution value of the given shape. More... | |
void | SetSensor (Shape &shape, bool value) |
Sets whether or not the given shape is a sensor. More... | |
void | SetVertexRadius (Shape &shape, ChildCounter idx, NonNegative< Length > value) |
Sets the vertex radius of the indexed child of the given shape. More... | |
void | Translate (Shape &shape, const Length2 &value) |
Translates all of the given shape's vertices by the given amount. More... | |
template<typename T > | |
std::add_pointer_t< std::add_const_t< T > > | TypeCast (const Shape *value) noexcept |
Converts the given shape into its current configuration value. More... | |
Related Functions | |
(Note that these are not member functions.) | |
AABB | ComputeAABB (const Shape &shape, const Transformation &xf) |
Computes the AABB for the given shape with the given transformation. | |
NonNegativeFF< Real > | GetDefaultFriction (const Shape &a, const Shape &b) |
Gets the default friction amount for the given shapes. | |
Real | GetDefaultRestitution (const Shape &a, const Shape &b) |
Gets the default restitution amount for the given shapes. | |
VertexCounter | GetVertexCount (const Shape &shape, ChildCounter index) |
Gets the vertex count for the specified child of the given shape. | |
auto | IsDestroyed (const Shape &value) noexcept -> bool |
Gets whether the given entity is in the is-destroyed state. | |
RayCastOutput | RayCast (const Shape &shape, ChildCounter childIndex, const RayCastInput &input, const Transformation &transform) noexcept |
Cast a ray against the child of the given shape. More... | |
bool | ShouldCollide (const Shape &a, const Shape &b) noexcept |
Whether contact calculations should be performed between the two instances. More... | |
bool | TestPoint (const Shape &shape, const Length2 &point) noexcept |
Test a point for containment in the given shape. More... | |
template<typename T > | |
T | TypeCast (const Shape &value) |
Casts the specified instance into the template specified type. More... | |
A shape is used for collision detection. You can create a shape from any supporting type. Shapes are conceptually made up of zero or more convex child shapes where each child shape is made up of zero or more vertices and an associated radius called its "vertex radius" or "skin".
T
satisfies the requirement that IsValidShapeTypeV<T> == true
.
|
defaultnoexcept |
|
inlineexplicit |
Initializing constructor for alternative types.
arg | Value to construct a shape instance for. |
T
for its values to be fully valid candidates for this function. IsValidShapeType
trait is intentionally not used to eliminate this function from resolution so that the compiler may offer insight into exactly which requirements are not met by the given type. has_value()
returns true. std::bad_alloc | if there's a failure allocating storage. |
|
inline |
Move assignment operator for alternative types.
T
for its values to be fully valid candidates for this function. IsValidShapeType
trait is intentionally not used to eliminate this function from resolution so that the compiler may offer insight into exactly which requirements are not met by the given type. has_value()
returns true.
|
friend |
Gets the "child" for the given index.
shape | Shape to get "child" shape of. |
index | Index to a child element of the shape. Value must be less than the number of child primitives of the shape. |
InvalidArgument | if the given index is out of range. |
|
friend |
Gets the number of child primitives of the shape.
|
friend |
Gets a pointer to the underlying data.
|
friend |
Gets the density of the given shape.
Gets the filter value for the given shape.
|
friend |
Gets the coefficient of friction.
Gets the mass properties of this shape using its dimensions and density.
Gets the coefficient of restitution value of the given shape.
Gets the type info of the use of the given shape.
GetTypeID<Shape>()
.
|
friend |
Gets the vertex radius of the indexed child of the given shape.
This gets 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. Here's an image of a shape configured via a PolygonShapeConf
with it's skin drawn:
shape | Shape to get child's vertex radius for. |
idx | Child index to get vertex radius for. |
InvalidArgument | if the child index is not less than the child count. |
|
friend |
Gets whether or not the given shape is a sensor.
Rotates all of the given shape's vertices by the given amount.
std::bad_alloc
or any exception that's thrown by the constructor for the model's underlying data type. std::bad_alloc | if there's a failure allocating storage. |
Scales all of the given shape's vertices by the given amount.
std::bad_alloc
or any exception that's thrown by the constructor for the model's underlying data type. std::bad_alloc | if there's a failure allocating storage. |
|
friend |
Sets the density of the given shape.
Sets the filter value for the given shape.
|
friend |
Sets the coefficient of friction.
Sets the coefficient of restitution value of the given shape.
|
friend |
Sets whether or not the given shape is a sensor.
|
friend |
Sets the vertex radius of the indexed child of the given shape.
InvalidArgument | if the vertex radius cannot be set to the specified value. |
Whether contact calculations should be performed between the two instances.
true
if contact calculations should be performed between these two instances; false
otherwise. Translates all of the given shape's vertices by the given amount.
std::bad_alloc
or any exception that's thrown by the constructor for the model's underlying data type. std::bad_alloc | if there's a failure allocating storage. |
|
related |
Casts the specified instance into the template specified type.
std::bad_cast | If the template specified type is not the type of data underlying the given instance. |
|
friend |
Converts the given shape into its current configuration value.
std::any
class and its associated std::any_cast
function. The code for this is based off of the std::any
code from the LLVM Project.