diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index cdc6c49ab2..91ef6cc975 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -968,8 +968,9 @@ namespace MWRender { osg::ref_ptr node = getNodeMap().at(it->first); // this should not throw, we already checked for the node existing in addAnimSource - node->addUpdateCallback(it->second); - mActiveControllers.emplace_back(node, it->second); + osg::Callback* callback = it->second->getAsCallback(); + node->addUpdateCallback(callback); + mActiveControllers.emplace_back(node, callback); if (blendMask == 0 && node == mAccumRoot) { diff --git a/components/nifosg/controller.hpp b/components/nifosg/controller.hpp index c6311fd5fc..5d88dda1f1 100644 --- a/components/nifosg/controller.hpp +++ b/components/nifosg/controller.hpp @@ -248,6 +248,7 @@ namespace NifOsg META_Object(NifOsg, KeyframeController) osg::Vec3f getTranslation(float time) const override; + osg::Callback* getAsCallback() override { return this; } void operator() (NifOsg::MatrixTransform*, osg::NodeVisitor*); diff --git a/components/sceneutil/keyframe.hpp b/components/sceneutil/keyframe.hpp index 5be6924a09..59a87ab08e 100644 --- a/components/sceneutil/keyframe.hpp +++ b/components/sceneutil/keyframe.hpp @@ -3,7 +3,7 @@ #include -#include +#include #include #include @@ -11,18 +11,20 @@ namespace SceneUtil { - class KeyframeController : public SceneUtil::Controller, public virtual osg::Callback + /// @note Derived classes are expected to derive from osg::Callback and implement getAsCallback(). + class KeyframeController : public SceneUtil::Controller, public virtual osg::Object { public: KeyframeController() {} KeyframeController(const KeyframeController& copy, const osg::CopyOp& copyop) - : osg::Callback(copy, copyop) - , SceneUtil::Controller(copy) - {} - META_Object(SceneUtil, KeyframeController) + : osg::Object(copy, copyop) + , SceneUtil::Controller(copy) {} virtual osg::Vec3f getTranslation(float time) const { return osg::Vec3f(); } + + /// @note We could drop this function in favour of osg::Object::asCallback from OSG 3.6 on. + virtual osg::Callback* getAsCallback() = 0; }; /// Wrapper object containing an animation track as a ref-countable osg::Object. diff --git a/components/sceneutil/nodecallback.hpp b/components/sceneutil/nodecallback.hpp index 6f0140d64c..942cb17ded 100644 --- a/components/sceneutil/nodecallback.hpp +++ b/components/sceneutil/nodecallback.hpp @@ -13,7 +13,7 @@ namespace SceneUtil { template -class NodeCallback : public virtual osg::Callback +class NodeCallback : public osg::Callback { public: NodeCallback(){} diff --git a/components/sceneutil/osgacontroller.hpp b/components/sceneutil/osgacontroller.hpp index 26212a3b99..893b8b1ebe 100644 --- a/components/sceneutil/osgacontroller.hpp +++ b/components/sceneutil/osgacontroller.hpp @@ -45,6 +45,8 @@ namespace SceneUtil META_Object(SceneUtil, OsgAnimationController) + osg::Callback* getAsCallback() override { return this; } + /// @brief Handles the location of the instance osg::Vec3f getTranslation(float time) const override;