|
void RenderBin::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& previous)
{
osg::State& state = *renderInfo.getState();
// osg::notify(osg::NOTICE)<<"begin RenderBin::drawImplementation "<<className()<<" sortMode "<<getSortMode()<<std::endl;
unsigned int numToPop = (previous ? StateGraph::numToPop(previous->_parent) : 0);
if (numToPop>1) --numToPop;
unsigned int insertStateSetPosition = state.getStateSetStackSize() - numToPop;
if (_stateset.valid())
{
state.insertStateSet(insertStateSetPosition, _stateset.get());
}
// draw first set of draw bins.
RenderBinList::iterator rbitr;
for(rbitr = _bins.begin();
rbitr!=_bins.end() && rbitr->first<0;
++rbitr)
{
rbitr->second->draw(renderInfo,previous);
}
// draw fine grained ordering.
for(RenderLeafList::iterator rlitr= _renderLeafList.begin();
rlitr!= _renderLeafList.end();
++rlitr)
{
RenderLeaf* rl = *rlitr;
rl->render(renderInfo,previous);
previous = rl;
}
bool draw_forward = true; //(_sortMode!=SORT_BY_STATE) || (state.getFrameStamp()->getFrameNumber() % 2)==0;
// draw coarse grained ordering.
if (draw_forward)
{
for(StateGraphList::iterator oitr=_stateGraphList.begin();
oitr!=_stateGraphList.end();
++oitr)
{
for(StateGraph:eafList::iterator dw_itr = (*oitr)->_leaves.begin();
dw_itr != (*oitr)->_leaves.end();
++dw_itr)
{
RenderLeaf* rl = dw_itr->get();
rl->render(renderInfo,previous);
previous = rl;
}
}
}
else
{
for(StateGraphList::reverse_iterator oitr=_stateGraphList.rbegin();
oitr!=_stateGraphList.rend();
++oitr)
{
for(StateGraph::LeafList::iterator dw_itr = (*oitr)->_leaves.begin();
dw_itr != (*oitr)->_leaves.end();
++dw_itr)
{
RenderLeaf* rl = dw_itr->get();
rl->render(renderInfo,previous);
previous = rl;
}
}
}
// draw post bins.
for(;
rbitr!=_bins.end();
++rbitr)
{
rbitr->second->draw(renderInfo,previous);
}
if (_stateset.valid())
{
state.removeStateSet(insertStateSetPosition);
// state.apply();
}
// osg::notify(osg::NOTICE)<<"end RenderBin::drawImplementation "<<className()<<std::endl;
} |
|