From 7a8a7e3dd6a28bb734abcdf85b51d3f8662ac1c8 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 18 Dec 2015 17:21:51 +0100 Subject: [PATCH] Add const version of getAnimation --- apps/openmw/mwrender/objects.cpp | 9 +++++++++ apps/openmw/mwrender/objects.hpp | 1 + apps/openmw/mwrender/renderingmanager.cpp | 8 ++++++++ apps/openmw/mwrender/renderingmanager.hpp | 1 + 4 files changed, 19 insertions(+) diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index d612824e2..f58ebb917 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -263,4 +263,13 @@ Animation* Objects::getAnimation(const MWWorld::Ptr &ptr) return NULL; } +const Animation* Objects::getAnimation(const MWWorld::ConstPtr &ptr) const +{ + PtrAnimationMap::const_iterator iter = mObjects.find(ptr); + if(iter != mObjects.end()) + return iter->second; + + return NULL; +} + } diff --git a/apps/openmw/mwrender/objects.hpp b/apps/openmw/mwrender/objects.hpp index 3ce6266c8..3d0c92cb4 100644 --- a/apps/openmw/mwrender/objects.hpp +++ b/apps/openmw/mwrender/objects.hpp @@ -81,6 +81,7 @@ public: void insertCreature (const MWWorld::Ptr& ptr, const std::string& model, bool weaponsShields); Animation* getAnimation(const MWWorld::Ptr &ptr); + const Animation* getAnimation(const MWWorld::ConstPtr &ptr) const; bool removeObject (const MWWorld::Ptr& ptr); ///< \return found? diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index b44d77722..775463eaf 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -706,6 +706,14 @@ namespace MWRender return mObjects->getAnimation(ptr); } + const MWRender::Animation* RenderingManager::getAnimation(const MWWorld::ConstPtr &ptr) const + { + if (mPlayerAnimation.get() && ptr == mPlayerAnimation->getPtr()) + return mPlayerAnimation.get(); + + return mObjects->getAnimation(ptr); + } + MWRender::Animation* RenderingManager::getPlayerAnimation() { return mPlayerAnimation.get(); diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 7b1c8529f..c48864e91 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -136,6 +136,7 @@ namespace MWRender void update(float dt, bool paused); Animation* getAnimation(const MWWorld::Ptr& ptr); + const Animation* getAnimation(const MWWorld::ConstPtr& ptr) const; Animation* getPlayerAnimation(); void addWaterRippleEmitter(const MWWorld::Ptr& ptr);