diff --git a/include/osg/KdTree b/include/osg/KdTree index 12279334e..8ebe80bd0 100644 --- a/include/osg/KdTree +++ b/include/osg/KdTree @@ -69,41 +69,45 @@ class OSG_EXPORT KdTree : public osg::Shape inline unsigned int addPoint(unsigned int p0) { unsigned int i = _vertexIndices.size(); - _primitiveIndices.push_back(i); + _vertexIndices.push_back(_primitiveIndices.size()); _vertexIndices.push_back(1); _vertexIndices.push_back(p0); + _primitiveIndices.push_back(i); return i; } inline unsigned int addLine(unsigned int p0, unsigned int p1) { unsigned int i = _vertexIndices.size(); - _primitiveIndices.push_back(i); + _vertexIndices.push_back(_primitiveIndices.size()); _vertexIndices.push_back(2); _vertexIndices.push_back(p0); _vertexIndices.push_back(p1); + _primitiveIndices.push_back(i); return i; } inline unsigned int addTriangle(unsigned int p0, unsigned int p1, unsigned int p2) { unsigned int i = _vertexIndices.size(); - _primitiveIndices.push_back(i); + _vertexIndices.push_back(_primitiveIndices.size()); _vertexIndices.push_back(3); _vertexIndices.push_back(p0); _vertexIndices.push_back(p1); _vertexIndices.push_back(p2); + _primitiveIndices.push_back(i); return i; } inline unsigned int addQuad(unsigned int p0, unsigned int p1, unsigned int p2, unsigned int p3) { unsigned int i = _vertexIndices.size(); - _primitiveIndices.push_back(i); + _vertexIndices.push_back(_primitiveIndices.size()); _vertexIndices.push_back(4); _vertexIndices.push_back(p0); _vertexIndices.push_back(p1); _vertexIndices.push_back(p2); _vertexIndices.push_back(p3); + _primitiveIndices.push_back(i); return i; } @@ -154,13 +158,14 @@ class OSG_EXPORT KdTree : public osg::Shape for(int i=istart; i0; --numPoints)