[osg-users] Cached switch nodes : switch one of them -> all of them gets switched!!!

36 views
Skip to first unread message

Arif Yetkin Sarı

unread,
Dec 24, 2010, 10:49:40 AM12/24/10
to osg-...@lists.openscenegraph.org
Hi all

I am trying to use osgDB::Registry cache to avoid loading the same models multiple times.

Caching works ok, reduces the memory usage as expected.

I enable caching with :


Code:
osgDB::Options* opt = osgDB::Registry::instance()->getOptions();
if (opt == NULL)
{
opt = new osgDB::Options();
}
opt->setObjectCacheHint(osgDB::Options::CACHE_ALL);
osgDB::Registry::instance()->setOptions(opt);

I read an ive file with :


Code:
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile(f);

(a quick question : if i enable caching globally like the above chunk of code, do i have to pass options parameter to the overloaded readNodeFile function ?)

But whenever i read an ive file with switch ability more than once; a switching action during runtime alters all of the models.

For eg. when i load two traffic lights, the second one is retrieved from cache. And if i change the switch on any of them, the other one gets affected too!

Any hints guys ?

PS : I was trying to read osgCal animated meshes in my OSG code a while ago. And i implemented a map to not to load the same animated mesh from file more than once. But at the time, i had the same problem : when an animation was triggered, all of the animated mesh instances got affected. I overcame this problem by caching osgCal::CoreModel instead of osgCal::Model

Thanks in advance
Arif Yetkin

------------------------
http://www.youtube.com/watch?v=naX3hOkDx8w

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=35156#35156

_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Sergey Polischuk

unread,
Dec 29, 2010, 10:46:11 AM12/29/10
to osg-...@lists.openscenegraph.org
You can try not using model directly, but make a copy using osg::CopyOp with appropriate options to reuse geometry data, textures etc, but make new nodes. I think osg::CopyOp::DEEP_COPY_NODES is mode that you should try.

Cheers,
Sergey

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=35216#35216

Reply all
Reply to author
Forward
0 new messages