4#ifndef GREM_PHYSICS_SHAPE_HPP
5#define GREM_PHYSICS_SHAPE_HPP
47 : index(
static_cast<uint8_t
>(index)) {}
54 constexpr explicit operator size_t() const noexcept {
55 return static_cast<size_t>(index);
97 : bits(uint32_t{1} <<
static_cast<size_t>(layer)) {}
113 [[nodiscard]]
constexpr bool empty() const noexcept {
137 return (bits & layers.bits) != 0;
149 return (bits & layers.bits) == layers.bits;
298 [[nodiscard]]
constexpr explicit operator bool() const noexcept {
365 const bool detectsCollision = wantsDetectionA && wantsDetectionB;
366 const bool respondsToCollision = wantsResponseA && wantsResponseB;
372 return {.passed = passed};
424 template <
typename T>
429 .maxDistance = Distance::reinterpret(ray.maxDistance),
430 .directionInverse = ray.directionInverse,
467 template <
typename OtherUnitT>
480template <
size_t N,
typename T>
485template <
size_t N,
typename T>
494 using Unit =
typename Distance::Unit;
521 template <
typename OtherUnitT>
557 template <
typename T>
561 .distance = Distance::reinterpret(hit.distance),
577 template <
typename OtherUnitT>
585template <
size_t N,
typename T>
590template <
size_t N,
typename T>
602 using Unit =
typename Distance::Unit;
616 template <
typename T>
630 template <
typename OtherUnitT>
638template <
size_t N,
typename T>
643template <
size_t N,
typename T>
670 template <
typename T>
696 template <
typename OtherUnitT>
705template <
size_t N,
typename T>
710template <
size_t N,
typename T>
766 template <
typename T>
782 template <
typename OtherUnitT>
799template <
size_t N,
typename T>
804template <
size_t N,
typename T>
828 template <
typename T>
843 template <
typename OtherUnitT>
923 return {.min =
min - expansion, .max =
max + expansion};
942template <
size_t N,
typename T>
947template <
size_t N,
typename T>
971 template <
typename T>
986 template <
typename OtherUnitT>
1059template <
size_t N,
typename T>
1064template <
size_t N,
typename T>
1088 template <
typename T>
1109 template <
typename OtherUnitT>
1172template <
size_t N,
typename T>
1177template <
size_t N,
typename T>
1186 const Basis<N> basis = transformation.getBasis();
1187 Box<N> result{.min = transformation.getOrigin(), .max = transformation.getOrigin()};
1190 const Length1D a = basis[y][x] * -halfExtents[y];
1191 const Length1D b = basis[y][x] * halfExtents[y];
1192 result.
min[x] +=
min(a, b);
1193 result.
max[x] +=
max(a, b);
1217 return detail::getTransformedBoundingBox<N>(
Transformation<N>{transformation(localCenterOffset), transformation.
getBasis()}, halfExtents);
1226template <
typename T,
size_t N>
1242template <
typename T>
1250template <
typename T>
1259template <
typename T,
size_t N>
1270template <
typename T>
1278template <
typename T>
1287template <
typename T,
size_t N>
1300 { t.getFirstVertexIndexOfEdge(edgeIndex) } -> convertible_to<ConvexPolytopeVertexIndex>;
1301 { t.getFaceIndexOfEdge(edgeIndex) } -> convertible_to<ConvexPolytopeFaceIndex>;
1302 { t.getNextEdgeIndex(edgeIndex) } -> convertible_to<ConvexPolytopeEdgeIndex>;
1303 { t.getFirstEdgeIndexOfFace(faceIndex) } -> convertible_to<ConvexPolytopeEdgeIndex>;
1304 { t.getSomeEdgeIndexOfVertex(vertexIndex) } -> convertible_to<ConvexPolytopeEdgeIndex>;
1312template <
typename T>
1320template <
typename T>
1348 callback(
shape.getFirstVertexIndexOfEdge(edgeIndex));
1349 edgeIndex =
shape.getNextEdgeIndex(edgeIndex);
1350 }
while (edgeIndex != firstEdgeIndex);
1380 callback(
shape.getFaceIndexOfEdge(edgeIndex));
1382 }
while (edgeIndex != firstEdgeIndex);
1416 callback(twinVertexIndex);
1417 edgeIndex =
shape.getNextEdgeIndex(twinEdgeIndex);
1418 }
while (edgeIndex != firstEdgeIndex);
1459 (void)localRayOrigin;
1460 (void)localRayDirection;
1461 (void)maxLocalRayDistance;
1473 (void)localDirection;
1477extern template struct PointShape<2>;
1478extern template struct PointShape<3>;
1511 return Box<N>{.min = transformation.
getOrigin() -
min(halfVectorA, halfVectorB), .max = transformation.
getOrigin() +
max(halfVectorA, halfVectorB)};
1528 (void)localRayOrigin;
1529 (void)localRayDirection;
1530 (void)maxLocalRayDistance;
1544 return (localDirection.getY() >= 0) ? halfLineVector : -halfLineVector;
1547extern template struct LineSegmentShape<2>;
1548extern template struct LineSegmentShape<3>;
1574 (void)transformation;
1593 (void)localRayOrigin;
1594 (void)localRayDirection;
1595 (void)maxLocalRayDistance;
1607 return Y_AXIS<N> * ((localDirection.getY() >= 0) ? Distance::MAX : Distance::MIN);
1610extern template struct InfiniteLineShape<2>;
1611extern template struct InfiniteLineShape<3>;
1637 (void)transformation;
1682 (void)transformation;
1722 return detail::getTransformedBoundingBox<N>(transformation,
halfExtents);
1755 if constexpr (N == 2) {
1764 if constexpr (N == 2) {
1868 if constexpr (N == 2) {
1877 if constexpr (N == 2) {
1935extern template struct CubeShape<2>;
1936extern template struct CubeShape<3>;
2065 const Box<N> boxA{.min = pointA -
Length<N>{maxTransformedRadius}, .max = pointA +
Length<N>{maxTransformedRadius}};
2066 const Box<N> boxB{.min = pointB -
Length<N>{maxTransformedRadius}, .max = pointB +
Length<N>{maxTransformedRadius}};
2214 return BoxShape3D{.halfExtents{maxRadius,
halfLength, maxRadius}}.getBoundingBox(transformation);
2259 : polytope(std::move(polytope)) {
2329 if constexpr (N == 3) {
2391 : mesh(std::move(mesh)) {
2534 : subColliders(std::move(subColliders))
2536 , boundingRadius(calculateCompoundBoundingRadius(
getSubColliders())) {
2576 if (!boundingRadius) {
2621 return match(*
this)([&](
const convex_shape_2d auto&) ->
bool {
return true; }, [&](
const auto&) ->
bool {
return false; });
2639 [[nodiscard]]
Volume calculateVolume()
const;
2708 :
Variant<PointShape3D, LineSegmentShape3D, InfiniteLineShape3D, InfiniteHalfSpaceShape3D, InfinitePlaneShape3D, BoxShape3D, CubeShape3D, EllipsoidShape3D, SphereShape3D,
2709 CapsuleShape3D, TaperedCapsuleShape3D, CylinderShape3D, TaperedCylinderShape3D, ConvexPolytopeShape3D, TriangleMeshShape3D, LocallyTransformedShape3D,
2710 CompoundColliderShape3D> {
2722 return match(*
this)([&](
const convex_shape_3d auto&) ->
bool {
return true; }, [&](
const auto&) ->
bool {
return false; });
2740 [[nodiscard]]
Volume calculateVolume()
const;
2847 template <
typename T>
2849 : shapeData(
match(
shape)([](const auto& s) -> const void* {
return &s; }))
2850 , shapeTypeIndex(
shape.index()) {}
2858 template <
typename T>
2879 return shapeTypeIndex;
2902 template <
typename T>
2931 template <
typename T>
2934 return *
static_cast<const T*
>(shapeData);
2951 template <
typename T>
2973 template <
typename T>
3063 const
void* shapeData;
3088template <typename Visitor,
size_t N>
3098 return ShapeView2D{*
this}.calculatePrincipalMomentsOfInertia(mass);
3102 return ShapeView2D{*
this}.getBoundingBox(transformation);
3106 return ShapeView2D{*
this}.getBoundingRadius(basis);
3110 return ShapeView2D{*
this}.getReferenceArea(basis, direction);
3114 return ShapeView2D{*
this}.castLocalRay(localRayOrigin, localRayDirection, maxLocalRayDistance);
3122 return ShapeView3D{*
this}.calculatePrincipalMomentsOfInertia(mass);
3126 return ShapeView3D{*
this}.getBoundingBox(transformation);
3130 return ShapeView3D{*
this}.getBoundingRadius(basis);
3134 return ShapeView3D{*
this}.getReferenceArea(basis, direction);
3138 return ShapeView3D{*
this}.castLocalRay(localRayOrigin, localRayDirection, maxLocalRayDistance);
3158 template <
typename T>
3168 template <
typename T>
3231 template <
typename T>
3241 template <
typename T>
3457 :
shape(collider.shape)
3458 ,
filter(collider.filter) {}
3471extern template struct ColliderView<2>;
3472extern template struct ColliderView<3>;
3479struct TriangleShape {
3494 const Position<N> transformedPointA = transformation(pointA);
3495 const Position<N> transformedPointB = transformation(pointB);
3496 const Position<N> transformedPointC = transformation(pointC);
3497 return {.min =
min(
min(transformedPointA, transformedPointB), transformedPointC), .max =
max(
max(transformedPointA, transformedPointB), transformedPointC)};
3501 const Length<N> offsetA = basis * pointA;
3502 const Length<N> offsetB = basis * pointB;
3503 const Length<N> offsetC = basis * pointC;
3508 const Length<N> offsetA = basis * pointA;
3509 const Length<N> offsetB = basis * pointB;
3510 const Length<N> offsetC = basis * pointC;
3511 return Scalar{0.5} *
abs(
dot(
cross(offsetB - offsetA, offsetC - offsetA), direction));
3516 Ray<N>{.origin = localRayOrigin, .direction = localRayDirection, .maxDistance = maxLocalRayDistance});
3525 return getLocalVertexOffset(getLocalSupportPointVertexIndex(localDirection, 0));
3530 (void)searchStartVertexIndex;
3532 Length1D farthestSignedDistance =
dot(pointA, localDirection);
3533 const Length1D signedDistanceB =
dot(pointB, localDirection);
3534 if (signedDistanceB > farthestSignedDistance) {
3535 farthestVertexIndex = 1;
3536 farthestSignedDistance = signedDistanceB;
3538 const Length1D signedDistanceC =
dot(pointC, localDirection);
3539 if (signedDistanceC > farthestSignedDistance) {
3540 farthestVertexIndex = 2;
3541 farthestSignedDistance = signedDistanceC;
3543 return farthestVertexIndex;
3551 if constexpr (N == 2) {
3564 switch (vertexIndex) {
3565 case 0:
return pointA;
3566 case 1:
return pointB;
3567 case 2:
return pointC;
3575 if constexpr (N == 2) {
3578 return (faceIndex == 0) ? pointA : pointB;
3583 if constexpr (N == 2) {
3596 (void)searchStartFaceIndex;
3597 if constexpr (N == 2) {
3599 Scale1D largestDotProduct =
dot(localDirection, getLocalFaceNormal(0));
3600 const Scale1D dotProductB =
dot(localDirection, getLocalFaceNormal(1));
3601 if (dotProductB > largestDotProduct) {
3602 mostFittingFaceIndex = 1;
3603 largestDotProduct = dotProductB;
3605 const Scale1D dotProductC =
dot(localDirection, getLocalFaceNormal(2));
3606 if (dotProductC > largestDotProduct) {
3607 mostFittingFaceIndex = 2;
3608 largestDotProduct = dotProductC;
3610 return mostFittingFaceIndex;
3612 const auto vector =
cross(pointB - pointA, pointC - pointA);
3619 switch (edgeIndex) {
3633 switch (edgeIndex) {
3647 switch (edgeIndex) {
3669using TriangleShape2D = TriangleShape<2>;
3670using TriangleShape3D = TriangleShape<3>;
#define GREM_MATCH(...)
Definition Variant.hpp:1997
#define GREM_CASE(...)
Definition Variant.hpp:1998
#define GREM_ASSERT(expression)
Definition assertions.hpp:77
#define GREM_ALWAYS_INLINE
Definition attributes.hpp:10
Definition Allocation.hpp:25
Convex polytope.
Definition ConvexPolytope.hpp:171
ConvexPolytopeFace< N, Scalar > Face
Face type of the convex polytope.
Definition ConvexPolytope.hpp:175
ConvexPolytopeEdge< N, Scalar > Edge
Edge type of the convex polytope.
Definition ConvexPolytope.hpp:174
ConvexPolytopeVertex< N, Scalar > Vertex
Vertex type of the convex polytope.
Definition ConvexPolytope.hpp:173
Optional value type that holds either a value or no value.
Definition Optional.hpp:58
Definition SharedPointer.hpp:65
Triangle mesh.
Definition TriangleMesh.hpp:40
TriangleMeshVertexIndex VertexIndex
Vertex index type of the triangle mesh.
Definition TriangleMesh.hpp:43
TriangleMeshVertex< N, Scalar > Vertex
Vertex type of the triangle mesh.
Definition TriangleMesh.hpp:42
TriangleMeshFaceIndex FaceIndex
Face index type of the triangle mesh.
Definition TriangleMesh.hpp:44
Tagged union value type that holds a value of one of the given types.
Definition Variant.hpp:293
friend class Variant
Definition Variant.hpp:1402
Identifier for a collision layer that a collider may belong to.
Definition Shape.hpp:34
constexpr CollisionLayer(size_t index) noexcept
Construct a layer identifier with a specific index.
Definition Shape.hpp:46
constexpr bool operator==(const CollisionLayer &other) const noexcept=default
Compare this layer identifier to another for equality.
static const CollisionLayer MAX
Maximum collision layer value.
Definition Shape.hpp:39
Set of collision layers that a collider may belong to.
Definition Shape.hpp:76
constexpr bool operator==(const CollisionLayers &other) const noexcept=default
Compare this layer set to another for equality.
friend constexpr CollisionLayers operator&(CollisionLayers a, CollisionLayers b) noexcept
Get the intersection of two layer sets.
Definition Shape.hpp:172
friend constexpr CollisionLayers & operator^=(CollisionLayers &a, CollisionLayers b) noexcept
Assign the symmetric difference of two layer sets to the first set.
Definition Shape.hpp:233
friend constexpr CollisionLayers operator~(CollisionLayers a) noexcept
Get the complement of a layer set.
Definition Shape.hpp:160
friend constexpr CollisionLayers & operator|=(CollisionLayers &a, CollisionLayers b) noexcept
Assign the union of two layer sets to the first set.
Definition Shape.hpp:221
friend constexpr CollisionLayers operator|(CollisionLayers a, CollisionLayers b) noexcept
Get the union of two layer sets.
Definition Shape.hpp:184
constexpr bool contains(CollisionLayer layer) const noexcept
Check if the layer set contains the given layer.
Definition Shape.hpp:124
friend constexpr CollisionLayers & operator&=(CollisionLayers &a, CollisionLayers b) noexcept
Assign the intersection of two layer sets to the first set.
Definition Shape.hpp:209
constexpr CollisionLayers() noexcept=default
Construct an empty layer set.
constexpr bool containsAllOf(CollisionLayers layers) const noexcept
Check if the layer set contains all of the given layers.
Definition Shape.hpp:148
constexpr bool empty() const noexcept
Check if the layer set is empty.
Definition Shape.hpp:113
friend constexpr CollisionLayers operator^(CollisionLayers a, CollisionLayers b) noexcept
Get the symmetric difference of two layer sets.
Definition Shape.hpp:197
static const CollisionLayers ALL
Set containing all possible layers.
Definition Shape.hpp:81
constexpr bool containsAnyOf(CollisionLayers layers) const noexcept
Check if the layer set contains at least one of the given layers.
Definition Shape.hpp:136
Shape that combines multiple colliders.
Definition Shape.hpp:2526
Optional< Area > getReferenceArea(const Basis< N > &basis, Direction< N > direction) const
Get an estimate of the reference area of the shape for a certain direction, typically calculated as t...
PrincipalMomentsOfInertia< N > calculatePrincipalMomentsOfInertia(Mass mass) const
Calculate an estimate of the local moment of inertia of the shape given a certain mass.
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius(const Basis< N > &basis) const
Get the radius of the bounding sphere of the shape.
Definition Shape.hpp:2575
GREM_ALWAYS_INLINE CompoundColliderShape(SharedPointer< SubCollider< N >[]> subColliders) noexcept
Construct a compound collider shape from a set of colliders.
Definition Shape.hpp:2533
RaycastResult< N > castLocalRay(Length< N > localRayOrigin, Direction< N > localRayDirection, Distance maxLocalRayDistance) const
Find the closest intersection of this shape with a given ray in local space.
GREM_ALWAYS_INLINE Optional< Box< N > > getBoundingBox(const Transformation< N > &transformation) const
Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Definition Shape.hpp:2567
CompoundColliderShape(Span< const SubCollider< N > > subColliders)
Construct a compound shape from a set of colliders.
Volume calculateVolume() const
Calculate an estimate of the volume of the shape.
GREM_ALWAYS_INLINE Span< const SubCollider< N > > getSubColliders() const noexcept
Definition Shape.hpp:2556
View of a generic convex polytope shape.
Definition Shape.hpp:3220
ConvexPolytopeEdgeIndex getEdgeCount() const
Get the total number of edges, including twin edges, on the convex polyhedron defined by this 3-dimen...
ConvexPolytopeEdgeIndex getFirstEdgeIndexOfFace(ConvexPolytopeFaceIndex faceIndex) const
Direction< N > getLocalFaceNormal(ConvexPolytopeFaceIndex faceIndex) const
ConvexPolytopeEdgeIndex getNextEdgeIndex(ConvexPolytopeEdgeIndex edgeIndex) const
ConvexPolytopeVertexIndex getLocalSupportPointVertexIndex(Direction< N > localDirection, ConvexPolytopeVertexIndex searchStartVertexIndex) const
Get the vertex index of the farthest point on the shape in a certain local direction.
GREM_ALWAYS_INLINE constexpr ConvexPolytopeShapeView(const T &shape) noexcept
Construct a convex polytope shape view.
Definition Shape.hpp:3242
ConvexPolytopeVertexIndex getVertexCount() const
Get the total number of vertices in the convex polytope defined by this shape.
ConvexPolytopeFaceIndex getFaceIndexOfEdge(ConvexPolytopeEdgeIndex edgeIndex) const
GREM_ALWAYS_INLINE constexpr ConvexPolytopeShapeView(ShapeView< N > shape)
Construct a shape view.
Definition Shape.hpp:3252
ConvexPolytopeEdgeIndex getSomeEdgeIndexOfVertex(ConvexPolytopeVertexIndex vertexIndex) const
GREM_ALWAYS_INLINE constexpr ConvexPolytopeShapeView(const T &shape) noexcept
Construct a convex polytope shape view.
Definition Shape.hpp:3232
ConvexPolytopeVertexIndex getFirstVertexIndexOfEdge(ConvexPolytopeEdgeIndex edgeIndex) const
ConvexPolytopeFaceIndex getFaceIndexWithMostFittingLocalNormal(Direction< N > localDirection, ConvexPolytopeFaceIndex searchStartFaceIndex) const
ConvexPolytopeFaceIndex getFaceCount() const
Get the total number of faces on the convex polytope defined by this shape.
Length< N > getLocalVertexOffset(ConvexPolytopeVertexIndex vertexIndex) const
Length< N > getLocalFaceOffset(ConvexPolytopeFaceIndex faceIndex) const
Convex polytope shape.
Definition Shape.hpp:2247
GREM_ALWAYS_INLINE ConvexPolytopeEdgeIndex getEdgeCount() const
Get the total number of edges, including twin edges, on the convex polyhedron defined by this 3-dimen...
Definition Shape.hpp:2328
GREM_ALWAYS_INLINE ConvexPolytopeVertexIndex getVertexCount() const
Get the total number of vertices in the convex polytope defined by this shape.
Definition Shape.hpp:2318
ConvexPolytopeEdgeIndex getNextEdgeIndex(ConvexPolytopeEdgeIndex edgeIndex) const
Get the index of the next edge after another edge on the same face on the convex polyhedron defined b...
GREM_ALWAYS_INLINE const SharedPointer< ConvexPolytope< N, float > > & getConvexPolytope() const noexcept
Get the underlying convex polytope of the shape.
Definition Shape.hpp:2282
typename ConvexPolytope< N, float >::Vertex Vertex
Vertex type of the convex polytope shape.
Definition Shape.hpp:2249
typename ConvexPolytope< N, float >::Edge Edge
Edge type of the convex polytope shape.
Definition Shape.hpp:2251
GREM_ALWAYS_INLINE Optional< Box< N > > getBoundingBox(const Transformation< N > &transformation) const
Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Definition Shape.hpp:2293
bool containsLocalPoint(Length< N > localPoint) const
Check if a local point relative to the origin of the shape is contained within the shape.
Length< N > getLocalFaceOffset(ConvexPolytopeFaceIndex faceIndex) const
Get the local offset of a specific face on the convex polytope defined by this shape.
PrincipalMomentsOfInertia< N > calculatePrincipalMomentsOfInertia(Mass mass) const
Calculate an estimate of the local moment of inertia of the shape given a certain mass.
GREM_ALWAYS_INLINE ConvexPolytopeFaceIndex getFaceCount() const
Get the total number of faces on the convex polytope defined by this shape.
Definition Shape.hpp:2323
Optional< Area > getReferenceArea(const Basis< N > &basis, Direction< N > direction) const
Get an estimate of the reference area of the shape for a certain direction, typically calculated as t...
ConvexPolytopeFaceIndex getFaceIndexOfEdge(ConvexPolytopeEdgeIndex edgeIndex) const
Get the index of the face that a specific edge is part of on the convex polyhedron defined by this 3-...
ConvexPolytopeEdgeIndex getSomeEdgeIndexOfVertex(ConvexPolytopeVertexIndex vertexIndex) const
Get the index of some edge that has a specific vertex as its origin on the convex polyhedron defined ...
ConvexPolytopeVertexIndex getFirstVertexIndexOfEdge(ConvexPolytopeEdgeIndex edgeIndex) const
Get the vertex index of the first point of a specific edge on the convex polyhedron defined by this 3...
ConvexPolytopeVertexIndex getLocalSupportPointVertexIndex(Direction< N > localDirection, ConvexPolytopeVertexIndex searchStartVertexIndex) const
Get the vertex index of the farthest point on the shape in a certain local direction.
Length< N > getLocalVertexOffset(ConvexPolytopeVertexIndex vertexIndex) const
Get the local offset of a specific vertex in the convex polytope defined by this shape.
Volume calculateVolume() const
Calculate an estimate of the volume of the shape.
Direction< N > getLocalFaceNormal(ConvexPolytopeFaceIndex faceIndex) const
Get the local normal of a specific face on the convex polytope defined by this shape.
Length< N > getLocalSupportPointOffset(Direction< N > localDirection) const
Get the local offset from the origin of the shape to the farthest point on the shape in a certain loc...
GREM_ALWAYS_INLINE ConvexPolytopeShape(SharedPointer< ConvexPolytope< N, float > > polytope) noexcept
Construct a convex polytope shape from an existing convex polytope.
Definition Shape.hpp:2258
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius(const Basis< N > &basis) const
Get the radius of the bounding sphere of the shape.
Definition Shape.hpp:2298
typename ConvexPolytope< N, float >::Face Face
Face type of the convex polytope shape.
Definition Shape.hpp:2250
ConvexPolytopeEdgeIndex getFirstEdgeIndexOfFace(ConvexPolytopeFaceIndex faceIndex) const
Get the index of the first edge that a specific face is made up of on the convex polyhedron defined b...
ConvexPolytopeShape(Span< const Vertex > vertices, ConvexPolytopeVertexIndex maxVertexCount=Limits< ConvexPolytopeVertexIndex >::MAX)
Construct a convex polytope shape from a set of vertices.
ConvexPolytopeFaceIndex getFaceIndexWithMostFittingLocalNormal(Direction< N > localDirection, ConvexPolytopeFaceIndex searchStartFaceIndex) const
Get the index of the face on the convex polytope defined by this shape whose local normal is the most...
RaycastResult< N > castLocalRay(Length< N > localRayOrigin, Direction< N > localRayDirection, Distance maxLocalRayDistance) const
Find the closest intersection of this shape with a given ray in local space.
View of a generic convex shape.
Definition Shape.hpp:3147
GREM_ALWAYS_INLINE constexpr ConvexShapeView(const T &shape) noexcept
Construct a convex shape view.
Definition Shape.hpp:3159
GREM_ALWAYS_INLINE constexpr ConvexShapeView(const T &shape) noexcept
Construct a convex shape view.
Definition Shape.hpp:3169
GREM_ALWAYS_INLINE constexpr ConvexShapeView(ShapeView< N > shape)
Construct a shape view.
Definition Shape.hpp:3178
Length< N > getLocalSupportPointOffset(Direction< N > localDirection) const
Get the local offset from the origin of the shape to the farthest point on the shape in a certain loc...
bool containsLocalPoint(Length< N > localPoint) const
Check if a local point relative to the origin of the shape is contained within the shape.
View of a generic shape.
Definition Shape.hpp:2833
constexpr const T * get_if() const noexcept
Access the underlying shape with the given type if it is the currently active alternative.
Definition Shape.hpp:2974
GREM_ALWAYS_INLINE constexpr const void * data() const noexcept
Get an untyped pointer to the data of the underlying shape.
Definition Shape.hpp:2869
constexpr bool is() const noexcept
Check if the shape view currently references the alternative with the given type.
Definition Shape.hpp:2903
Optional< Distance > getBoundingRadius(const Basis< N > &basis) const
bool isConvexPolytopeShapeType() const noexcept
GREM_ALWAYS_INLINE constexpr ShapeView(const T &shape) noexcept
Construct a shape view.
Definition Shape.hpp:2848
constexpr const T & as() const &noexcept
Access the underlying value with the given type without a safety check.
Definition Shape.hpp:2932
typename Shape< N >::value_type value_type
Underling shape variant type.
Definition Shape.hpp:2836
Optional< Area > getReferenceArea(const Basis< N > &basis, Direction< N > direction) const
constexpr const T & get() const &
Access the underlying value with the given type.
Definition Shape.hpp:2952
bool isConvexShapeType() const noexcept
Check if the shape held by this wrapper is a convex shape type.
GREM_ALWAYS_INLINE constexpr ShapeView(const T &shape) noexcept
Construct a shape view.
Definition Shape.hpp:2859
PrincipalMomentsOfInertia< N > calculatePrincipalMomentsOfInertia(Mass mass) const
RaycastResult< N > castLocalRay(Length< N > localRayOrigin, Direction< N > localRayDirection, Distance maxLocalRayDistance) const
Optional< Box< N > > getBoundingBox(const Transformation< N > &transformation) const
value_type::index_type index_type
Index type used to encode the active shape type.
Definition Shape.hpp:2839
constexpr bool valueless_by_exception() const noexcept
Check if the shape view is in the valueless by exception state.
Definition Shape.hpp:2888
GREM_ALWAYS_INLINE constexpr index_type index() const noexcept
Get the type index of the underlying shape.
Definition Shape.hpp:2878
Volume calculateVolume() const
Triangle mesh shape.
Definition Shape.hpp:2379
TriangleMeshShape(Allocation< Vertex > vertices, Allocation< VertexIndex > indices)
Construct a triangle mesh shape from a set of vertices.
PrincipalMomentsOfInertia< N > calculatePrincipalMomentsOfInertia(Mass mass) const
Calculate an estimate of the local moment of inertia of the shape given a certain mass.
typename TriangleMesh< N, float >::Vertex Vertex
Vertex type of the triangle mesh shape.
Definition Shape.hpp:2381
Optional< Area > getReferenceArea(const Basis< N > &basis, Direction< N > direction) const
Get an estimate of the reference area of the shape for a certain direction, typically calculated as t...
RaycastResult< N > castLocalRay(Length< N > localRayOrigin, Direction< N > localRayDirection, Distance maxLocalRayDistance) const
Find the closest intersection of this shape with a given ray in local space.
GREM_ALWAYS_INLINE const SharedPointer< TriangleMesh< N, float > > & getTriangleMesh() const noexcept
Get the underlying triangle mesh of the shape.
Definition Shape.hpp:2429
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius(const Basis< N > &basis) const
Get the radius of the bounding sphere of the shape.
Definition Shape.hpp:2445
typename TriangleMesh< N, float >::VertexIndex VertexIndex
Vertex index type of the triangle mesh shape.
Definition Shape.hpp:2382
GREM_ALWAYS_INLINE TriangleMeshShape(SharedPointer< TriangleMesh< N, float > > mesh) noexcept
Construct a triangle mesh shape from an existing triangle mesh.
Definition Shape.hpp:2390
GREM_ALWAYS_INLINE Optional< Box< N > > getBoundingBox(const Transformation< N > &transformation) const
Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Definition Shape.hpp:2440
TriangleMeshShape(Span< const Vertex > vertices, Span< const VertexIndex > indices)
Construct a triangle mesh shape from a set of vertices and indices.
Volume calculateVolume() const
Calculate an estimate of the volume of the shape.
typename TriangleMesh< N, float >::FaceIndex FaceIndex
Face index type of the triangle mesh shape.
Definition Shape.hpp:2383
Definition concepts.hpp:47
Concept that checks if a type is a valid 2-dimensional convex polytope shape type.
Definition Shape.hpp:1313
Concept that checks if a type is a valid 3-dimensional convex polytope shape type.
Definition Shape.hpp:1321
Concept that checks if a type is a valid convex polytope shape type.
Definition Shape.hpp:1288
Concept that checks if a type is a valid 2-dimensional convex shape type.
Definition Shape.hpp:1271
Concept that checks if a type is a valid 3-dimensional convex shape type.
Definition Shape.hpp:1279
Concept that checks if a type is a valid convex shape type.
Definition Shape.hpp:1260
Concept that checks if a type is a valid 2-dimensional shape type.
Definition Shape.hpp:1243
Concept that checks if a type is a valid 3-dimensional shape type.
Definition Shape.hpp:1251
Concept that checks if a type is a valid shape type.
Definition Shape.hpp:1227
Concept that checks if a type is a valid physical unit type.
Definition quantities.hpp:515
Definition concepts.hpp:35
Definition Broadphase.hpp:24
Length1D Distance
Scalar length quantity.
Definition quantities.hpp:4962
Collider< 2 > Collider2D
Generic collider in 2-dimensional space.
Definition Shape.hpp:2816
GREM_ALWAYS_INLINE constexpr auto rotate90DegreesClockwise(A a)
Definition quantities.hpp:4232
PointShape< 3 > PointShape3D
Point shape in 3-dimensional space.
Definition Shape.hpp:1480
consteval auto operator*(const UnitT1 &a, const UnitlessT2 &b)
Get the unit resulting from multiplying a unit by a dimensionless unit with a magnitude of 1.
Definition quantities.hpp:759
GREM_ALWAYS_INLINE auto GREM_VECTORCALL abs(A a)
Definition quantities.hpp:3217
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL distance2(A a, B b)
Definition quantities.hpp:3316
BoxShape2D RectangleShape2D
Rectangle shape in 2-dimensional space.
Definition Shape.hpp:1809
Direction< 2 > Direction2D
Normalized unit vector in 2-dimensional space. Unitless.
Definition quantities.hpp:4151
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL lessThan(A a, B b)
Definition quantities.hpp:3595
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL length(A a)
Definition quantities.hpp:3302
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL cross(A a, B b)
Definition quantities.hpp:3239
constexpr decltype(auto) visit(Visitor &&visitor, ShapeView< N > shape)
Call a visitor functor with a reference to the currently active underlying shape of a ShapeView.
Definition Shape.hpp:3089
SphereShape< 2 > SphereShape2D
Sphere shape in 2-dimensional space.
Definition Shape.hpp:2036
ConvexPolytopeShape< 2 > ConvexPolytopeShape2D
Convex polytope shape in 2-dimensional space.
Definition Shape.hpp:2368
Box< 3 > Box3D
Description of an axis-aligned box in 3-dimensional space.
Definition Shape.hpp:940
Quantity< 1, SquareMeters > Area
Scalar area quantity.
Definition quantities.hpp:5525
GREM_ALWAYS_INLINE auto GREM_VECTORCALL signbit(A a)
Definition quantities.hpp:3150
constexpr CollisionLayers operator|(CollisionLayer a, CollisionLayer b) noexcept
Get the union of two collision layers.
Definition Shape.hpp:265
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL midpoint(A a, B b)
Definition quantities.hpp:3497
Sphere< 2 > Sphere2D
Description of a sphere in 2-dimensional space.
Definition Shape.hpp:1055
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL min(Quantity< N1, UnitT1 > a, Quantity< N2, UnitT2 > b)
Definition quantities.hpp:2982
Ray< 3 > Ray3D
Description of a ray in 3-dimensional space.
Definition Shape.hpp:478
Triangle< 2 > Triangle2D
Description of a triangle in 2-dimensional space.
Definition Shape.hpp:1169
CubeShape2D SquareShape2D
Square shape in 2-dimensional space.
Definition Shape.hpp:1941
float Scalar
Underlying scalar type of physics quantity components.
Definition quantities.hpp:1480
RayHitInterior< 3 > RayHitInterior3D
Result of a raycast interior hit in 3-dimensional space.
Definition Shape.hpp:636
ShapeView< 3 > ShapeView3D
View of a generic shape in 3-dimensional space.
Definition Shape.hpp:3069
ShapeView< 2 > ShapeView2D
View of a generic shape in 2-dimensional space.
Definition Shape.hpp:3068
PointShape< 2 > PointShape2D
Point shape in 2-dimensional space.
Definition Shape.hpp:1479
ConvexPolytopeShapeView< 2 > ConvexPolytopeShapeView2D
View of a generic convex polytope shape in 2-dimensional space.
Definition Shape.hpp:3435
void forEachNeighboringVertexIndex(const convex_polytope_shape_2d auto &shape, ConvexPolytopeVertexIndex vertexIndex, auto callback)
Execute a function for each vertex that is directly connected to a specific vertex of a convex polyto...
Definition Shape.hpp:1395
constexpr Dimension< 0, 1, 0 > LENGTH
L.
Definition quantities.hpp:187
Direction< 3 > Direction3D
Normalized unit vector in 3-dimensional space. Unitless.
Definition quantities.hpp:4152
TaperedCapsuleShape< 3 > TaperedCapsuleShape3D
Tapered capsule shape aligned with the local Y axis in 3-dimensional space.
Definition Shape.hpp:2147
LocallyTransformedShape< 2 > LocallyTransformedShape2D
Wrapper of another shape with a local transformation applied to it in 2-dimensional space.
Definition Shape.hpp:2505
SubCollider< 3 > SubCollider3D
Sub-collider of a compound collider shape in 3-dimensional space.
Definition Shape.hpp:2518
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL flipSignIf(A a, bool b)
Definition quantities.hpp:4155
Basis< 3 > Basis3D
Basis matrix in 3-dimensional space. Unitless.
Definition quantities.hpp:4000
LineSegment< 2 > LineSegment2D
Description of a line segment in 2-dimensional space.
Definition Shape.hpp:796
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL greaterThanEqual(A a, B b)
Definition quantities.hpp:3697
Sphere< 3 > Sphere3D
Description of a sphere in 3-dimensional space.
Definition Shape.hpp:1056
Triangle< 3 > Triangle3D
Description of a triangle in 3-dimensional space.
Definition Shape.hpp:1170
Quantity< 1, CubicMeters > Volume
Scalar volume quantity.
Definition quantities.hpp:5539
CubeShape< 3 > CubeShape3D
Cube shape in 3-dimensional space.
Definition Shape.hpp:1938
PrincipalMomentsOfInertia< N > calculatePrincipalMomentsOfInertia(const Shape< N > &shape, Mass mass)
Calculate the principal moments of inertia of an object given its shape and mass.
Definition objects.hpp:573
EllipsoidShape< 3 > EllipsoidShape3D
Ellipsoid shape in 3-dimensional space.
Definition Shape.hpp:1983
InfiniteLineShape< 2 > InfiniteLineShape2D
Infinite line shape parallel to the local Y axis in 2-dimensional space.
Definition Shape.hpp:1612
LineSegment< 3 > LineSegment3D
Description of a line segment in 3-dimensional space.
Definition Shape.hpp:797
ConvexShapeView< 2 > ConvexShapeView2D
View of a generic convex shape in 2-dimensional space.
Definition Shape.hpp:3209
ConvexPolytopeShape< 3 > ConvexPolytopeShape3D
Convex polytope shape in 3-dimensional space.
Definition Shape.hpp:2369
Basis< 2 > Basis2D
Basis matrix in 2-dimensional space. Unitless.
Definition quantities.hpp:3999
TensorQuantity< N, Unitless > Basis
Basis matrix.
Definition quantities.hpp:3998
Length< 1 > Length1D
Relative distance/length offset in 1-dimensional space. Unit: Meters.
Definition quantities.hpp:4925
CubeShape< 2 > CubeShape2D
Cube shape in 2-dimensional space.
Definition Shape.hpp:1937
Ray< 2 > Ray2D
Description of a ray in 2-dimensional space.
Definition Shape.hpp:477
Plane< 3 > Plane3D
Description of an infinite plane in 3-dimensional space.
Definition Shape.hpp:742
Plane< 2 > Plane2D
Description of an infinite plane in 2-dimensional space.
Definition Shape.hpp:741
RayHitInterior< 2 > RayHitInterior2D
Result of a raycast interior hit in 2-dimensional space.
Definition Shape.hpp:635
CompoundColliderShape< 2 > CompoundColliderShape2D
Shape that combines multiple colliders in 2-dimensional space.
Definition Shape.hpp:2598
EllipsoidShape< 2 > EllipsoidShape2D
Ellipsoid shape in 2-dimensional space.
Definition Shape.hpp:1982
constexpr Direction< N > Y_AXIS
The Y axis in the space with the given number of dimensions.
Definition quantities.hpp:4897
ConvexPolytopeShapeView< 3 > ConvexPolytopeShapeView3D
View of a generic convex polytope shape in 3-dimensional space.
Definition Shape.hpp:3436
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL greaterThan(A a, B b)
Definition quantities.hpp:3663
EllipsoidShape2D EllipseShape2D
Ellipse shape in 2-dimensional space.
Definition Shape.hpp:1986
Shape< 2 > Shape2D
Generic shape in 2-dimensional space.
Definition Shape.hpp:2803
LineSegmentShape< 3 > LineSegmentShape3D
Line segment shape parallel to the local Y axis in 3-dimensional space.
Definition Shape.hpp:1550
TriangleMeshShape< 3 > TriangleMeshShape3D
Triangle mesh shape in 3-dimensional space.
Definition Shape.hpp:2461
Quantity< 1, Kilograms > Mass
Scalar mass quantity.
Definition quantities.hpp:5504
InfiniteLineShape< 3 > InfiniteLineShape3D
Infinite line shape parallel to the local Y axis in 3-dimensional space.
Definition Shape.hpp:1613
CompoundColliderShape< 3 > CompoundColliderShape3D
Shape that combines multiple colliders in 3-dimensional space.
Definition Shape.hpp:2599
ColliderView< 2 > ColliderView2D
View of a generic collider in 2-dimensional space.
Definition Shape.hpp:3473
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL normalize(A a)
Definition quantities.hpp:4187
RaycastResult< 3 > RaycastResult3D
Result of a raycast in 3-dimensional space.
Definition Shape.hpp:703
GREM_ALWAYS_INLINE auto GREM_VECTORCALL copysign(A a, B b)
Definition quantities.hpp:4175
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL length2(A a)
Definition quantities.hpp:3295
LineSegmentShape< 2 > LineSegmentShape2D
Line segment shape parallel to the local Y axis in 2-dimensional space.
Definition Shape.hpp:1549
ColliderView< 3 > ColliderView3D
View of a generic collider in 3-dimensional space.
Definition Shape.hpp:3474
Length< 3 > Length3D
Relative distance/length offset in 3-dimensional space. Unit: Meters.
Definition quantities.hpp:4927
CapsuleShape< 3 > CapsuleShape3D
Capsule shape aligned with the local Y axis in 3-dimensional space.
Definition Shape.hpp:2092
Transformation< 2 > Transformation2D
Affine transformation in 2-dimensional space.
Definition quantities.hpp:5183
BoxShape< 2 > BoxShape2D
Box shape in 2-dimensional space.
Definition Shape.hpp:1805
RaycastResult< 2 > RaycastResult2D
Result of a raycast in 2-dimensional space.
Definition Shape.hpp:702
void forEachVertexIndexInFace(const convex_polytope_shape_2d auto &shape, ConvexPolytopeFaceIndex faceIndex, auto callback)
Execute a function for each vertex of a face of a convex polytope shape.
Definition Shape.hpp:1331
Quantity< N, Meters > Length
Relative distance/length offset quantity.
Definition quantities.hpp:4924
TriangleMeshShape< 2 > TriangleMeshShape2D
Triangle mesh shape in 2-dimensional space.
Definition Shape.hpp:2460
Sphere2D Circle
Description of a circle in 2-dimensional space.
Definition Shape.hpp:1057
SphereShape2D CircleShape2D
Circle shape in 2-dimensional space.
Definition Shape.hpp:2040
TaperedCapsuleShape< 2 > TaperedCapsuleShape2D
Tapered capsule shape aligned with the local Y axis in 2-dimensional space.
Definition Shape.hpp:2146
consteval auto sqrt(UnitT a)
Get the canonical unit resulting from taking the square root of a quantity of a given unit.
Definition quantities.hpp:1051
InfiniteHalfSpaceShape< 3 > InfiniteHalfSpaceShape3D
Infinite half-space shape perpendicular to the local Y axis in 3-dimensional space.
Definition Shape.hpp:1660
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL dot(A a, B b)
Definition quantities.hpp:3234
RayHit< 3 > RayHit3D
Result of a raycast hit in 3-dimensional space.
Definition Shape.hpp:583
BoxShape< 3 > BoxShape3D
Box shape in 3-dimensional space.
Definition Shape.hpp:1806
PrincipalMomentsOfInertia< 3 > PrincipalMomentsOfInertia3D
Principal moments of inertia in 3-dimensional inertia major axis space. Unit: kilogram square meters.
Definition quantities.hpp:5862
Quantity< N, Absolute< Meters > > Position
Absolute position in world space.
Definition quantities.hpp:4949
Quantity< N, Unitless > Scale
Dimensionless scale.
Definition quantities.hpp:3984
RayHit< 2 > RayHit2D
Result of a raycast hit in 2-dimensional space.
Definition Shape.hpp:582
void forEachFaceIndexAroundVertex(const convex_polytope_shape_2d auto &shape, ConvexPolytopeVertexIndex vertexIndex, auto callback)
Execute a function for each face that is adjacent to a vertex of a convex polytope shape.
Definition Shape.hpp:1362
constexpr ComponentSwizzle< 1 > Y
Tag specifying the Y component at index 1 of a vector.
Definition quantities.hpp:1493
Box< N > getTransformedBoundingBox(const Transformation< N > &transformation, const Box< N > &box)
Get the axis-aligned bounding box of an axis-aligned box with a transformation applied to it.
Definition Shape.hpp:1214
Shape< 3 > Shape3D
Generic shape in 3-dimensional space.
Definition Shape.hpp:2804
SubCollider< 2 > SubCollider2D
Sub-collider of a compound collider shape in 2-dimensional space.
Definition Shape.hpp:2517
PrincipalMomentsOfInertia< 2 > PrincipalMomentsOfInertia2D
Principal moments of inertia in 2-dimensional inertia major axis space. Unit: kilogram square meters.
Definition quantities.hpp:5861
CapsuleShape2D StadiumShape2D
Stadium shape in 2-dimensional space.
Definition Shape.hpp:2095
Collider< 3 > Collider3D
Generic collider in 3-dimensional space.
Definition Shape.hpp:2817
Box< 2 > Box2D
Description of an axis-aligned box in 2-dimensional space.
Definition Shape.hpp:939
CapsuleShape< 2 > CapsuleShape2D
Capsule shape aligned with the local Y axis in 2-dimensional space.
Definition Shape.hpp:2091
LocallyTransformedShape< 3 > LocallyTransformedShape3D
Wrapper of another shape with a local transformation applied to it in 3-dimensional space.
Definition Shape.hpp:2506
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL max(Quantity< N1, UnitT1 > a, Quantity< N2, UnitT2 > b)
Definition quantities.hpp:3001
SphereShape< 3 > SphereShape3D
Sphere shape in 3-dimensional space.
Definition Shape.hpp:2037
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL maxComponent(A a)
Definition quantities.hpp:3103
Scale< 1 > Scale1D
Dimensionless scale in 1-dimensional space. Unitless.
Definition quantities.hpp:3985
ConvexShapeView< 3 > ConvexShapeView3D
View of a generic convex shape in 3-dimensional space.
Definition Shape.hpp:3210
InfiniteHalfSpaceShape< 2 > InfiniteHalfSpaceShape2D
Infinite half-space shape perpendicular to the local Y axis in 2-dimensional space.
Definition Shape.hpp:1659
AngularQuantity< N, KilogramSquareMeters > PrincipalMomentsOfInertia
Principal moments of inertia in inertia major axis space.
Definition quantities.hpp:5860
constexpr CollisionLayers operator~(CollisionLayer a) noexcept
Get the complement of a collision layer.
Definition Shape.hpp:253
Length< 2 > Length2D
Relative distance/length offset in 2-dimensional space. Unit: Meters.
Definition quantities.hpp:4926
Transformation< 3 > Transformation3D
Affine transformation in 3-dimensional space.
Definition quantities.hpp:5184
uint8_t ConvexPolytopeEdgeIndex
Index of an edge in a convex polytope.
Definition ConvexPolytope.hpp:29
constexpr bool variant_has_alternative_v
Check if a variant type has a given type as one of its possible alternatives.
Definition Variant.hpp:179
constexpr Box< N, T > getTransformedBoundingBox(const mat< N+1, N+1, T > &transformation, const Box< N, T > &aabb) noexcept
Get the axis-aligned bounding box of an axis-aligned box with an affine transformation applied to it.
Definition geometry.hpp:1637
uint8_t ConvexPolytopeVertexIndex
Index of a vertex in a convex polytope.
Definition ConvexPolytope.hpp:24
vec< N, T > Length
Generic length in N-dimensional space.
Definition geometry.hpp:38
void unreachable()
Definition assertions.hpp:125
uint8_t ConvexPolytopeFaceIndex
Index of a face in a convex polytope.
Definition ConvexPolytope.hpp:34
constexpr detail::Matcher< V > match(V &&variant)
Choose a function overload to execute based on the active alternative of a variant.
Definition Variant.hpp:1922
GREM_ALWAYS_INLINE constexpr bool GREM_VECTORCALL all(bool a)
Definition math.hpp:1285
constexpr std::size_t variant_index_v
Get the index of the variant alternative with a given type in a variant type.
Definition Variant.hpp:196
Exception type that is thrown on an attempt to erroneously access an inactive alternative of a Varian...
Definition Variant.hpp:284
Generic axis-aligned box shape with minimum and maximum extents in N-dimensional space.
Definition geometry.hpp:149
Point< N, T > max
Position with the maximum coordinates of the box extents on each coordinate axis.
Definition geometry.hpp:154
constexpr bool intersects(const Ray< N, T > &ray) const noexcept
Check if this box intersects a given ray.
Definition geometry.hpp:193
Point< N, T > min
Position with the minimum coordinates of the box extents on each coordinate axis.
Definition geometry.hpp:153
static constexpr T MAX
Definition fundamentals.hpp:29
Generic line segment between two points in N-dimensional space.
Definition geometry.hpp:772
Result of an interor raycast hit.
Definition geometry.hpp:123
Result of a raycast hit.
Definition geometry.hpp:110
Result of a raycast miss.
Definition geometry.hpp:101
Generic ray with an origin and direction in N-dimensional space.
Definition geometry.hpp:47
static constexpr Optional< Ray > between(Point< N, T > origin, Point< N, T > destination)
Create a ray between two points.
Definition geometry.hpp:61
Result of a raycast.
Definition geometry.hpp:134
Generic sphere shape with a center and radius in N-dimensional space.
Definition geometry.hpp:1018
Generic triangle shape in N-dimensional space.
Definition geometry.hpp:586
Box shape.
Definition Shape.hpp:1710
GREM_ALWAYS_INLINE ConvexPolytopeFaceIndex getFaceCount() const
Get the total number of faces on the convex polytope defined by this shape.
Definition Shape.hpp:1763
GREM_ALWAYS_INLINE RaycastResult< N > castLocalRay(Length< N > localRayOrigin, Direction< N > localRayDirection, Distance maxLocalRayDistance) const
Find the closest intersection of this shape with a given ray in local space.
Definition Shape.hpp:1734
GREM_ALWAYS_INLINE bool containsLocalPoint(Length< N > localPoint) const
Check if a local point relative to the origin of the shape is contained within the shape.
Definition Shape.hpp:1740
GREM_ALWAYS_INLINE ConvexPolytopeEdgeIndex getEdgeCount() const
Get the total number of edges, including twin edges, on the convex polyhedron defined by this 3-dimen...
Definition Shape.hpp:1772
ConvexPolytopeVertexIndex getFirstVertexIndexOfEdge(ConvexPolytopeEdgeIndex edgeIndex) const
Get the vertex index of the first point of a specific edge on the convex polyhedron defined by this 3...
ConvexPolytopeEdgeIndex getSomeEdgeIndexOfVertex(ConvexPolytopeVertexIndex vertexIndex) const
Get the index of some edge that has a specific vertex as its origin on the convex polyhedron defined ...
Direction< N > getLocalFaceNormal(ConvexPolytopeFaceIndex faceIndex) const
Get the local normal of a specific face on the convex polytope defined by this shape.
Length< N > getLocalVertexOffset(ConvexPolytopeVertexIndex vertexIndex) const
Get the local offset of a specific vertex in the convex polytope defined by this shape.
PrincipalMomentsOfInertia< N > calculatePrincipalMomentsOfInertia(Mass mass) const
Calculate an estimate of the local moment of inertia of the shape given a certain mass.
GREM_ALWAYS_INLINE Length< N > getLocalSupportPointOffset(Direction< N > localDirection) const
Get the local offset from the origin of the shape to the farthest point on the shape in a certain loc...
Definition Shape.hpp:1745
GREM_ALWAYS_INLINE ConvexPolytopeVertexIndex getVertexCount() const
Get the total number of vertices in the convex polytope defined by this shape.
Definition Shape.hpp:1754
ConvexPolytopeEdgeIndex getNextEdgeIndex(ConvexPolytopeEdgeIndex edgeIndex) const
Get the index of the next edge after another edge on the same face on the convex polyhedron defined b...
Length< N > getLocalFaceOffset(ConvexPolytopeFaceIndex faceIndex) const
Get the local offset of a specific face on the convex polytope defined by this shape.
ConvexPolytopeFaceIndex getFaceIndexOfEdge(ConvexPolytopeEdgeIndex edgeIndex) const
Get the index of the face that a specific edge is part of on the convex polyhedron defined by this 3-...
Volume calculateVolume() const
Calculate an estimate of the volume of the shape.
ConvexPolytopeVertexIndex getLocalSupportPointVertexIndex(Direction< N > localDirection, ConvexPolytopeVertexIndex searchStartVertexIndex) const
Get the vertex index of the farthest point on the shape in a certain local direction.
ConvexPolytopeEdgeIndex getFirstEdgeIndexOfFace(ConvexPolytopeFaceIndex faceIndex) const
Get the index of the first edge that a specific face is made up of on the convex polyhedron defined b...
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius(const Basis< N > &basis) const
Get the radius of the bounding sphere of the shape.
Definition Shape.hpp:1726
Length< N > halfExtents
Definition Shape.hpp:1711
GREM_ALWAYS_INLINE Optional< Box< N > > getBoundingBox(const Transformation< N > &transformation) const
Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Definition Shape.hpp:1720
Optional< Area > getReferenceArea(const Basis< N > &basis, Direction< N > direction) const
Get an estimate of the reference area of the shape for a certain direction, typically calculated as t...
ConvexPolytopeFaceIndex getFaceIndexWithMostFittingLocalNormal(Direction< N > localDirection, ConvexPolytopeFaceIndex searchStartFaceIndex) const
Get the index of the face on the convex polytope defined by this shape whose local normal is the most...
Description of an axis-aligned box in world space.
Definition Shape.hpp:813
GREM_ALWAYS_INLINE constexpr bool intersects(const Ray< N > &ray) const noexcept
Check if this box intersects a given ray.
Definition Shape.hpp:888
GREM_ALWAYS_INLINE constexpr RaycastResult< N > raycast(const Ray< N > &ray) const noexcept
Find the closest intersection of this box with a given ray.
Definition Shape.hpp:899
Position< N > min
Definition Shape.hpp:833
typename Position< N >::Unit Unit
Unit type.
Definition Shape.hpp:814
GREM_ALWAYS_INLINE constexpr Box< N > getExpanded(Length< N > expansion) const noexcept
Get a version of the box that is symmetrically expanded by a certain amount.
Definition Shape.hpp:921
bool operator==(const Box &other) const =default
Compare this box to another for equality.
GREM_ALWAYS_INLINE friend constexpr bool intersects(const Box &a, const Box &b) noexcept
Check if two axis-aligned boxes intersect.
Definition Shape.hpp:877
Position< N > max
Definition Shape.hpp:834
typename Unit::DimensionType DimensionType
Unit dimension type.
Definition Shape.hpp:815
static constexpr DimensionType DIMENSION
Definition Shape.hpp:818
GREM_ALWAYS_INLINE constexpr Box< N > getExpanded(Distance expansion) const noexcept
Get a version of the box that is symmetrically expanded by a certain amount.
Definition Shape.hpp:935
static constexpr Unit UNIT
Definition Shape.hpp:817
GREM_ALWAYS_INLINE constexpr Box< N > getBoundingBox() const noexcept
Get the axis-aligned bounding box of the box.
Definition Shape.hpp:908
GREM_ALWAYS_INLINE constexpr grem::Box< N, Scalar > in(OtherUnitT unit) const noexcept
Convert this physical box to a unitless box given a desired unit.
Definition Shape.hpp:844
GREM_ALWAYS_INLINE constexpr bool contains(const Position< N > &point) const noexcept
Check if a given point is contained within the extents of this box.
Definition Shape.hpp:864
static constexpr MagnitudeType MAGNITUDE
Definition Shape.hpp:819
static GREM_ALWAYS_INLINE constexpr Box reinterpret(const grem::Box< N, T > &box) noexcept
Reinterpret a unitless box as a physical box in default units.
Definition Shape.hpp:829
typename Unit::MagnitudeType MagnitudeType
Unit magnitude type.
Definition Shape.hpp:816
Capsule shape aligned with the local Y axis.
Definition Shape.hpp:2048
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius(const Basis< N > &basis) const
Get the radius of the bounding sphere of the shape.
Definition Shape.hpp:2071
Distance radius
Definition Shape.hpp:2049
Volume calculateVolume() const
Calculate an estimate of the volume of the shape.
GREM_ALWAYS_INLINE Optional< Box< N > > getBoundingBox(const Transformation< N > &transformation) const
Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Definition Shape.hpp:2059
bool containsLocalPoint(Length< N > localPoint) const
Check if a local point relative to the origin of the shape is contained within the shape.
Distance halfLength
Definition Shape.hpp:2050
Length< N > getLocalSupportPointOffset(Direction< N > localDirection) const
Get the local offset from the origin of the shape to the farthest point on the shape in a certain loc...
Optional< Area > getReferenceArea(const Basis< N > &basis, Direction< N > direction) const
Get an estimate of the reference area of the shape for a certain direction, typically calculated as t...
RaycastResult< N > castLocalRay(Length< N > localRayOrigin, Direction< N > localRayDirection, Distance maxLocalRayDistance) const
Find the closest intersection of this shape with a given ray in local space.
PrincipalMomentsOfInertia< N > calculatePrincipalMomentsOfInertia(Mass mass) const
Calculate an estimate of the local moment of inertia of the shape given a certain mass.
View of a generic collider.
Definition Shape.hpp:3446
CollisionFilter filter
Definition Shape.hpp:3448
GREM_ALWAYS_INLINE constexpr ColliderView(ShapeView< N > shape, CollisionFilter filter) noexcept
Construct a collider view from a shape and collision filter.
Definition Shape.hpp:3467
GREM_ALWAYS_INLINE constexpr ColliderView(const Collider< N > &collider) noexcept
Construct a collider view.
Definition Shape.hpp:3456
Generic collider.
Definition Shape.hpp:2812
CollisionFilter filter
Definition Shape.hpp:2814
Result of a CollisionFilterTest.
Definition Shape.hpp:283
uint8_t TestFlags
Definition Shape.hpp:284
TestFlag
Definition Shape.hpp:285
@ RESPONDS_TO_COLLISION
Both colliders wanted to respond to collisions with each other on at least one of the tested layers.
Definition Shape.hpp:287
@ DETECTS_COLLISION
Both colliders wanted to detect collisions with each other on at least one of the tested layers.
Definition Shape.hpp:286
constexpr bool respondsToCollision() const noexcept
Check if both colliders want to respond to collisions with each other on at least some tested layer.
Definition Shape.hpp:329
TestFlags passed
Set of filter tests that passed.
Definition Shape.hpp:290
constexpr bool operator==(const CollisionFilterTestResult &other) const noexcept=default
Compare this filter test result to another for equality.
constexpr bool detectsCollision() const noexcept
Check if both colliders want to detect collisions with each other on at least some tested layer.
Definition Shape.hpp:318
Test that checks if a pair of colliders should collide.
Definition Shape.hpp:337
CollisionLayers responseLayers
Layers to test for collision response.
Definition Shape.hpp:342
static const CollisionFilterTest RESPONSE
Test that checks if a pair of colliders may respond to collisions with each other on any layer.
Definition Shape.hpp:339
static const CollisionFilterTest DETECTION
Test that checks if a pair of colliders may detect collisions with each other on any layer.
Definition Shape.hpp:338
CollisionLayers detectionLayers
Layers to test for collision detection.
Definition Shape.hpp:341
constexpr CollisionFilterTestResult operator()(CollisionFilter a, CollisionFilter b) const noexcept
Check if a given pair of collider's filters meet the requirements.
Definition Shape.hpp:352
Collision filtering options for a collider.
Definition Shape.hpp:272
CollisionLayers detectionLayers
Other colliders' layers that this collider wants to detect collisions with.
Definition Shape.hpp:274
CollisionLayers noResponseLayers
Other colliders' layers that this collider skips collision response with.
Definition Shape.hpp:277
CollisionLayers layers
Layers that the collider belongs to.
Definition Shape.hpp:273
CollisionLayers noDetectionLayers
Other colliders' layers that this collider skips collision detection with.
Definition Shape.hpp:275
CollisionLayers responseLayers
Other colliders' layers that this collider wants to respond to collisions with.
Definition Shape.hpp:276
Cube shape.
Definition Shape.hpp:1817
GREM_ALWAYS_INLINE RaycastResult< N > castLocalRay(Length< N > localRayOrigin, Direction< N > localRayDirection, Distance maxLocalRayDistance) const
Find the closest intersection of this shape with a given ray in local space.
Definition Shape.hpp:1846
GREM_ALWAYS_INLINE ConvexPolytopeFaceIndex getFaceIndexOfEdge(ConvexPolytopeEdgeIndex edgeIndex) const
Get the index of the face that a specific edge is part of on the convex polyhedron defined by this 3-...
Definition Shape.hpp:1916
GREM_ALWAYS_INLINE Optional< Box< N > > getBoundingBox(const Transformation< N > &transformation) const
Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Definition Shape.hpp:1831
Distance halfExtent
Definition Shape.hpp:1818
GREM_ALWAYS_INLINE ConvexPolytopeVertexIndex getFirstVertexIndexOfEdge(ConvexPolytopeEdgeIndex edgeIndex) const
Get the vertex index of the first point of a specific edge on the convex polyhedron defined by this 3...
Definition Shape.hpp:1911
GREM_ALWAYS_INLINE Length< N > getLocalSupportPointOffset(Direction< N > localDirection) const
Get the local offset from the origin of the shape to the farthest point on the shape in a certain loc...
Definition Shape.hpp:1856
GREM_ALWAYS_INLINE Length< N > getLocalVertexOffset(ConvexPolytopeVertexIndex vertexIndex) const
Get the local offset of a specific vertex in the convex polytope defined by this shape.
Definition Shape.hpp:1890
GREM_ALWAYS_INLINE bool containsLocalPoint(Length< N > localPoint) const
Check if a local point relative to the origin of the shape is contained within the shape.
Definition Shape.hpp:1851
GREM_ALWAYS_INLINE ConvexPolytopeFaceIndex getFaceIndexWithMostFittingLocalNormal(Direction< N > localDirection, ConvexPolytopeFaceIndex searchStartFaceIndex) const
Get the index of the face on the convex polytope defined by this shape whose local normal is the most...
Definition Shape.hpp:1905
GREM_ALWAYS_INLINE Volume calculateVolume() const
Calculate an estimate of the volume of the shape.
Definition Shape.hpp:1821
GREM_ALWAYS_INLINE ConvexPolytopeVertexIndex getVertexCount() const
Get the total number of vertices in the convex polytope defined by this shape.
Definition Shape.hpp:1867
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius(const Basis< N > &basis) const
Get the radius of the bounding sphere of the shape.
Definition Shape.hpp:1836
GREM_ALWAYS_INLINE ConvexPolytopeFaceIndex getFaceCount() const
Get the total number of faces on the convex polytope defined by this shape.
Definition Shape.hpp:1876
GREM_ALWAYS_INLINE Length< N > getLocalFaceOffset(ConvexPolytopeFaceIndex faceIndex) const
Get the local offset of a specific face on the convex polytope defined by this shape.
Definition Shape.hpp:1895
GREM_ALWAYS_INLINE ConvexPolytopeEdgeIndex getNextEdgeIndex(ConvexPolytopeEdgeIndex edgeIndex) const
Get the index of the next edge after another edge on the same face on the convex polyhedron defined b...
Definition Shape.hpp:1921
GREM_ALWAYS_INLINE PrincipalMomentsOfInertia< N > calculatePrincipalMomentsOfInertia(Mass mass) const
Calculate an estimate of the local moment of inertia of the shape given a certain mass.
Definition Shape.hpp:1826
GREM_ALWAYS_INLINE ConvexPolytopeVertexIndex getLocalSupportPointVertexIndex(Direction< N > localDirection, ConvexPolytopeVertexIndex searchStartVertexIndex) const
Get the vertex index of the farthest point on the shape in a certain local direction.
Definition Shape.hpp:1861
GREM_ALWAYS_INLINE Optional< Area > getReferenceArea(const Basis< N > &basis, Direction< N > direction) const
Get an estimate of the reference area of the shape for a certain direction, typically calculated as t...
Definition Shape.hpp:1841
GREM_ALWAYS_INLINE Direction< N > getLocalFaceNormal(ConvexPolytopeFaceIndex faceIndex) const
Get the local normal of a specific face on the convex polytope defined by this shape.
Definition Shape.hpp:1900
GREM_ALWAYS_INLINE ConvexPolytopeEdgeIndex getSomeEdgeIndexOfVertex(ConvexPolytopeVertexIndex vertexIndex) const
Get the index of some edge that has a specific vertex as its origin on the convex polyhedron defined ...
Definition Shape.hpp:1931
GREM_ALWAYS_INLINE ConvexPolytopeEdgeIndex getFirstEdgeIndexOfFace(ConvexPolytopeFaceIndex faceIndex) const
Get the index of the first edge that a specific face is made up of on the convex polyhedron defined b...
Definition Shape.hpp:1926
GREM_ALWAYS_INLINE ConvexPolytopeEdgeIndex getEdgeCount() const
Get the total number of edges, including twin edges, on the convex polyhedron defined by this 3-dimen...
Definition Shape.hpp:1885
Cylinder shape aligned with the local Y axis in 3-dimensional world space.
Definition Shape.hpp:2155
bool containsLocalPoint(Length3D localPoint) const
Check if a local point relative to the origin of the shape is contained within the shape.
Distance radius
Radius of the cylinder. Must be positive.
Definition Shape.hpp:2156
PrincipalMomentsOfInertia3D calculatePrincipalMomentsOfInertia(Mass mass) const
Calculate an estimate of the local moment of inertia of the shape given a certain mass.
Optional< Area > getReferenceArea(const Basis3D &basis, Direction3D direction) const
Get an estimate of the reference area of the shape for a certain direction, typically calculated as t...
Volume calculateVolume() const
Calculate an estimate of the volume of the shape.
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius(const Basis3D &basis) const
Get the radius of the bounding sphere of the shape.
Definition Shape.hpp:2173
GREM_ALWAYS_INLINE Optional< Box3D > getBoundingBox(const Transformation3D &transformation) const
Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Definition Shape.hpp:2166
Length3D getLocalSupportPointOffset(Direction3D localDirection) const
Get the local offset from the origin of the shape to the farthest point on the shape in a certain loc...
RaycastResult3D castLocalRay(Length3D localRayOrigin, Direction3D localRayDirection, Distance maxLocalRayDistance) const
Find the closest intersection of this shape with a given ray in local space.
Distance halfLength
Half of the length of the cylinder's center line along its local Y axis. Must be positive.
Definition Shape.hpp:2157
Normalized unit vector.
Definition quantities.hpp:4105
static GREM_ALWAYS_INLINE constexpr Direction reinterpret(auto other)
Definition quantities.hpp:4117
Ellipsoid shape.
Definition Shape.hpp:1949
Optional< Area > getReferenceArea(const Basis< N > &basis, Direction< N > direction) const
Get an estimate of the reference area of the shape for a certain direction, typically calculated as t...
Volume calculateVolume() const
Calculate an estimate of the volume of the shape.
Length< N > getLocalSupportPointOffset(Direction< N > localDirection) const
Get the local offset from the origin of the shape to the farthest point on the shape in a certain loc...
PrincipalMomentsOfInertia< N > calculatePrincipalMomentsOfInertia(Mass mass) const
Calculate an estimate of the local moment of inertia of the shape given a certain mass.
bool containsLocalPoint(Length< N > localPoint) const
Check if a local point relative to the origin of the shape is contained within the shape.
Length< N > radii
Definition Shape.hpp:1950
GREM_ALWAYS_INLINE Optional< Box< N > > getBoundingBox(const Transformation< N > &transformation) const
Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Definition Shape.hpp:1959
RaycastResult< N > castLocalRay(Length< N > localRayOrigin, Direction< N > localRayDirection, Distance maxLocalRayDistance) const
Find the closest intersection of this shape with a given ray in local space.
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius(const Basis< N > &basis) const
Get the radius of the bounding sphere of the shape.
Definition Shape.hpp:1964
Infinite half-space shape perpendicular to the local Y axis.
Definition Shape.hpp:1623
GREM_ALWAYS_INLINE Volume calculateVolume() const
Calculate an estimate of the volume of the shape.
Definition Shape.hpp:1625
RaycastResult< N > castLocalRay(Length< N > localRayOrigin, Direction< N > localRayDirection, Distance maxLocalRayDistance) const
Find the closest intersection of this shape with a given ray in local space.
GREM_ALWAYS_INLINE PrincipalMomentsOfInertia< N > calculatePrincipalMomentsOfInertia(Mass mass) const
Calculate an estimate of the local moment of inertia of the shape given a certain mass.
Definition Shape.hpp:1630
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius(const Basis< N > &basis) const
Get the radius of the bounding sphere of the shape.
Definition Shape.hpp:1642
GREM_ALWAYS_INLINE Optional< Box< N > > getBoundingBox(const Transformation< N > &transformation) const
Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Definition Shape.hpp:1636
GREM_ALWAYS_INLINE Optional< Area > getReferenceArea(const Basis< N > &basis, Direction< N > direction) const
Get an estimate of the reference area of the shape for a certain direction, typically calculated as t...
Definition Shape.hpp:1648
Infinite line shape parallel to the local Y axis.
Definition Shape.hpp:1560
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius(const Basis< N > &basis) const
Get the radius of the bounding sphere of the shape.
Definition Shape.hpp:1579
GREM_ALWAYS_INLINE Optional< Box< N > > getBoundingBox(const Transformation< N > &transformation) const
Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Definition Shape.hpp:1573
GREM_ALWAYS_INLINE PrincipalMomentsOfInertia< N > calculatePrincipalMomentsOfInertia(Mass mass) const
Calculate an estimate of the local moment of inertia of the shape given a certain mass.
Definition Shape.hpp:1567
GREM_ALWAYS_INLINE bool containsLocalPoint(Length< N > localPoint) const
Check if a local point relative to the origin of the shape is contained within the shape.
Definition Shape.hpp:1600
GREM_ALWAYS_INLINE Volume calculateVolume() const
Calculate an estimate of the volume of the shape.
Definition Shape.hpp:1562
GREM_ALWAYS_INLINE RaycastResult< N > castLocalRay(Length< N > localRayOrigin, Direction< N > localRayDirection, Distance maxLocalRayDistance) const
Find the closest intersection of this shape with a given ray in local space.
Definition Shape.hpp:1592
GREM_ALWAYS_INLINE Optional< Area > getReferenceArea(const Basis< N > &basis, Direction< N > direction) const
Get an estimate of the reference area of the shape for a certain direction, typically calculated as t...
Definition Shape.hpp:1585
GREM_ALWAYS_INLINE Length< N > getLocalSupportPointOffset(Direction< N > localDirection) const
Get the local offset from the origin of the shape to the farthest point on the shape in a certain loc...
Definition Shape.hpp:1606
Infinite plane shape perpendicular to the local Y axis in 3-dimensional space.
Definition Shape.hpp:1668
RaycastResult3D castLocalRay(Length3D localRayOrigin, Direction3D localRayDirection, Distance maxLocalRayDistance) const
Find the closest intersection of this shape with a given ray in local space.
GREM_ALWAYS_INLINE PrincipalMomentsOfInertia3D calculatePrincipalMomentsOfInertia(Mass mass) const
Calculate an estimate of the local moment of inertia of the shape given a certain mass.
Definition Shape.hpp:1675
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius(const Basis3D &basis) const
Get the radius of the bounding sphere of the shape.
Definition Shape.hpp:1687
GREM_ALWAYS_INLINE Optional< Area > getReferenceArea(const Basis3D &basis, Direction3D direction) const
Get an estimate of the reference area of the shape for a certain direction, typically calculated as t...
Definition Shape.hpp:1693
GREM_ALWAYS_INLINE Volume calculateVolume() const
Calculate an estimate of the volume of the shape.
Definition Shape.hpp:1670
GREM_ALWAYS_INLINE Optional< Box3D > getBoundingBox(const Transformation3D &transformation) const
Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Definition Shape.hpp:1681
Line segment shape parallel to the local Y axis.
Definition Shape.hpp:1490
GREM_ALWAYS_INLINE Volume calculateVolume() const
Calculate an estimate of the volume of the shape.
Definition Shape.hpp:1494
GREM_ALWAYS_INLINE RaycastResult< N > castLocalRay(Length< N > localRayOrigin, Direction< N > localRayDirection, Distance maxLocalRayDistance) const
Find the closest intersection of this shape with a given ray in local space.
Definition Shape.hpp:1527
GREM_ALWAYS_INLINE Optional< Box< N > > getBoundingBox(const Transformation< N > &transformation) const
Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Definition Shape.hpp:1507
Distance halfLength
Definition Shape.hpp:1491
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius(const Basis< N > &basis) const
Get the radius of the bounding sphere of the shape.
Definition Shape.hpp:1515
GREM_ALWAYS_INLINE Optional< Area > getReferenceArea(const Basis< N > &basis, Direction< N > direction) const
Get an estimate of the reference area of the shape for a certain direction, typically calculated as t...
Definition Shape.hpp:1520
GREM_ALWAYS_INLINE bool containsLocalPoint(Length< N > localPoint) const
Check if a local point relative to the origin of the shape is contained within the shape.
Definition Shape.hpp:1535
GREM_ALWAYS_INLINE Length< N > getLocalSupportPointOffset(Direction< N > localDirection) const
Get the local offset from the origin of the shape to the farthest point on the shape in a certain loc...
Definition Shape.hpp:1541
GREM_ALWAYS_INLINE PrincipalMomentsOfInertia< N > calculatePrincipalMomentsOfInertia(Mass mass) const
Calculate an estimate of the local moment of inertia of the shape given a certain mass.
Definition Shape.hpp:1500
Description of a line segment in world space.
Definition Shape.hpp:750
static GREM_ALWAYS_INLINE constexpr LineSegment reinterpret(const grem::LineSegment< N, T > &line) noexcept
Reinterpret a unitless line segment as a physical line segment in default units.
Definition Shape.hpp:767
static constexpr MagnitudeType MAGNITUDE
Definition Shape.hpp:756
typename Unit::DimensionType DimensionType
Unit dimension type.
Definition Shape.hpp:752
GREM_ALWAYS_INLINE constexpr grem::LineSegment< N, Scalar > in(OtherUnitT unit) const noexcept
Convert this physical line segment to a unitless line segment given a desired unit.
Definition Shape.hpp:783
static constexpr DimensionType DIMENSION
Definition Shape.hpp:755
bool operator==(const LineSegment &other) const =default
Compare this line segment to another for equality.
static constexpr Unit UNIT
Definition Shape.hpp:754
typename Unit::MagnitudeType MagnitudeType
Unit magnitude type.
Definition Shape.hpp:753
Position< N > pointA
Definition Shape.hpp:771
Position< N > pointB
Definition Shape.hpp:772
typename Position< N >::Unit Unit
Unit type.
Definition Shape.hpp:751
Absolute orientation in world space.
Definition quantities.hpp:4431
Description of an infinite plane in world space.
Definition Shape.hpp:721
typename Unit::DimensionType DimensionType
Unit dimension type.
Definition Shape.hpp:723
static constexpr MagnitudeType MAGNITUDE
Definition Shape.hpp:727
static constexpr Unit UNIT
Definition Shape.hpp:725
typename Unit::MagnitudeType MagnitudeType
Unit magnitude type.
Definition Shape.hpp:724
Direction< N > normal
Definition Shape.hpp:730
static constexpr DimensionType DIMENSION
Definition Shape.hpp:726
bool operator==(const Plane &other) const =default
Compare this plane to another for equality.
typename Position< N >::Unit Unit
Unit type.
Definition Shape.hpp:722
Position< N > point
Definition Shape.hpp:729
Point shape.
Definition Shape.hpp:1427
GREM_ALWAYS_INLINE PrincipalMomentsOfInertia< N > calculatePrincipalMomentsOfInertia(Mass mass) const
Calculate an estimate of the local moment of inertia of the shape given a certain mass.
Definition Shape.hpp:1434
GREM_ALWAYS_INLINE bool containsLocalPoint(Length< N > localPoint) const
Check if a local point relative to the origin of the shape is contained within the shape.
Definition Shape.hpp:1466
GREM_ALWAYS_INLINE Optional< Box< N > > getBoundingBox(const Transformation< N > &transformation) const
Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Definition Shape.hpp:1440
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius(const Basis< N > &basis) const
Get the radius of the bounding sphere of the shape.
Definition Shape.hpp:1445
GREM_ALWAYS_INLINE Optional< Area > getReferenceArea(const Basis< N > &basis, Direction< N > direction) const
Get an estimate of the reference area of the shape for a certain direction, typically calculated as t...
Definition Shape.hpp:1451
GREM_ALWAYS_INLINE RaycastResult< N > castLocalRay(Length< N > localRayOrigin, Direction< N > localRayDirection, Distance maxLocalRayDistance) const
Find the closest intersection of this shape with a given ray in local space.
Definition Shape.hpp:1458
GREM_ALWAYS_INLINE Volume calculateVolume() const
Calculate an estimate of the volume of the shape.
Definition Shape.hpp:1429
GREM_ALWAYS_INLINE Length< N > getLocalSupportPointOffset(Direction< N > localDirection) const
Get the local offset from the origin of the shape to the farthest point on the shape in a certain loc...
Definition Shape.hpp:1472
Result of a raycast interior hit.
Definition Shape.hpp:601
typename Unit::MagnitudeType MagnitudeType
Unit magnitude type.
Definition Shape.hpp:604
typename Distance::Unit Unit
Unit type.
Definition Shape.hpp:602
Length< N > localOffset
Definition Shape.hpp:621
typename Unit::DimensionType DimensionType
Unit dimension type.
Definition Shape.hpp:603
static constexpr MagnitudeType MAGNITUDE
Definition Shape.hpp:607
static GREM_ALWAYS_INLINE constexpr RayHitInterior reinterpret(const grem::RayHitInterior< N, T > &hit) noexcept
Reinterpret a unitless ray hit as a physical ray hit in default units.
Definition Shape.hpp:617
static constexpr DimensionType DIMENSION
Definition Shape.hpp:606
static constexpr Unit UNIT
Definition Shape.hpp:605
GREM_ALWAYS_INLINE constexpr grem::RayHitInterior< N, Scalar > in(OtherUnitT unit) const noexcept
Convert this physical ray hit to a unitless ray hit given a desired unit.
Definition Shape.hpp:631
Result of a raycast hit.
Definition Shape.hpp:542
typename Unit::MagnitudeType MagnitudeType
Unit magnitude type.
Definition Shape.hpp:545
static GREM_ALWAYS_INLINE constexpr RayHit reinterpret(const grem::RayHit< N, T > &hit) noexcept
Reinterpret a unitless ray hit as a physical ray hit in default units.
Definition Shape.hpp:558
typename Position< N >::Unit Unit
Unit type.
Definition Shape.hpp:543
static constexpr Unit UNIT
Definition Shape.hpp:546
Length< N > localOffset
Definition Shape.hpp:566
static constexpr MagnitudeType MAGNITUDE
Definition Shape.hpp:548
typename Unit::DimensionType DimensionType
Unit dimension type.
Definition Shape.hpp:544
static constexpr DimensionType DIMENSION
Definition Shape.hpp:547
Direction< N > normal
Definition Shape.hpp:568
GREM_ALWAYS_INLINE constexpr grem::RayHit< N, Scalar > in(OtherUnitT unit) const noexcept
Convert this physical ray hit to a unitless ray hit given a desired unit.
Definition Shape.hpp:578
Distance distance
Definition Shape.hpp:567
Result of a raycast miss.
Definition Shape.hpp:493
static GREM_ALWAYS_INLINE constexpr RayMiss reinterpret(const grem::RayMiss &miss) noexcept
Reinterpret a unitless ray miss as a physical ray miss in default units.
Definition Shape.hpp:508
typename Unit::DimensionType DimensionType
Unit dimension type.
Definition Shape.hpp:495
GREM_ALWAYS_INLINE constexpr grem::RayMiss in(OtherUnitT unit) const noexcept
Convert this physical ray miss to a unitless ray miss given a desired unit.
Definition Shape.hpp:522
typename Unit::MagnitudeType MagnitudeType
Unit magnitude type.
Definition Shape.hpp:496
static constexpr MagnitudeType MAGNITUDE
Unit magnitude.
Definition Shape.hpp:499
static constexpr DimensionType DIMENSION
Unit dimension.
Definition Shape.hpp:498
typename Distance::Unit Unit
Unit type.
Definition Shape.hpp:494
static constexpr Unit UNIT
Unit.
Definition Shape.hpp:497
Description of a ray.
Definition Shape.hpp:392
Position< N > origin
Definition Shape.hpp:437
static constexpr DimensionType DIMENSION
Definition Shape.hpp:397
static GREM_ALWAYS_INLINE constexpr Ray reinterpret(const grem::Ray< N, T > &ray) noexcept
Reinterpret a unitless ray as a physical ray in default units.
Definition Shape.hpp:425
typename Position< N >::Unit Unit
Unit type.
Definition Shape.hpp:393
typename Unit::DimensionType DimensionType
Unit dimension type.
Definition Shape.hpp:394
GREM_ALWAYS_INLINE constexpr grem::Ray< N, Scalar > in(OtherUnitT unit) const noexcept
Convert this physical ray to a unitless ray given a desired unit.
Definition Shape.hpp:468
static constexpr Optional< Ray > between(Position< N > origin, Position< N > destination)
Create a ray between two points.
Definition Shape.hpp:410
Scale< N > directionInverse
Definition Shape.hpp:458
typename Unit::MagnitudeType MagnitudeType
Unit magnitude type.
Definition Shape.hpp:395
static constexpr MagnitudeType MAGNITUDE
Definition Shape.hpp:398
static constexpr Unit UNIT
Definition Shape.hpp:396
Direction< N > direction
Definition Shape.hpp:444
Distance maxDistance
Definition Shape.hpp:451
Result of a raycast.
Definition Shape.hpp:654
static GREM_ALWAYS_INLINE constexpr RaycastResult reinterpret(const grem::RaycastResult< N, T > &raycastResult) noexcept
Reinterpret a unitless raycast result as a physical raycast result in default units.
Definition Shape.hpp:671
static constexpr MagnitudeType MAGNITUDE
Definition Shape.hpp:660
GREM_ALWAYS_INLINE constexpr grem::RaycastResult< N, Scalar > in(OtherUnitT unit) const
Convert this physical raycast result to a unitless raycast result given a desired unit.
Definition Shape.hpp:697
static constexpr Unit UNIT
Definition Shape.hpp:658
static constexpr DimensionType DIMENSION
Definition Shape.hpp:659
typename Unit::MagnitudeType MagnitudeType
Unit magnitude type.
Definition Shape.hpp:657
typename Unit::DimensionType DimensionType
Unit dimension type.
Definition Shape.hpp:656
typename Position< N >::Unit Unit
Unit type.
Definition Shape.hpp:655
constexpr Variant() noexcept(std::is_nothrow_default_constructible_v< variant_alternative_t< 0, Variant > >)
Default-construct a variant with the first variant alternative, if it is default-constructible.
Definition Variant.hpp:351
bool isConvexShapeType() const
Check if the shape held by this wrapper is a convex shape type.
Definition Shape.hpp:2620
Variant value_type
Definition Shape.hpp:2610
bool isConvexPolytopeShapeType() const
Check if the shape held by this wrapper is a convex polytope shape type.
Definition Shape.hpp:2630
bool isConvexPolytopeShapeType() const
Check if the shape held by this wrapper is a convex polytope shape type.
Definition Shape.hpp:2731
constexpr Variant() noexcept(std::is_nothrow_default_constructible_v< variant_alternative_t< 0, Variant > >)
Default-construct a variant with the first variant alternative, if it is default-constructible.
Definition Variant.hpp:351
Variant value_type
Definition Shape.hpp:2711
bool isConvexShapeType() const
Check if the shape held by this wrapper is a convex shape type.
Definition Shape.hpp:2721
Generic shape.
Definition Shape.hpp:2471
Sphere shape.
Definition Shape.hpp:1994
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius(const Basis< N > &basis) const
Get the radius of the bounding sphere of the shape.
Definition Shape.hpp:2016
bool containsLocalPoint(Length< N > localPoint) const
Check if a local point relative to the origin of the shape is contained within the shape.
GREM_ALWAYS_INLINE Optional< Area > getReferenceArea(const Basis< N > &basis, Direction< N > direction) const
Get an estimate of the reference area of the shape for a certain direction, typically calculated as t...
Definition Shape.hpp:2021
RaycastResult< N > castLocalRay(Length< N > localRayOrigin, Direction< N > localRayDirection, Distance maxLocalRayDistance) const
Find the closest intersection of this shape with a given ray in local space.
GREM_ALWAYS_INLINE PrincipalMomentsOfInertia< N > calculatePrincipalMomentsOfInertia(Mass mass) const
Calculate an estimate of the local moment of inertia of the shape given a certain mass.
Definition Shape.hpp:2003
Distance radius
Definition Shape.hpp:1995
Length< N > getLocalSupportPointOffset(Direction< N > localDirection) const
Get the local offset from the origin of the shape to the farthest point on the shape in a certain loc...
GREM_ALWAYS_INLINE Optional< Box< N > > getBoundingBox(const Transformation< N > &transformation) const
Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Definition Shape.hpp:2008
GREM_ALWAYS_INLINE Volume calculateVolume() const
Calculate an estimate of the volume of the shape.
Definition Shape.hpp:1998
Description of a sphere in world space.
Definition Shape.hpp:956
static constexpr MagnitudeType MAGNITUDE
Definition Shape.hpp:962
GREM_ALWAYS_INLINE constexpr bool intersects(const Ray< N > &ray) const noexcept
Check if this sphere intersects a given ray.
Definition Shape.hpp:1031
typename Position< N >::Unit Unit
Unit type.
Definition Shape.hpp:957
typename Unit::MagnitudeType MagnitudeType
Unit magnitude type.
Definition Shape.hpp:959
GREM_ALWAYS_INLINE constexpr RaycastResult< N > raycast(const Ray< N > &ray) const noexcept
Find the closest intersection of this sphere with a given ray.
Definition Shape.hpp:1042
Distance radius
Definition Shape.hpp:977
GREM_ALWAYS_INLINE constexpr Box< N > getBoundingBox() const noexcept
Get the axis-aligned bounding box of the sphere.
Definition Shape.hpp:1051
static constexpr DimensionType DIMENSION
Definition Shape.hpp:961
typename Unit::DimensionType DimensionType
Unit dimension type.
Definition Shape.hpp:958
Position< N > center
Definition Shape.hpp:976
GREM_ALWAYS_INLINE constexpr bool contains(const Position< N > &point) const noexcept
Check if a given point is contained within the extents of this sphere.
Definition Shape.hpp:1007
static GREM_ALWAYS_INLINE constexpr Sphere reinterpret(const grem::Sphere< N, T > &sphere) noexcept
Reinterpret a unitless sphere as a physical sphere in default units.
Definition Shape.hpp:972
static constexpr Unit UNIT
Definition Shape.hpp:960
GREM_ALWAYS_INLINE constexpr grem::Sphere< N, Scalar > in(OtherUnitT unit) const noexcept
Convert this physical sphere to a unitless sphere given a desired unit.
Definition Shape.hpp:987
bool operator==(const Sphere &other) const =default
Compare this sphere to another for equality.
GREM_ALWAYS_INLINE friend constexpr bool intersects(const Sphere &a, const Sphere &b) noexcept
Check if two spheres intersect.
Definition Shape.hpp:1020
Sub-collider of a compound collider shape.
Definition Shape.hpp:2820
Collider< N > collider
Definition Shape.hpp:2821
Length< N > localOffset
Definition Shape.hpp:2822
Orientation< N > localOrientation
Definition Shape.hpp:2823
Scale< N > localScale
Definition Shape.hpp:2824
Tapered capsule shape aligned with the local Y axis.
Definition Shape.hpp:2103
Distance halfLength
Definition Shape.hpp:2106
Distance bottomRadius
Definition Shape.hpp:2104
GREM_ALWAYS_INLINE Optional< Box< N > > getBoundingBox(const Transformation< N > &transformation) const
Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Definition Shape.hpp:2115
Optional< Area > getReferenceArea(const Basis< N > &basis, Direction< N > direction) const
Get an estimate of the reference area of the shape for a certain direction, typically calculated as t...
Distance topRadius
Definition Shape.hpp:2105
Length< N > getLocalSupportPointOffset(Direction< N > localDirection) const
Get the local offset from the origin of the shape to the farthest point on the shape in a certain loc...
bool containsLocalPoint(Length< N > localPoint) const
Check if a local point relative to the origin of the shape is contained within the shape.
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius(const Basis< N > &basis) const
Get the radius of the bounding sphere of the shape.
Definition Shape.hpp:2124
PrincipalMomentsOfInertia< N > calculatePrincipalMomentsOfInertia(Mass mass) const
Calculate an estimate of the local moment of inertia of the shape given a certain mass.
RaycastResult< N > castLocalRay(Length< N > localRayOrigin, Direction< N > localRayDirection, Distance maxLocalRayDistance) const
Find the closest intersection of this shape with a given ray in local space.
Volume calculateVolume() const
Calculate an estimate of the volume of the shape.
Conical frustum shape aligned with the local Y axis in 3-dimensional space.
Definition Shape.hpp:2196
Distance topRadius
Radius of the top (+Y) disc of the conical frustum. Must be non-negative. Must be positive if bottomR...
Definition Shape.hpp:2198
Distance halfLength
Half of the length of the conical frustum's center line along its local Y axis. Must be positive.
Definition Shape.hpp:2199
GREM_ALWAYS_INLINE Optional< Distance > getBoundingRadius(const Basis3D &basis) const
Get the radius of the bounding sphere of the shape.
Definition Shape.hpp:2218
RaycastResult3D castLocalRay(Length3D localRayOrigin, Direction3D localRayDirection, Distance maxLocalRayDistance) const
Find the closest intersection of this shape with a given ray in local space.
Optional< Area > getReferenceArea(const Basis3D &basis, Direction3D direction) const
Get an estimate of the reference area of the shape for a certain direction, typically calculated as t...
GREM_ALWAYS_INLINE Optional< Box3D > getBoundingBox(const Transformation3D &transformation) const
Get the axis-aligned bounding box of the shape given its position and orientation in the world.
Definition Shape.hpp:2208
Volume calculateVolume() const
Calculate an estimate of the volume of the shape.
Distance bottomRadius
Radius of the bottom (-Y) disc of the conical frustum. Must be non-negative. Must be positive if topR...
Definition Shape.hpp:2197
Length3D getLocalSupportPointOffset(Direction3D localDirection) const
Get the local offset from the origin of the shape to the farthest point on the shape in a certain loc...
PrincipalMomentsOfInertia3D calculatePrincipalMomentsOfInertia(Mass mass) const
Calculate an estimate of the local moment of inertia of the shape given a certain mass.
bool containsLocalPoint(Length3D localPoint) const
Check if a local point relative to the origin of the shape is contained within the shape.
GREM_ALWAYS_INLINE Quantity< N, Square< Relative< UnitT > > > getScale2() const noexcept
Definition quantities.hpp:3798
GREM_ALWAYS_INLINE Quantity< N, Relative< UnitT > > getScale() const noexcept
Definition quantities.hpp:3790
Description of a triangle in world space.
Definition Shape.hpp:1073
GREM_ALWAYS_INLINE constexpr bool contains(const Position< N > &point) const noexcept
Check if a given point is contained within the extents of this triangle.
Definition Shape.hpp:1134
bool operator==(const Triangle &other) const =default
Compare this triangle to another for equality.
typename Unit::DimensionType DimensionType
Unit dimension type.
Definition Shape.hpp:1075
Position< N > pointC
Definition Shape.hpp:1099
GREM_ALWAYS_INLINE constexpr RaycastResult< N > raycast(const Ray< N > &ray) const noexcept
Find the closest intersection of this triangle with a given ray.
Definition Shape.hpp:1156
Position< N > pointA
Definition Shape.hpp:1097
static constexpr Unit UNIT
Definition Shape.hpp:1077
static constexpr MagnitudeType MAGNITUDE
Definition Shape.hpp:1079
typename Unit::MagnitudeType MagnitudeType
Unit magnitude type.
Definition Shape.hpp:1076
static GREM_ALWAYS_INLINE constexpr Triangle reinterpret(const grem::Triangle< N, T > &triangle) noexcept
Reinterpret a unitless triangle as a physical triangle in default units.
Definition Shape.hpp:1089
GREM_ALWAYS_INLINE constexpr Box< N > getBoundingBox() const noexcept
Get the axis-aligned bounding box of the triangle.
Definition Shape.hpp:1165
GREM_ALWAYS_INLINE constexpr bool intersects(const Ray< N > &ray) const noexcept
Check if this triangle intersects a given ray.
Definition Shape.hpp:1145
Position< N > pointB
Definition Shape.hpp:1098
GREM_ALWAYS_INLINE constexpr grem::Triangle< N, Scalar > in(OtherUnitT unit) const noexcept
Convert this physical triangle to a unitless triangle given a desired unit.
Definition Shape.hpp:1110
typename Position< N >::Unit Unit
Unit type.
Definition Shape.hpp:1074
static constexpr DimensionType DIMENSION
Definition Shape.hpp:1078