I have a code that handles a Cull Callback by overriding traverse method:
void SomeNode::traverse(osg::NodeVisitor& nv)
{
if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
{
//adjust child node positions depending on the projection
}
}
but looks like there is an alternate way how to add a Cull Callback with
void Node::setCullCallback(Callback* nc);
Which one is better and in what situation? And is the first way is correct?
The most common way is to set a Cull Callback on the node, as it doesn't require you to write a custom osg::Node derived class. As such you can add the callback to any existing node type, in particular to models loaded from file.
It's also quite flexible since you can easily add/remove/replace callbacks at runtime.
In both cases, if culling is active on the node of interest, the traverse() method or the callback are invoked only if the node passes the culling test.