diff --git a/examples/osgocclusionquery/osgocclusionquery.cpp b/examples/osgocclusionquery/osgocclusionquery.cpp index ae0f530cc..c51825e02 100644 --- a/examples/osgocclusionquery/osgocclusionquery.cpp +++ b/examples/osgocclusionquery/osgocclusionquery.cpp @@ -264,11 +264,8 @@ OcclusionQueryVisitor::OcclusionQueryVisitor() // We'll then share that state between all OQNs we add to the visited scene graph. osg::ref_ptr oqn = new osg::OcclusionQueryNode; - osg::StateSet* ss( NULL ); - osg::StateSet* ssDebug( NULL ); - oqn->getQueryStateSets( ss, ssDebug ); - _state = ss; - _debugState = ssDebug; + _state = oqn->getQueryStateSet(); + _debugState = oqn->getDebugStateSet(); } OcclusionQueryVisitor::~OcclusionQueryVisitor() @@ -354,7 +351,8 @@ OcclusionQueryVisitor::addOQN( osg::Node& node ) oqn->setName( getNextOQNName() ); // Set all OQNs to use the same query StateSets (instead of multiple copies // of the same StateSet) for efficiency. - oqn->setQueryStateSets( _state.get(), _debugState.get() ); + oqn->setQueryStateSet( _state.get() ); + oqn->setDebugStateSet( _debugState.get() ); } } } diff --git a/include/osg/OcclusionQueryNode b/include/osg/OcclusionQueryNode index 9ac232e9b..9a398189c 100644 --- a/include/osg/OcclusionQueryNode +++ b/include/osg/OcclusionQueryNode @@ -67,10 +67,20 @@ public: bool getDebugDisplay() const; - // Set the StateSets used by the OQN when rendering OQ geometry - // or debug bounding geometry. - void setQueryStateSets( osg::StateSet* ss, osg::StateSet* ssDebug ); - void getQueryStateSets( osg::StateSet* ss, osg::StateSet* ssDebug ); + // Set and get the StateSet used by the OcclusionQueryNode + // when rendering the query geometry. OQN creates its own by + // default, but if you use many OQNs you might want to use + // this method to set all OQNs to use the same StateSet + // for more efficient processing. + void setQueryStateSet( osg::StateSet* ss ); + osg::StateSet* getQueryStateSet(); + const osg::StateSet* getQueryStateSet() const; + + // Set and get the StateSet used by the OcclusionQueryNode + // when rendering the debug query geometry (see setDebugDisplay). + void setDebugStateSet( osg::StateSet* ss ); + osg::StateSet* getDebugStateSet(); + const osg::StateSet* getDebugStateSet() const; // For statistics gathering, e.g., by a NodeVisitor. bool getPassed() const; diff --git a/src/osg/OcclusionQueryNode.cpp b/src/osg/OcclusionQueryNode.cpp index 3e6191387..12f1201ba 100644 --- a/src/osg/OcclusionQueryNode.cpp +++ b/src/osg/OcclusionQueryNode.cpp @@ -654,22 +654,68 @@ OcclusionQueryNode::getDebugDisplay() const void -OcclusionQueryNode::setQueryStateSets( osg::StateSet* ss, osg::StateSet* ssDebug ) +OcclusionQueryNode::setQueryStateSet( osg::StateSet* ss ) { - if (!_queryGeode.valid() || !_debugGeode.valid()) + if (!_queryGeode) { - osg::notify( osg::WARN ) << "osgOQ: OcclusionQueryNode:: Invalid support node(s)." << std::endl; + osg::notify( osg::WARN ) << "osgOQ: OcclusionQueryNode:: Invalid query support node." << std::endl; return; } _queryGeode->setStateSet( ss ); - _debugGeode->setStateSet( ssDebug ); } -void -OcclusionQueryNode::getQueryStateSets( osg::StateSet* ss, osg::StateSet* ssDebug ) +osg::StateSet* +OcclusionQueryNode::getQueryStateSet() { - ss = _queryGeode->getStateSet(); - ssDebug = _debugGeode->getStateSet(); + if (!_queryGeode) + { + osg::notify( osg::WARN ) << "osgOQ: OcclusionQueryNode:: Invalid query support node." << std::endl; + return NULL; + } + return _queryGeode->getStateSet(); +} + +const osg::StateSet* +OcclusionQueryNode::getQueryStateSet() const +{ + if (!_queryGeode) + { + osg::notify( osg::WARN ) << "osgOQ: OcclusionQueryNode:: Invalid query support node." << std::endl; + return NULL; + } + return _queryGeode->getStateSet(); +} + +void +OcclusionQueryNode::setDebugStateSet( osg::StateSet* ss ) +{ + if (!_debugGeode) + { + osg::notify( osg::WARN ) << "osgOQ: OcclusionQueryNode:: Invalid debug support node." << std::endl; + return; + } + _debugGeode->setStateSet( ss ); +} + +osg::StateSet* +OcclusionQueryNode::getDebugStateSet() +{ + if (!_debugGeode.valid()) + { + osg::notify( osg::WARN ) << "osgOQ: OcclusionQueryNode:: Invalid debug support node." << std::endl; + return NULL; + } + return _debugGeode->getStateSet(); +} +const osg::StateSet* +OcclusionQueryNode::getDebugStateSet() const +{ + if (!_debugGeode.valid()) + { + osg::notify( osg::WARN ) << "osgOQ: OcclusionQueryNode:: Invalid debug support node." << std::endl; + return NULL; + } + return _debugGeode->getStateSet(); } bool @@ -724,7 +770,8 @@ OcclusionQueryNode::createSupportNodes() // Creste state sets. Note that the osgOQ visitors (which place OQNs throughout // the scene graph) create a single instance of these StateSets shared // between all OQNs for efficiency. - setQueryStateSets( initOQState(), initOQDebugState() ); + setQueryStateSet( initOQState() ); + setDebugStateSet( initOQDebugState() ); } diff --git a/src/osgWrappers/osg/OcclusionQueryNode.cpp b/src/osgWrappers/osg/OcclusionQueryNode.cpp index 1b313a653..fb25b3c05 100644 --- a/src/osgWrappers/osg/OcclusionQueryNode.cpp +++ b/src/osgWrappers/osg/OcclusionQueryNode.cpp @@ -117,14 +117,34 @@ BEGIN_OBJECT_REFLECTOR(osg::OcclusionQueryNode) __bool__getDebugDisplay, "", ""); - I_Method2(void, setQueryStateSets, IN, osg::StateSet *, ss, IN, osg::StateSet *, ssDebug, + I_Method1(void, setQueryStateSet, IN, osg::StateSet *, ss, Properties::NON_VIRTUAL, - __void__setQueryStateSets__osg_StateSet_P1__osg_StateSet_P1, + __void__setQueryStateSet__osg_StateSet_P1, "", ""); - I_Method2(void, getQueryStateSets, IN, osg::StateSet *, ss, IN, osg::StateSet *, ssDebug, + I_Method0(osg::StateSet *, getQueryStateSet, Properties::NON_VIRTUAL, - __void__getQueryStateSets__osg_StateSet_P1__osg_StateSet_P1, + __osg_StateSet_P1__getQueryStateSet, + "", + ""); + I_Method0(const osg::StateSet *, getQueryStateSet, + Properties::NON_VIRTUAL, + __C5_osg_StateSet_P1__getQueryStateSet, + "", + ""); + I_Method1(void, setDebugStateSet, IN, osg::StateSet *, ss, + Properties::NON_VIRTUAL, + __void__setDebugStateSet__osg_StateSet_P1, + "", + ""); + I_Method0(osg::StateSet *, getDebugStateSet, + Properties::NON_VIRTUAL, + __osg_StateSet_P1__getDebugStateSet, + "", + ""); + I_Method0(const osg::StateSet *, getDebugStateSet, + Properties::NON_VIRTUAL, + __C5_osg_StateSet_P1__getDebugStateSet, "", ""); I_Method0(bool, getPassed, @@ -164,6 +184,9 @@ BEGIN_OBJECT_REFLECTOR(osg::OcclusionQueryNode) I_SimpleProperty(bool, DebugDisplay, __bool__getDebugDisplay, __void__setDebugDisplay__bool); + I_SimpleProperty(osg::StateSet *, DebugStateSet, + __osg_StateSet_P1__getDebugStateSet, + __void__setDebugStateSet__osg_StateSet_P1); I_SimpleProperty(bool, Passed, __bool__getPassed, 0); @@ -173,6 +196,9 @@ BEGIN_OBJECT_REFLECTOR(osg::OcclusionQueryNode) I_SimpleProperty(int, QueryFrameCount, __int__getQueryFrameCount, __void__setQueryFrameCount__int); + I_SimpleProperty(osg::StateSet *, QueryStateSet, + __osg_StateSet_P1__getQueryStateSet, + __void__setQueryStateSet__osg_StateSet_P1); I_SimpleProperty(unsigned int, VisibilityThreshold, __unsigned_int__getVisibilityThreshold, __void__setVisibilityThreshold__unsigned_int);