Added: BoundingBoxFaces assignments, calculations and doxygen comments.

This commit is contained in:
Foxar
2020-12-20 13:24:50 +01:00
parent 44776f7aba
commit 9b2d39505b
2 changed files with 28 additions and 2 deletions
+18 -2
View File
@@ -22,7 +22,7 @@
*/ */
struct BoundingBoxFace struct BoundingBoxFace
{ {
BoundingBoxFace(Vector3 t_minCorner, Vector3 t_maxCorner, float t_axisPos) BoundingBoxFace(const Vector3 &t_minCorner, const Vector3 &t_maxCorner, float t_axisPos)
{ {
minCorner = t_minCorner; minCorner = t_minCorner;
maxCorner = t_maxCorner; maxCorner = t_maxCorner;
@@ -51,18 +51,34 @@ public:
const float &getWidth() { return _width; }; const float &getWidth() { return _width; };
/** Return the vector directly in middle of the bounding box. */ /** Return the vector directly in middle of the bounding box. */
const Vector3 &getCenter() { return _centerVector; }; const Vector3 &getCenter() { return _centerVector; };
/** Return the front face (furhter on z-axis) */ /** Return the front face (further on z-axis) */
const BoundingBoxFace &getFrontFace() { return _frontFace; }; const BoundingBoxFace &getFrontFace() { return _frontFace; };
/** Return the back face (nearer on z-axis) */
const BoundingBoxFace &getBackFace() { return _backFace; };
/** Return the left face (further on x-axis) */
const BoundingBoxFace &getLeftFace() { return _leftFace; };
/** Return the right face (nearer on x-axis) */
const BoundingBoxFace &getRightFace() { return _rightFace; };
/** Return the top face (further on y-axis) */
const BoundingBoxFace &getTopFace() { return _frontFace; };
/** Return the bottom face (nearer on y-axis) */
const BoundingBoxFace &getBottomFace() { return _bottomFace; };
private: private:
Vector3 _vertices[8]; Vector3 _vertices[8];
float _height, _depth, _width; float _height, _depth, _width;
Vector3 _centerVector; Vector3 _centerVector;
/** Front face (further on z-axis) */
BoundingBoxFace _frontFace; BoundingBoxFace _frontFace;
/** Back face (nearer on z-axis) */
BoundingBoxFace _backFace; BoundingBoxFace _backFace;
/** Left face (nearer on x-axis) */
BoundingBoxFace _leftFace; BoundingBoxFace _leftFace;
/** Right face (further on x-axis) */
BoundingBoxFace _rightFace; BoundingBoxFace _rightFace;
/** Top face (further on y-axis) */
BoundingBoxFace _topFace; BoundingBoxFace _topFace;
/** Bottom face (nearer on y-axis) */
BoundingBoxFace _bottomFace; BoundingBoxFace _bottomFace;
}; };
+10
View File
@@ -30,4 +30,14 @@ BoundingBox::BoundingBox(Vector3 *t_vectorArray)
_centerVector.x += (_width / 2); _centerVector.x += (_width / 2);
_centerVector.y += (_height / 2); _centerVector.y += (_height / 2);
_centerVector.z += (_depth / 2); _centerVector.z += (_depth / 2);
//Z-Axis faces
_frontFace = BoundingBoxFace(_vertices[1], _vertices[7], _vertices[1].z);
_backFace = BoundingBoxFace(_vertices[0], _vertices[6], _vertices[0].z);
//X-Axis faces
_leftFace = BoundingBoxFace(_vertices[0], _vertices[3], _vertices[0].x);
_rightFace = BoundingBoxFace(_vertices[4], _vertices[7], _vertices[4].x);
//Y-Axis faces
_topFace = BoundingBoxFace(_vertices[2], _vertices[7], _vertices[2].y);
_bottomFace = BoundingBoxFace(_vertices[0], _vertices[5], _vertices[0].y);
} }