diff --git a/Core/CCamera.cpp b/Core/CCamera.cpp
index b6d25268..b0b41fec 100644
--- a/Core/CCamera.cpp
+++ b/Core/CCamera.cpp
@@ -12,81 +12,63 @@ CCamera::CCamera()
mYaw = -Math::skHalfPi;
mPitch = 0.0f;
- CalculateDirection();
+ SetOrbit(CVector3f(0), 5.f);
+ Update();
- mMoveSpeed = 1.f; // Old: 0.01f
- mLookSpeed = 1.f; // Old: 0.003f
+ mMoveSpeed = 1.f;
+ mLookSpeed = 1.f;
mViewOutdated = true;
mProjectionOutdated = true;
mFrustumPlanesOutdated = true;
}
-CCamera::CCamera(CVector3f Position, CVector3f)
+CCamera::CCamera(CVector3f Position, CVector3f /*Target*/)
{
// todo: make it actually look at the target!
- // Not using parameter 2 (CVector3f - Target)
mMode = eFreeCamera;
- mMoveSpeed = 1.f; // Old: 0.01f
- mLookSpeed = 1.f; // Old: 0.003f
+ mMoveSpeed = 1.f;
+ mLookSpeed = 1.f;
mPosition = Position;
mYaw = -Math::skHalfPi;
mPitch = 0.0f;
- CalculateDirection();
+ Update();
}
void CCamera::Pan(float XAmount, float YAmount)
{
- switch (mMode)
+ if (mMode == eFreeCamera)
{
-
- case eFreeCamera:
- {
- CVector3f Right(
- cos(mYaw - Math::skHalfPi),
- sin(mYaw - Math::skHalfPi),
- 0
- );
- CVector3f Up = Right.Cross(mDirection);
-
- mPosition += Right * (XAmount * mMoveSpeed);
- mPosition += Up * (YAmount * mMoveSpeed);
+ Update();
+ mPosition += mRightVector * (XAmount * mMoveSpeed);
+ mPosition += mUpVector * (YAmount * mMoveSpeed);
mViewOutdated = true;
mFrustumPlanesOutdated = true;
- break;
}
- // Unfinished
- case eOrbitCamera:
- {
- CVector3f Right(
- cos(mYaw - Math::skHalfPi),
- sin(mYaw - Math::skHalfPi),
- 0
- );
- CVector3f Up = Right.Cross(mDirection);
-
- CVector3f TargetDirection = mPosition - mOrbitTarget;
- //CMatrix4f YawRotation = CQuaternion::F
- }
- }
+ else
+ Rotate(-XAmount * 0.3f, YAmount * 0.3f);
}
void CCamera::Rotate(float XAmount, float YAmount)
{
- switch (mMode)
- {
- case eFreeCamera:
- mYaw -= (XAmount * mLookSpeed * 0.3f);
- mPitch -= (YAmount * mLookSpeed * 0.3f);
- mViewOutdated = true;
- mFrustumPlanesOutdated = true;
- break;
- }
+ mYaw -= (XAmount * mLookSpeed * 0.3f);
+ mPitch -= (YAmount * mLookSpeed * 0.3f);
+
+ mViewOutdated = true;
+ mFrustumPlanesOutdated = true;
}
void CCamera::Zoom(float Amount)
{
- mPosition += (mDirection * Amount) * (mMoveSpeed * 25.f);
+ if (mMode == eFreeCamera)
+ {
+ Update();
+ mPosition += (mDirection * Amount) * (mMoveSpeed * 25.f);
+ }
+
+ else
+ mOrbitDistance -= Amount * mMoveSpeed * 25.f;
+
mViewOutdated = true;
mFrustumPlanesOutdated = true;
}
@@ -98,21 +80,19 @@ void CCamera::Snap(CVector3f Position)
mPitch = 0.0f;
mViewOutdated = true;
mFrustumPlanesOutdated = true;
- CalculateDirection();
+ Update();
}
void CCamera::ProcessKeyInput(EKeyInputs KeyFlags, double DeltaTime)
{
float FDeltaTime = (float) DeltaTime;
- if (mMode == eFreeCamera)
- {
- if (KeyFlags & eWKey) Zoom(FDeltaTime);
- if (KeyFlags & eSKey) Zoom(-FDeltaTime);
- if (KeyFlags & eQKey) Pan(0, -FDeltaTime * 25.f);
- if (KeyFlags & eEKey) Pan(0, FDeltaTime * 25.f);
- if (KeyFlags & eAKey) Pan(-FDeltaTime * 25.f, 0);
- if (KeyFlags & eDKey) Pan(FDeltaTime * 25.f, 0);
- }
+
+ if (KeyFlags & eWKey) Zoom(FDeltaTime);
+ if (KeyFlags & eSKey) Zoom(-FDeltaTime);
+ if (KeyFlags & eQKey) Pan(0, -FDeltaTime * 25.f);
+ if (KeyFlags & eEKey) Pan(0, FDeltaTime * 25.f);
+ if (KeyFlags & eAKey) Pan(-FDeltaTime * 25.f, 0);
+ if (KeyFlags & eDKey) Pan(FDeltaTime * 25.f, 0);
}
void CCamera::ProcessMouseInput(EKeyInputs KeyFlags, EMouseInputs MouseFlags, float XMovement, float YMovement)
@@ -132,14 +112,9 @@ void CCamera::ProcessMouseInput(EKeyInputs KeyFlags, EMouseInputs MouseFlags, fl
// Orbit Camera
else if (mMode == eOrbitCamera)
{
- if ((MouseFlags & eMiddleButton) && (KeyFlags & eCtrlKey))
- Zoom(-YMovement * 0.2f);
-
- else if ((MouseFlags & eMiddleButton) || (MouseFlags & eRightButton))
- Pan(XMovement, YMovement);
+ if ((MouseFlags & eMiddleButton) || (MouseFlags & eRightButton))
+ Pan(-XMovement, YMovement);
}
-
- CalculateDirection();
}
CRay CCamera::CastRay(CVector2f DeviceCoords)
@@ -156,6 +131,52 @@ CRay CCamera::CastRay(CVector2f DeviceCoords)
return Ray;
}
+void CCamera::SetMoveMode(ECameraMoveMode Mode)
+{
+ mMode = Mode;
+ mViewOutdated = true;
+ mFrustumPlanesOutdated = true;
+}
+
+void CCamera::SetOrbit(const CVector3f& OrbitTarget, float Distance)
+{
+ mOrbitTarget = OrbitTarget;
+ mOrbitDistance = Distance;
+
+ if (mMode == eOrbitCamera)
+ {
+ mViewOutdated = true;
+ mFrustumPlanesOutdated = true;
+ }
+}
+
+void CCamera::SetOrbit(const CAABox& OrbitTarget, float DistScale /*= 2.5f*/)
+{
+ CVector3f Min = OrbitTarget.Min();
+ CVector3f Max = OrbitTarget.Max();
+
+ mOrbitTarget = OrbitTarget.Center();
+ mOrbitDistance = ((Max.x - Min.x) + (Max.y - Min.y) + (Max.z - Min.z)) / 3.f;
+ mOrbitDistance *= DistScale;
+
+ if (mMode == eOrbitCamera)
+ {
+ mViewOutdated = true;
+ mFrustumPlanesOutdated = true;
+ }
+}
+
+void CCamera::SetOrbitDistance(float Distance)
+{
+ mOrbitDistance = Distance;
+
+ if (mMode == eOrbitCamera)
+ {
+ mViewOutdated = true;
+ mFrustumPlanesOutdated = true;
+ }
+}
+
void CCamera::LoadMatrices()
{
CGraphics::sMVPBlock.ViewMatrix = ViewMatrix();
@@ -199,10 +220,15 @@ float CCamera::FieldOfView() const
return 55.f;
}
+ECameraMoveMode CCamera::MoveMode() const
+{
+ return mMode;
+}
+
const CMatrix4f& CCamera::ViewMatrix()
{
if (mViewOutdated)
- CalculateView();
+ UpdateView();
return mCachedViewMatrix;
}
@@ -210,7 +236,7 @@ const CMatrix4f& CCamera::ViewMatrix()
const CMatrix4f& CCamera::ProjectionMatrix()
{
if (mProjectionOutdated)
- CalculateProjection();
+ UpdateProjection();
return mCachedProjectionMatrix;
}
@@ -218,7 +244,7 @@ const CMatrix4f& CCamera::ProjectionMatrix()
const CFrustumPlanes& CCamera::FrustumPlanes()
{
if (mFrustumPlanesOutdated)
- CalculateFrustumPlanes();
+ UpdateFrustum();
return mCachedFrustumPlanes;
}
@@ -258,17 +284,6 @@ void CCamera::SetLookSpeed(float LookSpeed)
mLookSpeed = LookSpeed;
}
-void CCamera::SetFree()
-{
- mMode = eFreeCamera;
-}
-
-void CCamera::SetOrbit(const CVector3f& OrbitTarget)
-{
- mMode = eOrbitCamera;
- mOrbitTarget = OrbitTarget;
-}
-
void CCamera::SetAspectRatio(float AspectRatio)
{
mAspectRatio = AspectRatio;
@@ -277,8 +292,9 @@ void CCamera::SetAspectRatio(float AspectRatio)
}
// ************ PRIVATE ************
-void CCamera::CalculateDirection()
+void CCamera::Update()
{
+ // Update direction
if (mPitch > Math::skHalfPi) mPitch = Math::skHalfPi;
if (mPitch < -Math::skHalfPi) mPitch = -Math::skHalfPi;
@@ -295,12 +311,22 @@ void CCamera::CalculateDirection()
);
mUpVector = mRightVector.Cross(mDirection);
+
+ // Update position
+ if (mMode == eOrbitCamera)
+ {
+ if (mOrbitDistance < 1.f) mOrbitDistance = 1.f;
+ mPosition = mOrbitTarget + (mDirection * -mOrbitDistance);
+ }
+
+ mViewOutdated = true;
+ mFrustumPlanesOutdated = true;
}
-void CCamera::CalculateView()
+void CCamera::UpdateView()
{
// todo: don't use glm
- CalculateDirection();
+ Update();
glm::vec3 glmpos(mPosition.x, mPosition.y, mPosition.z);
glm::vec3 glmdir(mDirection.x, mDirection.y, mDirection.z);
@@ -309,13 +335,13 @@ void CCamera::CalculateView()
mViewOutdated = false;
}
-void CCamera::CalculateProjection()
+void CCamera::UpdateProjection()
{
mCachedProjectionMatrix = Math::PerspectiveMatrix(55.f, mAspectRatio, 0.1f, 4096.f);
mProjectionOutdated = false;
}
-void CCamera::CalculateFrustumPlanes()
+void CCamera::UpdateFrustum()
{
mCachedFrustumPlanes.SetPlanes(mPosition, mDirection, 55.f, mAspectRatio, 0.1f, 4096.f);
mFrustumPlanesOutdated = false;
diff --git a/Core/CCamera.h b/Core/CCamera.h
index 233520b6..e664b9d3 100644
--- a/Core/CCamera.h
+++ b/Core/CCamera.h
@@ -28,6 +28,7 @@ class CCamera
float mYaw;
float mPitch;
CVector3f mOrbitTarget;
+ float mOrbitDistance;
float mMoveSpeed;
float mLookSpeed;
@@ -51,6 +52,11 @@ public:
CRay CastRay(CVector2f DeviceCoords);
void LoadMatrices();
+ void SetMoveMode(ECameraMoveMode Mode);
+ void SetOrbit(const CVector3f& OrbitTarget, float Distance);
+ void SetOrbit(const CAABox& OrbitTarget, float DistScale = 2.5f);
+ void SetOrbitDistance(float Distance);
+
// Getters
CVector3f Position() const;
CVector3f Direction() const;
@@ -59,6 +65,7 @@ public:
float Yaw() const;
float Pitch() const;
float FieldOfView() const;
+ ECameraMoveMode MoveMode() const;
const CMatrix4f& ViewMatrix();
const CMatrix4f& ProjectionMatrix();
const CFrustumPlanes& FrustumPlanes();
@@ -70,17 +77,14 @@ public:
void SetPitch(float Pitch);
void SetMoveSpeed(float MoveSpeed);
void SetLookSpeed(float LookSpeed);
- void SetFree();
- void SetOrbit(const CVector3f& OrbitTarget);
- void SetOrbit(const CAABox& OrbitTarget);
void SetAspectRatio(float AspectRatio);
// Private
private:
- void CalculateDirection();
- void CalculateView();
- void CalculateProjection();
- void CalculateFrustumPlanes();
+ void Update();
+ void UpdateView();
+ void UpdateProjection();
+ void UpdateFrustum();
};
#endif // CCAMERA_H
diff --git a/UI/CBasicViewport.h b/UI/CBasicViewport.h
index c65114ac..db533efd 100644
--- a/UI/CBasicViewport.h
+++ b/UI/CBasicViewport.h
@@ -47,8 +47,8 @@ public:
void mouseReleaseEvent(QMouseEvent *pEvent);
void mouseMoveEvent(QMouseEvent *pEvent);
void wheelEvent(QWheelEvent *pEvent);
- void keyPressEvent(QKeyEvent *pEvent);
- void keyReleaseEvent(QKeyEvent *pEvent);
+ virtual void keyPressEvent(QKeyEvent *pEvent);
+ virtual void keyReleaseEvent(QKeyEvent *pEvent);
void focusOutEvent(QFocusEvent *pEvent);
void contextMenuEvent(QContextMenuEvent *pEvent);
diff --git a/UI/CModelEditorWindow.cpp b/UI/CModelEditorWindow.cpp
index b250e3fd..e80ee930 100644
--- a/UI/CModelEditorWindow.cpp
+++ b/UI/CModelEditorWindow.cpp
@@ -39,7 +39,8 @@ CModelEditorWindow::CModelEditorWindow(QWidget *parent) :
CCamera& camera = ui->Viewport->Camera();
camera.Snap(CVector3f(0, 3, 1));
- camera.SetFree();
+ camera.SetMoveMode(eOrbitCamera);
+ camera.SetOrbit(CVector3f(0, 0, 1), 3.f);
camera.SetMoveSpeed(0.5f);
// UI initialization
@@ -153,6 +154,7 @@ void CModelEditorWindow::SetActiveModel(CModel *pModel)
mpCurrentModelNode->MarkTransformChanged();
mpCurrentModel = pModel;
mModelToken = CToken(pModel);
+ ui->Viewport->Camera().SetOrbit(pModel->AABox());
u32 numVertices = (pModel ? pModel->GetVertexCount() : 0);
u32 numTriangles = (pModel ? pModel->GetTriangleCount() : 0);
@@ -807,3 +809,26 @@ void CModelEditorWindow::on_actionSave_as_triggered()
TString name = TString(filename.toStdString());
setWindowTitle("Prime World Editor - Model Editor: " + TO_QSTRING(name));
}
+
+void CModelEditorWindow::on_CameraModeButton_clicked()
+{
+ CCamera *pCam = &ui->Viewport->Camera();
+
+ if (pCam->MoveMode() == eOrbitCamera)
+ {
+ pCam->SetMoveMode(eFreeCamera);
+ ui->CameraModeButton->setIcon(QIcon(":/icons/EditorAssets/Free Camera.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->setToolTip(QString("Orbit Camera"));
+
+ CVector3f Pos = pCam->Position();
+ CVector3f Target = mpCurrentModelNode->AABox().Center();
+ pCam->SetOrbitDistance(Pos.Distance(Target));
+ }
+}
diff --git a/UI/CModelEditorWindow.h b/UI/CModelEditorWindow.h
index 2b0603e0..ecd68142 100644
--- a/UI/CModelEditorWindow.h
+++ b/UI/CModelEditorWindow.h
@@ -115,6 +115,8 @@ private slots:
void on_actionSave_as_triggered();
+ void on_CameraModeButton_clicked();
+
signals:
void Closed();
};
diff --git a/UI/CModelEditorWindow.ui b/UI/CModelEditorWindow.ui
index 4bb89193..ff716819 100644
--- a/UI/CModelEditorWindow.ui
+++ b/UI/CModelEditorWindow.ui
@@ -2140,7 +2140,7 @@
-
-
+
50
@@ -2227,6 +2227,32 @@
+ -
+
+
+ Orbit Camera
+
+
+
+
+
+
+ :/icons/EditorAssets/Orbit Camera.png:/icons/EditorAssets/Orbit Camera.png
+
+
+
+ 32
+ 32
+
+
+
+ false
+
+
+ true
+
+
+
-
diff --git a/UI/CSceneViewport.cpp b/UI/CSceneViewport.cpp
index 2844a41f..a7034160 100644
--- a/UI/CSceneViewport.cpp
+++ b/UI/CSceneViewport.cpp
@@ -109,6 +109,26 @@ bool CSceneViewport::IsHoveringGizmo()
return mGizmoHovering;
}
+void CSceneViewport::keyPressEvent(QKeyEvent* pEvent)
+{
+ CBasicViewport::keyPressEvent(pEvent);
+
+ if (pEvent->key() == Qt::Key_Z)
+ {
+ mCamera.SetMoveMode(eOrbitCamera);
+ }
+}
+
+void CSceneViewport::keyReleaseEvent(QKeyEvent* pEvent)
+{
+ CBasicViewport::keyReleaseEvent(pEvent);
+
+ if (pEvent->key() == Qt::Key_Z)
+ {
+ mCamera.SetMoveMode(eFreeCamera);
+ }
+}
+
// ************ PROTECTED SLOTS ************
void CSceneViewport::CheckUserInput()
{
diff --git a/UI/CSceneViewport.h b/UI/CSceneViewport.h
index d88ff52e..4b617908 100644
--- a/UI/CSceneViewport.h
+++ b/UI/CSceneViewport.h
@@ -34,6 +34,9 @@ public:
void ResetHover();
bool IsHoveringGizmo();
+ void keyPressEvent(QKeyEvent* pEvent);
+ void keyReleaseEvent(QKeyEvent* pEvent);
+
signals:
void GizmoMoved();
diff --git a/UI/CWorldEditor.cpp b/UI/CWorldEditor.cpp
index 3fe1f53d..dfc1db17 100644
--- a/UI/CWorldEditor.cpp
+++ b/UI/CWorldEditor.cpp
@@ -95,6 +95,7 @@ void CWorldEditor::SetArea(CWorld *pWorld, CGameArea *pArea)
ui->ModifyTabContents->ClearCachedEditors();
ui->InstancesTabContents->SetMaster(nullptr);
ui->InstancesTabContents->SetArea(pArea);
+ mUndoStack.clear();
// Clear old area - hack until better world/area loader is implemented
if ((mpArea) && (pArea != mpArea))
@@ -109,10 +110,17 @@ void CWorldEditor::SetArea(CWorld *pWorld, CGameArea *pArea)
mScene.SetActiveWorld(pWorld);
mScene.SetActiveArea(pArea);
- // Snap camera to location of area
- CTransform4f AreaTransform = pArea->GetTransform();
- CVector3f AreaPosition(AreaTransform[0][3], AreaTransform[1][3], AreaTransform[2][3]);
- ui->MainViewport->Camera().Snap(AreaPosition);
+ // Snap camera to new area
+ CCamera *pCamera = &ui->MainViewport->Camera();
+
+ if (pCamera->MoveMode() == eFreeCamera)
+ {
+ CTransform4f AreaTransform = pArea->GetTransform();
+ CVector3f AreaPosition(AreaTransform[0][3], AreaTransform[1][3], AreaTransform[2][3]);
+ pCamera->Snap(AreaPosition);
+ }
+
+ UpdateCameraOrbit();
// Default bloom to Fake Bloom for Metroid Prime 3; disable for other games
if (mpWorld->Version() == eCorruption)
@@ -137,63 +145,7 @@ CGameArea* CWorldEditor::ActiveArea()
return mpArea;
}
-// ************ SLOTS ************
-void CWorldEditor::UpdateCursor()
-{
- if (ui->MainViewport->IsCursorVisible())
- {
- CSceneNode *pHoverNode = ui->MainViewport->HoverNode();
-
- if (ui->MainViewport->IsHoveringGizmo())
- ui->MainViewport->SetCursorState(Qt::SizeAllCursor);
- else if ((pHoverNode) && (pHoverNode->NodeType() != eStaticNode))
- ui->MainViewport->SetCursorState(Qt::PointingHandCursor);
- else
- ui->MainViewport->SetCursorState(Qt::ArrowCursor);
- }
-}
-
-void CWorldEditor::UpdateStatusBar()
-{
- // Would be cool to do more frequent status bar updates with more info. Unfortunately, this causes lag.
- QString StatusText = "";
-
- if (!mGizmoHovering)
- {
- if (ui->MainViewport->underMouse())
- {
- CSceneNode *pHoverNode = ui->MainViewport->HoverNode();
-
- if (pHoverNode && (pHoverNode->NodeType() != eStaticNode))
- StatusText = TO_QSTRING(pHoverNode->Name());
- }
- }
-
- if (ui->statusbar->currentMessage() != StatusText)
- ui->statusbar->showMessage(StatusText);
-}
-
-void CWorldEditor::UpdateSelectionUI()
-{
- // Update sidebar
- ui->ModifyTabContents->GenerateUI(mSelection);
-
- // Update selection info text
- QString SelectionText;
-
- if (mSelection.size() == 1)
- SelectionText = TO_QSTRING(mSelection.front()->Name());
- else if (mSelection.size() > 1)
- SelectionText = QString("%1 objects selected").arg(mSelection.size());
-
- QFontMetrics Metrics(ui->SelectionInfoLabel->font());
- SelectionText = Metrics.elidedText(SelectionText, Qt::ElideRight, ui->SelectionInfoFrame->width() - 10);
- ui->SelectionInfoLabel->setText(SelectionText);
-
- // Update gizmo stuff
- UpdateGizmoUI();
-}
-
+// ************ UPDATE UI ************
void CWorldEditor::UpdateGizmoUI()
{
// Update transform XYZ spin boxes
@@ -248,13 +200,83 @@ void CWorldEditor::UpdateGizmoUI()
}
}
+void CWorldEditor::UpdateSelectionUI()
+{
+ // Update camera orbit
+ UpdateCameraOrbit();
+
+ // Update sidebar
+ ui->ModifyTabContents->GenerateUI(mSelection);
+
+ // Update selection info text
+ QString SelectionText;
+
+ if (mSelection.size() == 1)
+ SelectionText = TO_QSTRING(mSelection.front()->Name());
+ else if (mSelection.size() > 1)
+ SelectionText = QString("%1 objects selected").arg(mSelection.size());
+
+ QFontMetrics Metrics(ui->SelectionInfoLabel->font());
+ SelectionText = Metrics.elidedText(SelectionText, Qt::ElideRight, ui->SelectionInfoFrame->width() - 10);
+ ui->SelectionInfoLabel->setText(SelectionText);
+
+ // Update gizmo stuff
+ UpdateGizmoUI();
+}
+
+void CWorldEditor::UpdateStatusBar()
+{
+ // Would be cool to do more frequent status bar updates with more info. Unfortunately, this causes lag.
+ QString StatusText = "";
+
+ if (!mGizmoHovering)
+ {
+ if (ui->MainViewport->underMouse())
+ {
+ CSceneNode *pHoverNode = ui->MainViewport->HoverNode();
+
+ if (pHoverNode && (pHoverNode->NodeType() != eStaticNode))
+ StatusText = TO_QSTRING(pHoverNode->Name());
+ }
+ }
+
+ if (ui->statusbar->currentMessage() != StatusText)
+ ui->statusbar->showMessage(StatusText);
+}
+
+// ************ PROTECTED ************
void CWorldEditor::GizmoModeChanged(CGizmo::EGizmoMode mode)
{
ui->TransformSpinBox->SetSingleStep( (mode == CGizmo::eRotate ? 1.0 : 0.1) );
ui->TransformSpinBox->SetDefaultValue( (mode == CGizmo::eScale ? 1.0 : 0.0) );
}
-// ************ ACTIONS ************
+void CWorldEditor::UpdateCursor()
+{
+ if (ui->MainViewport->IsCursorVisible())
+ {
+ CSceneNode *pHoverNode = ui->MainViewport->HoverNode();
+
+ if (ui->MainViewport->IsHoveringGizmo())
+ ui->MainViewport->SetCursorState(Qt::SizeAllCursor);
+ else if ((pHoverNode) && (pHoverNode->NodeType() != eStaticNode))
+ ui->MainViewport->SetCursorState(Qt::PointingHandCursor);
+ else
+ ui->MainViewport->SetCursorState(Qt::ArrowCursor);
+ }
+}
+
+void CWorldEditor::UpdateCameraOrbit()
+{
+ CCamera *pCamera = &ui->MainViewport->Camera();
+
+ if (!mSelection.isEmpty())
+ pCamera->SetOrbit(mSelectionBounds);
+ else
+ pCamera->SetOrbit(mpArea->AABox(), 0.8f);
+}
+
+// ************ PRIVATE SLOTS ************
void CWorldEditor::RefreshViewport()
{
if (!mGizmo.IsTransforming())
@@ -413,37 +435,6 @@ void CWorldEditor::on_ActionBloom_triggered()
ui->ActionBloom->setChecked(true);
}
-void CWorldEditor::on_ActionZoomOnSelection_triggered()
-{
- static const float skDistScale = 2.5f;
- static const float skAreaDistScale = 0.8f;
-
- CCamera& Camera = ui->MainViewport->Camera();
- CVector3f CamDir = Camera.Direction();
- CVector3f NewPos;
-
- // Zoom on selection
- if (mSelection.size() != 0)
- {
- CVector3f Min = mSelectionBounds.Min();
- CVector3f Max = mSelectionBounds.Max();
- float Dist = ((Max.x - Min.x) + (Max.y - Min.y) + (Max.z - Min.z)) / 3.f;
- NewPos = mSelectionBounds.Center() + (CamDir * -(Dist * skDistScale));
- }
-
- // Zoom on area
- else
- {
- CAABox AreaBox = mpArea->AABox();
- CVector3f Min = AreaBox.Min();
- CVector3f Max = AreaBox.Max();
- float Dist = ((Max.x - Min.x) + (Max.y - Min.y) + (Max.z - Min.z)) / 3.f;
- NewPos = AreaBox.Center() + (CamDir * -(Dist * skAreaDistScale));
- }
-
- Camera.SetPosition(NewPos);
-}
-
void CWorldEditor::on_ActionDisableBackfaceCull_triggered()
{
ui->MainViewport->Renderer()->ToggleBackfaceCull(!ui->ActionDisableBackfaceCull->isChecked());
diff --git a/UI/CWorldEditor.h b/UI/CWorldEditor.h
index b5023d59..53dc5565 100644
--- a/UI/CWorldEditor.h
+++ b/UI/CWorldEditor.h
@@ -50,10 +50,8 @@ public:
protected:
void GizmoModeChanged(CGizmo::EGizmoMode mode);
-
-private:
void UpdateCursor();
- void OnSidebarResize();
+ void UpdateCameraOrbit();
private slots:
void RefreshViewport();
@@ -72,7 +70,6 @@ private slots:
void on_ActionBloomMaps_triggered();
void on_ActionFakeBloom_triggered();
void on_ActionBloom_triggered();
- void on_ActionZoomOnSelection_triggered();
void on_ActionDisableBackfaceCull_triggered();
void on_ActionDisableAlpha_triggered();
void on_ActionEditLayers_triggered();
diff --git a/UI/CWorldEditor.ui b/UI/CWorldEditor.ui
index 2e3bc942..58548906 100644
--- a/UI/CWorldEditor.ui
+++ b/UI/CWorldEditor.ui
@@ -267,8 +267,6 @@
-
-