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:
Robert Osfield
2001-10-19 12:56:37 +00:00
parent e467f44575
commit 54d490e24b
5 changed files with 209 additions and 10 deletions

View File

@@ -367,7 +367,10 @@ CullViewState::CullingMode CullVisitor::getCullingMode() const
void CullVisitor::apply(Node& node)
{
CullViewState::CullingMode mode = _cullingModeStack.back();
if (isCulled(node.getBound(),mode)) return;
if (!node.getCullingActive()) mode = 0;
else if (node.getNumChildrenWithCullingDisabled()==0 &&
isCulled(node.getBound(),mode)) return;
// push the culling mode.
_cullingModeStack.push_back(mode);
@@ -391,7 +394,10 @@ void CullVisitor::apply(Geode& node)
// return if object's bounding sphere is culled.
CullViewState::CullingMode mode = _cullingModeStack.back();
if (isCulled(node.getBound(),mode)) return;
if (!node.getCullingActive()) mode = 0;
else if (node.getNumChildrenWithCullingDisabled()==0 &&
isCulled(node.getBound(),mode)) return;
// push the node's state.
StateSet* node_state = node.getStateSet();
@@ -465,7 +471,10 @@ void CullVisitor::apply(Billboard& node)
{
// return if object's bounding sphere is culled.
CullViewState::CullingMode mode = _cullingModeStack.back();
if (isCulled(node.getBound(),mode)) return;
if (!node.getCullingActive()) mode = 0;
else if (node.getNumChildrenWithCullingDisabled()==0 &&
isCulled(node.getBound(),mode)) return;
// push the node's state.
StateSet* node_state = node.getStateSet();
@@ -566,7 +575,10 @@ void CullVisitor::apply(Group& node)
{
// return if object's bounding sphere is culled.
CullViewState::CullingMode mode = _cullingModeStack.back();
if (isCulled(node.getBound(),mode)) return;
if (!node.getCullingActive()) mode = 0;
else if (node.getNumChildrenWithCullingDisabled()==0 &&
isCulled(node.getBound(),mode)) return;
// push the culling mode.
_cullingModeStack.push_back(mode);
@@ -589,7 +601,10 @@ void CullVisitor::apply(Transform& node)
{
// return if object's bounding sphere is culled.
CullViewState::CullingMode mode = _cullingModeStack.back();
if (isCulled(node.getBound(),mode)) return;
if (!node.getCullingActive()) mode = 0;
else if (node.getNumChildrenWithCullingDisabled()==0 &&
isCulled(node.getBound(),mode)) return;
// push the culling mode.
_cullingModeStack.push_back(mode);
@@ -622,7 +637,10 @@ void CullVisitor::apply(LOD& node)
{
// return if object's bounding sphere is culled.
CullViewState::CullingMode mode = _cullingModeStack.back();
if (isCulled(node.getBound(),mode)) return;
if (!node.getCullingActive()) mode = 0;
else if (node.getNumChildrenWithCullingDisabled()==0 &&
isCulled(node.getBound(),mode)) return;
int eval = node.evaluate(getEyeLocal(),_LODBias);
if (eval<0) return;
@@ -667,7 +685,10 @@ void CullVisitor::apply(Impostor& node)
// return if object's bounding sphere is culled.
CullViewState::CullingMode mode = _cullingModeStack.back();
if (isCulled(bs,mode)) return;
if (!node.getCullingActive()) mode = 0;
else if (node.getNumChildrenWithCullingDisabled()==0 &&
isCulled(node.getBound(),mode)) return;
osg::Vec3 eyeLocal = getEyeLocal();