1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-03 20:39:40 +00:00

Don't copy osga-data in base class keyframecontroller, fix warnings.

This commit is contained in:
Nelsson Huotari 2020-11-20 19:38:29 +02:00
parent 6e77ad1f6a
commit 32d4344803
5 changed files with 20 additions and 21 deletions

View file

@ -31,7 +31,7 @@ namespace OsgAOpenMW
osg::ref_ptr<OsgaController::KeyframeController> callback = new OsgaController::KeyframeController(); osg::ref_ptr<OsgaController::KeyframeController> callback = new OsgaController::KeyframeController();
std::vector<SceneUtil::EmulatedAnimation> emulatedAnimations; std::vector<OsgaController::EmulatedAnimation> emulatedAnimations;
for (auto animation : mAnimationManager->getAnimationList()) for (auto animation : mAnimationManager->getAnimationList())
{ {
@ -69,7 +69,7 @@ namespace OsgAOpenMW
mTarget.mTextKeys.emplace(startTime, std::move(loopstart)); mTarget.mTextKeys.emplace(startTime, std::move(loopstart));
mTarget.mTextKeys.emplace(stopTime, std::move(loopstop)); mTarget.mTextKeys.emplace(stopTime, std::move(loopstop));
SceneUtil::EmulatedAnimation emulatedAnimation; OsgaController::EmulatedAnimation emulatedAnimation;
emulatedAnimation.mStartTime = startTime; emulatedAnimation.mStartTime = startTime;
emulatedAnimation.mStopTime = stopTime; emulatedAnimation.mStopTime = stopTime;
emulatedAnimation.mName = animationName; emulatedAnimation.mName = animationName;

View file

@ -17,7 +17,7 @@ namespace OsgAOpenMW
public: public:
RetrieveAnimationsVisitor(SceneUtil::KeyframeHolder& target, osg::ref_ptr<osgAnimation::BasicAnimationManager> animationManager); RetrieveAnimationsVisitor(SceneUtil::KeyframeHolder& target, osg::ref_ptr<osgAnimation::BasicAnimationManager> animationManager);
virtual void apply(osg::Node& node); virtual void apply(osg::Node& node) override;
private: private:
SceneUtil::KeyframeHolder& mTarget; SceneUtil::KeyframeHolder& mTarget;

View file

@ -11,13 +11,6 @@
namespace SceneUtil namespace SceneUtil
{ {
struct EmulatedAnimation
{
float mStartTime;
float mStopTime;
std::string mName;
};
class KeyframeController : public osg::NodeCallback, public SceneUtil::Controller class KeyframeController : public osg::NodeCallback, public SceneUtil::Controller
{ {
public: public:
@ -26,18 +19,12 @@ namespace SceneUtil
KeyframeController(const KeyframeController& copy, const osg::CopyOp& copyop) KeyframeController(const KeyframeController& copy, const osg::CopyOp& copyop)
: osg::NodeCallback(copy, copyop) : osg::NodeCallback(copy, copyop)
, SceneUtil::Controller(copy) , SceneUtil::Controller(copy)
, mMergedAnimationTracks(copy.mMergedAnimationTracks)
, mEmulatedAnimations(copy.mEmulatedAnimations)
{} {}
META_Object(SceneUtil, KeyframeController) META_Object(SceneUtil, KeyframeController)
virtual osg::Vec3f getTranslation(float time) const { return osg::Vec3f(); } virtual osg::Vec3f getTranslation(float time) const { return osg::Vec3f(); }
virtual void operator() (osg::Node* node, osg::NodeVisitor* nodeVisitor) { traverse(node, nodeVisitor); } virtual void operator() (osg::Node* node, osg::NodeVisitor* nodeVisitor) override { traverse(node, nodeVisitor); }
protected:
std::vector<osg::ref_ptr<Resource::Animation>> mMergedAnimationTracks; // Used only by osgAnimation-based formats (e.g. dae)
std::vector<EmulatedAnimation> mEmulatedAnimations;
}; };
/// Wrapper object containing an animation track as a ref-countable osg::Object. /// Wrapper object containing an animation track as a ref-countable osg::Object.

View file

@ -102,6 +102,8 @@ namespace OsgaController
} }
KeyframeController::KeyframeController(const KeyframeController &copy, const osg::CopyOp &copyop) : SceneUtil::KeyframeController(copy, copyop) KeyframeController::KeyframeController(const KeyframeController &copy, const osg::CopyOp &copyop) : SceneUtil::KeyframeController(copy, copyop)
, mMergedAnimationTracks(copy.mMergedAnimationTracks)
, mEmulatedAnimations(copy.mEmulatedAnimations)
{ {
mLinker = nullptr; mLinker = nullptr;
} }
@ -183,7 +185,7 @@ namespace OsgaController
traverse(node, nv); traverse(node, nv);
} }
void KeyframeController::setEmulatedAnimations(std::vector<SceneUtil::EmulatedAnimation> emulatedAnimations) void KeyframeController::setEmulatedAnimations(std::vector<EmulatedAnimation> emulatedAnimations)
{ {
mEmulatedAnimations = emulatedAnimations; mEmulatedAnimations = emulatedAnimations;
} }

View file

@ -18,6 +18,13 @@
namespace OsgaController namespace OsgaController
{ {
struct EmulatedAnimation
{
float mStartTime;
float mStopTime;
std::string mName;
};
class LinkVisitor : public osg::NodeVisitor class LinkVisitor : public osg::NodeVisitor
{ {
public: public:
@ -29,9 +36,9 @@ namespace OsgaController
virtual void setAnimation(Resource::Animation* animation); virtual void setAnimation(Resource::Animation* animation);
virtual void apply(osg::Node& node); virtual void apply(osg::Node& node) override;
virtual void apply(osg::Geode& node); virtual void apply(osg::Geode& node) override;
protected: protected:
Resource::Animation* mAnimation; Resource::Animation* mAnimation;
@ -57,13 +64,16 @@ namespace OsgaController
void operator() (osg::Node*, osg::NodeVisitor*) override; void operator() (osg::Node*, osg::NodeVisitor*) override;
/// @brief Sets details of the animations /// @brief Sets details of the animations
void setEmulatedAnimations(std::vector<SceneUtil::EmulatedAnimation> emulatedAnimations); void setEmulatedAnimations(std::vector<EmulatedAnimation> emulatedAnimations);
/// @brief Adds an animation track to a model /// @brief Adds an animation track to a model
void addMergedAnimationTrack(osg::ref_ptr<Resource::Animation> animationTrack); void addMergedAnimationTrack(osg::ref_ptr<Resource::Animation> animationTrack);
private: private:
bool mNeedToLink = true; bool mNeedToLink = true;
osg::ref_ptr<LinkVisitor> mLinker; osg::ref_ptr<LinkVisitor> mLinker;
std::vector<osg::ref_ptr<Resource::Animation>> mMergedAnimationTracks; // Used only by osgAnimation-based formats (e.g. dae)
std::vector<EmulatedAnimation> mEmulatedAnimations;
}; };
} }