Dirk Reiners wrote:
Hi Allen,
On Wed, 2004-04-28 at 09:52, Allen Bierbaum wrote:
I have a scenegraph that I have constructed that I would like to delete
after I am done with it. What is the recommended way to do this?
So for example I have a root node:
osg::NodePtr rootNode = osg::Node::create();
... Add a bunch more nodes ...
Then I would like to issue a command here on the rootNode to delete the
tree.
My first thought was that reference counting should handle this similar
to how smart pointers work. So I thought maybe:
rootNode.settNull()
or
rootNode = NullFC
But the implementation of those methods in FieldContainerPtrBase doesn't
seem to have any code for decreasing the reference count.
So I need to explicitly call subRef(rootNode) to make this work?
Yup.
Either that, or use a reference counting pointer (OSGRefPtr.h) for the
variables that you use to keep references to FieldContainers around.
OSG::RefPtr<OSG::NodePtr> rootNode = OSG::Node::create();
...
rootNode = OSG::NullFC;
(We recommend using OSG:: instead of osg::, as the former is a macro
that allows us to change the namespace later on, if there are
conflicts.)
Given that you're explicitly creating Nodes, you might have missed the
convenience function makeCoredNode, that creates the necessary core too.
OSG::RefPtr<OSG::NodePtr> n1 = OSG::makeCoredNode<OSG::Group>();
GeometryPtr geo;
OSG::RefPtr<OSG::NodePtr> n2 = OSG::makeCoredNode<OSG::Geometry>(&geo);
Hope it helps
Dirk
That definitely helps.
Thanks for the pointers to RefPtr and makeCoredNode as well. They will
be a great help for me. I don't think I ran across those in the
documentation. I will look again though as I would like to understand
RefPtr much better to make sure I use it correctly.
Thanks,
Allen
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users