From Paul Martz, "The osgocclusionquery example contained some duplicate code that was also in the core OSG occlusion query code. This change removes the need for that."
This commit is contained in:
parent
532d573a06
commit
b222d4201c
@ -63,66 +63,6 @@
|
|||||||
|
|
||||||
// NodeVisitors and utility functions for OcclusionQueryNode
|
// NodeVisitors and utility functions for OcclusionQueryNode
|
||||||
|
|
||||||
// Create and return a StateSet appropriate for performing an occlusion
|
|
||||||
// query test (disable lighting, texture mapping, etc). Probably some
|
|
||||||
// room for improvement here. Could disable shaders, for example.
|
|
||||||
osg::StateSet*
|
|
||||||
initOQState()
|
|
||||||
{
|
|
||||||
osg::StateSet* state = new osg::StateSet;
|
|
||||||
// TBD Possible bug, need to allow user to set render bin number.
|
|
||||||
state->setRenderBinDetails( 9, "RenderBin" );
|
|
||||||
|
|
||||||
state->setMode( GL_LIGHTING, osg::StateAttribute::OFF |
|
|
||||||
osg::StateAttribute::PROTECTED);
|
|
||||||
state->setTextureMode( 0, GL_TEXTURE_2D, osg::StateAttribute::OFF |
|
|
||||||
osg::StateAttribute::PROTECTED);
|
|
||||||
state->setMode( GL_CULL_FACE, osg::StateAttribute::ON |
|
|
||||||
osg::StateAttribute::PROTECTED);
|
|
||||||
|
|
||||||
osg::ColorMask* cm = new osg::ColorMask( false, false, false, false );
|
|
||||||
state->setAttributeAndModes( cm, osg::StateAttribute::ON |
|
|
||||||
osg::StateAttribute::PROTECTED);
|
|
||||||
osg::Depth* d = new osg::Depth( osg::Depth::LEQUAL, 0.f, 1.f, false );
|
|
||||||
state->setAttributeAndModes( d, osg::StateAttribute::ON |
|
|
||||||
osg::StateAttribute::PROTECTED);
|
|
||||||
osg::PolygonMode* pm = new osg::PolygonMode(
|
|
||||||
osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::FILL );
|
|
||||||
state->setAttributeAndModes( pm, osg::StateAttribute::ON |
|
|
||||||
osg::StateAttribute::PROTECTED);
|
|
||||||
|
|
||||||
osg::PolygonOffset* po = new osg::PolygonOffset( -1., -1. );
|
|
||||||
state->setAttributeAndModes( po, osg::StateAttribute::ON |
|
|
||||||
osg::StateAttribute::PROTECTED);
|
|
||||||
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create and return a StateSet for rendering a debug representation of query geometry.
|
|
||||||
osg::StateSet*
|
|
||||||
initOQDebugState()
|
|
||||||
{
|
|
||||||
osg::StateSet* debugState = new osg::StateSet;
|
|
||||||
|
|
||||||
debugState->setMode( GL_LIGHTING, osg::StateAttribute::OFF |
|
|
||||||
osg::StateAttribute::PROTECTED);
|
|
||||||
debugState->setTextureMode( 0, GL_TEXTURE_2D, osg::StateAttribute::OFF |
|
|
||||||
osg::StateAttribute::PROTECTED);
|
|
||||||
debugState->setMode( GL_CULL_FACE, osg::StateAttribute::ON |
|
|
||||||
osg::StateAttribute::PROTECTED);
|
|
||||||
|
|
||||||
osg::PolygonMode* pm = new osg::PolygonMode(
|
|
||||||
osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE );
|
|
||||||
debugState->setAttributeAndModes( pm, osg::StateAttribute::ON |
|
|
||||||
osg::StateAttribute::PROTECTED);
|
|
||||||
|
|
||||||
osg::PolygonOffset* po = new osg::PolygonOffset( -1., -1. );
|
|
||||||
debugState->setAttributeAndModes( po, osg::StateAttribute::ON |
|
|
||||||
osg::StateAttribute::PROTECTED);
|
|
||||||
|
|
||||||
return debugState;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use this visitor to insert OcclusionQueryNodes (OQNs) in the
|
// Use this visitor to insert OcclusionQueryNodes (OQNs) in the
|
||||||
// visited subgraph. Only one OQN will test any particular node
|
// visited subgraph. Only one OQN will test any particular node
|
||||||
// (no nesting). See also OcclusionQueryNonFlatVisitor.
|
// (no nesting). See also OcclusionQueryNonFlatVisitor.
|
||||||
@ -320,10 +260,15 @@ OcclusionQueryVisitor::OcclusionQueryVisitor()
|
|||||||
_nameIdx( 0 ),
|
_nameIdx( 0 ),
|
||||||
_occluderThreshold( 5000 )
|
_occluderThreshold( 5000 )
|
||||||
{
|
{
|
||||||
// Init StateSet for occlusion query geometry.
|
// Create a dummy OcclusionQueryNode just so we can get its state.
|
||||||
_state = initOQState();
|
// We'll then share that state between all OQNs we add to the visited scene graph.
|
||||||
// Initialize StateSet for debug geometry
|
osg::ref_ptr<osg::OcclusionQueryNode> oqn = new osg::OcclusionQueryNode;
|
||||||
_debugState = initOQDebugState();
|
|
||||||
|
osg::StateSet* ss( NULL );
|
||||||
|
osg::StateSet* ssDebug( NULL );
|
||||||
|
oqn->getQueryStateSets( ss, ssDebug );
|
||||||
|
_state = ss;
|
||||||
|
_debugState = ssDebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
OcclusionQueryVisitor::~OcclusionQueryVisitor()
|
OcclusionQueryVisitor::~OcclusionQueryVisitor()
|
||||||
|
@ -67,6 +67,7 @@ public:
|
|||||||
// Set the StateSets used by the OQN when rendering OQ geometry
|
// Set the StateSets used by the OQN when rendering OQ geometry
|
||||||
// or debug bounding geometry.
|
// or debug bounding geometry.
|
||||||
void setQueryStateSets( osg::StateSet* ss, osg::StateSet* ssDebug );
|
void setQueryStateSets( osg::StateSet* ss, osg::StateSet* ssDebug );
|
||||||
|
void getQueryStateSets( osg::StateSet* ss, osg::StateSet* ssDebug );
|
||||||
|
|
||||||
// For statistics gathering, e.g., by a NodeVisitor.
|
// For statistics gathering, e.g., by a NodeVisitor.
|
||||||
bool getPassed() const;
|
bool getPassed() const;
|
||||||
|
@ -626,6 +626,12 @@ OcclusionQueryNode::setQueryStateSets( osg::StateSet* ss, osg::StateSet* ssDebug
|
|||||||
_queryGeode->setStateSet( ss );
|
_queryGeode->setStateSet( ss );
|
||||||
_debugGeode->setStateSet( ssDebug );
|
_debugGeode->setStateSet( ssDebug );
|
||||||
}
|
}
|
||||||
|
void
|
||||||
|
OcclusionQueryNode::getQueryStateSets( osg::StateSet* ss, osg::StateSet* ssDebug )
|
||||||
|
{
|
||||||
|
ss = _queryGeode->getStateSet();
|
||||||
|
ssDebug = _debugGeode->getStateSet();
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
OcclusionQueryNode::getPassed() const
|
OcclusionQueryNode::getPassed() const
|
||||||
|
@ -116,6 +116,11 @@ BEGIN_OBJECT_REFLECTOR(osg::OcclusionQueryNode)
|
|||||||
__void__setQueryStateSets__osg_StateSet_P1__osg_StateSet_P1,
|
__void__setQueryStateSets__osg_StateSet_P1__osg_StateSet_P1,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
|
I_Method2(void, getQueryStateSets, IN, osg::StateSet *, ss, IN, osg::StateSet *, ssDebug,
|
||||||
|
Properties::NON_VIRTUAL,
|
||||||
|
__void__getQueryStateSets__osg_StateSet_P1__osg_StateSet_P1,
|
||||||
|
"",
|
||||||
|
"");
|
||||||
I_Method0(bool, getPassed,
|
I_Method0(bool, getPassed,
|
||||||
Properties::NON_VIRTUAL,
|
Properties::NON_VIRTUAL,
|
||||||
__bool__getPassed,
|
__bool__getPassed,
|
||||||
|
Loading…
Reference in New Issue
Block a user