Added support for specifying whether view frustum and small feature culling
should be applied to a node or its child with the new osg::Node::setCullingActive() flag. A mechanism has been implemented so that if child has its culling disabled then their parents, all the way up to the root are also have their culling implicitly disabled. The osg::CullVisitor has updated to take account of both the explicit control via setCullingActive and the implicit culling disabling through children being disabled. This feature is useful for nodes which don't have a bounding volume to cull against, earth sky implementations and light sources. The default osg::Node::_cullingActive is true, i.e. culling is enabled by default.
This commit is contained in:
@@ -15,6 +15,10 @@ Node::Node()
|
||||
_nodeMask = 0xffffffff;
|
||||
|
||||
_numChildrenRequiringAppTraversal = 0;
|
||||
|
||||
_cullingActive = true;
|
||||
_numChildrenWithCullingDisabled = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -112,6 +116,81 @@ void Node::setNumChildrenRequiringAppTraversal(const int num)
|
||||
|
||||
}
|
||||
|
||||
void Node::setCullingActive(const bool active)
|
||||
{
|
||||
// if no changes just return.
|
||||
if (_cullingActive == active) return;
|
||||
|
||||
// culling active has been changed, will need to update
|
||||
// both _cullActive and possibly the parents numChildrenWithCullingDisabled
|
||||
// if culling disabled changes.
|
||||
|
||||
// update the parents _numChildrenWithCullingDisabled
|
||||
// note, if _numChildrenWithCullingDisabled!=0 then the
|
||||
// parents won't be affected by any app callback change,
|
||||
// so no need to inform them.
|
||||
if (_numChildrenWithCullingDisabled==0 && !_parents.empty())
|
||||
{
|
||||
int delta = 0;
|
||||
if (!_cullingActive) --delta;
|
||||
if (!active) ++delta;
|
||||
if (delta!=0)
|
||||
{
|
||||
// the number of callbacks has changed, need to pass this
|
||||
// on to parents so they know whether app traversal is
|
||||
// reqired on this subgraph.
|
||||
for(ParentList::iterator itr =_parents.begin();
|
||||
itr != _parents.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->setNumChildrenWithCullingDisabled(
|
||||
(*itr)->getNumChildrenWithCullingDisabled()+delta );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// set the cullingActive itself.
|
||||
_cullingActive = active;
|
||||
}
|
||||
|
||||
void Node::setNumChildrenWithCullingDisabled(const int num)
|
||||
{
|
||||
// if no changes just return.
|
||||
if (_numChildrenWithCullingDisabled==num) return;
|
||||
|
||||
// note, if _cullingActive is false then the
|
||||
// parents won't be affected by any changes to
|
||||
// _numChildrenWithCullingDisabled so no need to inform them.
|
||||
if (_cullingActive && !_parents.empty())
|
||||
{
|
||||
|
||||
// need to pass on changes to parents.
|
||||
int delta = 0;
|
||||
if (_numChildrenWithCullingDisabled>0) --delta;
|
||||
if (num>0) ++delta;
|
||||
if (delta!=0)
|
||||
{
|
||||
// the number of callbacks has changed, need to pass this
|
||||
// on to parents so they know whether app traversal is
|
||||
// reqired on this subgraph.
|
||||
for(ParentList::iterator itr =_parents.begin();
|
||||
itr != _parents.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->setNumChildrenWithCullingDisabled(
|
||||
(*itr)->getNumChildrenWithCullingDisabled()+delta
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// finally update this objects value.
|
||||
_numChildrenWithCullingDisabled=num;
|
||||
}
|
||||
|
||||
|
||||
const bool Node::computeBound() const
|
||||
{
|
||||
_bsphere.init();
|
||||
|
||||
Reference in New Issue
Block a user