[osg-users] Remove all LOD children

Bruno Oliveira bruno.manata.oliveira at gmail.com
Fri May 13 06:48:05 PDT 2016


Hello,

Sorry to bother again. I think this is somwhat a different topic from my
previous post.
I am using a LOD based node, with several gourps/LODs.
At some point I want to completely wipe out my scene. How can I delete all
nodes?


This is my code. I think it still leaves some nodes floating.

void rRemoveChildren(osg::Node* currNode) {

    osg::Group* currGroup;
    osg::Node*  foundNode;

    // check to see if we have a valid (non-NULL) node.
    // if we do have a null node, return NULL.
    if (!currNode) {
        return;
    }

    currGroup = currNode->asGroup(); // returns NULL if not a group.
    if (currGroup) {
        auto nChildren = currGroup->getNumChildren();
        for (int i = nChildren-1; i >=0; i--) {
            osg::Group* asGroup = currGroup->getChild(i)->asGroup();
            if (!asGroup || asGroup->getNumChildren() < 1) {
                osg::Node* shild = currGroup->getChild(i);
                shild->releaseGLObjects();
                currGroup->removeChild(shild);


            }
            else rRemoveChildren(asGroup);
        }
    } else {
        auto parents = currNode->getParents();
        for (auto p : parents)
            p->removeChild(currNode);
    }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20160513/94761765/attachment-0002.htm>


More information about the osg-users mailing list