Changed: Removed old vertex array boundingbox declaration, forced usage of temporary vector array in initial boundingbox calculations.

This commit is contained in:
Foxar
2020-12-21 19:05:33 +01:00
parent 02d7916925
commit 586fe136ea
4 changed files with 8 additions and 10 deletions
-2
View File
@@ -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,
@@ -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;
+1 -4
View File
@@ -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);
+7 -3
View File
@@ -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);
}