diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 69136bac31..aa12d7adb2 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -1481,10 +1481,10 @@ namespace MWRender void Animation::setObjectRoot(const std::string &model, bool forceskeleton, bool baseonly, bool isCreature) { osg::ref_ptr previousStateset; + osg::ref_ptr previousCullCallback; if (mObjectRoot) { - if (mLightListCallback) - mObjectRoot->removeCullCallback(mLightListCallback); + previousCullCallback = mObjectRoot->getCullCallback(); previousStateset = mObjectRoot->getStateSet(); mObjectRoot->getParent(0)->removeChild(mObjectRoot); } @@ -1573,9 +1573,9 @@ namespace MWRender removeTriBipVisitor.remove(); } - if (!mLightListCallback) - mLightListCallback = new SceneUtil::LightListCallback; - mObjectRoot->addCullCallback(mLightListCallback); + if (!previousCullCallback) + previousCullCallback = mLightListCallback; + mObjectRoot->setCullCallback(previousCullCallback); } osg::Group* Animation::getObjectRoot()