From 8a2f1bc056861bb2000f74ffa9cf48433f201576 Mon Sep 17 00:00:00 2001 From: Jordi Date: Wed, 31 May 2017 13:30:50 +0200 Subject: [PATCH 1/7] Fixes kdtree building --- src/osg/KdTree.cpp | 2 -- src/osgUtil/LineSegmentIntersector.cpp | 16 ++++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/osg/KdTree.cpp b/src/osg/KdTree.cpp index 32c12eb00..eeadfb816 100644 --- a/src/osg/KdTree.cpp +++ b/src/osg/KdTree.cpp @@ -361,8 +361,6 @@ int BuildKdTree::divide(KdTree::BuildOptions& options, osg::BoundingBox& bb, int while(leftmid)) { --right; } - while(leftmid)) { --right; } - if (leftesplison) + const value_type epsilon = 1e-10; + if (det>epsilon) { value_type u = (P*T); if (u<0.0 || u>det) return; @@ -271,7 +271,7 @@ struct IntersectFunctor r2 = v; r = t * _inverse_length; } - else if (det<-esplison) + else if (det<-epsilon) { value_type u = (P*T); if (u>0.0 || u Date: Tue, 30 May 2017 18:38:25 -0400 Subject: [PATCH 2/7] examples: osgkeyboardmouse: add primitive index to LineSegmentIntersector output --- examples/osgkeyboardmouse/osgkeyboardmouse.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/osgkeyboardmouse/osgkeyboardmouse.cpp b/examples/osgkeyboardmouse/osgkeyboardmouse.cpp index 4aad0d668..f772e898e 100644 --- a/examples/osgkeyboardmouse/osgkeyboardmouse.cpp +++ b/examples/osgkeyboardmouse/osgkeyboardmouse.cpp @@ -349,7 +349,9 @@ public: if (picker->containsIntersections()) { osgUtil::LineSegmentIntersector::Intersection intersection = picker->getFirstIntersection(); - osg::notify(osg::NOTICE)<<"Picked "<=1)?nodePath[nodePath.size()-1]:0; From 47efc556215b9e4ea353d4dd325b3788420cde5f Mon Sep 17 00:00:00 2001 From: blobfish Date: Mon, 29 May 2017 12:19:08 -0400 Subject: [PATCH 3/7] osgUtil: PolytopeIntersector: don't increment primitive index until after adding intersection --- src/osgUtil/PolytopeIntersector.cpp | 43 ++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/src/osgUtil/PolytopeIntersector.cpp b/src/osgUtil/PolytopeIntersector.cpp index 12c680145..ae0debacb 100644 --- a/src/osgUtil/PolytopeIntersector.cpp +++ b/src/osgUtil/PolytopeIntersector.cpp @@ -256,9 +256,11 @@ struct IntersectFunctor { if (_settings->_limitOneIntersection && _hit) return; - ++_primitiveIndex; - - if ((_settings->_primitiveMask&PolytopeIntersector::POINT_PRIMITIVES)==0) return; + if ((_settings->_primitiveMask&PolytopeIntersector::POINT_PRIMITIVES)==0) + { + ++_primitiveIndex; + return; + } // initialize the set of vertices to test. src.clear(); @@ -278,7 +280,11 @@ struct IntersectFunctor { const osg::Plane& plane=*pitr; double d1=plane.distance(v0); - if (d1<0.0) return; // point outside + if (d1<0.0) // point outside + { + ++_primitiveIndex; + return; + } } } } @@ -286,6 +292,8 @@ struct IntersectFunctor src.push_back(v0); addIntersection(); + + ++_primitiveIndex; } // handle lines @@ -293,9 +301,11 @@ struct IntersectFunctor { if (_settings->_limitOneIntersection && _hit) return; - ++_primitiveIndex; - - if ((_settings->_primitiveMask&PolytopeIntersector::LINE_PRIMITIVES)==0) return; + if ((_settings->_primitiveMask&PolytopeIntersector::LINE_PRIMITIVES)==0) + { + ++_primitiveIndex; + return; + } src.clear(); src.push_back(v0); @@ -305,6 +315,7 @@ struct IntersectFunctor { addIntersection(); } + ++_primitiveIndex; } // handle triangles @@ -312,9 +323,11 @@ struct IntersectFunctor { if (_settings->_limitOneIntersection && _hit) return; - ++_primitiveIndex; - - if ((_settings->_primitiveMask&PolytopeIntersector::TRIANGLE_PRIMITIVES)==0) return; + if ((_settings->_primitiveMask&PolytopeIntersector::TRIANGLE_PRIMITIVES)==0) + { + ++_primitiveIndex; + return; + } src.clear(); src.push_back(v0); @@ -326,15 +339,18 @@ struct IntersectFunctor { addIntersection(); } + ++_primitiveIndex; } void operator()(const osg::Vec3& v0, const osg::Vec3& v1, const osg::Vec3& v2, const osg::Vec3& v3, bool /*treatVertexDataAsTemporary*/) { if (_settings->_limitOneIntersection && _hit) return; - ++_primitiveIndex; - - if ((_settings->_primitiveMask&PolytopeIntersector::TRIANGLE_PRIMITIVES)==0) return; + if ((_settings->_primitiveMask&PolytopeIntersector::TRIANGLE_PRIMITIVES)==0) + { + ++_primitiveIndex; + return; + } src.clear(); @@ -348,6 +364,7 @@ struct IntersectFunctor { addIntersection(); } + ++_primitiveIndex; } void intersect(const osg::Vec3Array* vertices, int primitiveIndex, unsigned int p0) From b52bc2bcd1f379d2125a2923e1036027a2075c85 Mon Sep 17 00:00:00 2001 From: blobfish Date: Tue, 30 May 2017 18:46:03 -0400 Subject: [PATCH 4/7] osgUtil: LineSegmentIntersector: don't increment primitive index until after adding intersection --- src/osgUtil/LineSegmentIntersector.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/osgUtil/LineSegmentIntersector.cpp b/src/osgUtil/LineSegmentIntersector.cpp index 22dd74d2c..63cb30366 100644 --- a/src/osgUtil/LineSegmentIntersector.cpp +++ b/src/osgUtil/LineSegmentIntersector.cpp @@ -357,15 +357,15 @@ struct IntersectFunctor // handle triangles void operator()(const osg::Vec3& v0, const osg::Vec3& v1, const osg::Vec3& v2, bool /*treatVertexDataAsTemporary*/) { - ++_primitiveIndex; intersect(v0,v1,v2); + ++_primitiveIndex; } void operator()(const osg::Vec3& v0, const osg::Vec3& v1, const osg::Vec3& v2, const osg::Vec3& v3, bool /*treatVertexDataAsTemporary*/) { - ++_primitiveIndex; intersect(v0,v1,v3); intersect(v1,v2,v3); + ++_primitiveIndex; } void intersect(const osg::Vec3Array*, int , unsigned int) From bb804c2045061c892ae2ad5ba41091a1166481c6 Mon Sep 17 00:00:00 2001 From: blobfish Date: Thu, 1 Jun 2017 15:25:38 -0400 Subject: [PATCH 5/7] 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) From f5bd280b51fcbffc12ece0ae1d26511f73f7936a Mon Sep 17 00:00:00 2001 From: blobfish Date: Fri, 2 Jun 2017 15:43:54 -0400 Subject: [PATCH 6/7] osg: KdTree: count degenerates to keep original primitive index in sync --- include/osg/KdTree | 10 +++++----- src/osg/KdTree.cpp | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) 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) { From 5812c267b1555314f04d6cedb1cc349fbf34571e Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 7 Jun 2017 07:50:55 -0400 Subject: [PATCH 7/7] Added osgUI to Doxygen-generated documentation --- doc/Doxyfiles/doxyfile.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/Doxyfiles/doxyfile.cmake b/doc/Doxyfiles/doxyfile.cmake index 07f08b056..d3d17271c 100644 --- a/doc/Doxyfiles/doxyfile.cmake +++ b/doc/Doxyfiles/doxyfile.cmake @@ -84,21 +84,22 @@ WARN_LOGFILE = # configuration options related to the input files #--------------------------------------------------------------------------- INPUT = "${OpenSceneGraph_SOURCE_DIR}/include/osg" \ + "${OpenSceneGraph_SOURCE_DIR}/include/osgAnimation" \ "${OpenSceneGraph_SOURCE_DIR}/include/osgDB" \ "${OpenSceneGraph_SOURCE_DIR}/include/osgFX" \ "${OpenSceneGraph_SOURCE_DIR}/include/osgGA" \ "${OpenSceneGraph_SOURCE_DIR}/include/osgManipulator" \ "${OpenSceneGraph_SOURCE_DIR}/include/osgParticle" \ + "${OpenSceneGraph_SOURCE_DIR}/include/osgQt" \ "${OpenSceneGraph_SOURCE_DIR}/include/osgShadow" \ "${OpenSceneGraph_SOURCE_DIR}/include/osgSim" \ "${OpenSceneGraph_SOURCE_DIR}/include/osgTerrain" \ "${OpenSceneGraph_SOURCE_DIR}/include/osgText" \ + "${OpenSceneGraph_SOURCE_DIR}/include/osgUI" \ "${OpenSceneGraph_SOURCE_DIR}/include/osgUtil" \ "${OpenSceneGraph_SOURCE_DIR}/include/osgViewer" \ "${OpenSceneGraph_SOURCE_DIR}/include/osgVolume" \ - "${OpenSceneGraph_SOURCE_DIR}/include/osgWidget" \ - "${OpenSceneGraph_SOURCE_DIR}/include/osgQt" \ - "${OpenSceneGraph_SOURCE_DIR}/include/osgAnimation" + "${OpenSceneGraph_SOURCE_DIR}/include/osgWidget" INPUT_ENCODING = UTF-8 FILE_PATTERNS = *include* \ *.cpp