From 3fc3dcbb56d4bb91366ccfa7db600c83dd1608da Mon Sep 17 00:00:00 2001 From: Daniel Trstenjak Date: Tue, 26 May 2020 18:28:42 +0200 Subject: [PATCH] OcclusionQueryNode: don't override existing callbacks in camera --- src/osg/OcclusionQueryNode.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/osg/OcclusionQueryNode.cpp b/src/osg/OcclusionQueryNode.cpp index 02509788d..0c31192df 100644 --- a/src/osg/OcclusionQueryNode.cpp +++ b/src/osg/OcclusionQueryNode.cpp @@ -320,15 +320,20 @@ QueryGeometry::drawImplementation( osg::RenderInfo& renderInfo ) const osg::Camera* cam = renderInfo.getCurrentCamera(); - // Add callbacks if necessary. - if (!cam->getPostDrawCallback()) + RetrieveQueriesCallback* rqcb = cam->findPostDrawCallback(); + if (!rqcb) { - RetrieveQueriesCallback* rqcb = new RetrieveQueriesCallback( ext ); - cam->setPostDrawCallback( rqcb ); + rqcb = new RetrieveQueriesCallback( ext ); + cam->addPostDrawCallback( rqcb ); + + ClearQueriesCallback* cqcb = cam->findPreDrawCallback(); + if (!cqcb) + { + cqcb = new ClearQueriesCallback; + cam->addPreDrawCallback( cqcb ); + } - ClearQueriesCallback* cqcb = new ClearQueriesCallback; cqcb->_rqcb = rqcb; - cam->setPreDrawCallback( cqcb ); } // Get TestResult from Camera map @@ -343,7 +348,6 @@ QueryGeometry::drawImplementation( osg::RenderInfo& renderInfo ) const } } - // Issue query if (!tr->_init) { @@ -358,9 +362,6 @@ QueryGeometry::drawImplementation( osg::RenderInfo& renderInfo ) const return; } - // Add TestResult to RQCB. - RetrieveQueriesCallback* rqcb = dynamic_cast< - RetrieveQueriesCallback* >( cam->getPostDrawCallback() ); if (!rqcb) { OSG_FATAL << "osgOQ: QG: Invalid RQCB." << std::endl;