BoxShape¶
class BoxShape : public Shape
A box shape, defined by a width, an height, and a depth.
Operators¶
Name | Description |
---|---|
operator== | Compares this shape with another shape for equality. |
operator!= | Compares this shape with another shape for inequality. |
Functions¶
Name | Description |
---|---|
Create | Creates a new BoxShape from a definition. |
BoxShape | Constructs a new BoxShape . |
BoxShape | Constructs a new BoxShape . |
GetHalfWidth | Gets the half width of the BoxShape . |
GetHalfHeight | Gets the half height of the BoxShape . |
GetHalfDepth | Gets the half depth of the BoxShape . |
GetWidth | Gets the width of the BoxShape . |
GetHeight | Gets the height of the BoxShape . |
GetDepth | Gets the depth of the BoxShape . |
SetHalfWidth | Sets the half width of the BoxShape . |
SetHalfHeight | Sets the half height of the BoxShape . |
SetHalfDepth | Sets the half depth of the BoxShape . |
GetShortestDistanceToEdge | Gets the shortest distance to the edge of this shape. |
Contains | Checks if the given position is contained in this shape. |
GetClosestPoint | Gets the closest point to the given location. |
GetCorners | Gets the corners of the box shape. |
Operator Details¶
operator!=¶
bool operator!=(const BoxShape& other) const
Compares this shape with another shape for inequality.
Note
Shapes are equal if they have the same dimensions, the position, and the same orientation.
- Parameter
other
- The other shape to compare with.
- Return
false
if the shapes are equal,true
otherwise.
operator==¶
bool operator==(const BoxShape& other) const
Compares this shape with another shape for equality.
Note
Shapes are equal if they have the same dimensions, the position, and the same orientation.
- Parameter
other
- The other shape to compare with.
- Return
true
if the shapes are equal,false
otherwise.
Function Details¶
BoxShape¶
explicit BoxShape(AmReal32 halfWidth, AmReal32 halfHeight, AmReal32 halfDepth)
Constructs a new BoxShape
.
- Parameter
halfWidth
- The half width of the box shape.
- Parameter
halfHeight
- The half height of the box shape.
- Parameter
halfDepth
- The half depth of the box shape.
explicit BoxShape(const AmVec3& position, const AmVec3& dimensions)
Constructs a new BoxShape
.
- Parameter
position
- The position of the box shape.
- Parameter
dimensions
- The dimensions of the box shape.
Contains¶
[[nodiscard]] bool Contains(const AmVec3& location) final
Checks if the given position is contained in this shape.
- Parameter
location
- The 3D position to check.
- Return
true
if the shape contains the given position,false
otherwise.
Create¶
static BoxShape* Create(const BoxShapeDefinition* definition)
Creates a new BoxShape
from a definition.
- Parameter
definition
- The definition of the shape generated from a flatbuffer binary.
Warning
This method is intended for internal usage only.
GetClosestPoint¶
[[nodiscard]] AmVec3 GetClosestPoint(const AmVec3& location) const
Gets the closest point to the given location.
- Parameter
location
- The location to get the closest point for.
- Return
- The closest point to the given location.
GetCorners¶
[[nodiscard]] std::array<AmVec3, 8> GetCorners() const
Gets the corners of the box shape.
The returned corners are arranged in the following order:
6 - - - - 4
| \ | \
| 3 - - - - 5
| | | |
1 | - - 7 |
\ | \ |
0 - - - - 2
- Return
- The corners of the box shape.
GetDepth¶
[[nodiscard]] AmReal32 GetDepth() const
Gets the depth of the BoxShape
.
- Return
- The box shape's depth.
GetHalfDepth¶
[[nodiscard]] AmReal32 GetHalfDepth() const
Gets the half depth of the BoxShape
.
- Return
- The box shape's half depth.
GetHalfHeight¶
[[nodiscard]] AmReal32 GetHalfHeight() const
Gets the half height of the BoxShape
.
- Return
- The box shape's half height.
GetHalfWidth¶
[[nodiscard]] AmReal32 GetHalfWidth() const
Gets the half width of the BoxShape
.
- Return
- The box shape's half width.
GetHeight¶
[[nodiscard]] AmReal32 GetHeight() const
Gets the height of the BoxShape
.
- Return
- The box shape's height.
GetShortestDistanceToEdge¶
[[nodiscard]] AmReal32 GetShortestDistanceToEdge(const AmVec3& location) final
Gets the shortest distance to the edge of this shape.
- Parameter
location
- The location from which calculate the distance.
- Return
- The shortest distance from the location to the edge of this shape. If negative, the given location in outside the shape.
GetWidth¶
[[nodiscard]] AmReal32 GetWidth() const
Gets the width of the BoxShape
.
- Return
- The box shape's width.
SetHalfDepth¶
void SetHalfDepth(AmReal32 halfDepth)
Sets the half depth of the BoxShape
.
- Parameter
halfDepth
- The new box shape's half depth.
SetHalfHeight¶
void SetHalfHeight(AmReal32 halfHeight)
Sets the half height of the BoxShape
.
- Parameter
halfHeight
- The new box shape's half height.
SetHalfWidth¶
void SetHalfWidth(AmReal32 halfWidth)
Sets the half width of the BoxShape
.
- Parameter
halfWidth
- The new box shape's half width.