From 4bad61acec4a98357c15bd6fa3fb086545a17f68 Mon Sep 17 00:00:00 2001 From: parax0 Date: Fri, 27 Nov 2015 14:18:22 -0700 Subject: [PATCH] Camera orbit bugfixes --- Scene/script/CWaypointExtra.cpp | 4 ++-- UI/CSceneViewport.cpp | 5 +++-- UI/CSceneViewport.h | 1 + UI/CWorldEditor.cpp | 3 ++- UI/INodeEditor.h | 1 + UI/undo/CRotateNodeCommand.cpp | 4 ++++ UI/undo/CScaleNodeCommand.cpp | 4 ++++ UI/undo/CTranslateNodeCommand.cpp | 4 ++++ 8 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Scene/script/CWaypointExtra.cpp b/Scene/script/CWaypointExtra.cpp index c8a9f967..4590b4be 100644 --- a/Scene/script/CWaypointExtra.cpp +++ b/Scene/script/CWaypointExtra.cpp @@ -78,8 +78,8 @@ void CWaypointExtra::LinksModified() void CWaypointExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo) { - // This call is necessary because if we try to build links in the constructor, it'll - // fail because we haven't finished loading the scene yet. + // This call is necessary because if we try to build links in the constructor, it + // won't work properly because we haven't finished loading the scene yet. if (!mLinksBuilt) BuildLinks(); if (!ViewInfo.GameMode && mpParent->IsVisible() && !mpParent->IsSelected()) diff --git a/UI/CSceneViewport.cpp b/UI/CSceneViewport.cpp index 3eca2bc9..20bae9c8 100644 --- a/UI/CSceneViewport.cpp +++ b/UI/CSceneViewport.cpp @@ -113,9 +113,10 @@ void CSceneViewport::keyPressEvent(QKeyEvent* pEvent) { CBasicViewport::keyPressEvent(pEvent); - if (!pEvent->modifiers() && pEvent->key() == Qt::Key_Z) + if (!pEvent->modifiers() && pEvent->key() == Qt::Key_Z && !pEvent->isAutoRepeat()) { mCamera.SetMoveMode(eOrbitCamera); + emit CameraOrbit(); } } @@ -123,7 +124,7 @@ void CSceneViewport::keyReleaseEvent(QKeyEvent* pEvent) { CBasicViewport::keyReleaseEvent(pEvent); - if (pEvent->key() == Qt::Key_Z) + if (pEvent->key() == Qt::Key_Z && !pEvent->isAutoRepeat()) { mCamera.SetMoveMode(eFreeCamera); } diff --git a/UI/CSceneViewport.h b/UI/CSceneViewport.h index 4b617908..e93d0fbd 100644 --- a/UI/CSceneViewport.h +++ b/UI/CSceneViewport.h @@ -39,6 +39,7 @@ public: signals: void GizmoMoved(); + void CameraOrbit(); protected slots: void CheckUserInput(); diff --git a/UI/CWorldEditor.cpp b/UI/CWorldEditor.cpp index c1e8ffc7..32781bef 100644 --- a/UI/CWorldEditor.cpp +++ b/UI/CWorldEditor.cpp @@ -64,8 +64,9 @@ CWorldEditor::CWorldEditor(QWidget *parent) : // Connect signals and slots connect(ui->MainViewport, SIGNAL(GizmoMoved()), this, SLOT(OnGizmoMoved())); - connect(ui->MainViewport, SIGNAL(GizmoMoved()), this, SLOT(UpdateCameraOrbit())); + connect(ui->MainViewport, SIGNAL(CameraOrbit()), this, SLOT(UpdateCameraOrbit())); connect(this, SIGNAL(SelectionModified()), this, SLOT(UpdateCameraOrbit())); + connect(this, SIGNAL(SelectionTransformed()), this, SLOT(UpdateCameraOrbit())); connect(ui->TransformSpinBox, SIGNAL(ValueChanged(CVector3f)), this, SLOT(OnTransformSpinBoxModified(CVector3f))); connect(ui->TransformSpinBox, SIGNAL(EditingDone(CVector3f)), this, SLOT(OnTransformSpinBoxEdited(CVector3f))); connect(ui->CamSpeedSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnCameraSpeedChange(double))); diff --git a/UI/INodeEditor.h b/UI/INodeEditor.h index a5bd436f..095b3d2f 100644 --- a/UI/INodeEditor.h +++ b/UI/INodeEditor.h @@ -62,6 +62,7 @@ public: signals: void SelectionModified(); + void SelectionTransformed(); public slots: void OnGizmoMoved(); diff --git a/UI/undo/CRotateNodeCommand.cpp b/UI/undo/CRotateNodeCommand.cpp index eacedc3d..839f0bab 100644 --- a/UI/undo/CRotateNodeCommand.cpp +++ b/UI/undo/CRotateNodeCommand.cpp @@ -27,6 +27,8 @@ CRotateNodeCommand::CRotateNodeCommand(INodeEditor *pEditor, const QListLocalRotation(); mNodeList.push_back(rotate); } + + mpEditor->SelectionTransformed(); } CRotateNodeCommand::~CRotateNodeCommand() @@ -78,6 +80,7 @@ void CRotateNodeCommand::undo() } mpEditor->RecalculateSelectionBounds(); + mpEditor->SelectionTransformed(); mpEditor->UpdateGizmoUI(); } @@ -92,6 +95,7 @@ void CRotateNodeCommand::redo() } mpEditor->RecalculateSelectionBounds(); + mpEditor->SelectionTransformed(); mpEditor->UpdateGizmoUI(); } diff --git a/UI/undo/CScaleNodeCommand.cpp b/UI/undo/CScaleNodeCommand.cpp index 2741a7d6..56589a46 100644 --- a/UI/undo/CScaleNodeCommand.cpp +++ b/UI/undo/CScaleNodeCommand.cpp @@ -27,6 +27,8 @@ CScaleNodeCommand::CScaleNodeCommand(INodeEditor *pEditor, const QListLocalScale(); mNodeList.push_back(scale); } + + mpEditor->SelectionTransformed(); } CScaleNodeCommand::~CScaleNodeCommand() @@ -78,6 +80,7 @@ void CScaleNodeCommand::undo() } mpEditor->RecalculateSelectionBounds(); + mpEditor->SelectionTransformed(); mpEditor->UpdateGizmoUI(); } @@ -92,6 +95,7 @@ void CScaleNodeCommand::redo() } mpEditor->RecalculateSelectionBounds(); + mpEditor->SelectionTransformed(); mpEditor->UpdateGizmoUI(); } diff --git a/UI/undo/CTranslateNodeCommand.cpp b/UI/undo/CTranslateNodeCommand.cpp index a5365adb..ba0e44fc 100644 --- a/UI/undo/CTranslateNodeCommand.cpp +++ b/UI/undo/CTranslateNodeCommand.cpp @@ -25,6 +25,8 @@ CTranslateNodeCommand::CTranslateNodeCommand(INodeEditor *pEditor, const QListLocalPosition(); mNodeList.push_back(translate); } + + mpEditor->SelectionTransformed(); } CTranslateNodeCommand::~CTranslateNodeCommand() @@ -70,6 +72,7 @@ void CTranslateNodeCommand::undo() translate.pNode->SetPosition(translate.initialPos); mpEditor->RecalculateSelectionBounds(); + mpEditor->SelectionTransformed(); mpEditor->UpdateGizmoUI(); } @@ -81,6 +84,7 @@ void CTranslateNodeCommand::redo() translate.pNode->SetPosition(translate.newPos); mpEditor->RecalculateSelectionBounds(); + mpEditor->SelectionTransformed(); mpEditor->UpdateGizmoUI(); }