From dd6a33da49ba42f94d20fa4e0ea58dba09896688 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 11 Jul 2006 21:53:57 +0000 Subject: [PATCH] Removed StateSet::ENCLOSE_RENDERBIN_DETAILS since it is rendendent, and implemented the OVERRIDE_RENDERBIN_DETAILS. --- include/osg/StateSet | 3 +-- include/osgUtil/CullVisitor | 19 +++++++++++++++++-- src/osgPlugins/ive/StateSet.cpp | 3 +-- src/osgPlugins/osg/StateSet.cpp | 3 +-- src/osgUtil/CullVisitor.cpp | 5 ++++- src/osgWrappers/osg/StateSet.cpp | 1 - 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/include/osg/StateSet b/include/osg/StateSet index 8b449f427..0e28986ea 100644 --- a/include/osg/StateSet +++ b/include/osg/StateSet @@ -327,8 +327,7 @@ class OSG_EXPORT StateSet : public Object { INHERIT_RENDERBIN_DETAILS, USE_RENDERBIN_DETAILS, - OVERRIDE_RENDERBIN_DETAILS, - ENCLOSE_RENDERBIN_DETAILS + OVERRIDE_RENDERBIN_DETAILS }; /** Set the render bin details.*/ diff --git a/include/osgUtil/CullVisitor b/include/osgUtil/CullVisitor index 02a7afe5a..bcdefa02b 100644 --- a/include/osgUtil/CullVisitor +++ b/include/osgUtil/CullVisitor @@ -92,10 +92,14 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac inline void pushStateSet(const osg::StateSet* ss) { _currentStateGraph = _currentStateGraph->find_or_insert(ss); - if (ss->useRenderBinDetails()) + if (_numberOfEncloseOverrideRenderBinDetails==0 && ss->useRenderBinDetails() && !ss->getBinName().empty()) { _currentRenderBin = _currentRenderBin->find_or_insert(ss->getBinNumber(),ss->getBinName()); } + if (ss->getRenderBinMode()==osg::StateSet::OVERRIDE_RENDERBIN_DETAILS) + { + ++_numberOfEncloseOverrideRenderBinDetails; + } } /** Pop the top state set and hence associated state group. @@ -104,9 +108,18 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac */ inline void popStateSet() { - if (_currentStateGraph->_stateset->useRenderBinDetails()) + const osg::StateSet* ss = _currentStateGraph->_stateset; + if (_numberOfEncloseOverrideRenderBinDetails==0 && ss->useRenderBinDetails() && !ss->getBinName().empty()) { _currentRenderBin = _currentRenderBin->getParent(); + if (_currentRenderBin->getParent()) + { + _currentRenderBin = _currentRenderBin->getParent(); + } + } + if (ss->getRenderBinMode()==osg::StateSet::OVERRIDE_RENDERBIN_DETAILS) + { + --_numberOfEncloseOverrideRenderBinDetails; } _currentStateGraph = _currentStateGraph->_parent; } @@ -269,6 +282,8 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac inline RenderLeaf* createOrReuseRenderLeaf(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* matrix, float depth=0.0f); + unsigned int _numberOfEncloseOverrideRenderBinDetails; + osg::ref_ptr _state; diff --git a/src/osgPlugins/ive/StateSet.cpp b/src/osgPlugins/ive/StateSet.cpp index e8a4cd5ad..58c377d10 100644 --- a/src/osgPlugins/ive/StateSet.cpp +++ b/src/osgPlugins/ive/StateSet.cpp @@ -36,7 +36,6 @@ void StateSet::write(DataOutputStream* out){ case osg::StateSet::INHERIT_RENDERBIN_DETAILS: out->writeChar((char)0);break; case osg::StateSet::USE_RENDERBIN_DETAILS: out->writeChar((char)1);break; case osg::StateSet::OVERRIDE_RENDERBIN_DETAILS: out->writeChar((char)2);break; - case osg::StateSet::ENCLOSE_RENDERBIN_DETAILS: out->writeChar((char)3);break; default: throw Exception("Unknown RenderBinMode in StateSet::write()"); } out->writeInt(getBinNumber()); @@ -131,7 +130,7 @@ void StateSet::read(DataInputStream* in){ setRenderBinDetails(num, name, osg::StateSet::OVERRIDE_RENDERBIN_DETAILS); break; case 3: - setRenderBinDetails(num, name, osg::StateSet::ENCLOSE_RENDERBIN_DETAILS); + setRenderBinDetails(num, name, osg::StateSet::USE_RENDERBIN_DETAILS); break; default: throw Exception("Unknown RenderBinMode in StateSet::read()"); } diff --git a/src/osgPlugins/osg/StateSet.cpp b/src/osgPlugins/osg/StateSet.cpp index 4f0970837..f4e97f196 100644 --- a/src/osgPlugins/osg/StateSet.cpp +++ b/src/osgPlugins/osg/StateSet.cpp @@ -642,7 +642,7 @@ bool StateSet_matchRenderBinModeStr(const char* str,StateSet::RenderBinMode& mod if (strcmp(str,"INHERIT")==0) mode = StateSet::INHERIT_RENDERBIN_DETAILS; else if (strcmp(str,"USE")==0) mode = StateSet::USE_RENDERBIN_DETAILS; else if (strcmp(str,"OVERRIDE")==0) mode = StateSet::OVERRIDE_RENDERBIN_DETAILS; - else if (strcmp(str,"ENCLOSE")==0) mode = StateSet::ENCLOSE_RENDERBIN_DETAILS; + else if (strcmp(str,"ENCLOSE")==0) mode = StateSet::USE_RENDERBIN_DETAILS; else return false; return true; } @@ -654,7 +654,6 @@ const char* StateSet_getRenderBinModeStr(StateSet::RenderBinMode mode) case(StateSet::INHERIT_RENDERBIN_DETAILS): return "INHERIT"; case(StateSet::USE_RENDERBIN_DETAILS): return "USE"; case(StateSet::OVERRIDE_RENDERBIN_DETAILS): return "OVERRIDE"; - case(StateSet::ENCLOSE_RENDERBIN_DETAILS): return "ENCLOSE"; } return ""; } diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index 879a8ba13..d634697d8 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -95,7 +95,8 @@ CullVisitor::CullVisitor(): _currentRenderBin(NULL), _computed_znear(FLT_MAX), _computed_zfar(-FLT_MAX), - _currentReuseRenderLeafIndex(0) + _currentReuseRenderLeafIndex(0), + _numberOfEncloseOverrideRenderBinDetails(0) { // _nearFarRatio = 0.000005f; } @@ -116,6 +117,8 @@ void CullVisitor::reset() CullStack::reset(); + _numberOfEncloseOverrideRenderBinDetails = 0; + // reset the calculated near far planes. _computed_znear = FLT_MAX; _computed_zfar = -FLT_MAX; diff --git a/src/osgWrappers/osg/StateSet.cpp b/src/osgWrappers/osg/StateSet.cpp index b6f83c2c2..97231a8d6 100644 --- a/src/osgWrappers/osg/StateSet.cpp +++ b/src/osgWrappers/osg/StateSet.cpp @@ -51,7 +51,6 @@ BEGIN_ENUM_REFLECTOR(osg::StateSet::RenderBinMode) I_EnumLabel(osg::StateSet::INHERIT_RENDERBIN_DETAILS); I_EnumLabel(osg::StateSet::USE_RENDERBIN_DETAILS); I_EnumLabel(osg::StateSet::OVERRIDE_RENDERBIN_DETAILS); - I_EnumLabel(osg::StateSet::ENCLOSE_RENDERBIN_DETAILS); END_REFLECTOR BEGIN_OBJECT_REFLECTOR(osg::StateSet)