mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
getting rid of some magic numbers
This commit is contained in:
parent
07d20a2013
commit
e987199949
@ -18,6 +18,7 @@ namespace CSVRender
|
|||||||
, mSceneMgr(NULL), mNavigationMode (NavigationMode_Free), mUpdate (false)
|
, mSceneMgr(NULL), mNavigationMode (NavigationMode_Free), mUpdate (false)
|
||||||
, mKeyForward (false), mKeyBackward (false), mKeyLeft (false), mKeyRight (false)
|
, mKeyForward (false), mKeyBackward (false), mKeyLeft (false), mKeyRight (false)
|
||||||
, mFast (false), mDragging (false)
|
, mFast (false), mDragging (false)
|
||||||
|
, mMouseSensitivity (2), mFastFactor (4) /// \todo make these configurable
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_PaintOnScreen);
|
setAttribute(Qt::WA_PaintOnScreen);
|
||||||
setAttribute(Qt::WA_NoSystemBackground);
|
setAttribute(Qt::WA_NoSystemBackground);
|
||||||
@ -168,9 +169,7 @@ namespace CSVRender
|
|||||||
{
|
{
|
||||||
if (int delta = event->delta())
|
if (int delta = event->delta())
|
||||||
{
|
{
|
||||||
int factor = mFast ? 4 : 1; /// \todo make this configurable
|
mCamera->move ((getFastFactor() * mCamera->getDirection() * delta)/mMouseSensitivity);
|
||||||
/// \todo make mouse sensitivity configurable (the factor 2)
|
|
||||||
mCamera->move ((factor * mCamera->getDirection() * delta)/2);
|
|
||||||
mUpdate = true;
|
mUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,8 +181,6 @@ namespace CSVRender
|
|||||||
|
|
||||||
void SceneWidget::mouseMoveEvent (QMouseEvent *event)
|
void SceneWidget::mouseMoveEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
int factor = mFast ? 4 : 1; /// \todo make this configurable
|
|
||||||
|
|
||||||
if (event->buttons() & Qt::LeftButton)
|
if (event->buttons() & Qt::LeftButton)
|
||||||
{
|
{
|
||||||
if (mDragging)
|
if (mDragging)
|
||||||
@ -194,16 +191,14 @@ namespace CSVRender
|
|||||||
if (diff.x())
|
if (diff.x())
|
||||||
{
|
{
|
||||||
Ogre::Vector3 direction = mCamera->getDerivedRight();
|
Ogre::Vector3 direction = mCamera->getDerivedRight();
|
||||||
/// \todo make mouse sensitivity configurable (the factor 2)
|
mCamera->move ((getFastFactor() * direction * diff.x())/mMouseSensitivity);
|
||||||
mCamera->move ((factor * direction * diff.x())/2);
|
|
||||||
mUpdate = true;
|
mUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diff.y())
|
if (diff.y())
|
||||||
{
|
{
|
||||||
Ogre::Vector3 direction = mCamera->getDerivedUp();
|
Ogre::Vector3 direction = mCamera->getDerivedUp();
|
||||||
/// \todo make mouse sensitivity configurable (the factor 2)
|
mCamera->move ((getFastFactor() * -direction * diff.y())/mMouseSensitivity);
|
||||||
mCamera->move ((factor * -direction * diff.y())/2);
|
|
||||||
mUpdate = true;
|
mUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,31 +229,29 @@ namespace CSVRender
|
|||||||
|
|
||||||
void SceneWidget::update()
|
void SceneWidget::update()
|
||||||
{
|
{
|
||||||
int factor = mFast ? 4 : 1; /// \todo make this configurable
|
|
||||||
|
|
||||||
if (mKeyForward && !mKeyBackward)
|
if (mKeyForward && !mKeyBackward)
|
||||||
{
|
{
|
||||||
mCamera->move (factor * mCamera->getDirection());
|
mCamera->move (getFastFactor() * mCamera->getDirection());
|
||||||
mUpdate = true;
|
mUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mKeyForward && mKeyBackward)
|
if (!mKeyForward && mKeyBackward)
|
||||||
{
|
{
|
||||||
mCamera->move (factor * -mCamera->getDirection());
|
mCamera->move (getFastFactor() * -mCamera->getDirection());
|
||||||
mUpdate = true;
|
mUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mKeyLeft && !mKeyRight)
|
if (mKeyLeft && !mKeyRight)
|
||||||
{
|
{
|
||||||
Ogre::Vector3 direction = mCamera->getDerivedRight();
|
Ogre::Vector3 direction = mCamera->getDerivedRight();
|
||||||
mCamera->move (factor * -direction);
|
mCamera->move (getFastFactor() * -direction);
|
||||||
mUpdate = true;
|
mUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mKeyLeft && mKeyRight)
|
if (!mKeyLeft && mKeyRight)
|
||||||
{
|
{
|
||||||
Ogre::Vector3 direction = mCamera->getDerivedRight();
|
Ogre::Vector3 direction = mCamera->getDerivedRight();
|
||||||
mCamera->move (factor * direction);
|
mCamera->move (getFastFactor() * direction);
|
||||||
mUpdate = true;
|
mUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,4 +261,9 @@ namespace CSVRender
|
|||||||
mWindow->update();
|
mWindow->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SceneWidget::getFastFactor() const
|
||||||
|
{
|
||||||
|
return mFast ? mFastFactor : 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,8 @@ namespace CSVRender
|
|||||||
|
|
||||||
void updateOgreWindow();
|
void updateOgreWindow();
|
||||||
|
|
||||||
|
int getFastFactor() const;
|
||||||
|
|
||||||
Ogre::Camera* mCamera;
|
Ogre::Camera* mCamera;
|
||||||
Ogre::SceneManager* mSceneMgr;
|
Ogre::SceneManager* mSceneMgr;
|
||||||
Ogre::RenderWindow* mWindow;
|
Ogre::RenderWindow* mWindow;
|
||||||
@ -62,6 +64,8 @@ namespace CSVRender
|
|||||||
bool mFast;
|
bool mFast;
|
||||||
bool mDragging;
|
bool mDragging;
|
||||||
QPoint mOldPos;
|
QPoint mOldPos;
|
||||||
|
int mMouseSensitivity;
|
||||||
|
int mFastFactor;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user