Permalink
Browse files

OcclusionQueryNode: add resetting of queries

If there's a big view change then it might not be appropriate to wait
for '_queryFrameCount' till the next query is issued, because then
geometry might pop into the view after '_queryFrameCount'.

This is especially important for applications not having a constant
frame rate, but just issue a new frame on demand.
  • Loading branch information...
dan-t authored and robertosfield committed Jan 23, 2019
1 parent c6eb63d commit f21ca61476ee98b65529ae9dbaeedef93fde9b47
Showing with 11 additions and 0 deletions.
  1. +5 −0 include/osg/OcclusionQueryNode
  2. +6 −0 src/osg/OcclusionQueryNode.cpp
@@ -125,6 +125,11 @@ public:
void setQueryFrameCount( unsigned int frames ) { _queryFrameCount = frames; }
unsigned int getQueryFrameCount() const { return _queryFrameCount; }

// Resets the queries. The next frame will issue a new query.
// This is useful for big view changes, if it shouldn't be waited for
// '_queryFrameCount' till the frame contents change.
void resetQueries();

// Indicate whether or not the bounding box used in the occlusion query test
// should be rendered. Handy for debugging and development.
// Should only be called outside of cull/draw. No thread issues.
@@ -588,6 +588,12 @@ void OcclusionQueryNode::setQueriesEnabled( bool enable )
_enabled = enable;
}

void OcclusionQueryNode::resetQueries()
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock( _frameCountMutex );
_frameCountMap.clear();
}

// Should only be called outside of cull/draw. No thread issues.
void OcclusionQueryNode::setDebugDisplay( bool debug )
{

0 comments on commit f21ca61

Please sign in to comment.