Removed StateSet::ENCLOSE_RENDERBIN_DETAILS since it is rendendent, and

implemented the OVERRIDE_RENDERBIN_DETAILS.
This commit is contained in:
Robert Osfield 2006-07-11 21:53:57 +00:00
parent 165351196e
commit dd6a33da49
6 changed files with 24 additions and 10 deletions

View File

@ -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.*/

View File

@ -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<osg::State> _state;

View File

@ -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()");
}

View File

@ -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 "";
}

View File

@ -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;

View File

@ -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)