From b6cb73e6e8d5c513a72bd36a43c4f163e8269e2a Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 14 May 2015 15:07:58 +0200 Subject: [PATCH] Fix deep copying of controllers This fixes the cell loading crash. --- components/sceneutil/clone.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/components/sceneutil/clone.cpp b/components/sceneutil/clone.cpp index 862a070d8f..237417974e 100644 --- a/components/sceneutil/clone.cpp +++ b/components/sceneutil/clone.cpp @@ -27,7 +27,7 @@ namespace SceneUtil if (!stateset) return NULL; if (stateset->getDataVariance() == osg::StateSet::DYNAMIC) - return osg::clone(stateset, osg::CopyOp::DEEP_COPY_STATESETS); + return osg::clone(stateset, *this); return const_cast(stateset); } @@ -37,7 +37,7 @@ namespace SceneUtil return operator()(processor); if (const osgParticle::ParticleSystemUpdater* updater = dynamic_cast(node)) { - osgParticle::ParticleSystemUpdater* cloned = osg::clone(updater, osg::CopyOp::DEEP_COPY_NODES); + osgParticle::ParticleSystemUpdater* cloned = osg::clone(updater, *this); mMap2[cloned] = updater->getParticleSystem(0); return cloned; } @@ -50,21 +50,26 @@ namespace SceneUtil return operator()(partsys); if (dynamic_cast(drawable) || dynamic_cast(drawable)) - return osg::clone(drawable, osg::CopyOp::DEEP_COPY_DRAWABLES); + { + osg::Drawable* cloned = osg::clone(drawable, *this); + if (cloned->getUpdateCallback()) + cloned->setUpdateCallback(osg::clone(cloned->getUpdateCallback(), *this)); + return cloned; + } return osg::CopyOp::operator()(drawable); } osgParticle::ParticleProcessor* CopyOp::operator() (const osgParticle::ParticleProcessor* processor) const { - osgParticle::ParticleProcessor* cloned = osg::clone(processor, osg::CopyOp::DEEP_COPY_NODES); + osgParticle::ParticleProcessor* cloned = osg::clone(processor, *this); mMap[cloned] = processor->getParticleSystem(); return cloned; } osgParticle::ParticleSystem* CopyOp::operator ()(const osgParticle::ParticleSystem* partsys) const { - osgParticle::ParticleSystem* cloned = osg::clone(partsys, osg::CopyOp::DEEP_COPY_DRAWABLES); + osgParticle::ParticleSystem* cloned = osg::clone(partsys, *this); for (std::map::const_iterator it = mMap.begin(); it != mMap.end(); ++it) {