From Paul Martz, fixed get/set methods API

This commit is contained in:
Robert Osfield
2008-02-27 11:43:58 +00:00
parent 335eed204b
commit 3b4af26136
4 changed files with 104 additions and 23 deletions

View File

@@ -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<osg::OcclusionQueryNode> 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() );
}
}
}

View File

@@ -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;

View File

@@ -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() );
}

View File

@@ -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);