mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Cleanup, isModified was a remnant of an old design and is only used in the first person camera mode.
This commit is contained in:
parent
6c471349f0
commit
0ef7c778e0
2 changed files with 10 additions and 46 deletions
|
@ -27,7 +27,6 @@ namespace CSVRender
|
||||||
|
|
||||||
CameraController::CameraController()
|
CameraController::CameraController()
|
||||||
: mActive(false)
|
: mActive(false)
|
||||||
, mModified(false)
|
|
||||||
, mCameraSensitivity(1/650.f)
|
, mCameraSensitivity(1/650.f)
|
||||||
, mSecondaryMoveMult(50)
|
, mSecondaryMoveMult(50)
|
||||||
, mWheelMoveMult(8)
|
, mWheelMoveMult(8)
|
||||||
|
@ -44,11 +43,6 @@ namespace CSVRender
|
||||||
return mActive;
|
return mActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CameraController::isModified() const
|
|
||||||
{
|
|
||||||
return mModified;
|
|
||||||
}
|
|
||||||
|
|
||||||
osg::Camera* CameraController::getCamera() const
|
osg::Camera* CameraController::getCamera() const
|
||||||
{
|
{
|
||||||
return mCamera;
|
return mCamera;
|
||||||
|
@ -129,22 +123,13 @@ namespace CSVRender
|
||||||
getCamera()->setViewMatrixAsLookAt(eye, center, up);
|
getCamera()->setViewMatrixAsLookAt(eye, center, up);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraController::setModified()
|
|
||||||
{
|
|
||||||
mModified = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CameraController::resetModified()
|
|
||||||
{
|
|
||||||
mModified = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Free Camera Controller
|
Free Camera Controller
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FreeCameraController::FreeCameraController()
|
FreeCameraController::FreeCameraController()
|
||||||
: mLockUpright(false)
|
: mLockUpright(false)
|
||||||
|
, mModified(false)
|
||||||
, mFast(false)
|
, mFast(false)
|
||||||
, mLeft(false)
|
, mLeft(false)
|
||||||
, mRight(false)
|
, mRight(false)
|
||||||
|
@ -193,7 +178,7 @@ namespace CSVRender
|
||||||
{
|
{
|
||||||
mLockUpright = true;
|
mLockUpright = true;
|
||||||
mUp = up;
|
mUp = up;
|
||||||
setModified();
|
mModified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeCameraController::unfixUpAxis()
|
void FreeCameraController::unfixUpAxis()
|
||||||
|
@ -209,37 +194,30 @@ namespace CSVRender
|
||||||
if (event->key() == Qt::Key_Q)
|
if (event->key() == Qt::Key_Q)
|
||||||
{
|
{
|
||||||
mRollLeft = pressed;
|
mRollLeft = pressed;
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else if (event->key() == Qt::Key_E)
|
else if (event->key() == Qt::Key_E)
|
||||||
{
|
{
|
||||||
mRollRight = pressed;
|
mRollRight = pressed;
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else if (event->key() == Qt::Key_A)
|
else if (event->key() == Qt::Key_A)
|
||||||
{
|
{
|
||||||
mLeft = pressed;
|
mLeft = pressed;
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else if (event->key() == Qt::Key_D)
|
else if (event->key() == Qt::Key_D)
|
||||||
{
|
{
|
||||||
mRight = pressed;
|
mRight = pressed;
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else if (event->key() == Qt::Key_W)
|
else if (event->key() == Qt::Key_W)
|
||||||
{
|
{
|
||||||
mForward = pressed;
|
mForward = pressed;
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else if (event->key() == Qt::Key_S)
|
else if (event->key() == Qt::Key_S)
|
||||||
{
|
{
|
||||||
mBackward = pressed;
|
mBackward = pressed;
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else if (event->key() == Qt::Key_Shift)
|
else if (event->key() == Qt::Key_Shift)
|
||||||
{
|
{
|
||||||
mFast = pressed;
|
mFast = pressed;
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -258,7 +236,6 @@ namespace CSVRender
|
||||||
{
|
{
|
||||||
yaw(x * getCameraSensitivity());
|
yaw(x * getCameraSensitivity());
|
||||||
pitch(y * getCameraSensitivity());
|
pitch(y * getCameraSensitivity());
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else if (mode == "s-navi")
|
else if (mode == "s-navi")
|
||||||
{
|
{
|
||||||
|
@ -267,7 +244,6 @@ namespace CSVRender
|
||||||
movement += LocalUp * y * getSecondaryMovementMultiplier();
|
movement += LocalUp * y * getSecondaryMovementMultiplier();
|
||||||
|
|
||||||
translate(movement);
|
translate(movement);
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else if (mode == "t-navi")
|
else if (mode == "t-navi")
|
||||||
{
|
{
|
||||||
|
@ -308,35 +284,38 @@ namespace CSVRender
|
||||||
if (mRollRight)
|
if (mRollRight)
|
||||||
roll(rotDist);
|
roll(rotDist);
|
||||||
}
|
}
|
||||||
else if(isModified())
|
else if(mModified)
|
||||||
{
|
{
|
||||||
stabilize();
|
stabilize();
|
||||||
|
mModified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalize the matrix to counter drift
|
// Normalize the matrix to counter drift
|
||||||
getCamera()->getViewMatrix().orthoNormal(getCamera()->getViewMatrix());
|
getCamera()->getViewMatrix().orthoNormal(getCamera()->getViewMatrix());
|
||||||
|
|
||||||
resetModified();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeCameraController::yaw(double value)
|
void FreeCameraController::yaw(double value)
|
||||||
{
|
{
|
||||||
getCamera()->getViewMatrix() *= osg::Matrixd::rotate(value, LocalUp);
|
getCamera()->getViewMatrix() *= osg::Matrixd::rotate(value, LocalUp);
|
||||||
|
mModified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeCameraController::pitch(double value)
|
void FreeCameraController::pitch(double value)
|
||||||
{
|
{
|
||||||
getCamera()->getViewMatrix() *= osg::Matrixd::rotate(value, LocalLeft);
|
getCamera()->getViewMatrix() *= osg::Matrixd::rotate(value, LocalLeft);
|
||||||
|
mModified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeCameraController::roll(double value)
|
void FreeCameraController::roll(double value)
|
||||||
{
|
{
|
||||||
getCamera()->getViewMatrix() *= osg::Matrixd::rotate(value, LocalForward);
|
getCamera()->getViewMatrix() *= osg::Matrixd::rotate(value, LocalForward);
|
||||||
|
mModified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeCameraController::translate(const osg::Vec3d& offset)
|
void FreeCameraController::translate(const osg::Vec3d& offset)
|
||||||
{
|
{
|
||||||
getCamera()->getViewMatrix() *= osg::Matrixd::translate(offset);
|
getCamera()->getViewMatrix() *= osg::Matrixd::translate(offset);
|
||||||
|
mModified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeCameraController::stabilize()
|
void FreeCameraController::stabilize()
|
||||||
|
@ -426,37 +405,30 @@ namespace CSVRender
|
||||||
if (event->key() == Qt::Key_Q)
|
if (event->key() == Qt::Key_Q)
|
||||||
{
|
{
|
||||||
mRollLeft = pressed;
|
mRollLeft = pressed;
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else if (event->key() == Qt::Key_E)
|
else if (event->key() == Qt::Key_E)
|
||||||
{
|
{
|
||||||
mRollRight = pressed;
|
mRollRight = pressed;
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else if (event->key() == Qt::Key_A)
|
else if (event->key() == Qt::Key_A)
|
||||||
{
|
{
|
||||||
mLeft = pressed;
|
mLeft = pressed;
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else if (event->key() == Qt::Key_D)
|
else if (event->key() == Qt::Key_D)
|
||||||
{
|
{
|
||||||
mRight = pressed;
|
mRight = pressed;
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else if (event->key() == Qt::Key_W)
|
else if (event->key() == Qt::Key_W)
|
||||||
{
|
{
|
||||||
mUp = pressed;
|
mUp = pressed;
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else if (event->key() == Qt::Key_S)
|
else if (event->key() == Qt::Key_S)
|
||||||
{
|
{
|
||||||
mDown = pressed;
|
mDown = pressed;
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else if (event->key() == Qt::Key_Shift)
|
else if (event->key() == Qt::Key_Shift)
|
||||||
{
|
{
|
||||||
mFast = pressed;
|
mFast = pressed;
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -478,7 +450,6 @@ namespace CSVRender
|
||||||
{
|
{
|
||||||
rotateHorizontal(x * getCameraSensitivity());
|
rotateHorizontal(x * getCameraSensitivity());
|
||||||
rotateVertical(-y * getCameraSensitivity());
|
rotateVertical(-y * getCameraSensitivity());
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else if (mode == "s-navi")
|
else if (mode == "s-navi")
|
||||||
{
|
{
|
||||||
|
@ -487,7 +458,6 @@ namespace CSVRender
|
||||||
movement += LocalUp * -y * getSecondaryMovementMultiplier();
|
movement += LocalUp * -y * getSecondaryMovementMultiplier();
|
||||||
|
|
||||||
translate(movement);
|
translate(movement);
|
||||||
setModified();
|
|
||||||
}
|
}
|
||||||
else if (mode == "t-navi")
|
else if (mode == "t-navi")
|
||||||
{
|
{
|
||||||
|
@ -530,8 +500,6 @@ namespace CSVRender
|
||||||
|
|
||||||
// Normalize the matrix to counter drift
|
// Normalize the matrix to counter drift
|
||||||
getCamera()->getViewMatrix().orthoNormal(getCamera()->getViewMatrix());
|
getCamera()->getViewMatrix().orthoNormal(getCamera()->getViewMatrix());
|
||||||
|
|
||||||
resetModified();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OrbitCameraController::onActivate()
|
void OrbitCameraController::onActivate()
|
||||||
|
|
|
@ -30,7 +30,6 @@ namespace CSVRender
|
||||||
virtual ~CameraController();
|
virtual ~CameraController();
|
||||||
|
|
||||||
bool isActive() const;
|
bool isActive() const;
|
||||||
bool isModified() const;
|
|
||||||
|
|
||||||
osg::Camera* getCamera() const;
|
osg::Camera* getCamera() const;
|
||||||
double getCameraSensitivity() const;
|
double getCameraSensitivity() const;
|
||||||
|
@ -52,14 +51,11 @@ namespace CSVRender
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void setModified();
|
|
||||||
void resetModified();
|
|
||||||
|
|
||||||
virtual void onActivate(){}
|
virtual void onActivate(){}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool mActive, mModified;
|
bool mActive;
|
||||||
double mCameraSensitivity;
|
double mCameraSensitivity;
|
||||||
double mSecondaryMoveMult;
|
double mSecondaryMoveMult;
|
||||||
double mWheelMoveMult;
|
double mWheelMoveMult;
|
||||||
|
@ -98,7 +94,7 @@ namespace CSVRender
|
||||||
|
|
||||||
void stabilize();
|
void stabilize();
|
||||||
|
|
||||||
bool mLockUpright;
|
bool mLockUpright, mModified;
|
||||||
bool mFast, mLeft, mRight, mForward, mBackward, mRollLeft, mRollRight;
|
bool mFast, mLeft, mRight, mForward, mBackward, mRollLeft, mRollRight;
|
||||||
osg::Vec3d mUp;
|
osg::Vec3d mUp;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue