From f4c8064d397f1c89a1d4baa7915818f0e6181f03 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 28 Jan 2015 19:14:57 +0100 Subject: [PATCH] Fix camera not being attached properly when player becomes vampire (Fixes #2319) --- apps/openmw/mwbase/world.hpp | 1 + apps/openmw/mwrender/npcanimation.cpp | 5 ++++- apps/openmw/mwworld/worldimp.cpp | 5 +++++ apps/openmw/mwworld/worldimp.hpp | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index f58ef0809..ccda90832 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -453,6 +453,7 @@ namespace MWBase /// \todo Probably shouldn't be here virtual MWRender::Animation* getAnimation(const MWWorld::Ptr &ptr) = 0; + virtual void reattachPlayerCamera() = 0; /// \todo this does not belong here virtual void frameStarted (float dt, bool paused) = 0; diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 9b05ce0a2..0926498c0 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -1020,7 +1020,10 @@ void NpcAnimation::setVampire(bool vampire) return; if ((mNpcType == Type_Vampire) != vampire) { - rebuild(); + if (mPtr == MWBase::Environment::get().getWorld()->getPlayerPtr()) + MWBase::Environment::get().getWorld()->reattachPlayerCamera(); + else + rebuild(); } } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 8bcfcb421..8cdd7037b 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2457,6 +2457,11 @@ namespace MWWorld return mLevitationEnabled; } + void World::reattachPlayerCamera() + { + mRendering->rebuildPtr(getPlayerPtr()); + } + void World::setWerewolf(const MWWorld::Ptr& actor, bool werewolf) { MWMechanics::NpcStats& npcStats = actor.getClass().getNpcStats(actor); diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 9834015ac..18fb354bc 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -537,6 +537,7 @@ namespace MWWorld /// \todo Probably shouldn't be here virtual MWRender::Animation* getAnimation(const MWWorld::Ptr &ptr); + virtual void reattachPlayerCamera(); /// \todo this does not belong here virtual void frameStarted (float dt, bool paused);