From 9b2d39505b9a35c0fd2b94d96eeab970c93f8095 Mon Sep 17 00:00:00 2001 From: Foxar Date: Sun, 20 Dec 2020 13:24:50 +0100 Subject: [PATCH] Added: BoundingBoxFaces assignments, calculations and doxygen comments. --- src/engine/include/models/bounding_box.hpp | 20 ++++++++++++++++++-- src/engine/models/bounding_box.cpp | 10 ++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/engine/include/models/bounding_box.hpp b/src/engine/include/models/bounding_box.hpp index 98a9128..b95244c 100644 --- a/src/engine/include/models/bounding_box.hpp +++ b/src/engine/include/models/bounding_box.hpp @@ -22,7 +22,7 @@ */ 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; maxCorner = t_maxCorner; @@ -51,18 +51,34 @@ public: const float &getWidth() { return _width; }; /** Return the vector directly in middle of the bounding box. */ 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; }; + /** 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: Vector3 _vertices[8]; float _height, _depth, _width; Vector3 _centerVector; + /** Front face (further on z-axis) */ BoundingBoxFace _frontFace; + /** Back face (nearer on z-axis) */ BoundingBoxFace _backFace; + /** Left face (nearer on x-axis) */ BoundingBoxFace _leftFace; + /** Right face (further on x-axis) */ BoundingBoxFace _rightFace; + /** Top face (further on y-axis) */ BoundingBoxFace _topFace; + /** Bottom face (nearer on y-axis) */ BoundingBoxFace _bottomFace; }; diff --git a/src/engine/models/bounding_box.cpp b/src/engine/models/bounding_box.cpp index e16f04e..9191021 100644 --- a/src/engine/models/bounding_box.cpp +++ b/src/engine/models/bounding_box.cpp @@ -30,4 +30,14 @@ BoundingBox::BoundingBox(Vector3 *t_vectorArray) _centerVector.x += (_width / 2); _centerVector.y += (_height / 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); } \ No newline at end of file