From 07e689071ae2d6e1d8e8832373ecb1451c2f4ee2 Mon Sep 17 00:00:00 2001 From: parax0 Date: Fri, 27 Nov 2015 05:26:32 -0700 Subject: [PATCH] More fixes --- Core/CCamera.cpp | 8 ++++---- Scene/CModelNode.cpp | 1 + UI/CBasicViewport.cpp | 2 +- UI/CModelEditorViewport.cpp | 4 ++++ UI/CModelEditorWindow.cpp | 4 ++-- UI/CWorldEditor.cpp | 28 ++++++++++++---------------- UI/CWorldEditor.h | 2 +- UI/INodeEditor.cpp | 8 ++++++++ UI/INodeEditor.h | 3 +++ 9 files changed, 36 insertions(+), 24 deletions(-) diff --git a/Core/CCamera.cpp b/Core/CCamera.cpp index b0b41fec..c91b6454 100644 --- a/Core/CCamera.cpp +++ b/Core/CCamera.cpp @@ -63,11 +63,11 @@ void CCamera::Zoom(float Amount) if (mMode == eFreeCamera) { Update(); - mPosition += (mDirection * Amount) * (mMoveSpeed * 25.f); + mPosition += mDirection * (Amount * mMoveSpeed); } else - mOrbitDistance -= Amount * mMoveSpeed * 25.f; + mOrbitDistance -= Amount * mMoveSpeed; mViewOutdated = true; mFrustumPlanesOutdated = true; @@ -87,8 +87,8 @@ void CCamera::ProcessKeyInput(EKeyInputs KeyFlags, double DeltaTime) { float FDeltaTime = (float) DeltaTime; - if (KeyFlags & eWKey) Zoom(FDeltaTime); - if (KeyFlags & eSKey) Zoom(-FDeltaTime); + if (KeyFlags & eWKey) Zoom(FDeltaTime * 25.f); + if (KeyFlags & eSKey) Zoom(-FDeltaTime * 25.f); if (KeyFlags & eQKey) Pan(0, -FDeltaTime * 25.f); if (KeyFlags & eEKey) Pan(0, FDeltaTime * 25.f); if (KeyFlags & eAKey) Pan(-FDeltaTime * 25.f, 0); diff --git a/Scene/CModelNode.cpp b/Scene/CModelNode.cpp index 48df61ff..8ac549f3 100644 --- a/Scene/CModelNode.cpp +++ b/Scene/CModelNode.cpp @@ -89,6 +89,7 @@ void CModelNode::DrawAsset(ERenderOptions Options, u32 Asset, const SViewInfo& V CGraphics::sPixelBlock.TevColor = CVector4f(1,1,1,1); CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f(); + CGraphics::UpdatePixelBlock(); LoadModelMatrix(); mpModel->DrawSurface(Options, Asset, mActiveMatSet); diff --git a/UI/CBasicViewport.cpp b/UI/CBasicViewport.cpp index 6c4d8fff..4fccea29 100644 --- a/UI/CBasicViewport.cpp +++ b/UI/CBasicViewport.cpp @@ -119,7 +119,7 @@ void CBasicViewport::mouseMoveEvent(QMouseEvent* /*pEvent*/) void CBasicViewport::wheelEvent(QWheelEvent *pEvent) { // Maybe track a "wheel delta" member variable and let CCamera decide what to do with it? - mCamera.Zoom(pEvent->angleDelta().y() / 6000.f); + mCamera.Zoom(pEvent->angleDelta().y() / 240.f); } void CBasicViewport::keyPressEvent(QKeyEvent *pEvent) diff --git a/UI/CModelEditorViewport.cpp b/UI/CModelEditorViewport.cpp index 7b1ff2e1..85f085e0 100644 --- a/UI/CModelEditorViewport.cpp +++ b/UI/CModelEditorViewport.cpp @@ -11,6 +11,10 @@ CModelEditorViewport::CModelEditorViewport(QWidget *pParent) mpRenderer->SetViewportSize(width(), height()); mpRenderer->SetClearColor(CColor::skBlack); mpRenderer->ToggleGrid(true); + + mViewInfo.pRenderer = mpRenderer; + mViewInfo.pScene = nullptr; + mViewInfo.GameMode = false; } CModelEditorViewport::~CModelEditorViewport() diff --git a/UI/CModelEditorWindow.cpp b/UI/CModelEditorWindow.cpp index 9ac3a654..5fc10506 100644 --- a/UI/CModelEditorWindow.cpp +++ b/UI/CModelEditorWindow.cpp @@ -818,14 +818,14 @@ void CModelEditorWindow::on_CameraModeButton_clicked() if (pCam->MoveMode() == eOrbitCamera) { pCam->SetMoveMode(eFreeCamera); - ui->CameraModeButton->setIcon(QIcon(":/icons/EditorAssets/Free Camera.png")); + ui->CameraModeButton->setIcon(QIcon(":/icons/EditorAssets/Show.png")); ui->CameraModeButton->setToolTip(QString("Free Camera")); } else if (pCam->MoveMode() == eFreeCamera) { pCam->SetMoveMode(eOrbitCamera); - ui->CameraModeButton->setIcon(QIcon(":/icons/EditorAssets/Orbit Camera v2.png")); + ui->CameraModeButton->setIcon(QIcon(":/icons/EditorAssets/Orbit Camera.png")); ui->CameraModeButton->setToolTip(QString("Orbit Camera")); CVector3f Pos = pCam->Position(); diff --git a/UI/CWorldEditor.cpp b/UI/CWorldEditor.cpp index b67aa343..c1e8ffc7 100644 --- a/UI/CWorldEditor.cpp +++ b/UI/CWorldEditor.cpp @@ -64,6 +64,8 @@ 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(this, SIGNAL(SelectionModified()), 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))); @@ -198,16 +200,10 @@ void CWorldEditor::UpdateGizmoUI() mGizmo.SetLocalRotation(mSelection.front()->AbsoluteRotation()); } } - - // Update camera orbit - UpdateCameraOrbit(); } void CWorldEditor::UpdateSelectionUI() { - // Update camera orbit - UpdateCameraOrbit(); - // Update sidebar ui->ModifyTabContents->GenerateUI(mSelection); @@ -269,16 +265,6 @@ void CWorldEditor::UpdateCursor() } } -void CWorldEditor::UpdateCameraOrbit() -{ - CCamera *pCamera = &ui->MainViewport->Camera(); - - if (!mSelection.isEmpty()) - pCamera->SetOrbit(mSelectionBounds); - else if (mpArea) - pCamera->SetOrbit(mpArea->AABox(), 0.8f); -} - // ************ PRIVATE SLOTS ************ void CWorldEditor::RefreshViewport() { @@ -295,6 +281,16 @@ void CWorldEditor::RefreshViewport() ui->MainViewport->Render(); } +void CWorldEditor::UpdateCameraOrbit() +{ + CCamera *pCamera = &ui->MainViewport->Camera(); + + if (!mSelection.isEmpty()) + pCamera->SetOrbit(mSelectionBounds); + else if (mpArea) + pCamera->SetOrbit(mpArea->AABox(), 0.8f); +} + void CWorldEditor::OnCameraSpeedChange(double speed) { static const double skDefaultSpeed = 1.0; diff --git a/UI/CWorldEditor.h b/UI/CWorldEditor.h index 815bf5b8..a4bc884a 100644 --- a/UI/CWorldEditor.h +++ b/UI/CWorldEditor.h @@ -51,10 +51,10 @@ public: protected: void GizmoModeChanged(CGizmo::EGizmoMode mode); void UpdateCursor(); - void UpdateCameraOrbit(); private slots: void RefreshViewport(); + void UpdateCameraOrbit(); void OnCameraSpeedChange(double speed); void OnTransformSpinBoxModified(CVector3f value); void OnTransformSpinBoxEdited(CVector3f value); diff --git a/UI/INodeEditor.cpp b/UI/INodeEditor.cpp index 8860119c..23af609f 100644 --- a/UI/INodeEditor.cpp +++ b/UI/INodeEditor.cpp @@ -134,18 +134,24 @@ void INodeEditor::SelectNode(CSceneNode *pNode) { if (!pNode->IsSelected()) mUndoStack.push(new CSelectNodeCommand(this, pNode, mSelection)); + + emit SelectionModified(); } void INodeEditor::DeselectNode(CSceneNode *pNode) { if (pNode->IsSelected()) mUndoStack.push(new CDeselectNodeCommand(this, pNode, mSelection)); + + emit SelectionModified(); } void INodeEditor::ClearSelection() { if (!mSelection.empty()) mUndoStack.push(new CClearSelectionCommand(this, mSelection)); + + emit SelectionModified(); } void INodeEditor::ClearAndSelectNode(CSceneNode *pNode) @@ -163,6 +169,8 @@ void INodeEditor::ClearAndSelectNode(CSceneNode *pNode) mUndoStack.push(new CSelectNodeCommand(this, pNode, mSelection)); mUndoStack.endMacro(); } + + emit SelectionModified(); } // ************ PUBLIC SLOTS ************ diff --git a/UI/INodeEditor.h b/UI/INodeEditor.h index 1ba97b2f..a5bd436f 100644 --- a/UI/INodeEditor.h +++ b/UI/INodeEditor.h @@ -60,6 +60,9 @@ public: virtual void UpdateGizmoUI() = 0; virtual void UpdateSelectionUI() = 0; +signals: + void SelectionModified(); + public slots: void OnGizmoMoved();