Cuberite
A lightweight, fast and extensible game server for Minecraft
BoundingBox.h
Go to the documentation of this file.
1 
2 // BoundingBox.h
3 
4 // Declares the cBoundingBox class representing an axis-aligned bounding box with floatingpoint coords
5 
6 
7 
8 
9 #pragma once
10 
11 #include "Defines.h"
12 
13 
14 
15 
16 
17 // tolua_begin
18 
24 {
25 public:
26  cBoundingBox(double a_MinX, double a_MaxX, double a_MinY, double a_MaxY, double a_MinZ, double a_MaxZ);
27  cBoundingBox(Vector3d a_Min, Vector3d a_Max);
28  cBoundingBox(Vector3d a_Pos, double a_Radius, double a_Height);
32  cBoundingBox(Vector3d a_Pos, double a_Radius, double a_Height, double a_VerticalOffset);
33  cBoundingBox(Vector3d a_Pos, double a_CubeLength);
34 
35  #ifdef TOLUA_EXPOSITION // tolua isn't aware of implicitly generated copy constructors
36  cBoundingBox(const cBoundingBox & a_Orig);
37  #endif
38 
40  void Move(double a_OffX, double a_OffY, double a_OffZ);
41 
43  void Move(Vector3d a_Off);
44 
46  void Expand(double a_ExpandX, double a_ExpandY, double a_ExpandZ);
47 
49  bool DoesIntersect(const cBoundingBox & a_Other);
50 
52  cBoundingBox Union(const cBoundingBox & a_Other);
53 
55  bool IsInside(Vector3d a_Point);
56 
58  bool IsInside(double a_X, double a_Y, double a_Z);
59 
61  bool IsInside(cBoundingBox & a_Other);
62 
64  bool IsInside(Vector3d a_Min, Vector3d a_Max);
65 
67  static bool IsInside(Vector3d a_Min, Vector3d a_Max, Vector3d a_Point);
68 
70  static bool IsInside(Vector3d a_Min, Vector3d a_Max, double a_X, double a_Y, double a_Z);
71 
72  // tolua_end
73 
78  bool CalcLineIntersection(Vector3d a_LinePoint1, Vector3d a_LinePoint2, double & a_LineCoeff, eBlockFace & a_Face) const;
79 
84  static bool CalcLineIntersection(Vector3d a_Min, Vector3d a_Max, Vector3d a_LinePoint1, Vector3d a_LinePoint2, double & a_LineCoeff, eBlockFace & a_Face);
85 
88  bool Intersect(const cBoundingBox & a_Other, cBoundingBox & a_Intersection) const;
89 
90  // tolua_begin
91 
92  double GetMinX(void) const { return m_Min.x; }
93  double GetMinY(void) const { return m_Min.y; }
94  double GetMinZ(void) const { return m_Min.z; }
95 
96  double GetMaxX(void) const { return m_Max.x; }
97  double GetMaxY(void) const { return m_Max.y; }
98  double GetMaxZ(void) const { return m_Max.z; }
99 
100  Vector3d GetMin(void) const { return m_Min; }
101  Vector3d GetMax(void) const { return m_Max; }
102 
103  // tolua_end
104 
105 protected:
108 
109 } ; // tolua_export
110 
111 
112 
113 
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
Definition: Defines.h:38
Represents two sets of coords, minimum and maximum for each direction.
Definition: BoundingBox.h:24
Vector3d m_Max
Definition: BoundingBox.h:107
double GetMinY(void) const
Definition: BoundingBox.h:93
bool IsInside(Vector3d a_Point)
Returns true if the point is inside the bounding box.
void Move(double a_OffX, double a_OffY, double a_OffZ)
Moves the entire boundingbox by the specified offset.
Definition: BoundingBox.cpp:62
double GetMinZ(void) const
Definition: BoundingBox.h:94
double GetMaxY(void) const
Definition: BoundingBox.h:97
bool DoesIntersect(const cBoundingBox &a_Other)
Returns true if the two bounding boxes intersect.
double GetMaxX(void) const
Definition: BoundingBox.h:96
Vector3d GetMax(void) const
Definition: BoundingBox.h:101
cBoundingBox(double a_MinX, double a_MaxX, double a_MinY, double a_MaxY, double a_MinZ, double a_MaxZ)
Definition: BoundingBox.cpp:12
bool Intersect(const cBoundingBox &a_Other, cBoundingBox &a_Intersection) const
Calculates the intersection of the two bounding boxes; returns true if nonempty.
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 calcula...
Vector3d m_Min
Definition: BoundingBox.h:106
double GetMinX(void) const
Definition: BoundingBox.h:92
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 * ...
Definition: BoundingBox.cpp:90
cBoundingBox Union(const cBoundingBox &a_Other)
Returns the union of the two bounding boxes.
Vector3d GetMin(void) const
Definition: BoundingBox.h:100
double GetMaxZ(void) const
Definition: BoundingBox.h:98
T x
Definition: Vector3.h:17
T y
Definition: Vector3.h:17
T z
Definition: Vector3.h:17