diff --git a/src/engine/include/models/mesh_frame.hpp b/src/engine/include/models/mesh_frame.hpp index 8ffe8e0..8b4214f 100644 --- a/src/engine/include/models/mesh_frame.hpp +++ b/src/engine/include/models/mesh_frame.hpp @@ -145,8 +145,6 @@ public: void calculateBoundingBoxes(); private: - /** Deprecated. It is advised to use BoundingBox class instead. */ - Vector3 boundingBox[8]; BoundingBox *boundingBoxObj; u8 _areSTsAllocated, _areVerticesAllocated, diff --git a/src/engine/include/models/mesh_material.hpp b/src/engine/include/models/mesh_material.hpp index dffcf8d..b2588f9 100644 --- a/src/engine/include/models/mesh_material.hpp +++ b/src/engine/include/models/mesh_material.hpp @@ -125,7 +125,6 @@ public: u8 isInFrustum(Plane *t_frustumPlanes, const Vector3 &position); private: - Vector3 boundingBox[8]; BoundingBox *boundingBoxObj; u32 facesCount, id; u32 *vertexFaces, *stFaces, *normalFaces; diff --git a/src/engine/models/mesh_frame.cpp b/src/engine/models/mesh_frame.cpp index 2180a57..0e224cd 100644 --- a/src/engine/models/mesh_frame.cpp +++ b/src/engine/models/mesh_frame.cpp @@ -94,6 +94,7 @@ void MeshFrame::allocateMaterials(const u32 &t_val) void MeshFrame::calculateBoundingBoxes() { + Vector3 boundingBox[8]; if (!_areVerticesAllocated) { PRINT_ERR("Can't calculate bounding box, because vertices were not allocated!"); @@ -134,10 +135,6 @@ void MeshFrame::calculateBoundingBoxes() boundingBox[7].set(hiX, hiY, hiZ); _isBoundingBoxCalculated = true; - //Function temporarily is a hybrid between old Vector3[8] boundingbox and - //the new class implementation. Upon confirmation that new implementation - //works correctly, delete the old code. - //BoundingBox is declared on the heap to prevent any ill-formed default //constructor instantiated BoundingBox objects. boundingBoxObj = new BoundingBox(boundingBox); diff --git a/src/engine/models/mesh_material.cpp b/src/engine/models/mesh_material.cpp index bf4667e..59e5daa 100644 --- a/src/engine/models/mesh_material.cpp +++ b/src/engine/models/mesh_material.cpp @@ -83,9 +83,9 @@ u8 MeshMaterial::isInFrustum(Plane *t_frustumPlanes, const Vector3 &position) for (u8 y = 0; y < 8 && (boxIn == 0 || boxOut == 0); y++) { boxCalcTemp.set( - boundingBox[y].x + position.x, - boundingBox[y].y + position.y, - boundingBox[y].z + position.z); + boundingBoxObj->getVertices()[y].x + position.x, + boundingBoxObj->getVertices()[y].y + position.y, + boundingBoxObj->getVertices()[y].z + position.z); if (t_frustumPlanes[i].distanceTo(boxCalcTemp) < 0) boxOut++; else @@ -102,6 +102,7 @@ u8 MeshMaterial::isInFrustum(Plane *t_frustumPlanes, const Vector3 &position) void MeshMaterial::calculateBoundingBox(Vector3 *t_vertices, u32 t_vertCount) { + Vector3 boundingBox[8]; float lowX, lowY, lowZ, hiX, hiY, hiZ; lowX = hiX = t_vertices[vertexFaces[0]].x; lowY = hiY = t_vertices[vertexFaces[0]].y; @@ -133,5 +134,8 @@ void MeshMaterial::calculateBoundingBox(Vector3 *t_vertices, u32 t_vertCount) boundingBox[6].set(hiX, hiY, lowZ); boundingBox[7].set(hiX, hiY, hiZ); _isBoundingBoxCalculated = true; + + //BoundingBox is declared on the heap to prevent any ill-formed default + //constructor instantiated BoundingBox objects. boundingBoxObj = new BoundingBox(boundingBox); }