diff --git a/apps/openmw/mwrender/camera.cpp b/apps/openmw/mwrender/camera.cpp index 59b320b65..7dd1c84d8 100644 --- a/apps/openmw/mwrender/camera.cpp +++ b/apps/openmw/mwrender/camera.cpp @@ -25,7 +25,9 @@ namespace MWRender mHeight(128.f), mCameraDistance(300.f), mDistanceAdjusted(false), - mAnimation(NULL) + mAnimation(NULL), + mNearest(30.f), + mFurthest(800.f) { mVanity.enabled = false; mVanity.allowed = true; @@ -232,16 +234,21 @@ namespace MWRender if(mFirstPersonView && !mPreviewMode && !mVanity.enabled) return; + mIsFurthest = false; + mIsNearest = false; + Ogre::Vector3 v(0.f, 0.f, dist); if (adjust) { v += mCamera->getPosition(); } - if (v.z > 800.f) { - v.z = 800.f; - } else if (v.z < 10.f) { + if (v.z >= mFurthest) { + v.z = mFurthest; + mIsFurthest = true; + } else if (!override && v.z < 10.f) { v.z = 10.f; - } else if (override && v.z < 50.f) { - v.z = 50.f; + } else if (override && v.z <= mNearest) { + v.z = mNearest; + mIsNearest = true; } mCamera->setPosition(v); @@ -320,4 +327,14 @@ namespace MWRender { return mPreviewMode || mVanity.enabled; } + + bool Camera::isNearest() + { + return mIsNearest; + } + + bool Camera::isFurthest() + { + return mIsFurthest; + } } diff --git a/apps/openmw/mwrender/camera.hpp b/apps/openmw/mwrender/camera.hpp index 2993bad05..cbfbd0919 100644 --- a/apps/openmw/mwrender/camera.hpp +++ b/apps/openmw/mwrender/camera.hpp @@ -33,6 +33,10 @@ namespace MWRender bool mFirstPersonView; bool mPreviewMode; bool mFreeLook; + float mNearest; + float mFurthest; + bool mIsNearest; + bool mIsFurthest; struct { bool enabled, allowed; @@ -99,6 +103,10 @@ namespace MWRender void togglePlayerLooking(bool enable); bool isVanityOrPreviewModeEnabled(); + + bool isNearest(); + + bool isFurthest(); }; } diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 4a9de259f..2f48a0ce9 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -903,7 +903,15 @@ void RenderingManager::setCameraDistance(float dist, bool adjust, bool override) { if(!mCamera->isVanityOrPreviewModeEnabled() && !mCamera->isFirstPerson()) { - mCamera->setCameraDistance(-dist / 120.f * 10, adjust, override); + if(mCamera->isNearest() && dist > 0.f) + mCamera->toggleViewMode(); + else + mCamera->setCameraDistance(-dist / 120.f * 10, adjust, override); + } + else if(mCamera->isFirstPerson() && dist < 0.f) + { + mCamera->toggleViewMode(); + mCamera->setCameraDistance(0.f, false, override); } }