Changed osgUtil::RenderBin and osg::State to allow nesting of StateSet's associated with RenderBin's.
This commit is contained in:
parent
8625598e00
commit
36330f7e40
@ -124,6 +124,18 @@ class OSG_EXPORT State : public Referenced
|
|||||||
/** pop all statesets off state stack, ensuring it is empty ready for the next frame.
|
/** pop all statesets off state stack, ensuring it is empty ready for the next frame.
|
||||||
* Note, to return OpenGL to default state, one should do any state.popAllStatSets(); state.apply().*/
|
* Note, to return OpenGL to default state, one should do any state.popAllStatSets(); state.apply().*/
|
||||||
void popAllStateSets();
|
void popAllStateSets();
|
||||||
|
|
||||||
|
/** Get the number of StateSet's on the StateSet stack.*/
|
||||||
|
unsigned int getStateSetStackSize() { return _stateStateStack.size(); }
|
||||||
|
|
||||||
|
/** Pop StateSet's for the StateSet stack till its size equals the specified size.*/
|
||||||
|
void popStateSetStackToSize(unsigned int size) { while (_stateStateStack.size()>size) popStateSet(); }
|
||||||
|
|
||||||
|
typedef std::vector<const StateSet*> StateSetStack;
|
||||||
|
|
||||||
|
/** Get the StateSet stack.*/
|
||||||
|
StateSetStack& getStateSetStack() { return _stateStateStack; }
|
||||||
|
|
||||||
|
|
||||||
/** Copy the modes and attributes which capture the current state.*/
|
/** Copy the modes and attributes which capture the current state.*/
|
||||||
void captureCurrentState(StateSet& stateset) const;
|
void captureCurrentState(StateSet& stateset) const;
|
||||||
@ -906,7 +918,6 @@ class OSG_EXPORT State : public Referenced
|
|||||||
|
|
||||||
typedef std::map<std::string,UniformStack> UniformMap;
|
typedef std::map<std::string,UniformStack> UniformMap;
|
||||||
|
|
||||||
typedef std::vector<const StateSet*> StateSetStack;
|
|
||||||
typedef std::vector<ref_ptr<const Matrix> > MatrixStack;
|
typedef std::vector<ref_ptr<const Matrix> > MatrixStack;
|
||||||
|
|
||||||
typedef std::set<osg::ref_ptr<const Program::PerContextProgram> > AppliedProgramObjectSet;
|
typedef std::set<osg::ref_ptr<const Program::PerContextProgram> > AppliedProgramObjectSet;
|
||||||
|
@ -367,11 +367,13 @@ void RenderBin::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& prev
|
|||||||
|
|
||||||
// osg::notify(osg::NOTICE)<<"begin RenderBin::drawImplementation "<<className()<<" sortMode "<<getSortMode()<<std::endl;
|
// osg::notify(osg::NOTICE)<<"begin RenderBin::drawImplementation "<<className()<<" sortMode "<<getSortMode()<<std::endl;
|
||||||
|
|
||||||
if (_stateset.valid())
|
unsigned int stateSetStackSize = state.getStateSetStackSize();
|
||||||
|
|
||||||
|
previous = 0;
|
||||||
|
|
||||||
|
if (_stateset.valid())
|
||||||
{
|
{
|
||||||
// first need to flush the stack
|
// first need to flush the stack
|
||||||
previous = 0;
|
|
||||||
state.popAllStateSets();
|
|
||||||
|
|
||||||
// now its safe to push RenderBin's StateSet as we now know its the root.
|
// now its safe to push RenderBin's StateSet as we now know its the root.
|
||||||
state.pushStateSet(_stateset.get());
|
state.pushStateSet(_stateset.get());
|
||||||
@ -424,10 +426,16 @@ void RenderBin::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& prev
|
|||||||
rbitr->second->draw(renderInfo,previous);
|
rbitr->second->draw(renderInfo,previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stateSetStackSize!=state.getStateSetStackSize())
|
||||||
|
{
|
||||||
|
state.popStateSetStackToSize(stateSetStackSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
previous = 0;
|
||||||
|
|
||||||
if (_stateset.valid())
|
if (_stateset.valid())
|
||||||
{
|
{
|
||||||
state.popAllStateSets();
|
|
||||||
previous = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//osg::notify(osg::NOTICE)<<"end RenderBin::drawImplementation "<<className()<<std::endl;
|
//osg::notify(osg::NOTICE)<<"end RenderBin::drawImplementation "<<className()<<std::endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user