From 60563afc1020851e025614236040ce23a7d2cdf8 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 17 May 2013 22:53:43 +0200 Subject: [PATCH] Fix a new game crash, reset camera --- apps/openmw/mwrender/camera.cpp | 8 ++++++++ apps/openmw/mwrender/camera.hpp | 3 +++ apps/openmw/mwrender/renderingmanager.cpp | 5 +++++ apps/openmw/mwrender/renderingmanager.hpp | 2 ++ apps/openmw/mwworld/worldimp.cpp | 2 ++ 5 files changed, 20 insertions(+) diff --git a/apps/openmw/mwrender/camera.cpp b/apps/openmw/mwrender/camera.cpp index b4fd6a5433..e71e694f96 100644 --- a/apps/openmw/mwrender/camera.cpp +++ b/apps/openmw/mwrender/camera.cpp @@ -37,6 +37,14 @@ namespace MWRender { } + void Camera::reset() + { + togglePreviewMode(false); + toggleVanityMode(false); + if (!mFirstPersonView) + toggleViewMode(); + } + void Camera::rotateCamera(const Ogre::Vector3 &rot, bool adjust) { if (adjust) { diff --git a/apps/openmw/mwrender/camera.hpp b/apps/openmw/mwrender/camera.hpp index 7bbdd303d0..ad5e35f939 100644 --- a/apps/openmw/mwrender/camera.hpp +++ b/apps/openmw/mwrender/camera.hpp @@ -52,6 +52,9 @@ namespace MWRender Camera(Ogre::Camera *camera); ~Camera(); + /// Reset to defaults + void reset(); + /// Set where the camera is looking at. Uses Morrowind (euler) angles /// \param rot Rotation angles in radians void rotateCamera(const Ogre::Vector3 &rot, bool adjust); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 0811d87749..6586cbba6b 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -950,4 +950,9 @@ void RenderingManager::frameStarted(float dt) mWater->frameStarted(dt); } +void RenderingManager::resetCamera() +{ + mCamera->reset(); +} + } // namespace diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 6a35bfb6d7..b492a0db90 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -83,6 +83,8 @@ public: mCamera->setCameraDistance(-factor/120.f*10, true, true); } + void resetCamera(); + bool vanityRotateCamera(const float *rot); void getCameraData(Ogre::Vector3 &eyepos, float &pitch, float &yaw); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index ce1a100e33..8b76efdaeb 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -236,6 +236,8 @@ namespace MWWorld setupPlayer(); const ESM::NPC* playerNpc = mStore.get().find("player"); MWWorld::Ptr player = mPlayer->getPlayer(); + renderPlayer(); + mRendering->resetCamera(); // removes NpcStats, ContainerStore etc player.getRefData().setCustomData(NULL);