From 71583b825f9a06fbd8e3a28548f968f3a26560fb Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 19 Apr 2018 19:36:19 +0100 Subject: [PATCH] Replaced the use of osgUtil::TriStripVisitor with ogUtil::MeshOptimizer usage to improve performance. Fixed set setColorArray assignement to pass in the color binding --- src/osgPlugins/obj/ReaderWriterOBJ.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/osgPlugins/obj/ReaderWriterOBJ.cpp b/src/osgPlugins/obj/ReaderWriterOBJ.cpp index 137996ea8..823a4eaf7 100644 --- a/src/osgPlugins/obj/ReaderWriterOBJ.cpp +++ b/src/osgPlugins/obj/ReaderWriterOBJ.cpp @@ -43,6 +43,7 @@ #include #include +#include #include #include @@ -533,8 +534,7 @@ osg::Geometry* ReaderWriterOBJ::convertElementListToGeometry(obj::Model& model, if (colors) { - geometry->setColorArray(colors); - geometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX); + geometry->setColorArray(colors, osg::Array::BIND_PER_VERTEX); } if (numPointElements>0) @@ -654,12 +654,6 @@ osg::Geometry* ReaderWriterOBJ::convertElementListToGeometry(obj::Model& model, obj::Element& element = *(*itr); if (element.dataType==obj::Element::POLYGON) { - - - - - - #ifdef USE_DRAWARRAYLENGTHS drawArrayLengths->push_back(element.vertexIndices.size()); #else @@ -804,8 +798,14 @@ osg::Node* ReaderWriterOBJ::convertModelToSceneGraph(obj::Model& model, ObjOptio // tri strip polygons to improve graphics peformance if (!localOptions.noTriStripPolygons) { - osgUtil::TriStripVisitor tsv; - tsv.stripify(*geometry); + osgUtil::IndexMeshVisitor imv; + imv.makeMesh(*geometry); + + osgUtil::VertexCacheVisitor vcv; + vcv.optimizeVertices(*geometry); + + osgUtil::VertexAccessOrderVisitor vaov; + vaov.optimizeOrder(*geometry); } // if no normals present add them.