Renamed osgUtil::RenderGraph to osgUtil::StateGraph
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
|
||||
#include <osg/CullStack>
|
||||
|
||||
#include <osgUtil/RenderGraph>
|
||||
#include <osgUtil/StateGraph>
|
||||
#include <osgUtil/RenderStage>
|
||||
|
||||
#include <osg/Vec3>
|
||||
@@ -91,7 +91,7 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac
|
||||
*/
|
||||
inline void pushStateSet(const osg::StateSet* ss)
|
||||
{
|
||||
_currentRenderGraph = _currentRenderGraph->find_or_insert(ss);
|
||||
_currentStateGraph = _currentStateGraph->find_or_insert(ss);
|
||||
if (ss->useRenderBinDetails())
|
||||
{
|
||||
_currentRenderBin = _currentRenderBin->find_or_insert(ss->getBinNumber(),ss->getBinName());
|
||||
@@ -104,27 +104,27 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac
|
||||
*/
|
||||
inline void popStateSet()
|
||||
{
|
||||
if (_currentRenderGraph->_stateset->useRenderBinDetails())
|
||||
if (_currentStateGraph->_stateset->useRenderBinDetails())
|
||||
{
|
||||
_currentRenderBin = _currentRenderBin->getParent();
|
||||
}
|
||||
_currentRenderGraph = _currentRenderGraph->_parent;
|
||||
_currentStateGraph = _currentStateGraph->_parent;
|
||||
}
|
||||
|
||||
inline void setRenderGraph(RenderGraph* rg)
|
||||
inline void setStateGraph(StateGraph* rg)
|
||||
{
|
||||
_rootRenderGraph = rg;
|
||||
_currentRenderGraph = rg;
|
||||
_rootStateGraph = rg;
|
||||
_currentStateGraph = rg;
|
||||
}
|
||||
|
||||
inline RenderGraph* getRootRenderGraph()
|
||||
inline StateGraph* getRootStateGraph()
|
||||
{
|
||||
return _rootRenderGraph.get();
|
||||
return _rootStateGraph.get();
|
||||
}
|
||||
|
||||
inline RenderGraph* getCurrentRenderGraph()
|
||||
inline StateGraph* getCurrentStateGraph()
|
||||
{
|
||||
return _currentRenderGraph;
|
||||
return _currentStateGraph;
|
||||
}
|
||||
|
||||
inline void setRenderStage(RenderStage* rg)
|
||||
@@ -252,8 +252,8 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac
|
||||
|
||||
osg::ref_ptr<const osg::ClearNode> _clearNode;
|
||||
|
||||
osg::ref_ptr<RenderGraph> _rootRenderGraph;
|
||||
RenderGraph* _currentRenderGraph;
|
||||
osg::ref_ptr<StateGraph> _rootStateGraph;
|
||||
StateGraph* _currentStateGraph;
|
||||
|
||||
osg::ref_ptr<RenderStage> _rootRenderStage;
|
||||
RenderBin* _currentRenderBin;
|
||||
@@ -315,29 +315,29 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac
|
||||
|
||||
inline void CullVisitor::addDrawable(osg::Drawable* drawable,osg::RefMatrix* matrix)
|
||||
{
|
||||
if (_currentRenderGraph->leaves_empty())
|
||||
if (_currentStateGraph->leaves_empty())
|
||||
{
|
||||
// this is first leaf to be added to RenderGraph
|
||||
// this is first leaf to be added to StateGraph
|
||||
// and therefore should not already know to current render bin,
|
||||
// so need to add it.
|
||||
_currentRenderBin->addRenderGraph(_currentRenderGraph);
|
||||
_currentRenderBin->addStateGraph(_currentStateGraph);
|
||||
}
|
||||
//_currentRenderGraph->addLeaf(new RenderLeaf(drawable,matrix));
|
||||
_currentRenderGraph->addLeaf(createOrReuseRenderLeaf(drawable,_projectionStack.back().get(),matrix));
|
||||
//_currentStateGraph->addLeaf(new RenderLeaf(drawable,matrix));
|
||||
_currentStateGraph->addLeaf(createOrReuseRenderLeaf(drawable,_projectionStack.back().get(),matrix));
|
||||
}
|
||||
|
||||
/** Add a drawable and depth to current render graph.*/
|
||||
inline void CullVisitor::addDrawableAndDepth(osg::Drawable* drawable,osg::RefMatrix* matrix,float depth)
|
||||
{
|
||||
if (_currentRenderGraph->leaves_empty())
|
||||
if (_currentStateGraph->leaves_empty())
|
||||
{
|
||||
// this is first leaf to be added to RenderGraph
|
||||
// this is first leaf to be added to StateGraph
|
||||
// and therefore should not already know to current render bin,
|
||||
// so need to add it.
|
||||
_currentRenderBin->addRenderGraph(_currentRenderGraph);
|
||||
_currentRenderBin->addStateGraph(_currentStateGraph);
|
||||
}
|
||||
//_currentRenderGraph->addLeaf(new RenderLeaf(drawable,matrix,depth));
|
||||
_currentRenderGraph->addLeaf(createOrReuseRenderLeaf(drawable,_projectionStack.back().get(),matrix,depth));
|
||||
//_currentStateGraph->addLeaf(new RenderLeaf(drawable,matrix,depth));
|
||||
_currentStateGraph->addLeaf(createOrReuseRenderLeaf(drawable,_projectionStack.back().get(),matrix,depth));
|
||||
}
|
||||
|
||||
/** Add an attribute which is positioned relative to the modelview matrix.*/
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <osg/State>
|
||||
|
||||
#include <osgUtil/RenderLeaf>
|
||||
#include <osgUtil/RenderGraph>
|
||||
#include <osgUtil/StateGraph>
|
||||
|
||||
namespace osgUtil {
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#ifndef OSGUTIL_RENDERBIN
|
||||
#define OSGUTIL_RENDERBIN 1
|
||||
|
||||
#include <osgUtil/RenderGraph>
|
||||
#include <osgUtil/StateGraph>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
@@ -35,7 +35,7 @@ class OSGUTIL_EXPORT RenderBin : public osg::Object
|
||||
public:
|
||||
|
||||
typedef std::vector<RenderLeaf*> RenderLeafList;
|
||||
typedef std::vector<RenderGraph*> RenderGraphList;
|
||||
typedef std::vector<StateGraph*> StateGraphList;
|
||||
typedef std::map< int, osg::ref_ptr<RenderBin> > RenderBinList;
|
||||
|
||||
enum SortMode
|
||||
@@ -80,8 +80,8 @@ class OSGUTIL_EXPORT RenderBin : public osg::Object
|
||||
|
||||
int getBinNum() const { return _binNum; }
|
||||
|
||||
RenderGraphList& getRenderGraphList() { return _renderGraphList; }
|
||||
const RenderGraphList& getRenderGraphList() const { return _renderGraphList; }
|
||||
StateGraphList& getStateGraphList() { return _stateGraphList; }
|
||||
const StateGraphList& getStateGraphList() const { return _stateGraphList; }
|
||||
|
||||
RenderBinList& getRenderBinList() { return _bins; }
|
||||
const RenderBinList& getRenderBinList() const { return _bins; }
|
||||
@@ -92,9 +92,9 @@ class OSGUTIL_EXPORT RenderBin : public osg::Object
|
||||
|
||||
RenderBin* find_or_insert(int binNum,const std::string& binName);
|
||||
|
||||
void addRenderGraph(RenderGraph* rg)
|
||||
void addStateGraph(StateGraph* rg)
|
||||
{
|
||||
_renderGraphList.push_back(rg);
|
||||
_stateGraphList.push_back(rg);
|
||||
}
|
||||
|
||||
void sort();
|
||||
@@ -138,7 +138,7 @@ class OSGUTIL_EXPORT RenderBin : public osg::Object
|
||||
void getPrims(Statistics* primStats);
|
||||
bool getPrims(Statistics* primStats, int nbin);
|
||||
|
||||
void copyLeavesFromRenderGraphListToRenderLeafList();
|
||||
void copyLeavesFromStateGraphListToRenderLeafList();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -148,7 +148,7 @@ class OSGUTIL_EXPORT RenderBin : public osg::Object
|
||||
RenderBin* _parent;
|
||||
RenderStage* _stage;
|
||||
RenderBinList _bins;
|
||||
RenderGraphList _renderGraphList;
|
||||
StateGraphList _stateGraphList;
|
||||
RenderLeafList _renderLeafList;
|
||||
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
|
||||
namespace osgUtil {
|
||||
|
||||
// Forward declare RenderGraph
|
||||
class RenderGraph;
|
||||
// Forward declare StateGraph
|
||||
class StateGraph;
|
||||
|
||||
/** Container class for all data required for rendering of drawables.
|
||||
*/
|
||||
@@ -61,12 +61,12 @@ class OSGUTIL_EXPORT RenderLeaf : public osg::Referenced
|
||||
|
||||
virtual void render(osg::State& state,RenderLeaf* previous);
|
||||
|
||||
/// Allow RenderGraph to change the RenderLeaf's _parent.
|
||||
friend class osgUtil::RenderGraph;
|
||||
/// Allow StateGraph to change the RenderLeaf's _parent.
|
||||
friend class osgUtil::StateGraph;
|
||||
|
||||
public:
|
||||
|
||||
RenderGraph* _parent;
|
||||
StateGraph* _parent;
|
||||
osg::Drawable* _drawable;
|
||||
osg::ref_ptr<osg::RefMatrix> _projection;
|
||||
osg::ref_ptr<osg::RefMatrix> _modelview;
|
||||
|
||||
@@ -262,17 +262,17 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced, public osg::CullSetting
|
||||
const osg::CollectOccludersVisitor* getCollectOccludersVisitor() const { return _collectOccludersVisistor.get(); }
|
||||
|
||||
|
||||
void setRenderGraph(osgUtil::RenderGraph* rg) { _rendergraph = rg; }
|
||||
osgUtil::RenderGraph* getRenderGraph() { return _rendergraph.get(); }
|
||||
const osgUtil::RenderGraph* getRenderGraph() const { return _rendergraph.get(); }
|
||||
void setStateGraph(osgUtil::StateGraph* rg) { _rendergraph = rg; }
|
||||
osgUtil::StateGraph* getStateGraph() { return _rendergraph.get(); }
|
||||
const osgUtil::StateGraph* getStateGraph() const { return _rendergraph.get(); }
|
||||
|
||||
void setRenderGraphLeft(osgUtil::RenderGraph* rg) { _rendergraphLeft = rg; }
|
||||
osgUtil::RenderGraph* getRenderGraphLeft() { return _rendergraphLeft.get(); }
|
||||
const osgUtil::RenderGraph* getRenderGraphLeft() const { return _rendergraphLeft.get(); }
|
||||
void setStateGraphLeft(osgUtil::StateGraph* rg) { _rendergraphLeft = rg; }
|
||||
osgUtil::StateGraph* getStateGraphLeft() { return _rendergraphLeft.get(); }
|
||||
const osgUtil::StateGraph* getStateGraphLeft() const { return _rendergraphLeft.get(); }
|
||||
|
||||
void setRenderGraphRight(osgUtil::RenderGraph* rg) { _rendergraphRight = rg; }
|
||||
osgUtil::RenderGraph* getRenderGraphRight() { return _rendergraphRight.get(); }
|
||||
const osgUtil::RenderGraph* getRenderGraphRight() const { return _rendergraphRight.get(); }
|
||||
void setStateGraphRight(osgUtil::StateGraph* rg) { _rendergraphRight = rg; }
|
||||
osgUtil::StateGraph* getStateGraphRight() { return _rendergraphRight.get(); }
|
||||
const osgUtil::StateGraph* getStateGraphRight() const { return _rendergraphRight.get(); }
|
||||
|
||||
|
||||
void setRenderStage(osgUtil::RenderStage* rs) { _renderStage = rs; }
|
||||
@@ -446,7 +446,7 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced, public osg::CullSetting
|
||||
virtual ~SceneView();
|
||||
|
||||
/** Do cull traversal of attached scene graph using Cull NodeVisitor.*/
|
||||
virtual void cullStage(const osg::Matrixd& projection,const osg::Matrixd& modelview,osgUtil::CullVisitor* cullVisitor, osgUtil::RenderGraph* rendergraph, osgUtil::RenderStage* renderStage);
|
||||
virtual void cullStage(const osg::Matrixd& projection,const osg::Matrixd& modelview,osgUtil::CullVisitor* cullVisitor, osgUtil::StateGraph* rendergraph, osgUtil::RenderStage* renderStage);
|
||||
|
||||
const osg::Matrix computeMVPW() const;
|
||||
|
||||
@@ -462,17 +462,17 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced, public osg::CullSetting
|
||||
osg::ref_ptr<osg::NodeVisitor> _initVisitor;
|
||||
osg::ref_ptr<osg::NodeVisitor> _updateVisitor;
|
||||
osg::ref_ptr<osgUtil::CullVisitor> _cullVisitor;
|
||||
osg::ref_ptr<osgUtil::RenderGraph> _rendergraph;
|
||||
osg::ref_ptr<osgUtil::StateGraph> _rendergraph;
|
||||
osg::ref_ptr<osgUtil::RenderStage> _renderStage;
|
||||
|
||||
osg::ref_ptr<ComputeStereoMatricesCallback> _computeStereoMatricesCallback;
|
||||
|
||||
osg::ref_ptr<osgUtil::CullVisitor> _cullVisitorLeft;
|
||||
osg::ref_ptr<osgUtil::RenderGraph> _rendergraphLeft;
|
||||
osg::ref_ptr<osgUtil::StateGraph> _rendergraphLeft;
|
||||
osg::ref_ptr<osgUtil::RenderStage> _renderStageLeft;
|
||||
|
||||
osg::ref_ptr<osgUtil::CullVisitor> _cullVisitorRight;
|
||||
osg::ref_ptr<osgUtil::RenderGraph> _rendergraphRight;
|
||||
osg::ref_ptr<osgUtil::StateGraph> _rendergraphRight;
|
||||
osg::ref_ptr<osgUtil::RenderStage> _renderStageRight;
|
||||
|
||||
osg::ref_ptr<osg::CollectOccludersVisitor> _collectOccludersVisistor;
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGUTIL_RENDERGRAPH
|
||||
#define OSGUTIL_RENDERGRAPH 1
|
||||
#ifndef OSGUTIL_STATEGRAPH
|
||||
#define OSGUTIL_STATEGRAPH 1
|
||||
|
||||
#include <osg/Matrix>
|
||||
#include <osg/Drawable>
|
||||
@@ -36,17 +36,17 @@ struct LeafDepthSortFunctor
|
||||
}
|
||||
};
|
||||
|
||||
/** RenderGraph - contained in a renderBin, defines the scene to be drawn.
|
||||
/** StateGraph - contained in a renderBin, defines the scene to be drawn.
|
||||
*/
|
||||
class OSGUTIL_EXPORT RenderGraph : public osg::Referenced
|
||||
class OSGUTIL_EXPORT StateGraph : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
typedef std::map< const osg::StateSet*, osg::ref_ptr<RenderGraph> > ChildList;
|
||||
typedef std::map< const osg::StateSet*, osg::ref_ptr<StateGraph> > ChildList;
|
||||
typedef std::vector< osg::ref_ptr<RenderLeaf> > LeafList;
|
||||
|
||||
RenderGraph* _parent;
|
||||
StateGraph* _parent;
|
||||
const osg::StateSet* _stateset;
|
||||
|
||||
int _depth;
|
||||
@@ -59,7 +59,7 @@ class OSGUTIL_EXPORT RenderGraph : public osg::Referenced
|
||||
osg::ref_ptr<osg::Referenced> _userData;
|
||||
|
||||
|
||||
RenderGraph():
|
||||
StateGraph():
|
||||
_parent(NULL),
|
||||
_stateset(NULL),
|
||||
_depth(0),
|
||||
@@ -69,7 +69,7 @@ class OSGUTIL_EXPORT RenderGraph : public osg::Referenced
|
||||
{
|
||||
}
|
||||
|
||||
RenderGraph(RenderGraph* parent,const osg::StateSet* stateset):
|
||||
StateGraph(StateGraph* parent,const osg::StateSet* stateset):
|
||||
_parent(parent),
|
||||
_stateset(stateset),
|
||||
_depth(0),
|
||||
@@ -80,9 +80,9 @@ class OSGUTIL_EXPORT RenderGraph : public osg::Referenced
|
||||
if (_parent) _depth = _parent->_depth + 1;
|
||||
}
|
||||
|
||||
~RenderGraph() {}
|
||||
~StateGraph() {}
|
||||
|
||||
RenderGraph* cloneType() const { return new RenderGraph; }
|
||||
StateGraph* cloneType() const { return new StateGraph; }
|
||||
|
||||
void setUserData(osg::Referenced* obj) { _userData = obj; }
|
||||
osg::Referenced* getUserData() { return _userData.get(); }
|
||||
@@ -141,18 +141,18 @@ class OSGUTIL_EXPORT RenderGraph : public osg::Referenced
|
||||
std::sort(_leaves.begin(),_leaves.end(),LeafDepthSortFunctor());
|
||||
}
|
||||
|
||||
/** Reset the internal contents of a RenderGraph, including deleting all children.*/
|
||||
/** Reset the internal contents of a StateGraph, including deleting all children.*/
|
||||
void reset();
|
||||
|
||||
/** 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 clean();
|
||||
|
||||
/** Recursively prune the RenderGraph of empty children.*/
|
||||
/** Recursively prune the StateGraph of empty children.*/
|
||||
void prune();
|
||||
|
||||
|
||||
inline RenderGraph* find_or_insert(const osg::StateSet* stateset)
|
||||
inline StateGraph* find_or_insert(const osg::StateSet* stateset)
|
||||
{
|
||||
// search for the appropriate state group, return it if found.
|
||||
ChildList::iterator itr = _children.find(stateset);
|
||||
@@ -160,7 +160,7 @@ class OSGUTIL_EXPORT RenderGraph : public osg::Referenced
|
||||
|
||||
// create a state group and insert it into the children list
|
||||
// then return the state group.
|
||||
RenderGraph* sg = new RenderGraph(this,stateset);
|
||||
StateGraph* sg = new StateGraph(this,stateset);
|
||||
_children[stateset] = sg;
|
||||
return sg;
|
||||
}
|
||||
@@ -177,7 +177,7 @@ class OSGUTIL_EXPORT RenderGraph : public osg::Referenced
|
||||
}
|
||||
}
|
||||
|
||||
static inline void moveRenderGraph(osg::State& state,RenderGraph* sg_curr,RenderGraph* sg_new)
|
||||
static inline void moveStateGraph(osg::State& state,StateGraph* sg_curr,StateGraph* sg_new)
|
||||
{
|
||||
if (sg_new==sg_curr || sg_new==NULL) return;
|
||||
|
||||
@@ -185,7 +185,7 @@ class OSGUTIL_EXPORT RenderGraph : public osg::Referenced
|
||||
{
|
||||
|
||||
// use return path to trace back steps to sg_new.
|
||||
std::vector<RenderGraph*> return_path;
|
||||
std::vector<StateGraph*> return_path;
|
||||
|
||||
// need to pop back root render graph.
|
||||
do
|
||||
@@ -194,11 +194,11 @@ class OSGUTIL_EXPORT RenderGraph : public osg::Referenced
|
||||
sg_new = sg_new->_parent;
|
||||
} while (sg_new);
|
||||
|
||||
for(std::vector<RenderGraph*>::reverse_iterator itr=return_path.rbegin();
|
||||
for(std::vector<StateGraph*>::reverse_iterator itr=return_path.rbegin();
|
||||
itr!=return_path.rend();
|
||||
++itr)
|
||||
{
|
||||
RenderGraph* rg = (*itr);
|
||||
StateGraph* rg = (*itr);
|
||||
if (rg->_stateset) state.pushStateSet(rg->_stateset);
|
||||
}
|
||||
return;
|
||||
@@ -226,7 +226,7 @@ class OSGUTIL_EXPORT RenderGraph : public osg::Referenced
|
||||
}
|
||||
|
||||
// use return path to trace back steps to sg_new.
|
||||
std::vector<RenderGraph*> return_path;
|
||||
std::vector<StateGraph*> return_path;
|
||||
|
||||
// need to pop back up to the same depth as the curr state group.
|
||||
while (sg_new->_depth>sg_curr->_depth)
|
||||
@@ -238,7 +238,7 @@ class OSGUTIL_EXPORT RenderGraph : public osg::Referenced
|
||||
// now pop back up both parent paths until they agree.
|
||||
|
||||
// DRT - 10/22/02
|
||||
// should be this to conform with above case where two RenderGraph
|
||||
// should be this to conform with above case where two StateGraph
|
||||
// nodes have the same parent
|
||||
while (sg_curr != sg_new)
|
||||
{
|
||||
@@ -249,17 +249,17 @@ class OSGUTIL_EXPORT RenderGraph : public osg::Referenced
|
||||
sg_new = sg_new->_parent;
|
||||
}
|
||||
|
||||
for(std::vector<RenderGraph*>::reverse_iterator itr=return_path.rbegin();
|
||||
for(std::vector<StateGraph*>::reverse_iterator itr=return_path.rbegin();
|
||||
itr!=return_path.rend();
|
||||
++itr)
|
||||
{
|
||||
RenderGraph* rg = (*itr);
|
||||
StateGraph* rg = (*itr);
|
||||
if (rg->_stateset) state.pushStateSet(rg->_stateset);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline static void moveToRootRenderGraph(osg::State& state,RenderGraph* sg_curr)
|
||||
inline static void moveToRootStateGraph(osg::State& state,StateGraph* sg_curr)
|
||||
{
|
||||
// need to pop back all statesets and matrices.
|
||||
while (sg_curr)
|
||||
@@ -273,9 +273,9 @@ class OSGUTIL_EXPORT RenderGraph : public osg::Referenced
|
||||
private:
|
||||
|
||||
/// disallow copy construction.
|
||||
RenderGraph(const RenderGraph&):osg::Referenced() {}
|
||||
StateGraph(const StateGraph&):osg::Referenced() {}
|
||||
/// disallow copy operator.
|
||||
RenderGraph& operator = (const RenderGraph&) { return *this; }
|
||||
StateGraph& operator = (const StateGraph&) { return *this; }
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user