diff --git a/apps/openmw/mwinput/actionmanager.cpp b/apps/openmw/mwinput/actionmanager.cpp index bbfad1fdd..ddde7a11e 100644 --- a/apps/openmw/mwinput/actionmanager.cpp +++ b/apps/openmw/mwinput/actionmanager.cpp @@ -110,30 +110,18 @@ namespace MWInput if (MWBase::Environment::get().getInputManager()->getControlSwitch("playerviewswitch")) { - static const bool separatePreviewCamera = Settings::Manager::getBool("separate preview camera", "Camera"); if (mBindingsManager->actionIsActive(A_TogglePOV)) { - if (separatePreviewCamera) - { - if (mPreviewPOVDelay <= 0.5 && (mPreviewPOVDelay += dt) > 0.5) - { - mPreviewPOVDelay = 1.f; - MWBase::Environment::get().getWorld()->togglePreviewMode(true); - } - } - else - { - if (mPreviewPOVDelay == 0) - MWBase::Environment::get().getWorld()->togglePreviewMode(true); - mPreviewPOVDelay += dt; - } + if (mPreviewPOVDelay == 0) + MWBase::Environment::get().getWorld()->togglePreviewMode(true); + mPreviewPOVDelay += dt; } else { //disable preview mode - if (mPreviewPOVDelay > 0 || separatePreviewCamera) + if (mPreviewPOVDelay > 0) MWBase::Environment::get().getWorld()->togglePreviewMode(false); - if (mPreviewPOVDelay > 0.f && mPreviewPOVDelay <= (separatePreviewCamera ? 0.5 : 0.25)) + if (mPreviewPOVDelay > 0.f && mPreviewPOVDelay <= 0.25) MWBase::Environment::get().getWorld()->togglePOV(); mPreviewPOVDelay = 0.f; } diff --git a/apps/openmw/mwrender/camera.cpp b/apps/openmw/mwrender/camera.cpp index 787e016ef..a674643d8 100644 --- a/apps/openmw/mwrender/camera.cpp +++ b/apps/openmw/mwrender/camera.cpp @@ -58,7 +58,6 @@ namespace MWRender mIsNearest(false), mHeight(124.f), mBaseCameraDistance(Settings::Manager::getFloat("third person camera distance", "Camera")), - mUseSeparatePreviewCam(Settings::Manager::getBool("separate preview camera", "Camera")), mVanityToggleQueued(false), mVanityToggleQueuedValue(false), mViewModeToggleQueued(false), @@ -77,13 +76,6 @@ namespace MWRender mVanity.enabled = false; mVanity.allowed = true; - mPreviewCam.pitch = 0.f; - mPreviewCam.yaw = 0.f; - mPreviewCam.offset = 400.f; - mMainCam.pitch = 0.f; - mMainCam.yaw = 0.f; - mMainCam.offset = 400.f; - mCameraDistance = mBaseCameraDistance; mUpdateCallback = new UpdateRenderCameraCallback(this); @@ -95,17 +87,11 @@ namespace MWRender mCamera->removeUpdateCallback(mUpdateCallback); } - MWWorld::Ptr Camera::getTrackingPtr() const - { - return mTrackingPtr; - } - osg::Vec3d Camera::getFocalPoint() const { - const osg::Node* trackNode = mTrackingNode; - if (!trackNode) + if (!mTrackingNode) return osg::Vec3d(); - osg::NodePathList nodepaths = trackNode->getParentalNodePaths(); + osg::NodePathList nodepaths = mTrackingNode->getParentalNodePaths(); if (nodepaths.empty()) return osg::Vec3d(); osg::Matrix worldMat = osg::computeLocalToWorld(nodepaths[0]); @@ -127,12 +113,9 @@ namespace MWRender osg::Vec3d Camera::getFocalPointOffset() const { osg::Vec3d offset(0, 0, 10.f); - if (!mUseSeparatePreviewCam || (!mPreviewMode && !mVanity.enabled)) - { - offset.x() += mFocalPointCurrentOffset.x() * cos(getYaw()); - offset.y() += mFocalPointCurrentOffset.x() * sin(getYaw()); - offset.z() += mFocalPointCurrentOffset.y(); - } + offset.x() += mFocalPointCurrentOffset.x() * cos(getYaw()); + offset.y() += mFocalPointCurrentOffset.x() * sin(getYaw()); + offset.z() += mFocalPointCurrentOffset.y(); return offset; } @@ -199,7 +182,6 @@ namespace MWRender } if (mViewModeToggleQueued) { - togglePreviewMode(false); toggleViewMode(); mViewModeToggleQueued = false; @@ -295,7 +277,7 @@ namespace MWRender mFirstPersonView = !mFirstPersonView; processViewChange(); } - + void Camera::allowVanityMode(bool allow) { if (!allow && mVanity.enabled) @@ -322,20 +304,6 @@ namespace MWRender mVanity.enabled = enable; processViewChange(); - - if (mUseSeparatePreviewCam) - { - float offset = mPreviewCam.offset; - if (mVanity.enabled) - { - setPitch(osg::DegreesToRadians(-30.f)); - mMainCam.offset = mCameraDistance; - } - else - offset = mMainCam.offset; - mCameraDistance = offset; - } - return true; } @@ -349,19 +317,6 @@ namespace MWRender mPreviewMode = enable; processViewChange(); - - if (mUseSeparatePreviewCam) - { - float offset = mCameraDistance; - if (mPreviewMode) { - mMainCam.offset = offset; - offset = mPreviewCam.offset; - } else { - mPreviewCam.offset = offset; - offset = mMainCam.offset; - } - mCameraDistance = offset; - } } void Camera::setSneakOffset(float offset) @@ -369,13 +324,6 @@ namespace MWRender mAnimation->setFirstPersonOffset(osg::Vec3f(0,0,-offset)); } - float Camera::getYaw() const - { - if (mUseSeparatePreviewCam && (mVanity.enabled || mPreviewMode)) - return mPreviewCam.yaw; - return mMainCam.yaw; - } - void Camera::setYaw(float angle) { if (angle > osg::PI) { @@ -383,35 +331,14 @@ namespace MWRender } else if (angle < -osg::PI) { angle += osg::PI*2; } - if (mUseSeparatePreviewCam && (mVanity.enabled || mPreviewMode)) - mPreviewCam.yaw = angle; - else - mMainCam.yaw = angle; - } - - float Camera::getPitch() const - { - if (mUseSeparatePreviewCam && (mVanity.enabled || mPreviewMode)) - return mPreviewCam.pitch; - return mMainCam.pitch; + mYaw = angle; } void Camera::setPitch(float angle) { const float epsilon = 0.000001f; float limit = osg::PI_2 - epsilon; - if(mUseSeparatePreviewCam && mPreviewMode) - limit /= 2; - - if(angle > limit) - angle = limit; - else if(angle < -limit) - angle = -limit; - - if (mUseSeparatePreviewCam && (mVanity.enabled || mPreviewMode)) - mPreviewCam.pitch = angle; - else - mMainCam.pitch = angle; + mPitch = osg::clampBetween(angle, -limit, limit); } float Camera::getCameraDistance() const @@ -426,28 +353,13 @@ namespace MWRender if(mFirstPersonView && !mPreviewMode && !mVanity.enabled) return; - mIsNearest = false; - if (adjust) - { - if (mUseSeparatePreviewCam && (mVanity.enabled || mPreviewMode)) - dist += mCameraDistance; - else - dist += std::min(mCameraDistance - getCameraDistanceCorrection(), mBaseCameraDistance); - } - + dist += std::min(mCameraDistance - getCameraDistanceCorrection(), mBaseCameraDistance); - if (dist >= mFurthest) - dist = mFurthest; - else if (dist <= mNearest) - { - dist = mNearest; - mIsNearest = true; - } + mIsNearest = dist <= mNearest; + dist = osg::clampBetween(dist, mNearest, mFurthest); - if (mUseSeparatePreviewCam && (mVanity.enabled || mPreviewMode)) - mPreviewCam.offset = dist; - else if (!mFirstPersonView) + if (!mFirstPersonView) { mBaseCameraDistance = dist; Settings::Manager::setFloat("third person camera distance", "Camera", dist); @@ -459,14 +371,9 @@ namespace MWRender { if(mFirstPersonView && !mPreviewMode && !mVanity.enabled) return; - - if (adjust) dist += mCameraDistance; - - if (dist >= mFurthest) - dist = mFurthest; - else if (dist < 10.f) - dist = 10.f; - mCameraDistance = dist; + if (adjust) + dist += mCameraDistance; + mCameraDistance = osg::clampBetween(dist, 10.f, mFurthest); } float Camera::getCameraDistanceCorrection() const @@ -484,21 +391,17 @@ namespace MWRender void Camera::setCameraDistance() { - if (mUseSeparatePreviewCam && (mVanity.enabled || mPreviewMode)) - mCameraDistance = mPreviewCam.offset; - else if (!mFirstPersonView) - { - mCameraDistance = mBaseCameraDistance + getCameraDistanceCorrection(); - if (mDynamicCameraDistanceEnabled) - mCameraDistance = std::min(mCameraDistance, mMaxNextCameraDistance); - } mFocalPointAdjustment = osg::Vec3d(); + if (mFirstPersonView) + return; + mCameraDistance = mBaseCameraDistance + getCameraDistanceCorrection(); + if (mDynamicCameraDistanceEnabled) + mCameraDistance = std::min(mCameraDistance, mMaxNextCameraDistance); } void Camera::setAnimation(NpcAnimation *anim) { mAnimation = anim; - processViewChange(); } @@ -525,13 +428,4 @@ namespace MWRender rotateCamera(getPitch(), getYaw(), false); } - bool Camera::isVanityOrPreviewModeEnabled() const - { - return mPreviewMode || mVanity.enabled; - } - - bool Camera::isNearest() const - { - return mIsNearest; - } } diff --git a/apps/openmw/mwrender/camera.hpp b/apps/openmw/mwrender/camera.hpp index fb83cf4d3..1701be375 100644 --- a/apps/openmw/mwrender/camera.hpp +++ b/apps/openmw/mwrender/camera.hpp @@ -24,10 +24,6 @@ namespace MWRender class Camera { private: - struct CamData { - float pitch, yaw, offset; - }; - MWWorld::Ptr mTrackingPtr; osg::ref_ptr mTrackingNode; float mHeightScale; @@ -47,8 +43,7 @@ namespace MWRender } mVanity; float mHeight, mBaseCameraDistance; - CamData mMainCam, mPreviewCam; - bool mUseSeparatePreviewCam; + float mPitch, mYaw; bool mVanityToggleQueued; bool mVanityToggleQueuedValue; @@ -83,7 +78,7 @@ namespace MWRender Camera(osg::Camera* camera); ~Camera(); - MWWorld::Ptr getTrackingPtr() const; + MWWorld::Ptr getTrackingPtr() const { return mTrackingPtr; } void setFocalPointTransitionSpeed(float v) { mFocalPointTransitionSpeedCoef = v; } void setFocalPointTargetOffset(osg::Vec2d v); @@ -101,10 +96,10 @@ namespace MWRender /// \param rot Rotation angles in radians void rotateCamera(float pitch, float yaw, bool adjust); - float getYaw() const; + float getYaw() const { return mYaw; } void setYaw(float angle); - float getPitch() const; + float getPitch() const { return mPitch; } void setPitch(float angle); /// Attach camera to object @@ -116,9 +111,6 @@ namespace MWRender bool toggleVanityMode(bool enable); void allowVanityMode(bool allow); - void useSeparatePreviewCamera(bool v) { mUseSeparatePreviewCam = v; } - bool isUsingSeparatePreviewCamera() const { return mUseSeparatePreviewCam; } - /// @note this may be ignored if an important animation is currently playing void togglePreviewMode(bool enable); @@ -155,10 +147,10 @@ namespace MWRender /// Stores focal and camera world positions in passed arguments void getPosition(osg::Vec3d &focal, osg::Vec3d &camera) const; - bool isVanityOrPreviewModeEnabled() const; + bool isVanityOrPreviewModeEnabled() const { return mPreviewMode || mVanity.enabled; } bool isVanityModeEnabled() const { return mVanity.enabled; } - bool isNearest() const; + bool isNearest() const { return mIsNearest; } }; } diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 46b573b2e..e4150eebc 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -1349,7 +1349,7 @@ namespace MWRender void RenderingManager::calculateDeferredRotation() { MWWorld::Ptr ptr = mCamera->getTrackingPtr(); - if (mCamera->isVanityOrPreviewModeEnabled() || mCamera->isUsingSeparatePreviewCamera() || ptr.isEmpty()) + if (mCamera->isVanityOrPreviewModeEnabled() || ptr.isEmpty()) return; if (mCamera->isFirstPerson() || mDeferredRotationDisabled) { diff --git a/files/settings-default.cfg b/files/settings-default.cfg index e4ef28f02..35be128a8 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -33,10 +33,6 @@ field of view = 60.0 # Best to leave this at the default since vanilla assets are not complete enough to adapt to high FoV's. Too low FoV would clip the hands off screen. first person field of view = 60.0 -# true - standard bahaviour of preview and vanity camera -# false - smooth preview mode -separate preview camera = true - # Distance from the camera to the character in third person mode. third person camera distance = 192