Added: Integrated new BoundingBox class implentation with mesh_frame boundingbox calculations.

This commit is contained in:
Foxar
2020-12-20 13:38:26 +01:00
parent 9b2d39505b
commit 53c134b0d5
2 changed files with 13 additions and 0 deletions
+3
View File
@@ -13,6 +13,7 @@
#include <stddef.h>
#include <tamtypes.h>
#include "bounding_box.hpp"
#include "math/point.hpp"
#include "math/vector3.hpp"
#include "./mesh_material.hpp"
@@ -139,7 +140,9 @@ public:
void calculateBoundingBoxes();
private:
/** Deprecated. It is advised to use BoundingBox class instead. */
Vector3 boundingBox[8];
BoundingBox *boundingBoxObj;
u8 _areSTsAllocated,
_areVerticesAllocated,
_areNormalsAllocated,
+10
View File
@@ -37,6 +37,7 @@ MeshFrame::~MeshFrame()
delete[] normals;
if (_areMaterialsAllocated)
delete[] materials;
delete boundingBoxObj;
}
// ----
@@ -121,6 +122,7 @@ void MeshFrame::calculateBoundingBoxes()
if (hiZ < vertices[i].z)
hiZ = vertices[i].z;
}
boundingBox[0].set(lowX, lowY, lowZ);
boundingBox[1].set(lowX, lowY, hiZ);
boundingBox[2].set(lowX, hiY, lowZ);
@@ -131,4 +133,12 @@ void MeshFrame::calculateBoundingBoxes()
boundingBox[6].set(hiX, hiY, lowZ);
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);
}