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."
This commit is contained in:
Robert Osfield
2006-10-30 12:19:41 +00:00
parent c5c4c5da1d
commit baeb41a416
2 changed files with 6 additions and 3 deletions

View File

@@ -117,6 +117,7 @@ class OSGSIM_EXPORT OverlayNode : public osg::Group
osg::ref_ptr<osg::Texture2D> _texture;
bool _continuousUpdate;
bool _updateCamera;
osg::Polytope _textureFrustum;
};

View File

@@ -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)