mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2024-12-29 12:20:41 +00:00
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`.
This commit is contained in:
parent
e4a9eefc2a
commit
14d15dcfac
@ -1,19 +1,12 @@
|
||||
#include <components/sceneutil/osgacontroller.hpp>
|
||||
|
||||
#include <osg/Geode>
|
||||
#include <osg/Node>
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/StateSet>
|
||||
|
||||
#include <osgAnimation/Animation>
|
||||
#include <osgAnimation/AnimationUpdateCallback>
|
||||
#include <osgAnimation/Channel>
|
||||
#include <osgAnimation/BasicAnimationManager>
|
||||
#include <osgAnimation/Bone>
|
||||
#include <osgAnimation/Sampler>
|
||||
#include <osgAnimation/Skeleton>
|
||||
#include <osgAnimation/RigGeometry>
|
||||
#include <osgAnimation/UpdateMatrixTransform>
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
@ -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<osgAnimation::UpdateMatrixTransform*>(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<osg::Node&>(node));
|
||||
if (node.getNumChildrenRequiringUpdateTraversal())
|
||||
traverse( node );
|
||||
}
|
||||
|
||||
OsgAnimationController::OsgAnimationController(const OsgAnimationController ©, const osg::CopyOp ©op) : SceneUtil::KeyframeController(copy, copyop), SceneUtil::NodeCallback<OsgAnimationController>(copy, copyop)
|
||||
|
@ -3,13 +3,7 @@
|
||||
|
||||
#include <osg/Node>
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/StateSet>
|
||||
#include <osg/ref_ptr>
|
||||
#include <osgAnimation/Animation>
|
||||
#include <osgAnimation/AnimationUpdateCallback>
|
||||
#include <osgAnimation/Channel>
|
||||
#include <osgAnimation/BasicAnimationManager>
|
||||
#include <osgAnimation/StackedTransform>
|
||||
#include <osgAnimation/UpdateMatrixTransform>
|
||||
|
||||
#include <components/sceneutil/controller.hpp>
|
||||
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user