From: James Turner Date: Sat, 13 Apr 2013 13:40:55 +0000 (+0100) Subject: Restructure to avoid ordering issues. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c2f44a51c4977328a2ec839d2737cf3807151ccf;p=simgear.git Restructure to avoid ordering issues. Create a pick group for each object, instead of a single one. This can be optimised in the future but this structure is backwards- compatible with existing usage, which is more important. --- diff --git a/simgear/scene/model/SGPickAnimation.cxx b/simgear/scene/model/SGPickAnimation.cxx index da3921f4..ddc41030 100644 --- a/simgear/scene/model/SGPickAnimation.cxx +++ b/simgear/scene/model/SGPickAnimation.cxx @@ -361,13 +361,11 @@ osg::StateSet* sharedHighlightStateSet() void SGPickAnimation::apply(osg::Group& group) { - if (_objectNames.empty()) { + if (_objectNames.empty() && _proxyNames.empty()) { return; } - osg::ref_ptr renderGroup, proxyGroup, pickGroup; group.traverse(*this); - SGSceneUserData* ud = NULL; // iterate over all group children int i = group.getNumChildren() - 1; @@ -382,37 +380,26 @@ SGPickAnimation::apply(osg::Group& group) _objectNames.erase(it); install(*child); -////// - if (!pickGroup) { - osg::Group* mainGroup = createMainGroup(&group); - mainGroup->setName(child->getName()); - - if (getConfig()->getBoolValue("visible", true)) { - renderGroup = new osg::Group; - renderGroup->setName("pick render group"); - mainGroup->addChild(renderGroup); - } - - pickGroup = new osg::Group; - pickGroup->setName("pick highlight group"); - pickGroup->setNodeMask(simgear::PICK_BIT); - pickGroup->setStateSet(sharedHighlightStateSet()); - mainGroup->addChild(pickGroup); - - if (!ud) { - ud = SGSceneUserData::getOrCreateSceneUserData(pickGroup); - setupCallbacks(ud, &group); - } else { - pickGroup->setUserData(ud); - } - } // of pick group setup + osg::ref_ptr renderGroup, pickGroup; + osg::Group* mainGroup = createMainGroup(&group); + mainGroup->setName(child->getName()); + child->setName(""); // don't apply other animations twice -//////// - child->setName(""); - if (renderGroup.valid()) { - renderGroup->addChild(child); + if (getConfig()->getBoolValue("visible", true)) { + renderGroup = new osg::Group; + renderGroup->setName("pick render group"); + renderGroup->addChild(child); + mainGroup->addChild(renderGroup); } + pickGroup = new osg::Group; + pickGroup->setName("pick highlight group"); + pickGroup->setNodeMask(simgear::PICK_BIT); + pickGroup->setStateSet(sharedHighlightStateSet()); + mainGroup->addChild(pickGroup); + + setupCallbacks(SGSceneUserData::getOrCreateSceneUserData(pickGroup), mainGroup); + pickGroup->addChild(child); group.removeChild(child); continue; @@ -424,20 +411,12 @@ SGPickAnimation::apply(osg::Group& group) } _proxyNames.erase(j); - if (!proxyGroup) { - proxyGroup = new osg::Group; - group.addChild(proxyGroup); - proxyGroup->setStateSet(sharedHighlightStateSet()); - proxyGroup->setNodeMask(simgear::PICK_BIT); + osg::ref_ptr proxyGroup = new osg::Group; + group.addChild(proxyGroup); + proxyGroup->setStateSet(sharedHighlightStateSet()); + proxyGroup->setNodeMask(simgear::PICK_BIT); - if (!ud) { - ud = SGSceneUserData::getOrCreateSceneUserData(proxyGroup); - setupCallbacks(ud, &group); - } else { - proxyGroup->setUserData(ud); - } - } // of proxy group setup - + setupCallbacks(SGSceneUserData::getOrCreateSceneUserData(proxyGroup), proxyGroup); proxyGroup->addChild(child); group.removeChild(child); } // of group children iteration