From baeb41a416c78f6d378c8f4a9e9a2df4e36b76c5 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 30 Oct 2006 12:19:41 +0000 Subject: [PATCH] From Michael Henheffer, "There's a problem with OverlayNodes where the texture will not display if continuous updating is set to false. The problem was being caused by the camera update call never being made if continuous updating was not set to true. This fix adds a flag that is set when dirtyOverlayTexture() is called and checked in the update visitor section of the traversal to determine if the camera should be updated. I tested the fix by making some changes to the osgAnimate example program so it has continuous updating off and calls dirtyOverlayTexture for each frame. The overlay texture now displays properly." --- include/osgSim/OverlayNode | 1 + src/osgSim/OverlayNode.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/osgSim/OverlayNode b/include/osgSim/OverlayNode index aabd47df5..80b66c9e2 100644 --- a/include/osgSim/OverlayNode +++ b/include/osgSim/OverlayNode @@ -117,6 +117,7 @@ class OSGSIM_EXPORT OverlayNode : public osg::Group osg::ref_ptr _texture; bool _continuousUpdate; + bool _updateCamera; osg::Polytope _textureFrustum; }; diff --git a/src/osgSim/OverlayNode.cpp b/src/osgSim/OverlayNode.cpp index 47a1a665e..9d3338ade 100644 --- a/src/osgSim/OverlayNode.cpp +++ b/src/osgSim/OverlayNode.cpp @@ -26,7 +26,8 @@ OverlayNode::OverlayNode(): _texEnvMode(GL_DECAL), _textureUnit(1), _textureSizeHint(1024), - _continuousUpdate(false) + _continuousUpdate(false), + _updateCamera(false) { setNumChildrenRequiringUpdateTraversal(1); init(); @@ -100,9 +101,8 @@ void OverlayNode::traverse(osg::NodeVisitor& nv) Group::traverse(nv); - if (_continuousUpdate) + if (_continuousUpdate || _updateCamera) { - // now compute the camera's view and projection matrix to point at the shadower (the camera's children) osg::BoundingSphere bs; for(unsigned int i=0; i<_camera->getNumChildren(); ++i) @@ -176,6 +176,7 @@ void OverlayNode::traverse(osg::NodeVisitor& nv) _textureFrustum.setToUnitFrustum(false,false); _textureFrustum.transformProvidingInverse(MVP); } + _updateCamera = false; } return; @@ -257,6 +258,7 @@ void OverlayNode::setOverlaySubgraph(osg::Node* node) void OverlayNode::dirtyOverlayTexture() { _textureObjectValidList.setAllElementsTo(0); + _updateCamera = true; } void OverlayNode::setOverlayClearColor(const osg::Vec4& color)