diff --git a/include/osgUtil/MeshOptimizers b/include/osgUtil/MeshOptimizers index ef3fbee52..c7083879c 100644 --- a/include/osgUtil/MeshOptimizers +++ b/include/osgUtil/MeshOptimizers @@ -46,11 +46,16 @@ class OSGUTIL_EXPORT IndexMeshVisitor : public GeometryCollector { public: IndexMeshVisitor(Optimizer* optimizer = 0) - : GeometryCollector(optimizer, Optimizer::INDEX_MESH) + : GeometryCollector(optimizer, Optimizer::INDEX_MESH), _isForcedReindexationEnable(false) { } + inline void setGenerateNewIndicesOnAllGeometries(bool b) { _isForcedReindexationEnable = b; } + inline bool getGenerateNewIndicesOnAllGeometries() const { return _isForcedReindexationEnable; } + void makeMesh(osg::Geometry& geom); void makeMesh(); +protected: + bool _isForcedReindexationEnable; }; // Optimize the triangle order in a mesh for best use of the GPU's diff --git a/src/osgUtil/MeshOptimizers.cpp b/src/osgUtil/MeshOptimizers.cpp index 79fcef100..286dee601 100644 --- a/src/osgUtil/MeshOptimizers.cpp +++ b/src/osgUtil/MeshOptimizers.cpp @@ -262,7 +262,7 @@ void IndexMeshVisitor::makeMesh(Geometry& geom) } // nothing to index - if (!numSurfacePrimitives || !numNonIndexedPrimitives) return; + if (!numSurfacePrimitives || (!_isForcedReindexationEnable && !numNonIndexedPrimitives)) return; // duplicate shared arrays as it isn't safe to rearrange vertices when arrays are shared. if (geom.containsSharedArrays()) geom.duplicateSharedArrays();