OcclusionQueryNode: don't override existing callbacks in camera

This commit is contained in:
Daniel Trstenjak 2020-05-26 18:28:42 +02:00
parent 048ece358a
commit 3fc3dcbb56

View File

@ -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<RetrieveQueriesCallback>();
if (!rqcb)
{
RetrieveQueriesCallback* rqcb = new RetrieveQueriesCallback( ext );
cam->setPostDrawCallback( rqcb );
rqcb = new RetrieveQueriesCallback( ext );
cam->addPostDrawCallback( rqcb );
ClearQueriesCallback* cqcb = cam->findPreDrawCallback<ClearQueriesCallback>();
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;