Cuberite
A lightweight, fast and extensible game server for Minecraft
|
Represents two sets of coords, minimum and maximum for each direction. More...
#include <BoundingBox.h>
Public Member Functions | |
bool | CalcLineIntersection (Vector3d a_LinePoint1, Vector3d a_LinePoint2, double &a_LineCoeff, eBlockFace &a_Face) const |
Returns true if this bounding box is intersected by the line specified by its two points Also calculates the distance along the line in which the intersection occurs, and the face hit (BLOCK_FACE_ constants) Only forward collisions (a_LineCoeff >= 0) are returned. More... | |
cBoundingBox (double a_MinX, double a_MaxX, double a_MinY, double a_MaxY, double a_MinZ, double a_MaxZ) | |
cBoundingBox (Vector3d a_Min, Vector3d a_Max) | |
cBoundingBox (Vector3d a_Pos, double a_CubeLength) | |
cBoundingBox (Vector3d a_Pos, double a_Radius, double a_Height) | |
cBoundingBox (Vector3d a_Pos, double a_Radius, double a_Height, double a_VerticalOffset) | |
Constructor that allows to define a bounding box given a center point (a_Pos), a horizontal radius (a_Radius), a height starting from given center point (a_Height) and a vertical offset (a_VerticalOffset) to adjust the vertical starting point. More... | |
bool | DoesIntersect (const cBoundingBox &a_Other) |
Returns true if the two bounding boxes intersect. More... | |
void | Expand (double a_ExpandX, double a_ExpandY, double a_ExpandZ) |
Expands the bounding box by the specified amount in each direction (so the box becomes larger by 2 * Expand in each direction) More... | |
Vector3d | GetMax (void) const |
double | GetMaxX (void) const |
double | GetMaxY (void) const |
double | GetMaxZ (void) const |
Vector3d | GetMin (void) const |
double | GetMinX (void) const |
double | GetMinY (void) const |
double | GetMinZ (void) const |
bool | Intersect (const cBoundingBox &a_Other, cBoundingBox &a_Intersection) const |
Calculates the intersection of the two bounding boxes; returns true if nonempty. More... | |
bool | IsInside (cBoundingBox &a_Other) |
Returns true if a_Other is inside this bounding box. More... | |
bool | IsInside (double a_X, double a_Y, double a_Z) |
Returns true if the point is inside the bounding box. More... | |
bool | IsInside (Vector3d a_Min, Vector3d a_Max) |
Returns true if a boundingbox specified by a_Min and a_Max is inside this bounding box. More... | |
bool | IsInside (Vector3d a_Point) |
Returns true if the point is inside the bounding box. More... | |
void | Move (double a_OffX, double a_OffY, double a_OffZ) |
Moves the entire boundingbox by the specified offset. More... | |
void | Move (Vector3d a_Off) |
Moves the entire boundingbox by the specified offset. More... | |
cBoundingBox | Union (const cBoundingBox &a_Other) |
Returns the union of the two bounding boxes. More... | |
Static Public Member Functions | |
static bool | CalcLineIntersection (Vector3d a_Min, Vector3d a_Max, Vector3d a_LinePoint1, Vector3d a_LinePoint2, double &a_LineCoeff, eBlockFace &a_Face) |
Returns true if the specified bounding box is intersected by the line specified by its two points Also calculates the distance along the line in which the intersection occurs, and the face hit (BLOCK_FACE_ constants) Only forward collisions (a_LineCoeff >= 0) are returned. More... | |
static bool | IsInside (Vector3d a_Min, Vector3d a_Max, double a_X, double a_Y, double a_Z) |
Returns true if the specified point is inside the bounding box specified by its min / max corners. More... | |
static bool | IsInside (Vector3d a_Min, Vector3d a_Max, Vector3d a_Point) |
Returns true if the specified point is inside the bounding box specified by its min / max corners. More... | |
Protected Attributes | |
Vector3d | m_Max |
Vector3d | m_Min |
Represents two sets of coords, minimum and maximum for each direction.
All the coords within those limits (inclusive the edges) are considered "inside" the box. For intersection purposes, though, if the intersection is "sharp" in any coord (i. e. zero volume), the boxes are considered non-intersecting.
Definition at line 23 of file BoundingBox.h.
cBoundingBox::cBoundingBox | ( | double | a_MinX, |
double | a_MaxX, | ||
double | a_MinY, | ||
double | a_MaxY, | ||
double | a_MinZ, | ||
double | a_MaxZ | ||
) |
Definition at line 12 of file BoundingBox.cpp.
Definition at line 22 of file BoundingBox.cpp.
cBoundingBox::cBoundingBox | ( | Vector3d | a_Pos, |
double | a_Radius, | ||
double | a_Height | ||
) |
Definition at line 32 of file BoundingBox.cpp.
cBoundingBox::cBoundingBox | ( | Vector3d | a_Pos, |
double | a_Radius, | ||
double | a_Height, | ||
double | a_VerticalOffset | ||
) |
Constructor that allows to define a bounding box given a center point (a_Pos), a horizontal radius (a_Radius), a height starting from given center point (a_Height) and a vertical offset (a_VerticalOffset) to adjust the vertical starting point.
For example: cBoundingBox([0, 0, 0], 6, 6, -3) would create a bounding cube from (-3, -3, -3) to (3, 3, 3).
Definition at line 42 of file BoundingBox.cpp.
cBoundingBox::cBoundingBox | ( | Vector3d | a_Pos, |
double | a_CubeLength | ||
) |
Definition at line 52 of file BoundingBox.cpp.
bool cBoundingBox::CalcLineIntersection | ( | Vector3d | a_LinePoint1, |
Vector3d | a_LinePoint2, | ||
double & | a_LineCoeff, | ||
eBlockFace & | a_Face | ||
) | const |
Returns true if this bounding box is intersected by the line specified by its two points Also calculates the distance along the line in which the intersection occurs, and the face hit (BLOCK_FACE_ constants) Only forward collisions (a_LineCoeff >= 0) are returned.
Exported to Lua manually, because ToLua++ would generate needless input params (a_LineCoeff, a_Face).
Definition at line 197 of file BoundingBox.cpp.
|
static |
Returns true if the specified bounding box is intersected by the line specified by its two points Also calculates the distance along the line in which the intersection occurs, and the face hit (BLOCK_FACE_ constants) Only forward collisions (a_LineCoeff >= 0) are returned.
Exported to Lua manually, because ToLua++ would generate needless input params (a_LineCoeff, a_Face).
Definition at line 206 of file BoundingBox.cpp.
bool cBoundingBox::DoesIntersect | ( | const cBoundingBox & | a_Other | ) |
Returns true if the two bounding boxes intersect.
Definition at line 104 of file BoundingBox.cpp.
void cBoundingBox::Expand | ( | double | a_ExpandX, |
double | a_ExpandY, | ||
double | a_ExpandZ | ||
) |
Expands the bounding box by the specified amount in each direction (so the box becomes larger by 2 * Expand in each direction)
Definition at line 90 of file BoundingBox.cpp.
|
inline |
Definition at line 101 of file BoundingBox.h.
|
inline |
Definition at line 96 of file BoundingBox.h.
|
inline |
Definition at line 97 of file BoundingBox.h.
|
inline |
Definition at line 98 of file BoundingBox.h.
|
inline |
Definition at line 100 of file BoundingBox.h.
|
inline |
Definition at line 92 of file BoundingBox.h.
|
inline |
Definition at line 93 of file BoundingBox.h.
|
inline |
Definition at line 94 of file BoundingBox.h.
bool cBoundingBox::Intersect | ( | const cBoundingBox & | a_Other, |
cBoundingBox & | a_Intersection | ||
) | const |
Calculates the intersection of the two bounding boxes; returns true if nonempty.
Exported manually, because ToLua++ would generate needless input params (a_Intersection).
Definition at line 272 of file BoundingBox.cpp.
bool cBoundingBox::IsInside | ( | cBoundingBox & | a_Other | ) |
Returns true if a_Other is inside this bounding box.
Definition at line 151 of file BoundingBox.cpp.
bool cBoundingBox::IsInside | ( | double | a_X, |
double | a_Y, | ||
double | a_Z | ||
) |
Returns true if the point is inside the bounding box.
Definition at line 142 of file BoundingBox.cpp.
Returns true if a boundingbox specified by a_Min and a_Max is inside this bounding box.
Definition at line 161 of file BoundingBox.cpp.
|
static |
Returns true if the specified point is inside the bounding box specified by its min / max corners.
Definition at line 184 of file BoundingBox.cpp.
Returns true if the specified point is inside the bounding box specified by its min / max corners.
Definition at line 171 of file BoundingBox.cpp.
bool cBoundingBox::IsInside | ( | Vector3d | a_Point | ) |
Returns true if the point is inside the bounding box.
Definition at line 133 of file BoundingBox.cpp.
void cBoundingBox::Move | ( | double | a_OffX, |
double | a_OffY, | ||
double | a_OffZ | ||
) |
Moves the entire boundingbox by the specified offset.
Definition at line 62 of file BoundingBox.cpp.
void cBoundingBox::Move | ( | Vector3d | a_Off | ) |
Moves the entire boundingbox by the specified offset.
Definition at line 76 of file BoundingBox.cpp.
cBoundingBox cBoundingBox::Union | ( | const cBoundingBox & | a_Other | ) |
Returns the union of the two bounding boxes.
Definition at line 117 of file BoundingBox.cpp.
|
protected |
Definition at line 107 of file BoundingBox.h.
|
protected |
Definition at line 106 of file BoundingBox.h.