From c1af863f786f5b2c7a04d8a57c09fc7fd92c2b7a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 13 Sep 2011 13:38:26 +0000 Subject: [PATCH] From Morten Hauknes, "I have been using the getLastVisiblePixelCount on pre 3.0 osg. I believe maybe this was a private function that we made public in our side. I use(d) this method to make a simple algorithm to tell how much visible an object was in percent. So with the 3.0 api change we propose the following change: - put OSG_EXPORT on the QueryGeometry class so that we get access to the getNumPixels method. - Create a function called getQueryGeometry that returns a casted _queryGeode->getDrawable(). Or a function called getQueryGeode that returns _queryGeode." --- include/osg/OcclusionQueryNode | 6 +++++- src/osg/OcclusionQueryNode.cpp | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/osg/OcclusionQueryNode b/include/osg/OcclusionQueryNode index b45cf3e78..9090d459a 100644 --- a/include/osg/OcclusionQueryNode +++ b/include/osg/OcclusionQueryNode @@ -60,7 +60,7 @@ public: // QueryGeometry -- A Drawable that performs an occlusion query, // using its geometric data as the query geometry. -class QueryGeometry : public osg::Geometry +class OSG_EXPORT QueryGeometry : public osg::Geometry { public: QueryGeometry( const std::string& oqnName=std::string("") ); @@ -141,6 +141,10 @@ public: osg::StateSet* getQueryStateSet(); const osg::StateSet* getQueryStateSet() const; + // Get the QueryGeometry object used for occlusion query. Returns 0 if no QueryGeometry is created. + osg::QueryGeometry* getQueryGeometry(); + const osg::QueryGeometry* getQueryGeometry() const; + // Set and get the StateSet used by the OcclusionQueryNode // when rendering the debug query geometry (see setDebugDisplay). void setDebugStateSet( osg::StateSet* ss ); diff --git a/src/osg/OcclusionQueryNode.cpp b/src/osg/OcclusionQueryNode.cpp index a701d85a1..5df6f6a69 100644 --- a/src/osg/OcclusionQueryNode.cpp +++ b/src/osg/OcclusionQueryNode.cpp @@ -754,5 +754,25 @@ void OcclusionQueryNode::discardDeletedQueryObjects( unsigned int contextID ) QueryGeometry::discardDeletedQueryObjects( contextID ); } +osg::QueryGeometry* OcclusionQueryNode::getQueryGeometry() +{ + if (_queryGeode && _queryGeode->getDrawable( 0 )) + { + QueryGeometry* qg = static_cast< QueryGeometry* >( _queryGeode->getDrawable( 0 ) ); + return qg; + } + return 0; +} + +const osg::QueryGeometry* OcclusionQueryNode::getQueryGeometry() const +{ + if (_queryGeode && _queryGeode->getDrawable( 0 )) + { + QueryGeometry* qg = static_cast< QueryGeometry* >( _queryGeode->getDrawable( 0 ) ); + return qg; + } + return 0; +} + }