From 14d15dcfac77647450e30561153cce3c2aac1f74 Mon Sep 17 00:00:00 2001 From: Bo Svensson <90132211+bosvensson1@users.noreply.github.com> Date: Mon, 4 Oct 2021 10:20:33 +0000 Subject: [PATCH] cleans up osgacontroller.cpp (#3142) `handle_stateset` is not needed because `UpdateMatrixTransform` is a `NodeCallback` only allowed to be set on a `Node`. `Geode` and `Drawable` do not need explicit logic because they are both derived from `Node`. --- components/sceneutil/osgacontroller.cpp | 38 ++----------------------- components/sceneutil/osgacontroller.hpp | 10 ------- 2 files changed, 2 insertions(+), 46 deletions(-) diff --git a/components/sceneutil/osgacontroller.cpp b/components/sceneutil/osgacontroller.cpp index b986c92884..520b2d177b 100644 --- a/components/sceneutil/osgacontroller.cpp +++ b/components/sceneutil/osgacontroller.cpp @@ -1,19 +1,12 @@ #include -#include #include #include #include -#include #include -#include #include -#include -#include #include -#include -#include #include #include @@ -55,19 +48,6 @@ namespace SceneUtil } } - void LinkVisitor::handle_stateset(osg::StateSet* stateset) - { - if (!stateset) - return; - const osg::StateSet::AttributeList& attributeList = stateset->getAttributeList(); - for (auto attribute : attributeList) - { - osg::StateAttribute* sattr = attribute.second.first.get(); - osgAnimation::UpdateMatrixTransform* umt = dynamic_cast(sattr->getUpdateCallback()); //Can this even be in sa? - if (umt) link(umt); - } - } - void LinkVisitor::setAnimation(Resource::Animation* animation) { mAnimation = animation; @@ -75,10 +55,6 @@ namespace SceneUtil void LinkVisitor::apply(osg::Node& node) { - osg::StateSet* st = node.getStateSet(); - if (st) - handle_stateset(st); - osg::Callback* cb = node.getUpdateCallback(); while (cb) { @@ -88,18 +64,8 @@ namespace SceneUtil cb = cb->getNestedCallback(); } - traverse( node ); - } - - void LinkVisitor::apply(osg::Geode& node) - { - for (unsigned int i = 0; i < node.getNumDrawables(); i++) - { - osg::Drawable* drawable = node.getDrawable(i); - if (drawable && drawable->getStateSet()) - handle_stateset(drawable->getStateSet()); - } - apply(static_cast(node)); + if (node.getNumChildrenRequiringUpdateTraversal()) + traverse( node ); } OsgAnimationController::OsgAnimationController(const OsgAnimationController ©, const osg::CopyOp ©op) : SceneUtil::KeyframeController(copy, copyop), SceneUtil::NodeCallback(copy, copyop) diff --git a/components/sceneutil/osgacontroller.hpp b/components/sceneutil/osgacontroller.hpp index 427a79ca97..26212a3b99 100644 --- a/components/sceneutil/osgacontroller.hpp +++ b/components/sceneutil/osgacontroller.hpp @@ -3,13 +3,7 @@ #include #include -#include #include -#include -#include -#include -#include -#include #include #include @@ -33,14 +27,10 @@ namespace SceneUtil virtual void link(osgAnimation::UpdateMatrixTransform* umt); - virtual void handle_stateset(osg::StateSet* stateset); - virtual void setAnimation(Resource::Animation* animation); virtual void apply(osg::Node& node) override; - virtual void apply(osg::Geode& node) override; - protected: Resource::Animation* mAnimation; };