Changed: Removed old vertex array boundingbox declaration, forced usage of temporary vector array in initial boundingbox calculations.
This commit is contained in:
@@ -145,8 +145,6 @@ public:
|
|||||||
void calculateBoundingBoxes();
|
void calculateBoundingBoxes();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Deprecated. It is advised to use BoundingBox class instead. */
|
|
||||||
Vector3 boundingBox[8];
|
|
||||||
BoundingBox *boundingBoxObj;
|
BoundingBox *boundingBoxObj;
|
||||||
u8 _areSTsAllocated,
|
u8 _areSTsAllocated,
|
||||||
_areVerticesAllocated,
|
_areVerticesAllocated,
|
||||||
|
|||||||
@@ -125,7 +125,6 @@ public:
|
|||||||
u8 isInFrustum(Plane *t_frustumPlanes, const Vector3 &position);
|
u8 isInFrustum(Plane *t_frustumPlanes, const Vector3 &position);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector3 boundingBox[8];
|
|
||||||
BoundingBox *boundingBoxObj;
|
BoundingBox *boundingBoxObj;
|
||||||
u32 facesCount, id;
|
u32 facesCount, id;
|
||||||
u32 *vertexFaces, *stFaces, *normalFaces;
|
u32 *vertexFaces, *stFaces, *normalFaces;
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ void MeshFrame::allocateMaterials(const u32 &t_val)
|
|||||||
|
|
||||||
void MeshFrame::calculateBoundingBoxes()
|
void MeshFrame::calculateBoundingBoxes()
|
||||||
{
|
{
|
||||||
|
Vector3 boundingBox[8];
|
||||||
if (!_areVerticesAllocated)
|
if (!_areVerticesAllocated)
|
||||||
{
|
{
|
||||||
PRINT_ERR("Can't calculate bounding box, because vertices were not allocated!");
|
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);
|
boundingBox[7].set(hiX, hiY, hiZ);
|
||||||
_isBoundingBoxCalculated = true;
|
_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
|
//BoundingBox is declared on the heap to prevent any ill-formed default
|
||||||
//constructor instantiated BoundingBox objects.
|
//constructor instantiated BoundingBox objects.
|
||||||
boundingBoxObj = new BoundingBox(boundingBox);
|
boundingBoxObj = new BoundingBox(boundingBox);
|
||||||
|
|||||||
@@ -83,9 +83,9 @@ u8 MeshMaterial::isInFrustum(Plane *t_frustumPlanes, const Vector3 &position)
|
|||||||
for (u8 y = 0; y < 8 && (boxIn == 0 || boxOut == 0); y++)
|
for (u8 y = 0; y < 8 && (boxIn == 0 || boxOut == 0); y++)
|
||||||
{
|
{
|
||||||
boxCalcTemp.set(
|
boxCalcTemp.set(
|
||||||
boundingBox[y].x + position.x,
|
boundingBoxObj->getVertices()[y].x + position.x,
|
||||||
boundingBox[y].y + position.y,
|
boundingBoxObj->getVertices()[y].y + position.y,
|
||||||
boundingBox[y].z + position.z);
|
boundingBoxObj->getVertices()[y].z + position.z);
|
||||||
if (t_frustumPlanes[i].distanceTo(boxCalcTemp) < 0)
|
if (t_frustumPlanes[i].distanceTo(boxCalcTemp) < 0)
|
||||||
boxOut++;
|
boxOut++;
|
||||||
else
|
else
|
||||||
@@ -102,6 +102,7 @@ u8 MeshMaterial::isInFrustum(Plane *t_frustumPlanes, const Vector3 &position)
|
|||||||
|
|
||||||
void MeshMaterial::calculateBoundingBox(Vector3 *t_vertices, u32 t_vertCount)
|
void MeshMaterial::calculateBoundingBox(Vector3 *t_vertices, u32 t_vertCount)
|
||||||
{
|
{
|
||||||
|
Vector3 boundingBox[8];
|
||||||
float lowX, lowY, lowZ, hiX, hiY, hiZ;
|
float lowX, lowY, lowZ, hiX, hiY, hiZ;
|
||||||
lowX = hiX = t_vertices[vertexFaces[0]].x;
|
lowX = hiX = t_vertices[vertexFaces[0]].x;
|
||||||
lowY = hiY = t_vertices[vertexFaces[0]].y;
|
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[6].set(hiX, hiY, lowZ);
|
||||||
boundingBox[7].set(hiX, hiY, hiZ);
|
boundingBox[7].set(hiX, hiY, hiZ);
|
||||||
_isBoundingBoxCalculated = true;
|
_isBoundingBoxCalculated = true;
|
||||||
|
|
||||||
|
//BoundingBox is declared on the heap to prevent any ill-formed default
|
||||||
|
//constructor instantiated BoundingBox objects.
|
||||||
boundingBoxObj = new BoundingBox(boundingBox);
|
boundingBoxObj = new BoundingBox(boundingBox);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user