From 4d53ab6c3210f4c2e59927a36461962d703489cc Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 8 Feb 2017 20:04:17 +0100 Subject: [PATCH] nifloader: attempt to remove redundant root node when a Skeleton is added --- components/nifosg/nifloader.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index abb9630a50..6fa8e4e498 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -361,7 +361,19 @@ namespace NifOsg if (nif->getUseSkinning()) { osg::ref_ptr skel = new SceneUtil::Skeleton; - skel->addChild(created); + + osg::Group* root = created->asGroup(); + if (root && root->getDataVariance() == osg::Object::STATIC) + { + skel->setStateSet(root->getStateSet()); + skel->setName(root->getName()); + for (unsigned int i=0; igetNumChildren(); ++i) + skel->addChild(root->getChild(i)); + root->removeChildren(0, root->getNumChildren()); + created = skel; + } + else + skel->addChild(created); created = skel; }