diff --git a/include/osg/Geometry b/include/osg/Geometry index 709870d44..da02eeb75 100644 --- a/include/osg/Geometry +++ b/include/osg/Geometry @@ -77,6 +77,10 @@ class SG_EXPORT Geometry : public Drawable PrimitiveList& getPrimitiveList() { return _primitives; } const PrimitiveList& getPrimitiveList() const { return _primitives; } + unsigned int getNumPrimitives() const { return _primitives.size(); } + Primitive* getPrimitive(unsigned int pos) { return _primitives[pos].get(); } + const Primitive* getPrimitive(unsigned int pos) const { return _primitives[pos].get(); } + void addPrimitive(Primitive* primitive) { if (primitive) _primitives.push_back(primitive); dirtyDisplayList(); } diff --git a/include/osgUtil/Optimizer b/include/osgUtil/Optimizer index 2f517d4aa..3c0c20cfc 100644 --- a/include/osgUtil/Optimizer +++ b/include/osgUtil/Optimizer @@ -329,8 +329,15 @@ class OSGUTIL_EXPORT Optimizer virtual void apply(osg::Billboard&) { /* don't do anything*/ } static bool mergeGeode(osg::Geode& geode); + static bool mergeGeometry(osg::Geometry& lhs,osg::Geometry& rhs); + static bool mergePrimitive(osg::DrawArrays& lhs,osg::DrawArrays& rhs); + static bool mergePrimitive(osg::DrawArrayLengths& lhs,osg::DrawArrayLengths& rhs); + static bool mergePrimitive(osg::DrawElementsUByte& lhs,osg::DrawElementsUByte& rhs); + static bool mergePrimitive(osg::DrawElementsUShort& lhs,osg::DrawElementsUShort& rhs); + static bool mergePrimitive(osg::DrawElementsUInt& lhs,osg::DrawElementsUInt& rhs); + }; }; diff --git a/src/osgPlugins/flt/GeoSetBuilder.cpp b/src/osgPlugins/flt/GeoSetBuilder.cpp index 14828682d..48ec0ca54 100644 --- a/src/osgPlugins/flt/GeoSetBuilder.cpp +++ b/src/osgPlugins/flt/GeoSetBuilder.cpp @@ -234,45 +234,15 @@ struct SortDynGeoSet osg::Geode* GeoSetBuilder::createOsgGeoSets(osg::Geode* geode) { if( geode == NULL) geode = _geode.get(); - if( geode == NULL) return geode; - DynGeoSetList::iterator itr; - - if (_dynGeoSetList.size()==1) + for(DynGeoSetList::iterator itr = _dynGeoSetList.begin(); + itr!=_dynGeoSetList.end(); + ++itr) { osg::Geometry* geom = new osg::Geometry; geode->addDrawable(geom); - - _dynGeoSetList.front()->addToGeometry(geom); - } - else if (_dynGeoSetList.size()>1) - { - std::sort(_dynGeoSetList.begin(),_dynGeoSetList.end(),SortDynGeoSet()); - - osg::Geometry* geom = new osg::Geometry; - geode->addDrawable(geom); - _dynGeoSetList.front()->addToGeometry(geom); - - - static int counter=0; - itr = _dynGeoSetList.begin(); - DynGeoSetList::iterator prev = itr++; - for(; - itr!=_dynGeoSetList.end(); - ++itr) - { - if ((*itr)->compatible(*(*prev))==0) - { - (*itr)->addToGeometry(geom); - counter++; - } else - { - geom = new osg::Geometry; - geode->addDrawable(geom); - (*itr)->addToGeometry(geom); - } - } + (*itr)->addToGeometry(geom); } osgUtil::Tesselator tesselator;