From cc93824605dacf96bce9ecf23499c8728d5f1326 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 1 Nov 2010 17:05:53 +0000 Subject: [PATCH] From Alexander Irion, "When a osg::Geometry node is loaded from a ".osgb" file, there is no element buffer object created for the primitives element indices, although _useVertexBufferObjects is enabled. This bug decreases the rendering performance." --- include/osg/Geometry | 3 ++- src/osg/Geometry.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/osg/Geometry b/include/osg/Geometry index 63d882935..acf73e5a4 100644 --- a/include/osg/Geometry +++ b/include/osg/Geometry @@ -227,7 +227,8 @@ class OSG_EXPORT Geometry : public Drawable typedef std::vector< ref_ptr > PrimitiveSetList; - void setPrimitiveSetList(const PrimitiveSetList& primitives) { _primitives = primitives; dirtyDisplayList(); dirtyBound(); } + void setPrimitiveSetList(const PrimitiveSetList& primitives); + PrimitiveSetList& getPrimitiveSetList() { return _primitives; } const PrimitiveSetList& getPrimitiveSetList() const { return _primitives; } diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index c199bf8ed..8d2b40448 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -509,6 +509,20 @@ bool Geometry::insertPrimitiveSet(unsigned int i,PrimitiveSet* primitiveset) return false; } +void Geometry::setPrimitiveSetList(const PrimitiveSetList& primitives) +{ + _primitives = primitives; + if (_useVertexBufferObjects) + { + for (unsigned int primitiveSetIndex=0;primitiveSetIndex<_primitives.size();++primitiveSetIndex) + { + addElementBufferObjectIfRequired(_primitives[primitiveSetIndex]); + } + + } + dirtyDisplayList(); dirtyBound(); +} + bool Geometry::removePrimitiveSet(unsigned int i, unsigned int numElementsToRemove) { if (numElementsToRemove==0) return false;