From 8fb5ba4a3f2a33fd0a133c7b3c6e181b2b1f058a Mon Sep 17 00:00:00 2001 From: Daniel Trstenjak Date: Tue, 29 Jan 2019 14:40:16 +0100 Subject: [PATCH] OcclusionQueryNode: reset the test result of the invalid geometry There're cases that the occlusion test result has been retrieved after the query geometry has been changed, it's the result of the geometry before the change. --- src/osg/OcclusionQueryNode.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/osg/OcclusionQueryNode.cpp b/src/osg/OcclusionQueryNode.cpp index 8acf40084..b6222acb7 100644 --- a/src/osg/OcclusionQueryNode.cpp +++ b/src/osg/OcclusionQueryNode.cpp @@ -483,8 +483,15 @@ bool OcclusionQueryNode::getPassed( const Camera* camera, NodeVisitor& nv ) return _passed; } + QueryGeometry* qg = static_cast< QueryGeometry* >( _queryGeode->getDrawable( 0 ) ); + if ( !_validQueryGeometry ) { + // There're cases that the occlusion test result has been retrieved + // after the query geometry has been changed, it's the result of the + // geometry before the change. + qg->reset(); + // The box of the query geometry is invalid, return false to not traverse // the subgraphs. _passed = false; @@ -513,7 +520,6 @@ bool OcclusionQueryNode::getPassed( const Camera* camera, NodeVisitor& nv ) _passed = true; return _passed; } - QueryGeometry* qg = static_cast< QueryGeometry* >( _queryGeode->getDrawable( 0 ) ); // Get the near plane for the upcoming distance calculation. osg::Matrix::value_type nearPlane;