Introduced bounding boxes to KDLeaf and KDNode structs
This commit is contained in:
parent
178d6ff423
commit
e2ae39c8f6
@ -299,6 +299,7 @@ int KDTreeBuilder::divide(KDTree& kdTree, osg::BoundingBox& bb, int nodeIndex, u
|
||||
kdTree.getNode(nodeNum).first = leftChildIndex;
|
||||
kdTree.getNode(nodeNum).second = rightChildIndex;
|
||||
|
||||
|
||||
return nodeNum;
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,38 @@ typedef std::vector< value_type > Indices;
|
||||
|
||||
//#define VERBOSE_OUTPUT
|
||||
|
||||
typedef std::pair< value_type, value_type> KDNode;
|
||||
typedef std::pair< value_type, value_type> KDLeaf;
|
||||
struct KDNode
|
||||
{
|
||||
KDNode():
|
||||
first(0),
|
||||
second(0) {}
|
||||
|
||||
KDNode(value_type f, value_type s):
|
||||
first(f),
|
||||
second(s) {}
|
||||
|
||||
value_type first;
|
||||
value_type second;
|
||||
|
||||
osg::BoundingBox bb;
|
||||
};
|
||||
|
||||
|
||||
struct KDLeaf
|
||||
{
|
||||
KDLeaf():
|
||||
first(0),
|
||||
second(0) {}
|
||||
|
||||
KDLeaf(value_type f, value_type s):
|
||||
first(f),
|
||||
second(s) {}
|
||||
|
||||
value_type first;
|
||||
value_type second;
|
||||
|
||||
osg::BoundingBox bb;
|
||||
};
|
||||
|
||||
struct Triangle
|
||||
{
|
||||
@ -136,6 +166,19 @@ class KDTree : public osg::Shape
|
||||
return _kdNodes[nodeNum];
|
||||
}
|
||||
|
||||
osg::BoundingBox& getBounindingBox(int nodeNum)
|
||||
{
|
||||
if (nodeNum<0)
|
||||
{
|
||||
int num = -nodeNum-1;
|
||||
return _kdLeaves[num].bb;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _kdNodes[nodeNum].bb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
typedef std::vector< osg::BoundingBox > BoundingBoxList;
|
||||
typedef std::vector< Triangle > TriangleList;
|
||||
|
Loading…
Reference in New Issue
Block a user