From 0a2264cad465fcca6ea9679f1db139d6ee6cd3e6 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Sun, 15 Nov 2009 23:51:08 +0100 Subject: [PATCH] When instantiating effects, copy user data of any created nodes. This bug was the cause of the huge memory consumption / death reported at some places: the BVH data on "raw" .ac models (random objects) was dropped on the floor. --- simgear/scene/model/model.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/simgear/scene/model/model.cxx b/simgear/scene/model/model.cxx index 1485173f..9ca65c89 100644 --- a/simgear/scene/model/model.cxx +++ b/simgear/scene/model/model.cxx @@ -241,6 +241,10 @@ void MakeEffectVisitor::apply(osg::Group& node) } } SplicingVisitor::apply(node); + // If a new node was created, copy the user data too. + ref_ptr userData = SGSceneUserData::getSceneUserData(&node); + if (userData.valid() && _childStack.back().back().get() != &node) + _childStack.back().back()->setUserData(new SGSceneUserData(*userData)); if (restoreEffect) _currentEffectParent = savedEffectRoot; } @@ -265,6 +269,9 @@ void MakeEffectVisitor::apply(osg::Geode& geode) } else { eg = new EffectGeode; eg->setEffect(effect); + ref_ptr userData = SGSceneUserData::getSceneUserData(&geode); + if (userData.valid()) + eg->setUserData(new SGSceneUserData(*userData)); for (int i = 0; i < geode.getNumDrawables(); ++i) eg->addDrawable(geode.getDrawable(i)); } -- 2.39.5