Slight changes in octree/bvh
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <worldoptimiser.h>
|
#include <worldoptimiser.h>
|
||||||
#include <cube.h>
|
#include <cube.h>
|
||||||
|
#include <objfile.h>
|
||||||
#include <transformation.h>
|
#include <transformation.h>
|
||||||
|
|
||||||
void BVHOptimisation::makeTree(Group *leaf, int depth)
|
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++)
|
for (i = 0 ; i < leaf->getObjectCount(); i++)
|
||||||
{
|
{
|
||||||
Shape *shp = leaf->getObject(i);
|
Shape *shp = leaf->getObject(i);
|
||||||
if ((shp->getType() != Shape::GROUP) && (shp->getType() != Shape::OBJFILE))
|
|
||||||
{
|
|
||||||
BoundingBox objBB = shp->getBounds();
|
BoundingBox objBB = shp->getBounds();
|
||||||
|
|
||||||
for (sliceIdx = 0 ; sliceIdx < 2 ; sliceIdx++)
|
for (sliceIdx = 0 ; sliceIdx < 2 ; sliceIdx++)
|
||||||
@@ -75,8 +74,6 @@ void BVHOptimisation::makeTree(Group *leaf, int depth)
|
|||||||
{
|
{
|
||||||
char name[32];
|
char name[32];
|
||||||
snprintf(name, 32, "%d_Slice %d", depth, sliceIdx);
|
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] = new Group(name);
|
||||||
|
|
||||||
Slices[sliceIdx]->setBounds(SlicesBB[sliceIdx]);
|
Slices[sliceIdx]->setBounds(SlicesBB[sliceIdx]);
|
||||||
@@ -89,11 +86,13 @@ void BVHOptimisation::makeTree(Group *leaf, int depth)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (shp->getType() == Shape::GROUP)
|
||||||
else
|
|
||||||
{
|
{
|
||||||
leaf->removeObject(shp);
|
this->makeTree((Group *)shp, depth + 1);
|
||||||
i -= 1;
|
}
|
||||||
|
else if (shp->getType() == Shape::OBJFILE)
|
||||||
|
{
|
||||||
|
this->makeTree((Group *)((OBJFile *)shp)->getBaseGroup(), depth + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +137,7 @@ void BVHOptimisation::run()
|
|||||||
this->moveInfiniteObjects();
|
this->moveInfiniteObjects();
|
||||||
|
|
||||||
/* Then let's have some fun! */
|
/* Then let's have some fun! */
|
||||||
this->moveAllObjects();
|
//this->moveAllObjects();
|
||||||
|
|
||||||
/* Now.. The fun start ! */
|
/* Now.. The fun start ! */
|
||||||
makeTree(this->root, 0);
|
makeTree(this->root, 0);
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ void OctreeOptimisation::makeTree(Group *leaf, int depth)
|
|||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
//if (leaf->getObjectCount() > 2)
|
|
||||||
{
|
|
||||||
/* Split the main bounding box into 8 boxes */
|
/* Split the main bounding box into 8 boxes */
|
||||||
octantBB[0] | Point(rootBB.min.x, rootBB.min.y, rootBB.min.z);
|
octantBB[0] | Point(rootBB.min.x, rootBB.min.y, rootBB.min.z);
|
||||||
octantBB[0] | Point(midX, midY, midZ);
|
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 */
|
/* Now add the quadrant to the root and recurse in it */
|
||||||
for (octantIdx = 0 ; octantIdx < 8 ; octantIdx++)
|
for (octantIdx = 0 ; octantIdx < 8 ; octantIdx++)
|
||||||
{
|
{
|
||||||
@@ -129,8 +126,6 @@ void OctreeOptimisation::makeTree(Group *leaf, int depth)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OctreeOptimisation::run()
|
void OctreeOptimisation::run()
|
||||||
|
|||||||
Reference in New Issue
Block a user