From 1e5b4bea0ac53cb544ec3a351c4a0f48ed3c5511 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 29 Feb 2016 17:50:18 +0100 Subject: [PATCH] Don't create an unnecessary osg::Group when copying over a rig --- components/sceneutil/attach.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/components/sceneutil/attach.cpp b/components/sceneutil/attach.cpp index d8cfa428a2..38330901d3 100644 --- a/components/sceneutil/attach.cpp +++ b/components/sceneutil/attach.cpp @@ -56,9 +56,18 @@ namespace SceneUtil CopyRigVisitor copyVisitor(handle, filter); toAttach->accept(copyVisitor); - master->asGroup()->addChild(handle); - - return handle; + if (handle->getNumChildren() == 1) + { + osg::ref_ptr newHandle = handle->getChild(0); + handle->removeChild(newHandle); + master->asGroup()->addChild(newHandle); + return newHandle; + } + else + { + master->asGroup()->addChild(handle); + return handle; + } } else {