From c231b06320ccffee77630ca8c52fe87fc6bab17e Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 23 Feb 2017 15:08:55 +0100 Subject: [PATCH] Remove boneOffset node after using it --- components/sceneutil/attach.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/sceneutil/attach.cpp b/components/sceneutil/attach.cpp index 2a8f94c7c..79defe196 100644 --- a/components/sceneutil/attach.cpp +++ b/components/sceneutil/attach.cpp @@ -121,6 +121,10 @@ namespace SceneUtil trans->setPosition(boneOffset->getMatrix().getTrans()); // The BoneOffset rotation seems to be incorrect trans->setAttitude(osg::Quat(osg::DegreesToRadians(-90.f), osg::Vec3f(1,0,0))); + + // Now that we used it, get rid of the redundant node. + if (boneOffset->getNumChildren() == 0 && boneOffset->getNumParents() == 1) + boneOffset->getParent(0)->removeChild(boneOffset); } if (attachNode->getName().find("Left") != std::string::npos)