Slight changes in octree/bvh

This commit is contained in:
Godzil
2020-03-17 00:44:58 +00:00
parent 71c236abb0
commit 5651570c2b
2 changed files with 103 additions and 109 deletions

View File

@@ -8,6 +8,7 @@
*/
#include <worldoptimiser.h>
#include <cube.h>
#include <objfile.h>
#include <transformation.h>
void BVHOptimisation::makeTree(Group *leaf, int depth)
@@ -63,8 +64,6 @@ void BVHOptimisation::makeTree(Group *leaf, int depth)
for (i = 0 ; i < leaf->getObjectCount(); i++)
{
Shape *shp = leaf->getObject(i);
if ((shp->getType() != Shape::GROUP) && (shp->getType() != Shape::OBJFILE))
{
BoundingBox objBB = shp->getBounds();
for (sliceIdx = 0 ; sliceIdx < 2 ; sliceIdx++)
@@ -75,8 +74,6 @@ void BVHOptimisation::makeTree(Group *leaf, int depth)
{
char name[32];
snprintf(name, 32, "%d_Slice %d", depth, sliceIdx);
//for(int j=0; j < depth; j++) { printf(" "); }
//printf("%s\n", name);
Slices[sliceIdx] = new Group(name);
Slices[sliceIdx]->setBounds(SlicesBB[sliceIdx]);
@@ -89,11 +86,13 @@ void BVHOptimisation::makeTree(Group *leaf, int depth)
break;
}
}
}
else
if (shp->getType() == Shape::GROUP)
{
leaf->removeObject(shp);
i -= 1;
this->makeTree((Group *)shp, depth + 1);
}
else if (shp->getType() == Shape::OBJFILE)
{
this->makeTree((Group *)((OBJFile *)shp)->getBaseGroup(), depth + 1);
}
}
@@ -138,7 +137,7 @@ void BVHOptimisation::run()
this->moveInfiniteObjects();
/* Then let's have some fun! */
this->moveAllObjects();
//this->moveAllObjects();
/* Now.. The fun start ! */
makeTree(this->root, 0);

View File

@@ -26,8 +26,7 @@ void OctreeOptimisation::makeTree(Group *leaf, int depth)
int i;
//if (leaf->getObjectCount() > 2)
{
/* Split the main bounding box into 8 boxes */
octantBB[0] | Point(rootBB.min.x, rootBB.min.y, rootBB.min.z);
octantBB[0] | Point(midX, midY, midZ);
@@ -94,8 +93,6 @@ void OctreeOptimisation::makeTree(Group *leaf, int depth)
}
}
//if (depth < 1)
{
/* Now add the quadrant to the root and recurse in it */
for (octantIdx = 0 ; octantIdx < 8 ; octantIdx++)
{
@@ -129,8 +126,6 @@ void OctreeOptimisation::makeTree(Group *leaf, int depth)
#endif
}
}
}
}
}
void OctreeOptimisation::run()