Renamed osgUtil::RenderGraph to osgUtil::StateGraph
This commit is contained in:
@@ -91,7 +91,7 @@ class PrintVisitor : public NodeVisitor
|
||||
|
||||
CullVisitor::CullVisitor():
|
||||
NodeVisitor(CULL_VISITOR,TRAVERSE_ACTIVE_CHILDREN),
|
||||
_currentRenderGraph(NULL),
|
||||
_currentStateGraph(NULL),
|
||||
_currentRenderBin(NULL),
|
||||
_computed_znear(FLT_MAX),
|
||||
_computed_zfar(-FLT_MAX),
|
||||
@@ -1185,8 +1185,7 @@ void CullVisitor::apply(osg::CameraNode& camera)
|
||||
setCurrentRenderBin(previousRenderBin);
|
||||
|
||||
|
||||
|
||||
if (rtts->getRenderGraphList().size()==0 && rtts->getRenderBinList().size()==0)
|
||||
if (rtts->getStateGraphList().size()==0 && rtts->getRenderBinList().size()==0)
|
||||
{
|
||||
// getting to this point means that all the subgraph has been
|
||||
// culled by small feature culling or is beyond LOD ranges.
|
||||
|
||||
@@ -13,7 +13,7 @@ CXXFILES = \
|
||||
IntersectVisitor.cpp\
|
||||
Optimizer.cpp\
|
||||
RenderBin.cpp\
|
||||
RenderGraph.cpp\
|
||||
StateGraph.cpp\
|
||||
RenderLeaf.cpp\
|
||||
RenderStage.cpp\
|
||||
PositionalStateContainer.cpp\
|
||||
|
||||
@@ -37,7 +37,7 @@ void PositionalStateContainer::draw(osg::State& state,RenderLeaf*& previous, con
|
||||
|
||||
if (previous)
|
||||
{
|
||||
RenderGraph::moveToRootRenderGraph(state,previous->_parent);
|
||||
StateGraph::moveToRootStateGraph(state,previous->_parent);
|
||||
state.apply();
|
||||
previous = NULL;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ RenderBin::RenderBin(const RenderBin& rhs,const CopyOp& copyop):
|
||||
_parent(rhs._parent),
|
||||
_stage(rhs._stage),
|
||||
_bins(rhs._bins),
|
||||
_renderGraphList(rhs._renderGraphList),
|
||||
_stateGraphList(rhs._stateGraphList),
|
||||
_renderLeafList(rhs._renderLeafList),
|
||||
_sortMode(rhs._sortMode),
|
||||
_sortCallback(rhs._sortCallback),
|
||||
@@ -151,7 +151,7 @@ RenderBin::~RenderBin()
|
||||
|
||||
void RenderBin::reset()
|
||||
{
|
||||
_renderGraphList.clear();
|
||||
_stateGraphList.clear();
|
||||
_bins.clear();
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ void RenderBin::sortImplementation()
|
||||
|
||||
struct SortByStateFunctor
|
||||
{
|
||||
bool operator() (const RenderGraph* lhs,const RenderGraph* rhs) const
|
||||
bool operator() (const StateGraph* lhs,const StateGraph* rhs) const
|
||||
{
|
||||
return (*(lhs->_stateset)<*(rhs->_stateset));
|
||||
}
|
||||
@@ -210,15 +210,15 @@ void RenderBin::sortByState()
|
||||
//osg::notify(osg::NOTICE)<<"sortByState()"<<std::endl;
|
||||
// actually we'll do nothing right now, as fine grained sorting by state
|
||||
// appears to cost more to do than it saves in draw. The contents of
|
||||
// the RenderGraph leaves is already coarse grained sorted, this
|
||||
// the StateGraph leaves is already coarse grained sorted, this
|
||||
// sorting is as a function of the cull traversal.
|
||||
// cout << "doing sortByState "<<this<<endl;
|
||||
}
|
||||
|
||||
|
||||
struct RenderGraphFrontToBackSortFunctor
|
||||
struct StateGraphFrontToBackSortFunctor
|
||||
{
|
||||
bool operator() (const RenderGraph* lhs,const RenderGraph* rhs) const
|
||||
bool operator() (const StateGraph* lhs,const StateGraph* rhs) const
|
||||
{
|
||||
return (lhs->_minimumDistance<rhs->_minimumDistance);
|
||||
}
|
||||
@@ -226,14 +226,14 @@ struct RenderGraphFrontToBackSortFunctor
|
||||
|
||||
void RenderBin::sortByStateThenFrontToBack()
|
||||
{
|
||||
for(RenderGraphList::iterator itr=_renderGraphList.begin();
|
||||
itr!=_renderGraphList.end();
|
||||
for(StateGraphList::iterator itr=_stateGraphList.begin();
|
||||
itr!=_stateGraphList.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->sortFrontToBack();
|
||||
(*itr)->getMinimumDistance();
|
||||
}
|
||||
std::sort(_renderGraphList.begin(),_renderGraphList.end(),RenderGraphFrontToBackSortFunctor());
|
||||
std::sort(_stateGraphList.begin(),_stateGraphList.end(),StateGraphFrontToBackSortFunctor());
|
||||
}
|
||||
|
||||
struct FrontToBackSortFunctor
|
||||
@@ -247,7 +247,7 @@ struct FrontToBackSortFunctor
|
||||
|
||||
void RenderBin::sortFrontToBack()
|
||||
{
|
||||
copyLeavesFromRenderGraphListToRenderLeafList();
|
||||
copyLeavesFromStateGraphListToRenderLeafList();
|
||||
|
||||
// now sort the list into acending depth order.
|
||||
std::sort(_renderLeafList.begin(),_renderLeafList.end(),FrontToBackSortFunctor());
|
||||
@@ -265,7 +265,7 @@ struct BackToFrontSortFunctor
|
||||
|
||||
void RenderBin::sortBackToFront()
|
||||
{
|
||||
copyLeavesFromRenderGraphListToRenderLeafList();
|
||||
copyLeavesFromStateGraphListToRenderLeafList();
|
||||
|
||||
// now sort the list into acending depth order.
|
||||
std::sort(_renderLeafList.begin(),_renderLeafList.end(),BackToFrontSortFunctor());
|
||||
@@ -273,14 +273,14 @@ void RenderBin::sortBackToFront()
|
||||
// cout << "sort back to front"<<endl;
|
||||
}
|
||||
|
||||
void RenderBin::copyLeavesFromRenderGraphListToRenderLeafList()
|
||||
void RenderBin::copyLeavesFromStateGraphListToRenderLeafList()
|
||||
{
|
||||
_renderLeafList.clear();
|
||||
|
||||
int totalsize=0;
|
||||
RenderGraphList::iterator itr;
|
||||
for(itr=_renderGraphList.begin();
|
||||
itr!=_renderGraphList.end();
|
||||
StateGraphList::iterator itr;
|
||||
for(itr=_stateGraphList.begin();
|
||||
itr!=_stateGraphList.end();
|
||||
++itr)
|
||||
{
|
||||
totalsize += (*itr)->_leaves.size();
|
||||
@@ -289,11 +289,11 @@ void RenderBin::copyLeavesFromRenderGraphListToRenderLeafList()
|
||||
_renderLeafList.reserve(totalsize);
|
||||
|
||||
// first copy all the leaves from the render graphs into the leaf list.
|
||||
for(itr=_renderGraphList.begin();
|
||||
itr!=_renderGraphList.end();
|
||||
for(itr=_stateGraphList.begin();
|
||||
itr!=_stateGraphList.end();
|
||||
++itr)
|
||||
{
|
||||
for(RenderGraph::LeafList::iterator dw_itr = (*itr)->_leaves.begin();
|
||||
for(StateGraph::LeafList::iterator dw_itr = (*itr)->_leaves.begin();
|
||||
dw_itr != (*itr)->_leaves.end();
|
||||
++dw_itr)
|
||||
{
|
||||
@@ -302,7 +302,7 @@ void RenderBin::copyLeavesFromRenderGraphListToRenderLeafList()
|
||||
}
|
||||
|
||||
// empty the render graph list to prevent it being drawn along side the render leaf list (see drawImplementation.)
|
||||
_renderGraphList.clear();
|
||||
_stateGraphList.clear();
|
||||
}
|
||||
|
||||
RenderBin* RenderBin::find_or_insert(int binNum,const std::string& binName)
|
||||
@@ -368,12 +368,12 @@ void RenderBin::drawImplementation(osg::State& state,RenderLeaf*& previous)
|
||||
|
||||
|
||||
// draw coarse grained ordering.
|
||||
for(RenderGraphList::iterator oitr=_renderGraphList.begin();
|
||||
oitr!=_renderGraphList.end();
|
||||
for(StateGraphList::iterator oitr=_stateGraphList.begin();
|
||||
oitr!=_stateGraphList.end();
|
||||
++oitr)
|
||||
{
|
||||
|
||||
for(RenderGraph::LeafList::iterator dw_itr = (*oitr)->_leaves.begin();
|
||||
for(StateGraph::LeafList::iterator dw_itr = (*oitr)->_leaves.begin();
|
||||
dw_itr != (*oitr)->_leaves.end();
|
||||
++dw_itr)
|
||||
{
|
||||
@@ -419,12 +419,12 @@ bool RenderBin::getStats(Statistics* primStats)
|
||||
|
||||
}
|
||||
|
||||
for(RenderGraphList::iterator oitr=_renderGraphList.begin();
|
||||
oitr!=_renderGraphList.end();
|
||||
for(StateGraphList::iterator oitr=_stateGraphList.begin();
|
||||
oitr!=_stateGraphList.end();
|
||||
++oitr)
|
||||
{
|
||||
|
||||
for(RenderGraph::LeafList::iterator dw_itr = (*oitr)->_leaves.begin();
|
||||
for(StateGraph::LeafList::iterator dw_itr = (*oitr)->_leaves.begin();
|
||||
dw_itr != (*oitr)->_leaves.end();
|
||||
++dw_itr)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
#include <osgUtil/RenderLeaf>
|
||||
#include <osgUtil/RenderGraph>
|
||||
#include <osgUtil/StateGraph>
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgUtil;
|
||||
@@ -33,12 +33,12 @@ void RenderLeaf::render(State& state,RenderLeaf* previous)
|
||||
state.applyModelViewMatrix(_modelview.get());
|
||||
|
||||
// apply state if required.
|
||||
RenderGraph* prev_rg = previous->_parent;
|
||||
RenderGraph* prev_rg_parent = prev_rg->_parent;
|
||||
RenderGraph* rg = _parent;
|
||||
StateGraph* prev_rg = previous->_parent;
|
||||
StateGraph* prev_rg_parent = prev_rg->_parent;
|
||||
StateGraph* rg = _parent;
|
||||
if (prev_rg_parent!=rg->_parent)
|
||||
{
|
||||
RenderGraph::moveRenderGraph(state,prev_rg_parent,rg->_parent);
|
||||
StateGraph::moveStateGraph(state,prev_rg_parent,rg->_parent);
|
||||
|
||||
// send state changes and matrix changes to OpenGL.
|
||||
state.apply(rg->_stateset);
|
||||
@@ -63,7 +63,7 @@ void RenderLeaf::render(State& state,RenderLeaf* previous)
|
||||
state.applyModelViewMatrix(_modelview.get());
|
||||
|
||||
// apply state if required.
|
||||
RenderGraph::moveRenderGraph(state,NULL,_parent->_parent);
|
||||
StateGraph::moveStateGraph(state,NULL,_parent->_parent);
|
||||
|
||||
state.apply(_parent->_stateset);
|
||||
|
||||
|
||||
@@ -703,7 +703,7 @@ void RenderStage::drawImplementation(osg::State& state,RenderLeaf*& previous)
|
||||
// now reset the state so its back in its default state.
|
||||
if (previous)
|
||||
{
|
||||
RenderGraph::moveToRootRenderGraph(state,previous->_parent);
|
||||
StateGraph::moveToRootStateGraph(state,previous->_parent);
|
||||
state.apply();
|
||||
previous = NULL;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ void SceneView::setDefaults(unsigned int options)
|
||||
|
||||
_state = new State;
|
||||
|
||||
_rendergraph = new RenderGraph;
|
||||
_rendergraph = new StateGraph;
|
||||
_renderStage = new RenderStage;
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ void SceneView::setDefaults(unsigned int options)
|
||||
|
||||
_cullVisitor = new CullVisitor;
|
||||
|
||||
_cullVisitor->setRenderGraph(_rendergraph.get());
|
||||
_cullVisitor->setStateGraph(_rendergraph.get());
|
||||
_cullVisitor->setRenderStage(_renderStage.get());
|
||||
|
||||
_globalStateSet->setGlobalDefaults();
|
||||
@@ -397,8 +397,8 @@ void SceneView::cull()
|
||||
}
|
||||
if (!_rendergraph)
|
||||
{
|
||||
osg::notify(osg::INFO) << "Warning: no valid osgUtil::SceneView:: attached, creating a global default RenderGraph automatically."<< std::endl;
|
||||
_rendergraph = new RenderGraph;
|
||||
osg::notify(osg::INFO) << "Warning: no valid osgUtil::SceneView:: attached, creating a global default StateGraph automatically."<< std::endl;
|
||||
_rendergraph = new StateGraph;
|
||||
}
|
||||
if (!_renderStage)
|
||||
{
|
||||
@@ -441,11 +441,11 @@ void SceneView::cull()
|
||||
{
|
||||
|
||||
if (!_cullVisitorLeft.valid()) _cullVisitorLeft = dynamic_cast<CullVisitor*>(_cullVisitor->cloneType());
|
||||
if (!_rendergraphLeft.valid()) _rendergraphLeft = dynamic_cast<RenderGraph*>(_rendergraph->cloneType());
|
||||
if (!_rendergraphLeft.valid()) _rendergraphLeft = dynamic_cast<StateGraph*>(_rendergraph->cloneType());
|
||||
if (!_renderStageLeft.valid()) _renderStageLeft = dynamic_cast<RenderStage*>(_renderStage->clone(osg::CopyOp::DEEP_COPY_ALL));
|
||||
|
||||
if (!_cullVisitorRight.valid()) _cullVisitorRight = dynamic_cast<CullVisitor*>(_cullVisitor->cloneType());
|
||||
if (!_rendergraphRight.valid()) _rendergraphRight = dynamic_cast<RenderGraph*>(_rendergraph->cloneType());
|
||||
if (!_rendergraphRight.valid()) _rendergraphRight = dynamic_cast<StateGraph*>(_rendergraph->cloneType());
|
||||
if (!_renderStageRight.valid()) _renderStageRight = dynamic_cast<RenderStage*>(_renderStage->clone(osg::CopyOp::DEEP_COPY_ALL));
|
||||
|
||||
_cullVisitorLeft->setDatabaseRequestHandler(_cullVisitor->getDatabaseRequestHandler());
|
||||
@@ -488,7 +488,7 @@ void SceneView::cull()
|
||||
|
||||
}
|
||||
|
||||
void SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& modelview,osgUtil::CullVisitor* cullVisitor, osgUtil::RenderGraph* rendergraph, osgUtil::RenderStage* renderStage)
|
||||
void SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& modelview,osgUtil::CullVisitor* cullVisitor, osgUtil::StateGraph* rendergraph, osgUtil::RenderStage* renderStage)
|
||||
{
|
||||
|
||||
if (!_sceneData || !_viewport->valid()) return;
|
||||
@@ -556,7 +556,7 @@ void SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
|
||||
cullVisitor->setClearNode(NULL); // reset earth sky on each frame.
|
||||
|
||||
cullVisitor->setRenderGraph(rendergraph);
|
||||
cullVisitor->setStateGraph(rendergraph);
|
||||
cullVisitor->setRenderStage(renderStage);
|
||||
|
||||
cullVisitor->setState( _state.get() );
|
||||
@@ -627,11 +627,11 @@ void SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
|
||||
renderStage->sort();
|
||||
|
||||
// prune out any empty RenderGraph children.
|
||||
// prune out any empty StateGraph children.
|
||||
// note, this would be not required if the rendergraph had been
|
||||
// reset at the start of each frame (see top of this method) but
|
||||
// a clean has been used instead to try to minimize the amount of
|
||||
// allocation and deleteing of the RenderGraph nodes.
|
||||
// allocation and deleteing of the StateGraph nodes.
|
||||
rendergraph->prune();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
#include <osgUtil/RenderGraph>
|
||||
#include <osgUtil/StateGraph>
|
||||
|
||||
#include <osg/Notify>
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgUtil;
|
||||
|
||||
void RenderGraph::reset()
|
||||
void StateGraph::reset()
|
||||
{
|
||||
_parent = NULL;
|
||||
_stateset = NULL;
|
||||
@@ -28,9 +28,9 @@ void RenderGraph::reset()
|
||||
_leaves.clear();
|
||||
}
|
||||
|
||||
/** recursively clean the RenderGraph of all its drawables, lights and depths.
|
||||
/** recursively clean the StateGraph of all its drawables, lights and depths.
|
||||
* Leaves children intact, and ready to be populated again.*/
|
||||
void RenderGraph::clean()
|
||||
void StateGraph::clean()
|
||||
{
|
||||
|
||||
// clean local drawables etc.
|
||||
@@ -46,8 +46,8 @@ void RenderGraph::clean()
|
||||
|
||||
}
|
||||
|
||||
/** recursively prune the RenderGraph of empty children.*/
|
||||
void RenderGraph::prune()
|
||||
/** recursively prune the StateGraph of empty children.*/
|
||||
void StateGraph::prune()
|
||||
{
|
||||
std::vector<const osg::StateSet*> toEraseList;
|
||||
|
||||
Reference in New Issue
Block a user