From bb804c2045061c892ae2ad5ba41091a1166481c6 Mon Sep 17 00:00:00 2001 From: blobfish Date: Thu, 1 Jun 2017 15:25:38 -0400 Subject: [PATCH] osg: KdTree: encode original primitive index into _vertexIndices --- include/osg/KdTree | 21 +++++++++++++-------- src/osg/KdTree.cpp | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) 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)