On Wed, 5 Jul 2006, Divick Kishore wrote:
Hi all,
what is the correct way to delete objects from heap in
openscenegraph ? Since all destructors are protected for all classes derived
from Referenced, so I cannot delete the objects created on heap and nor can I
create object on stack. Thus the only way is to create using new and assign
in a ref_ptr.
This is the correct behavior. Ref_ptr automatically takes care of deleting
unused objects. Please see the OpenSceneGraph web site article on ref_ptr.
Now the problem is if I have already something inside the ref_ptr and I
want to put something else in it then how shall I tell ref_ptr to delete it?
AFAIK, one should not use the release method of ref_ptr to delete the object.
So what option am I left with?
If you put something else in a ref_ptr, the old thing will be automatically
deleted correctly.
To be more precise in the code below I am loading a scenegraph from a file
and the point to it by a ref_ptr m_loadedModel. Now assume that I already
have a scenegraph loaded , then isn't it I need to unload or delete the
scenegraph that is already loaded?
osg::ref_ptr<osg::Node> m_loadedModel;
//Shouldn't I delete the scenegraph if it is already loaded in the
m_loadedModel ???
m_loadedModel = osgDB::readNodeFile(fileName.c_str());*
The old scene will be automatically removed, thanks to the magic that is
ref_ptr.
--
____ __ Eric Sokolowsky (GST) NASA Goddard Space Flight Center
/ __/__/_/__ Visualization Programmer Scientific Visualization Studio
/ __/ _/ / _/ 301.286.3751 Mailstop 610.3 Bldg 28 Rm E102
/___/_//_/__/ [EMAIL PROTECTED] Greenbelt, MD 20771
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/