Hi Ulrich,
Thanks for the advice, but I am still unclear.
If I root->removeChild(TransformMatrix1), and
root->removeChild(TransformMatrix2).
Won't that mean that Node is also deleted? Which is not what I want.
Are you saying that I need to keep another "dummy" node outside of the
scenegraph, referencing Node, just as a way of stopping Node being deleted?
"dummy"
|
|
> /TransformMatrix1\ |
> / \ |
> Root/ Node------Geometry
> \ /
> \ /
> TransformMatrix2/
Thanks
Mark
Message: 30
Date: Wed, 23 May 2007 11:17:15 +0200
From: Ulrich Hertlein <[EMAIL PROTECTED]>
Subject: Re: [osg-users] unlinking a node from the scenegraph
To: osg users <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=windows-1250
Mark Hurry wrote:
> I have a scenegraph that looks like
>
> /TransformMatrix1\
> / \
> Root/ Node------Geometry
> \ /
> \ /
> TransformMatrix2/
>
> I want to be able unlink and delete either or both of TransformMatrix
> nodes without destroying Node as at some time in the future I may need
> to link it in again with another transformmatrix node.
>
> I have tried using of unref () and unref_nodelete() but I get access
> violations. Obviously I am misunderstanding how these functions work.
> Can anyone suggest what I should be doing?
You shouldn't call unref() yourself but rather remove the
TransformMatrix* from its parent which will call unref() as necessary:
Root->removeChild(TransformMatrix1)
This will remove TransformMatrix1 from Root, calling
TransformMatrix1->unref() which in turn deletes TM1 (since its refcount
reaches 0). The destructor calls unref() on all of TM1's children (i.e.
Node->unref).
You have to take care if you remove both TM1 and TM2 since then the
entire Node branch may be deleted unless you keep a ref_ptr to Node.
Hope this helps,
/Ulrich
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.467 / Virus Database: 269.7.6/815 - Release Date: 22-May-07
3:49 PM
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/