Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
cBoundingBox Class Reference

Represents two sets of coords, minimum and maximum for each direction. More...

#include <BoundingBox.h>

Collaboration diagram for cBoundingBox:
Collaboration graph
[legend]

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ cBoundingBox() [1/5]

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.

◆ cBoundingBox() [2/5]

cBoundingBox::cBoundingBox ( Vector3d  a_Min,
Vector3d  a_Max 
)

Definition at line 22 of file BoundingBox.cpp.

◆ cBoundingBox() [3/5]

cBoundingBox::cBoundingBox ( Vector3d  a_Pos,
double  a_Radius,
double  a_Height 
)

Definition at line 32 of file BoundingBox.cpp.

◆ cBoundingBox() [4/5]

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() [5/5]

cBoundingBox::cBoundingBox ( Vector3d  a_Pos,
double  a_CubeLength 
)

Definition at line 52 of file BoundingBox.cpp.

Member Function Documentation

◆ CalcLineIntersection() [1/2]

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.

◆ CalcLineIntersection() [2/2]

bool cBoundingBox::CalcLineIntersection ( Vector3d  a_Min,
Vector3d  a_Max,
Vector3d  a_LinePoint1,
Vector3d  a_LinePoint2,
double &  a_LineCoeff,
eBlockFace a_Face 
)
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.

◆ DoesIntersect()

bool cBoundingBox::DoesIntersect ( const cBoundingBox a_Other)

Returns true if the two bounding boxes intersect.

Definition at line 104 of file BoundingBox.cpp.

◆ Expand()

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.

◆ GetMax()

Vector3d cBoundingBox::GetMax ( void  ) const
inline

Definition at line 101 of file BoundingBox.h.

◆ GetMaxX()

double cBoundingBox::GetMaxX ( void  ) const
inline

Definition at line 96 of file BoundingBox.h.

◆ GetMaxY()

double cBoundingBox::GetMaxY ( void  ) const
inline

Definition at line 97 of file BoundingBox.h.

◆ GetMaxZ()

double cBoundingBox::GetMaxZ ( void  ) const
inline

Definition at line 98 of file BoundingBox.h.

◆ GetMin()

Vector3d cBoundingBox::GetMin ( void  ) const
inline

Definition at line 100 of file BoundingBox.h.

◆ GetMinX()

double cBoundingBox::GetMinX ( void  ) const
inline

Definition at line 92 of file BoundingBox.h.

◆ GetMinY()

double cBoundingBox::GetMinY ( void  ) const
inline

Definition at line 93 of file BoundingBox.h.

◆ GetMinZ()

double cBoundingBox::GetMinZ ( void  ) const
inline

Definition at line 94 of file BoundingBox.h.

◆ Intersect()

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.

◆ IsInside() [1/6]

bool cBoundingBox::IsInside ( cBoundingBox a_Other)

Returns true if a_Other is inside this bounding box.

Definition at line 151 of file BoundingBox.cpp.

◆ IsInside() [2/6]

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.

◆ IsInside() [3/6]

bool cBoundingBox::IsInside ( Vector3d  a_Min,
Vector3d  a_Max 
)

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.

◆ IsInside() [4/6]

bool cBoundingBox::IsInside ( Vector3d  a_Min,
Vector3d  a_Max,
double  a_X,
double  a_Y,
double  a_Z 
)
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.

◆ IsInside() [5/6]

bool cBoundingBox::IsInside ( Vector3d  a_Min,
Vector3d  a_Max,
Vector3d  a_Point 
)
static

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.

◆ IsInside() [6/6]

bool cBoundingBox::IsInside ( Vector3d  a_Point)

Returns true if the point is inside the bounding box.

Definition at line 133 of file BoundingBox.cpp.

◆ Move() [1/2]

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.

◆ Move() [2/2]

void cBoundingBox::Move ( Vector3d  a_Off)

Moves the entire boundingbox by the specified offset.

Definition at line 76 of file BoundingBox.cpp.

◆ Union()

cBoundingBox cBoundingBox::Union ( const cBoundingBox a_Other)

Returns the union of the two bounding boxes.

Definition at line 117 of file BoundingBox.cpp.

Member Data Documentation

◆ m_Max

Vector3d cBoundingBox::m_Max
protected

Definition at line 107 of file BoundingBox.h.

◆ m_Min

Vector3d cBoundingBox::m_Min
protected

Definition at line 106 of file BoundingBox.h.


The documentation for this class was generated from the following files: