mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 09:45:36 +00:00
Fix camera input not being reset when focus for widget is lost.
This commit is contained in:
parent
447ba08be5
commit
2f39a6e20d
5 changed files with 35 additions and 1 deletions
|
@ -308,6 +308,17 @@ namespace CSVRender
|
|||
getCamera()->getViewMatrix().orthoNormal(getCamera()->getViewMatrix());
|
||||
}
|
||||
|
||||
void FreeCameraController::resetInput()
|
||||
{
|
||||
mFast = false;
|
||||
mLeft = false;
|
||||
mRight = false;
|
||||
mForward = false;
|
||||
mBackward = false;
|
||||
mRollLeft = false;
|
||||
mRollRight = false;
|
||||
}
|
||||
|
||||
void FreeCameraController::yaw(double value)
|
||||
{
|
||||
getCamera()->getViewMatrix() *= osg::Matrixd::rotate(value, LocalUp);
|
||||
|
@ -535,6 +546,17 @@ namespace CSVRender
|
|||
getCamera()->getViewMatrix().orthoNormal(getCamera()->getViewMatrix());
|
||||
}
|
||||
|
||||
void OrbitCameraController::resetInput()
|
||||
{
|
||||
mFast = false;
|
||||
mLeft = false;
|
||||
mRight =false;
|
||||
mUp = false;
|
||||
mDown = false;
|
||||
mRollLeft = false;
|
||||
mRollRight = false;
|
||||
}
|
||||
|
||||
void OrbitCameraController::onActivate()
|
||||
{
|
||||
mInitialized = false;
|
||||
|
|
|
@ -51,6 +51,8 @@ namespace CSVRender
|
|||
|
||||
virtual void update(double dt) = 0;
|
||||
|
||||
virtual void resetInput() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void onActivate(){}
|
||||
|
@ -87,6 +89,8 @@ namespace CSVRender
|
|||
|
||||
void update(double dt);
|
||||
|
||||
void resetInput();
|
||||
|
||||
private:
|
||||
|
||||
void yaw(double value);
|
||||
|
@ -126,6 +130,8 @@ namespace CSVRender
|
|||
|
||||
void update(double dt);
|
||||
|
||||
void resetInput();
|
||||
|
||||
private:
|
||||
|
||||
void onActivate();
|
||||
|
|
|
@ -175,6 +175,7 @@ SceneWidget::SceneWidget(boost::shared_ptr<Resource::ResourceSystem> resourceSys
|
|||
|
||||
// Recieve mouse move event even if mouse button is not pressed
|
||||
setMouseTracking(true);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
/// \todo make shortcut configurable
|
||||
QShortcut *focusToolbar = new QShortcut (Qt::Key_T, this, 0, 0, Qt::WidgetWithChildrenShortcut);
|
||||
|
@ -291,6 +292,11 @@ void SceneWidget::mouseMoveEvent (QMouseEvent *event)
|
|||
mPrevMouseY = event->y();
|
||||
}
|
||||
|
||||
void SceneWidget::focusOutEvent (QFocusEvent *event)
|
||||
{
|
||||
mCurrentCamControl->resetInput();
|
||||
}
|
||||
|
||||
void SceneWidget::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
mCurrentCamControl->handleMouseMoveEvent("t-navi", event->delta(), 0);
|
||||
|
|
|
@ -96,6 +96,7 @@ namespace CSVRender
|
|||
virtual void wheelEvent (QWheelEvent *event);
|
||||
virtual void keyPressEvent (QKeyEvent *event);
|
||||
virtual void keyReleaseEvent (QKeyEvent *event);
|
||||
virtual void focusOutEvent (QFocusEvent *event);
|
||||
|
||||
/// \return Is \a key a button mapping setting? (ignored otherwise)
|
||||
virtual bool storeMappingSetting (const CSMPrefs::Setting *setting);
|
||||
|
|
1
extern/osgQt/GraphicsWindowQt.cpp
vendored
1
extern/osgQt/GraphicsWindowQt.cpp
vendored
|
@ -245,7 +245,6 @@ bool GraphicsWindowQt::init( QWidget* parent, const QGLWidget* shareWidget, Qt::
|
|||
// initialize widget properties
|
||||
_widget->setAutoBufferSwap( false );
|
||||
_widget->setMouseTracking( true );
|
||||
_widget->setFocusPolicy( Qt::WheelFocus );
|
||||
_widget->setGraphicsWindow( this );
|
||||
useCursor( _traits->useCursor );
|
||||
|
||||
|
|
Loading…
Reference in a new issue