From c7692acb79635f04f98ea49a44d47bbaab260eca Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 17 Jul 2013 19:11:03 -0700 Subject: [PATCH] Update the player's Ptr in mwrender when changing cells --- apps/openmw/mwrender/camera.cpp | 4 ++-- apps/openmw/mwrender/renderingmanager.cpp | 8 ++++++++ apps/openmw/mwrender/renderingmanager.hpp | 3 +++ apps/openmw/mwworld/scene.cpp | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/camera.cpp b/apps/openmw/mwrender/camera.cpp index b763d84ac9..f8f954bf3f 100644 --- a/apps/openmw/mwrender/camera.cpp +++ b/apps/openmw/mwrender/camera.cpp @@ -82,8 +82,8 @@ namespace MWRender mCameraNode->getCreator()->destroySceneNode(mCameraNode); } mCameraNode = node; - mCamera->detachFromParent(); - mCameraNode->attachObject(mCamera); + if(!mCamera->isAttached()) + mCameraNode->attachObject(mCamera); } void Camera::updateListener() diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index c4b086b891..41b9a854a4 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -303,6 +303,14 @@ RenderingManager::updateObjectCell(const MWWorld::Ptr &old, const MWWorld::Ptr & } } +void RenderingManager::updatePlayerPtr(const MWWorld::Ptr &ptr) +{ + if(mPlayerAnimation) + mPlayerAnimation->updatePtr(ptr); + if(mCamera->getHandle() == ptr.getRefData().getHandle()) + mCamera->attachTo(ptr); +} + void RenderingManager::update (float duration, bool paused) { MWBase::World *world = MWBase::Environment::get().getWorld(); diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 2111b89f19..77e954e872 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -127,6 +127,9 @@ public: /// \param cur Object reference in new cell void updateObjectCell(const MWWorld::Ptr &old, const MWWorld::Ptr &cur); + /// Specifies an updated Ptr object for the player (used on cell change). + void updatePlayerPtr(const MWWorld::Ptr &ptr); + void update (float duration, bool paused); void setAmbientColour(const Ogre::ColourValue& colour); diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 09fde684de..5fa1400b16 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -167,6 +167,7 @@ namespace MWWorld world->getPlayer().setCell(cell); MWWorld::Ptr player = world->getPlayer().getPlayer(); + mRendering.updatePlayerPtr(player); if (adjustPlayerPos) { world->moveObject(player, pos.pos[0], pos.pos[1], pos.pos[2]);