Re: [osg-users] Swapping ref_ptr
Hi, passing a ref_ptr by reference. This sounds somehow strange to me. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29517#29517 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Swapping ref_ptr
just pass by reference .. I think that should do the trick .. On Wed, Jun 30, 2010 at 3:04 PM, Sam Warns wrote: > Hi, > > I am in a situation where I receive a osg::ref_ptr to which I should > add a Transform Node (or basically prepend it) > > Usually the group I receive is in a hierarchy of nodes, so I was thinking > about getting parents of this group, removing this group as a child and add > the Transform instead. > > But is there a better way? > Since I actually do not know anything about the parents of the group it is > also possible that there is no parent yet so the exchange is getting > difficult. > > Now I am wondering if it is possible and safe to swap the inner pointer of > the ref_ptr. Basically my functions looks like > > Code: > > void foo (osg::ref_ptr myGroup) > { > // do something > osg::ptr_ref mat = new MatrixTransform; > // change > myGroup.swap(mat); > } > > > > > Which is called from a parent function like > > Code: > > void parentFoo() > { > osg::ref_ptr myGroup = new osg::Group; > foo(myGroup); > > // now I need myGroup to point to MatrixTransform without noticing it > > } > > > > > Is this going to work? > I have no compiler on this maschine to test right now so I am just assuming > and browsing the docs. > > > Thank you! > > Cheers, > Sam > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=29515#29515 > > > > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Swapping ref_ptr
Hi, I am in a situation where I receive a osg::ref_ptr to which I should add a Transform Node (or basically prepend it) Usually the group I receive is in a hierarchy of nodes, so I was thinking about getting parents of this group, removing this group as a child and add the Transform instead. But is there a better way? Since I actually do not know anything about the parents of the group it is also possible that there is no parent yet so the exchange is getting difficult. Now I am wondering if it is possible and safe to swap the inner pointer of the ref_ptr. Basically my functions looks like Code: void foo (osg::ref_ptr myGroup) { // do something osg::ptr_ref mat = new MatrixTransform; // change myGroup.swap(mat); } Which is called from a parent function like Code: void parentFoo() { osg::ref_ptr myGroup = new osg::Group; foo(myGroup); // now I need myGroup to point to MatrixTransform without noticing it } Is this going to work? I have no compiler on this maschine to test right now so I am just assuming and browsing the docs. Thank you! Cheers, Sam -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29515#29515 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org