From d5ed4e2305eb20ecc3390aa6a147eb4c4fe78fb3 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 4 Oct 2001 14:35:42 +0000 Subject: [PATCH] Added an implemention of basic state sorting to the RenderBin, but have commented out the sort operation as Peformance benifit is currently negligable, will need to improve on the sort functor to see real benifits. --- include/osgUtil/RenderBin | 2 +- src/osgUtil/RenderBin.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/osgUtil/RenderBin b/include/osgUtil/RenderBin index 82f92b1e0..267bd9c50 100644 --- a/include/osgUtil/RenderBin +++ b/include/osgUtil/RenderBin @@ -47,7 +47,7 @@ class OSGUTIL_EXPORT RenderBin : public osg::Object void sort(); - virtual void sort_local() {} + virtual void sort_local(); virtual void draw(osg::State& state,RenderLeaf*& previous); diff --git a/src/osgUtil/RenderBin.cpp b/src/osgUtil/RenderBin.cpp index 26c5a76b3..acd487196 100644 --- a/src/osgUtil/RenderBin.cpp +++ b/src/osgUtil/RenderBin.cpp @@ -1,6 +1,8 @@ #include #include +#include + using namespace osg; using namespace osgUtil; @@ -71,6 +73,23 @@ void RenderBin::sort() sort_local(); } + +struct StateSortFunctor +{ + const bool operator() (const RenderGraph* lhs,const RenderGraph* rhs) + { + return (*(lhs->_stateset)<*(rhs->_stateset)); + } +}; + + + +void RenderBin::sort_local() +{ + // now sort the list into acending depth order. +// std::sort(_renderGraphList.begin(),_renderGraphList.end(),StateSortFunctor()); +} + RenderBin* RenderBin::find_or_insert(int binNum,const std::string& binName) { // search for appropriate bin.