add a bool parameter to allow forced reindexation of a mesh

This commit is contained in:
mp3butcher 2018-08-16 00:18:24 +02:00
parent e2fb88e187
commit b8f9249bea
2 changed files with 7 additions and 2 deletions

View File

@ -46,11 +46,16 @@ class OSGUTIL_EXPORT IndexMeshVisitor : public GeometryCollector
{ {
public: public:
IndexMeshVisitor(Optimizer* optimizer = 0) 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(osg::Geometry& geom);
void makeMesh(); void makeMesh();
protected:
bool _isForcedReindexationEnable;
}; };
// Optimize the triangle order in a mesh for best use of the GPU's // Optimize the triangle order in a mesh for best use of the GPU's

View File

@ -262,7 +262,7 @@ void IndexMeshVisitor::makeMesh(Geometry& geom)
} }
// nothing to index // 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. // duplicate shared arrays as it isn't safe to rearrange vertices when arrays are shared.
if (geom.containsSharedArrays()) geom.duplicateSharedArrays(); if (geom.containsSharedArrays()) geom.duplicateSharedArrays();