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).first = leftChildIndex;
|
||||||
kdTree.getNode(nodeNum).second = rightChildIndex;
|
kdTree.getNode(nodeNum).second = rightChildIndex;
|
||||||
|
|
||||||
|
|
||||||
return nodeNum;
|
return nodeNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +51,38 @@ typedef std::vector< value_type > Indices;
|
|||||||
|
|
||||||
//#define VERBOSE_OUTPUT
|
//#define VERBOSE_OUTPUT
|
||||||
|
|
||||||
typedef std::pair< value_type, value_type> KDNode;
|
struct KDNode
|
||||||
typedef std::pair< value_type, value_type> KDLeaf;
|
{
|
||||||
|
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
|
struct Triangle
|
||||||
{
|
{
|
||||||
@ -136,6 +166,19 @@ class KDTree : public osg::Shape
|
|||||||
return _kdNodes[nodeNum];
|
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< osg::BoundingBox > BoundingBoxList;
|
||||||
typedef std::vector< Triangle > TriangleList;
|
typedef std::vector< Triangle > TriangleList;
|
||||||
|
Loading…
Reference in New Issue
Block a user