mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 08:15:37 +00:00
refactors osg::Callback virtual inheritance (#3200)
With this PR we refactor `SceneUtil::KeyframeController` not to require `virtual osg::Callback` inheritance. I suppose such `virtual` overhead is not justified here because it negatively impacts many other classes we derive from `osg::Callback`.
This commit is contained in:
parent
4c81518abb
commit
356e9d7cf0
5 changed files with 15 additions and 9 deletions
|
@ -968,8 +968,9 @@ namespace MWRender
|
|||
{
|
||||
osg::ref_ptr<osg::Node> 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)
|
||||
{
|
||||
|
|
|
@ -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*);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <map>
|
||||
|
||||
#include <osg/Callback>
|
||||
#include <osg/Object>
|
||||
|
||||
#include <components/sceneutil/controller.hpp>
|
||||
#include <components/sceneutil/textkeymap.hpp>
|
||||
|
@ -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.
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace SceneUtil
|
|||
{
|
||||
|
||||
template <class Derived, typename NodeType=osg::Node*, typename VisitorType=osg::NodeVisitor*>
|
||||
class NodeCallback : public virtual osg::Callback
|
||||
class NodeCallback : public osg::Callback
|
||||
{
|
||||
public:
|
||||
NodeCallback(){}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue