Added CullCallbacks to osg::Node, and osgUtil::CullVisitor.

This commit is contained in:
Robert Osfield
2002-04-15 13:15:48 +00:00
parent 0222f10d27
commit bbef7164db
7 changed files with 69 additions and 21 deletions

View File

@@ -261,7 +261,19 @@ void set2dScene(osg::Group* rootNode)
}
struct MyCallback : public osg::NodeCallback
{
MyCallback(const std::string& str):_message(str) {}
virtual void operator() (osg::Node* node,osg::NodeVisitor* nv)
{
std::cout<<"In my callback '"<<_message<<"'"<<std::endl;
traverse(node,nv);
}
std::string _message;
};
@@ -328,6 +340,8 @@ int main( int argc, char **argv )
set2dScene(modelview_abs);
projection->addChild(modelview_abs);
projection->setAppCallback(osgNew MyCallback("App callback"));
projection->setCullCallback(osgNew MyCallback("Cull callback"));
group->addChild(projection);

View File

@@ -27,6 +27,7 @@ Node::Node(const Node& node,const CopyOp& copyop):
_parents(), // leave empty as parentList is managed by Group.
_appCallback(node._appCallback),
_numChildrenRequiringAppTraversal(0), // assume no children yet.
_cullCallback(node._cullCallback),
_cullingActive(node._cullingActive),
_numChildrenWithCullingDisabled(0), // assume no children yet.
_userData(copyop(node._userData.get())),

View File

@@ -350,7 +350,7 @@ void CullVisitor::apply(Node& node)
StateSet* node_state = node.getStateSet();
if (node_state) pushStateSet(node_state);
traverse(node);
handle_cull_callbacks_and_traverse(node);
// pop the node's state off the geostate stack.
if (node_state) popStateSet();
@@ -551,7 +551,7 @@ void CullVisitor::apply(Group& node)
StateSet* node_state = node.getStateSet();
if (node_state) pushStateSet(node_state);
traverse(node);
handle_cull_callbacks_and_traverse(node);
// pop the node's state off the render graph stack.
if (node_state) popStateSet();
@@ -581,7 +581,7 @@ void CullVisitor::apply(Transform& node)
node.getLocalToWorldMatrix(*matrix,this);
pushModelViewMatrix(matrix.get());
traverse(node);
handle_cull_callbacks_and_traverse(node);
popModelViewMatrix();
@@ -612,7 +612,7 @@ void CullVisitor::apply(Projection& node)
*matrix = node.getMatrix();
pushProjectionMatrix(matrix.get());
traverse(node);
handle_cull_callbacks_and_traverse(node);
popProjectionMatrix();
@@ -649,7 +649,7 @@ void CullVisitor::apply(LOD& node)
if (node_state) pushStateSet(node_state);
//notify(INFO) << "selecting child "<<eval<< std::endl;
node.getChild(eval)->accept(*this);
handle_cull_callbacks_and_accept(node,node.getChild(eval));
// pop the node's state off the render graph stack.
if (node_state) popStateSet();
@@ -667,7 +667,7 @@ void CullVisitor::apply(osg::EarthSky& node)
StateSet* node_state = node.getStateSet();
if (node_state) pushStateSet(node_state);
traverse(node);
handle_cull_callbacks_and_traverse(node);
// pop the node's state off the render graph stack.
if (node_state) popStateSet();
@@ -708,13 +708,13 @@ void CullVisitor::apply(Impostor& node)
{
// outwith the impostor distance threshold therefore simple
// traverse the appropriate child of the LOD.
node.getChild(eval)->accept(*this);
handle_cull_callbacks_and_accept(node,node.getChild(eval));
}
else if (_viewportStack.empty())
{
// need to use impostor but no valid viewport is defined to simply
// default to using the LOD child as above.
node.getChild(eval)->accept(*this);
handle_cull_callbacks_and_accept(node,node.getChild(eval));
}
else
{
@@ -799,7 +799,7 @@ void CullVisitor::apply(Impostor& node)
{
// no impostor has been selected or created so default to
// traversing the usual LOD selected child.
node.getChild(eval)->accept(*this);
handle_cull_callbacks_and_accept(node,node.getChild(eval));
}
}
@@ -973,7 +973,7 @@ ImpostorSprite* CullVisitor::createImpostorSprite(Impostor& node)
{
// traversing the usual LOD selected child.
node.getChild(eval)->accept(*this);
handle_cull_callbacks_and_accept(node,node.getChild(eval));
}