mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 07:53:51 +00:00
Remove 'separate preview camera' and make the new behavior the default one.
Also minor refactoring in camera.cpp
This commit is contained in:
parent
4d206d2c67
commit
8ac7ffc32b
5 changed files with 32 additions and 162 deletions
|
@ -110,30 +110,18 @@ namespace MWInput
|
||||||
|
|
||||||
if (MWBase::Environment::get().getInputManager()->getControlSwitch("playerviewswitch"))
|
if (MWBase::Environment::get().getInputManager()->getControlSwitch("playerviewswitch"))
|
||||||
{
|
{
|
||||||
static const bool separatePreviewCamera = Settings::Manager::getBool("separate preview camera", "Camera");
|
|
||||||
if (mBindingsManager->actionIsActive(A_TogglePOV))
|
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)
|
if (mPreviewPOVDelay == 0)
|
||||||
MWBase::Environment::get().getWorld()->togglePreviewMode(true);
|
MWBase::Environment::get().getWorld()->togglePreviewMode(true);
|
||||||
mPreviewPOVDelay += dt;
|
mPreviewPOVDelay += dt;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//disable preview mode
|
//disable preview mode
|
||||||
if (mPreviewPOVDelay > 0 || separatePreviewCamera)
|
if (mPreviewPOVDelay > 0)
|
||||||
MWBase::Environment::get().getWorld()->togglePreviewMode(false);
|
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();
|
MWBase::Environment::get().getWorld()->togglePOV();
|
||||||
mPreviewPOVDelay = 0.f;
|
mPreviewPOVDelay = 0.f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,6 @@ namespace MWRender
|
||||||
mIsNearest(false),
|
mIsNearest(false),
|
||||||
mHeight(124.f),
|
mHeight(124.f),
|
||||||
mBaseCameraDistance(Settings::Manager::getFloat("third person camera distance", "Camera")),
|
mBaseCameraDistance(Settings::Manager::getFloat("third person camera distance", "Camera")),
|
||||||
mUseSeparatePreviewCam(Settings::Manager::getBool("separate preview camera", "Camera")),
|
|
||||||
mVanityToggleQueued(false),
|
mVanityToggleQueued(false),
|
||||||
mVanityToggleQueuedValue(false),
|
mVanityToggleQueuedValue(false),
|
||||||
mViewModeToggleQueued(false),
|
mViewModeToggleQueued(false),
|
||||||
|
@ -77,13 +76,6 @@ namespace MWRender
|
||||||
mVanity.enabled = false;
|
mVanity.enabled = false;
|
||||||
mVanity.allowed = true;
|
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;
|
mCameraDistance = mBaseCameraDistance;
|
||||||
|
|
||||||
mUpdateCallback = new UpdateRenderCameraCallback(this);
|
mUpdateCallback = new UpdateRenderCameraCallback(this);
|
||||||
|
@ -95,17 +87,11 @@ namespace MWRender
|
||||||
mCamera->removeUpdateCallback(mUpdateCallback);
|
mCamera->removeUpdateCallback(mUpdateCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::Ptr Camera::getTrackingPtr() const
|
|
||||||
{
|
|
||||||
return mTrackingPtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
osg::Vec3d Camera::getFocalPoint() const
|
osg::Vec3d Camera::getFocalPoint() const
|
||||||
{
|
{
|
||||||
const osg::Node* trackNode = mTrackingNode;
|
if (!mTrackingNode)
|
||||||
if (!trackNode)
|
|
||||||
return osg::Vec3d();
|
return osg::Vec3d();
|
||||||
osg::NodePathList nodepaths = trackNode->getParentalNodePaths();
|
osg::NodePathList nodepaths = mTrackingNode->getParentalNodePaths();
|
||||||
if (nodepaths.empty())
|
if (nodepaths.empty())
|
||||||
return osg::Vec3d();
|
return osg::Vec3d();
|
||||||
osg::Matrix worldMat = osg::computeLocalToWorld(nodepaths[0]);
|
osg::Matrix worldMat = osg::computeLocalToWorld(nodepaths[0]);
|
||||||
|
@ -127,12 +113,9 @@ namespace MWRender
|
||||||
osg::Vec3d Camera::getFocalPointOffset() const
|
osg::Vec3d Camera::getFocalPointOffset() const
|
||||||
{
|
{
|
||||||
osg::Vec3d offset(0, 0, 10.f);
|
osg::Vec3d offset(0, 0, 10.f);
|
||||||
if (!mUseSeparatePreviewCam || (!mPreviewMode && !mVanity.enabled))
|
|
||||||
{
|
|
||||||
offset.x() += mFocalPointCurrentOffset.x() * cos(getYaw());
|
offset.x() += mFocalPointCurrentOffset.x() * cos(getYaw());
|
||||||
offset.y() += mFocalPointCurrentOffset.x() * sin(getYaw());
|
offset.y() += mFocalPointCurrentOffset.x() * sin(getYaw());
|
||||||
offset.z() += mFocalPointCurrentOffset.y();
|
offset.z() += mFocalPointCurrentOffset.y();
|
||||||
}
|
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +182,6 @@ namespace MWRender
|
||||||
}
|
}
|
||||||
if (mViewModeToggleQueued)
|
if (mViewModeToggleQueued)
|
||||||
{
|
{
|
||||||
|
|
||||||
togglePreviewMode(false);
|
togglePreviewMode(false);
|
||||||
toggleViewMode();
|
toggleViewMode();
|
||||||
mViewModeToggleQueued = false;
|
mViewModeToggleQueued = false;
|
||||||
|
@ -322,20 +304,6 @@ namespace MWRender
|
||||||
mVanity.enabled = enable;
|
mVanity.enabled = enable;
|
||||||
|
|
||||||
processViewChange();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,19 +317,6 @@ namespace MWRender
|
||||||
|
|
||||||
mPreviewMode = enable;
|
mPreviewMode = enable;
|
||||||
processViewChange();
|
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)
|
void Camera::setSneakOffset(float offset)
|
||||||
|
@ -369,13 +324,6 @@ namespace MWRender
|
||||||
mAnimation->setFirstPersonOffset(osg::Vec3f(0,0,-offset));
|
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)
|
void Camera::setYaw(float angle)
|
||||||
{
|
{
|
||||||
if (angle > osg::PI) {
|
if (angle > osg::PI) {
|
||||||
|
@ -383,35 +331,14 @@ namespace MWRender
|
||||||
} else if (angle < -osg::PI) {
|
} else if (angle < -osg::PI) {
|
||||||
angle += osg::PI*2;
|
angle += osg::PI*2;
|
||||||
}
|
}
|
||||||
if (mUseSeparatePreviewCam && (mVanity.enabled || mPreviewMode))
|
mYaw = angle;
|
||||||
mPreviewCam.yaw = angle;
|
|
||||||
else
|
|
||||||
mMainCam.yaw = angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
float Camera::getPitch() const
|
|
||||||
{
|
|
||||||
if (mUseSeparatePreviewCam && (mVanity.enabled || mPreviewMode))
|
|
||||||
return mPreviewCam.pitch;
|
|
||||||
return mMainCam.pitch;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::setPitch(float angle)
|
void Camera::setPitch(float angle)
|
||||||
{
|
{
|
||||||
const float epsilon = 0.000001f;
|
const float epsilon = 0.000001f;
|
||||||
float limit = osg::PI_2 - epsilon;
|
float limit = osg::PI_2 - epsilon;
|
||||||
if(mUseSeparatePreviewCam && mPreviewMode)
|
mPitch = osg::clampBetween(angle, -limit, limit);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float Camera::getCameraDistance() const
|
float Camera::getCameraDistance() const
|
||||||
|
@ -426,28 +353,13 @@ namespace MWRender
|
||||||
if(mFirstPersonView && !mPreviewMode && !mVanity.enabled)
|
if(mFirstPersonView && !mPreviewMode && !mVanity.enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mIsNearest = false;
|
|
||||||
|
|
||||||
if (adjust)
|
if (adjust)
|
||||||
{
|
|
||||||
if (mUseSeparatePreviewCam && (mVanity.enabled || mPreviewMode))
|
|
||||||
dist += mCameraDistance;
|
|
||||||
else
|
|
||||||
dist += std::min(mCameraDistance - getCameraDistanceCorrection(), mBaseCameraDistance);
|
dist += std::min(mCameraDistance - getCameraDistanceCorrection(), mBaseCameraDistance);
|
||||||
}
|
|
||||||
|
|
||||||
|
mIsNearest = dist <= mNearest;
|
||||||
|
dist = osg::clampBetween(dist, mNearest, mFurthest);
|
||||||
|
|
||||||
if (dist >= mFurthest)
|
if (!mFirstPersonView)
|
||||||
dist = mFurthest;
|
|
||||||
else if (dist <= mNearest)
|
|
||||||
{
|
|
||||||
dist = mNearest;
|
|
||||||
mIsNearest = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mUseSeparatePreviewCam && (mVanity.enabled || mPreviewMode))
|
|
||||||
mPreviewCam.offset = dist;
|
|
||||||
else if (!mFirstPersonView)
|
|
||||||
{
|
{
|
||||||
mBaseCameraDistance = dist;
|
mBaseCameraDistance = dist;
|
||||||
Settings::Manager::setFloat("third person camera distance", "Camera", dist);
|
Settings::Manager::setFloat("third person camera distance", "Camera", dist);
|
||||||
|
@ -459,14 +371,9 @@ namespace MWRender
|
||||||
{
|
{
|
||||||
if(mFirstPersonView && !mPreviewMode && !mVanity.enabled)
|
if(mFirstPersonView && !mPreviewMode && !mVanity.enabled)
|
||||||
return;
|
return;
|
||||||
|
if (adjust)
|
||||||
if (adjust) dist += mCameraDistance;
|
dist += mCameraDistance;
|
||||||
|
mCameraDistance = osg::clampBetween(dist, 10.f, mFurthest);
|
||||||
if (dist >= mFurthest)
|
|
||||||
dist = mFurthest;
|
|
||||||
else if (dist < 10.f)
|
|
||||||
dist = 10.f;
|
|
||||||
mCameraDistance = dist;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float Camera::getCameraDistanceCorrection() const
|
float Camera::getCameraDistanceCorrection() const
|
||||||
|
@ -484,21 +391,17 @@ namespace MWRender
|
||||||
|
|
||||||
void Camera::setCameraDistance()
|
void Camera::setCameraDistance()
|
||||||
{
|
{
|
||||||
if (mUseSeparatePreviewCam && (mVanity.enabled || mPreviewMode))
|
mFocalPointAdjustment = osg::Vec3d();
|
||||||
mCameraDistance = mPreviewCam.offset;
|
if (mFirstPersonView)
|
||||||
else if (!mFirstPersonView)
|
return;
|
||||||
{
|
|
||||||
mCameraDistance = mBaseCameraDistance + getCameraDistanceCorrection();
|
mCameraDistance = mBaseCameraDistance + getCameraDistanceCorrection();
|
||||||
if (mDynamicCameraDistanceEnabled)
|
if (mDynamicCameraDistanceEnabled)
|
||||||
mCameraDistance = std::min(mCameraDistance, mMaxNextCameraDistance);
|
mCameraDistance = std::min(mCameraDistance, mMaxNextCameraDistance);
|
||||||
}
|
}
|
||||||
mFocalPointAdjustment = osg::Vec3d();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Camera::setAnimation(NpcAnimation *anim)
|
void Camera::setAnimation(NpcAnimation *anim)
|
||||||
{
|
{
|
||||||
mAnimation = anim;
|
mAnimation = anim;
|
||||||
|
|
||||||
processViewChange();
|
processViewChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,13 +428,4 @@ namespace MWRender
|
||||||
rotateCamera(getPitch(), getYaw(), false);
|
rotateCamera(getPitch(), getYaw(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Camera::isVanityOrPreviewModeEnabled() const
|
|
||||||
{
|
|
||||||
return mPreviewMode || mVanity.enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Camera::isNearest() const
|
|
||||||
{
|
|
||||||
return mIsNearest;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,6 @@ namespace MWRender
|
||||||
class Camera
|
class Camera
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
struct CamData {
|
|
||||||
float pitch, yaw, offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
MWWorld::Ptr mTrackingPtr;
|
MWWorld::Ptr mTrackingPtr;
|
||||||
osg::ref_ptr<const osg::Node> mTrackingNode;
|
osg::ref_ptr<const osg::Node> mTrackingNode;
|
||||||
float mHeightScale;
|
float mHeightScale;
|
||||||
|
@ -47,8 +43,7 @@ namespace MWRender
|
||||||
} mVanity;
|
} mVanity;
|
||||||
|
|
||||||
float mHeight, mBaseCameraDistance;
|
float mHeight, mBaseCameraDistance;
|
||||||
CamData mMainCam, mPreviewCam;
|
float mPitch, mYaw;
|
||||||
bool mUseSeparatePreviewCam;
|
|
||||||
|
|
||||||
bool mVanityToggleQueued;
|
bool mVanityToggleQueued;
|
||||||
bool mVanityToggleQueuedValue;
|
bool mVanityToggleQueuedValue;
|
||||||
|
@ -83,7 +78,7 @@ namespace MWRender
|
||||||
Camera(osg::Camera* camera);
|
Camera(osg::Camera* camera);
|
||||||
~Camera();
|
~Camera();
|
||||||
|
|
||||||
MWWorld::Ptr getTrackingPtr() const;
|
MWWorld::Ptr getTrackingPtr() const { return mTrackingPtr; }
|
||||||
|
|
||||||
void setFocalPointTransitionSpeed(float v) { mFocalPointTransitionSpeedCoef = v; }
|
void setFocalPointTransitionSpeed(float v) { mFocalPointTransitionSpeedCoef = v; }
|
||||||
void setFocalPointTargetOffset(osg::Vec2d v);
|
void setFocalPointTargetOffset(osg::Vec2d v);
|
||||||
|
@ -101,10 +96,10 @@ namespace MWRender
|
||||||
/// \param rot Rotation angles in radians
|
/// \param rot Rotation angles in radians
|
||||||
void rotateCamera(float pitch, float yaw, bool adjust);
|
void rotateCamera(float pitch, float yaw, bool adjust);
|
||||||
|
|
||||||
float getYaw() const;
|
float getYaw() const { return mYaw; }
|
||||||
void setYaw(float angle);
|
void setYaw(float angle);
|
||||||
|
|
||||||
float getPitch() const;
|
float getPitch() const { return mPitch; }
|
||||||
void setPitch(float angle);
|
void setPitch(float angle);
|
||||||
|
|
||||||
/// Attach camera to object
|
/// Attach camera to object
|
||||||
|
@ -116,9 +111,6 @@ namespace MWRender
|
||||||
bool toggleVanityMode(bool enable);
|
bool toggleVanityMode(bool enable);
|
||||||
void allowVanityMode(bool allow);
|
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
|
/// @note this may be ignored if an important animation is currently playing
|
||||||
void togglePreviewMode(bool enable);
|
void togglePreviewMode(bool enable);
|
||||||
|
|
||||||
|
@ -155,10 +147,10 @@ namespace MWRender
|
||||||
/// Stores focal and camera world positions in passed arguments
|
/// Stores focal and camera world positions in passed arguments
|
||||||
void getPosition(osg::Vec3d &focal, osg::Vec3d &camera) const;
|
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 isVanityModeEnabled() const { return mVanity.enabled; }
|
||||||
|
|
||||||
bool isNearest() const;
|
bool isNearest() const { return mIsNearest; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1349,7 +1349,7 @@ namespace MWRender
|
||||||
void RenderingManager::calculateDeferredRotation()
|
void RenderingManager::calculateDeferredRotation()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptr = mCamera->getTrackingPtr();
|
MWWorld::Ptr ptr = mCamera->getTrackingPtr();
|
||||||
if (mCamera->isVanityOrPreviewModeEnabled() || mCamera->isUsingSeparatePreviewCamera() || ptr.isEmpty())
|
if (mCamera->isVanityOrPreviewModeEnabled() || ptr.isEmpty())
|
||||||
return;
|
return;
|
||||||
if (mCamera->isFirstPerson() || mDeferredRotationDisabled)
|
if (mCamera->isFirstPerson() || mDeferredRotationDisabled)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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.
|
# 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
|
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.
|
# Distance from the camera to the character in third person mode.
|
||||||
third person camera distance = 192
|
third person camera distance = 192
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue