From 9b33dee6acc8200ddd0fd62d87fae916945b0bc6 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 2 Aug 2004 12:19:50 +0000 Subject: [PATCH] Made the member variables in RenderStage and RenderBin protected --- examples/osgdepthshadow/osgdepthshadow.cpp | 12 ++++----- examples/osgdistortion/osgdistortion.cpp | 6 ++--- examples/osgprerender/osgprerender.cpp | 6 ++--- .../osgprerendercubemap.cpp | 6 ++--- .../osgshadowtexture/CreateShadowedScene.cpp | 8 +++--- include/osgUtil/CullVisitor | 6 ++--- include/osgUtil/RenderBin | 27 ++++++++++++++----- include/osgUtil/RenderStage | 8 +++--- include/osgUtil/SceneView | 9 +------ src/osgUtil/CullVisitor.cpp | 6 ++--- 10 files changed, 51 insertions(+), 43 deletions(-) diff --git a/examples/osgdepthshadow/osgdepthshadow.cpp b/examples/osgdepthshadow/osgdepthshadow.cpp index bfaa6cc07..08f5b492b 100644 --- a/examples/osgdepthshadow/osgdepthshadow.cpp +++ b/examples/osgdepthshadow/osgdepthshadow.cpp @@ -134,8 +134,8 @@ public: virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) { - osgUtil::CullVisitor* cullVisitor = dynamic_cast(nv); - if (cullVisitor && _texture.valid() && _subgraph.valid()) + osgUtil::CullVisitor* cullVisitor = dynamic_cast(nv); + if (cullVisitor && _texture.valid() && _subgraph.valid()) { _request_render_to_depth_texture(*node, *cullVisitor); } @@ -163,11 +163,11 @@ void RenderToTextureCallback::_request_render_to_depth_texture(osg::Node&, osgUt // set up lighting. // currently ignore lights in the scene graph itself.. // will do later. - osgUtil::RenderStage* previous_stage = cv.getCurrentRenderBin()->_stage; + osgUtil::RenderStage* previous_stage = cv.getCurrentRenderBin()->getStage(); // set up the background color and clear mask. rtts->setClearMask(GL_DEPTH_BUFFER_BIT); - rtts->_colorMask = new ColorMask(false, false, false, false); + rtts->setColorMask(new ColorMask(false, false, false, false)); // set up to charge the same RenderStageLighting is the parent previous stage. rtts->setRenderStageLighting(previous_stage->getRenderStageLighting()); @@ -219,7 +219,7 @@ void RenderToTextureCallback::_request_render_to_depth_texture(osg::Node&, osgUt // restore the previous renderbin. cv.setCurrentRenderBin(previousRenderBin); - if (rtts->_renderGraphList.size()==0 && rtts->_bins.size()==0) + if (rtts->getRenderGraphList().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. @@ -230,7 +230,7 @@ void RenderToTextureCallback::_request_render_to_depth_texture(osg::Node&, osgUt // and the render to texture stage to the current stages // dependancy list. - cv.getCurrentRenderBin()->_stage->addToDependencyList(rtts.get()); + cv.getCurrentRenderBin()->getStage()->addToDependencyList(rtts.get()); // if one exist attach texture to the RenderToTextureStage. rtts->setTexture(_texture.get()); diff --git a/examples/osgdistortion/osgdistortion.cpp b/examples/osgdistortion/osgdistortion.cpp index 90bfdce2a..6f80cd12c 100644 --- a/examples/osgdistortion/osgdistortion.cpp +++ b/examples/osgdistortion/osgdistortion.cpp @@ -185,7 +185,7 @@ void DistortionNode::preRender(osgUtil::CullVisitor& cv) // set up lighting. // currently ignore lights in the scene graph itself.. // will do later. - osgUtil::RenderStage* previous_stage = cv.getCurrentRenderBin()->_stage; + osgUtil::RenderStage* previous_stage = cv.getCurrentRenderBin()->getStage(); // set up the background color and clear mask. rtts->setClearColor(osg::Vec4(0.1f,0.1f,0.3f,1.0f)); @@ -216,7 +216,7 @@ void DistortionNode::preRender(osgUtil::CullVisitor& cv) // restore the previous renderbin. cv.setCurrentRenderBin(previousRenderBin); - if (rtts->_renderGraphList.size()==0 && rtts->_bins.size()==0) + if (rtts->getRenderGraphList().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. @@ -243,7 +243,7 @@ void DistortionNode::preRender(osgUtil::CullVisitor& cv) // and the render to texture stage to the current stages // dependancy list. - cv.getCurrentRenderBin()->_stage->addToDependencyList(rtts.get()); + cv.getCurrentRenderBin()->getStage()->addToDependencyList(rtts.get()); // if one exist attach texture to the RenderToTextureStage. if (_texture.valid()) rtts->setTexture(_texture.get()); diff --git a/examples/osgprerender/osgprerender.cpp b/examples/osgprerender/osgprerender.cpp index 8d497e159..37e3fdac0 100644 --- a/examples/osgprerender/osgprerender.cpp +++ b/examples/osgprerender/osgprerender.cpp @@ -100,7 +100,7 @@ void MyCullCallback::doPreRender(osg::Node&, osgUtil::CullVisitor& cv) // set up lighting. // currently ignore lights in the scene graph itself.. // will do later. - osgUtil::RenderStage* previous_stage = cv.getCurrentRenderBin()->_stage; + osgUtil::RenderStage* previous_stage = cv.getCurrentRenderBin()->getStage(); // set up the background color and clear mask. rtts->setClearColor(osg::Vec4(0.1f,0.1f,0.3f,1.0f)); @@ -159,7 +159,7 @@ void MyCullCallback::doPreRender(osg::Node&, osgUtil::CullVisitor& cv) // restore the previous renderbin. cv.setCurrentRenderBin(previousRenderBin); - if (rtts->_renderGraphList.size()==0 && rtts->_bins.size()==0) + if (rtts->getRenderGraphList().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. @@ -188,7 +188,7 @@ void MyCullCallback::doPreRender(osg::Node&, osgUtil::CullVisitor& cv) // and the render to texture stage to the current stages // dependancy list. - cv.getCurrentRenderBin()->_stage->addToDependencyList(rtts.get()); + cv.getCurrentRenderBin()->getStage()->addToDependencyList(rtts.get()); // if one exist attach texture to the RenderToTextureStage. if (_texture.valid()) rtts->setTexture(_texture.get()); diff --git a/examples/osgprerendercubemap/osgprerendercubemap.cpp b/examples/osgprerendercubemap/osgprerendercubemap.cpp index 9bf6ce6ca..da81f09ff 100644 --- a/examples/osgprerendercubemap/osgprerendercubemap.cpp +++ b/examples/osgprerendercubemap/osgprerendercubemap.cpp @@ -163,7 +163,7 @@ void PrerenderCullCallback::doPreRender(osg::Node& /*node*/, osgUtil::CullVisito // set up lighting. // currently ignore lights in the scene graph itself.. // will do later. - osgUtil::RenderStage* previous_stage = cv.getCurrentRenderBin()->_stage; + osgUtil::RenderStage* previous_stage = cv.getCurrentRenderBin()->getStage(); // set up the background color and clear mask. rtts->setClearColor(_clearColor); @@ -221,7 +221,7 @@ void PrerenderCullCallback::doPreRender(osg::Node& /*node*/, osgUtil::CullVisito // restore the previous renderbin. cv.setCurrentRenderBin(previousRenderBin); - if (rtts->_renderGraphList.size()==0 && rtts->_bins.size()==0) + if (rtts->getRenderGraphList().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. @@ -247,7 +247,7 @@ void PrerenderCullCallback::doPreRender(osg::Node& /*node*/, osgUtil::CullVisito // and the render to texture stage to the current stages // dependancy list. - cv.getCurrentRenderBin()->_stage->addToDependencyList(rtts.get()); + cv.getCurrentRenderBin()->getStage()->addToDependencyList(rtts.get()); // if one exist attach image to the RenderToTextureStage. // if (image.valid()) rtts->setImage(_image.get()); diff --git a/examples/osgshadowtexture/CreateShadowedScene.cpp b/examples/osgshadowtexture/CreateShadowedScene.cpp index dbc832394..7263f6538 100644 --- a/examples/osgshadowtexture/CreateShadowedScene.cpp +++ b/examples/osgshadowtexture/CreateShadowedScene.cpp @@ -79,11 +79,11 @@ void CreateShadowTextureCullCallback::doPreRender(osg::Node& node, osgUtil::Cull // set up lighting. // currently ignore lights in the scene graph itself.. // will do later. - osgUtil::RenderStage* previous_stage = cv.getCurrentRenderBin()->_stage; + osgUtil::RenderStage* previous_stage = cv.getCurrentRenderBin()->getStage(); // set up the background color and clear mask. rtts->setClearColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); - rtts->setClearMask(previous_stage->getClearMask()); + //rtts->setClearMask(previous_stage->getClearMask()); // set up to charge the same RenderStageLighting is the parent previous stage. rtts->setRenderStageLighting(previous_stage->getRenderStageLighting()); @@ -160,7 +160,7 @@ void CreateShadowTextureCullCallback::doPreRender(osg::Node& node, osgUtil::Cull // restore the previous renderbin. cv.setCurrentRenderBin(previousRenderBin); - if (rtts->_renderGraphList.size()==0 && rtts->_bins.size()==0) + if (rtts->getRenderGraphList().size()==0 && rtts->getRenderBinList().size()==0) { // getting to this point means that all the shadower has been // culled by small feature culling or is beyond LOD ranges. @@ -189,7 +189,7 @@ void CreateShadowTextureCullCallback::doPreRender(osg::Node& node, osgUtil::Cull // and the render to texture stage to the current stages // dependancy list. - cv.getCurrentRenderBin()->_stage->addToDependencyList(rtts.get()); + cv.getCurrentRenderBin()->getStage()->addToDependencyList(rtts.get()); // if one exist attach texture to the RenderToTextureStage. if (_texture.valid()) rtts->setTexture(_texture.get()); diff --git a/include/osgUtil/CullVisitor b/include/osgUtil/CullVisitor index c36d73847..2f45ad0f8 100644 --- a/include/osgUtil/CullVisitor +++ b/include/osgUtil/CullVisitor @@ -107,7 +107,7 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac { if (_currentRenderGraph->_stateset->useRenderBinDetails()) { - _currentRenderBin = _currentRenderBin->_parent; + _currentRenderBin = _currentRenderBin->getParent(); } _currentRenderGraph = _currentRenderGraph->_parent; } @@ -351,13 +351,13 @@ inline void CullVisitor::addDrawableAndDepth(osg::Drawable* drawable,osg::RefMat /** Add an attribute which is positioned related to the modelview matrix.*/ inline void CullVisitor::addPositionedAttribute(osg::RefMatrix* matrix,const osg::StateAttribute* attr) { - _currentRenderBin->_stage->addPositionedAttribute(matrix,attr); + _currentRenderBin->getStage()->addPositionedAttribute(matrix,attr); } /** Add an attribute which is positioned related to the modelview matrix.*/ inline void CullVisitor::addPositionedTextureAttribute(unsigned int textureUnit, osg::RefMatrix* matrix,const osg::StateAttribute* attr) { - _currentRenderBin->_stage->addPositionedTextureAttribute(textureUnit,matrix,attr); + _currentRenderBin->getStage()->addPositionedTextureAttribute(textureUnit,matrix,attr); } inline RenderLeaf* CullVisitor::createOrReuseRenderLeaf(osg::Drawable* drawable,osg::RefMatrix* projection,osg::RefMatrix* matrix, float depth) diff --git a/include/osgUtil/RenderBin b/include/osgUtil/RenderBin index d953bd078..626fa244a 100644 --- a/include/osgUtil/RenderBin +++ b/include/osgUtil/RenderBin @@ -62,6 +62,22 @@ class OSGUTIL_EXPORT RenderBin : public osg::Object virtual void reset(); + RenderBin* getParent() { return _parent; } + const RenderBin* getParent() const { return _parent; } + + RenderStage* getStage() { return _stage; } + const RenderStage* getStage() const { return _stage; } + + RenderGraphList& getRenderGraphList() { return _renderGraphList; } + const RenderGraphList& getRenderGraphList() const { return _renderGraphList; } + + RenderBinList& getRenderBinList() { return _bins; } + const RenderBinList& getRenderBinList() const { return _bins; } + + RenderLeafList& getRenderLeafList() { return _renderLeafList; } + const RenderLeafList& getRenderLeafList() const { return _renderLeafList; } + + RenderBin* find_or_insert(int binNum,const std::string& binName); void addRenderGraph(RenderGraph* rg) @@ -104,16 +120,16 @@ class OSGUTIL_EXPORT RenderBin : public osg::Object DrawCallback* getDrawCallback() { return _drawCallback.get(); } const DrawCallback* getDrawCallback() const { return _drawCallback.get(); } - - /** extract stats for current draw list. */ bool getStats(Statistics* primStats); void getPrims(Statistics* primStats); bool getPrims(Statistics* primStats, int nbin); +#ifndef USE_DEPRECATED_API + protected: +#endif - public: - + virtual ~RenderBin(); void copyLeavesFromRenderGraphListToRenderLeafList(); @@ -130,9 +146,6 @@ class OSGUTIL_EXPORT RenderBin : public osg::Object osg::ref_ptr _drawCallback; - protected: - - virtual ~RenderBin(); }; diff --git a/include/osgUtil/RenderStage b/include/osgUtil/RenderStage index 7412f62b1..8cf3dd8cc 100644 --- a/include/osgUtil/RenderStage +++ b/include/osgUtil/RenderStage @@ -133,8 +133,12 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin /** extract stats for current draw list. */ bool getStats(Statistics* primStats); - public: +#ifndef USE_DEPRECATED_API + protected: +#endif + virtual ~RenderStage(); + typedef std::vector< osg::ref_ptr > DependencyList; bool _stageDrawnThisFrame; @@ -152,9 +156,7 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin mutable osg::ref_ptr _renderStageLighting; - protected: - virtual ~RenderStage(); }; diff --git a/include/osgUtil/SceneView b/include/osgUtil/SceneView index b2dd24351..19a24856b 100644 --- a/include/osgUtil/SceneView +++ b/include/osgUtil/SceneView @@ -131,15 +131,8 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced, public osg::CullSetting osg::StateSet* getLocalStateSet() { return _localStateSet.get(); } const osg::StateSet* getLocalStateSet() const { return _localStateSet.get(); } -#if 1 typedef Options LightingMode; -#else - enum LightingMode { - HEADLIGHT, // default - SKY_LIGHT, - NO_SCENEVIEW_LIGHT - }; -#endif + void setLightingMode(LightingMode mode) { _lightingMode=mode; } LightingMode getLightingMode() const { return _lightingMode; } diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index ee9081610..68463878e 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -1202,7 +1202,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node) // set up lighting. // currently ignore lights in the scene graph itself.. // will do later. - RenderStage* previous_stage = _currentRenderBin->_stage; + RenderStage* previous_stage = _currentRenderBin->getStage(); // set up the background color and clear mask. osg::Vec4 clear_color = previous_stage->getClearColor(); @@ -1330,7 +1330,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node) - if (rtts->_renderGraphList.size()==0 && rtts->_bins.size()==0) + if (rtts->getRenderGraphList().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. @@ -1475,7 +1475,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node) // and the render to texture stage to the current stages // dependancy list. - _currentRenderBin->_stage->addToDependencyList(rtts.get()); + _currentRenderBin->getStage()->addToDependencyList(rtts.get()); // attach texture to the RenderToTextureStage. rtts->setTexture(texture);