diff --git a/include/osg/KdTree b/include/osg/KdTree index 8ebe80bd0..33f90ac98 100644 --- a/include/osg/KdTree +++ b/include/osg/KdTree @@ -69,7 +69,7 @@ class OSG_EXPORT KdTree : public osg::Shape inline unsigned int addPoint(unsigned int p0) { unsigned int i = _vertexIndices.size(); - _vertexIndices.push_back(_primitiveIndices.size()); + _vertexIndices.push_back(_primitiveIndices.size() + _degenerateCount); _vertexIndices.push_back(1); _vertexIndices.push_back(p0); _primitiveIndices.push_back(i); @@ -78,7 +78,7 @@ class OSG_EXPORT KdTree : public osg::Shape inline unsigned int addLine(unsigned int p0, unsigned int p1) { unsigned int i = _vertexIndices.size(); - _vertexIndices.push_back(_primitiveIndices.size()); + _vertexIndices.push_back(_primitiveIndices.size() + _degenerateCount); _vertexIndices.push_back(2); _vertexIndices.push_back(p0); _vertexIndices.push_back(p1); @@ -89,7 +89,7 @@ class OSG_EXPORT KdTree : public osg::Shape inline unsigned int addTriangle(unsigned int p0, unsigned int p1, unsigned int p2) { unsigned int i = _vertexIndices.size(); - _vertexIndices.push_back(_primitiveIndices.size()); + _vertexIndices.push_back(_primitiveIndices.size() + _degenerateCount); _vertexIndices.push_back(3); _vertexIndices.push_back(p0); _vertexIndices.push_back(p1); @@ -101,7 +101,7 @@ class OSG_EXPORT KdTree : public osg::Shape inline unsigned int addQuad(unsigned int p0, unsigned int p1, unsigned int p2, unsigned int p3) { unsigned int i = _vertexIndices.size(); - _vertexIndices.push_back(_primitiveIndices.size()); + _vertexIndices.push_back(_primitiveIndices.size() + _degenerateCount); _vertexIndices.push_back(4); _vertexIndices.push_back(p0); _vertexIndices.push_back(p1); @@ -179,7 +179,7 @@ class OSG_EXPORT KdTree : public osg::Shape } } - + unsigned int _degenerateCount; protected: diff --git a/src/osg/KdTree.cpp b/src/osg/KdTree.cpp index 9d03020e8..709c12f99 100644 --- a/src/osg/KdTree.cpp +++ b/src/osg/KdTree.cpp @@ -86,6 +86,7 @@ struct PrimitiveIndicesCollector if (v0==v1) { //OSG_NOTICE<<"Disgarding degenerate triangle"<_kdTree._degenerateCount++; return; } @@ -111,6 +112,7 @@ struct PrimitiveIndicesCollector if (v0==v1 || v1==v2 || v2==v0) { //OSG_NOTICE<<"Disgarding degenerate triangle"<_kdTree._degenerateCount++; return; } @@ -138,6 +140,7 @@ struct PrimitiveIndicesCollector if (v0==v1 || v1==v2 || v2==v0 || v3==v0 || v3==v1 || v3==v2) { //OSG_NOTICE<<"Disgarding degenerate quad"<_kdTree._degenerateCount++; return; } @@ -481,12 +484,13 @@ KdTree::BuildOptions::BuildOptions(): // // KdTree -KdTree::KdTree() +KdTree::KdTree() : _degenerateCount(0) { } KdTree::KdTree(const KdTree& rhs, const osg::CopyOp& copyop): Shape(rhs, copyop), + _degenerateCount(rhs._degenerateCount), _vertices(rhs._vertices), _kdNodes(rhs._kdNodes) {