More fixes

This commit is contained in:
parax0 2015-11-27 05:26:32 -07:00
parent aebb97c0f1
commit 07e689071a
9 changed files with 36 additions and 24 deletions

View File

@ -63,11 +63,11 @@ void CCamera::Zoom(float Amount)
if (mMode == eFreeCamera) if (mMode == eFreeCamera)
{ {
Update(); Update();
mPosition += (mDirection * Amount) * (mMoveSpeed * 25.f); mPosition += mDirection * (Amount * mMoveSpeed);
} }
else else
mOrbitDistance -= Amount * mMoveSpeed * 25.f; mOrbitDistance -= Amount * mMoveSpeed;
mViewOutdated = true; mViewOutdated = true;
mFrustumPlanesOutdated = true; mFrustumPlanesOutdated = true;
@ -87,8 +87,8 @@ void CCamera::ProcessKeyInput(EKeyInputs KeyFlags, double DeltaTime)
{ {
float FDeltaTime = (float) DeltaTime; float FDeltaTime = (float) DeltaTime;
if (KeyFlags & eWKey) Zoom(FDeltaTime); if (KeyFlags & eWKey) Zoom(FDeltaTime * 25.f);
if (KeyFlags & eSKey) Zoom(-FDeltaTime); if (KeyFlags & eSKey) Zoom(-FDeltaTime * 25.f);
if (KeyFlags & eQKey) Pan(0, -FDeltaTime * 25.f); if (KeyFlags & eQKey) Pan(0, -FDeltaTime * 25.f);
if (KeyFlags & eEKey) Pan(0, FDeltaTime * 25.f); if (KeyFlags & eEKey) Pan(0, FDeltaTime * 25.f);
if (KeyFlags & eAKey) Pan(-FDeltaTime * 25.f, 0); if (KeyFlags & eAKey) Pan(-FDeltaTime * 25.f, 0);

View File

@ -89,6 +89,7 @@ void CModelNode::DrawAsset(ERenderOptions Options, u32 Asset, const SViewInfo& V
CGraphics::sPixelBlock.TevColor = CVector4f(1,1,1,1); CGraphics::sPixelBlock.TevColor = CVector4f(1,1,1,1);
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f(); CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
CGraphics::UpdatePixelBlock();
LoadModelMatrix(); LoadModelMatrix();
mpModel->DrawSurface(Options, Asset, mActiveMatSet); mpModel->DrawSurface(Options, Asset, mActiveMatSet);

View File

@ -119,7 +119,7 @@ void CBasicViewport::mouseMoveEvent(QMouseEvent* /*pEvent*/)
void CBasicViewport::wheelEvent(QWheelEvent *pEvent) void CBasicViewport::wheelEvent(QWheelEvent *pEvent)
{ {
// Maybe track a "wheel delta" member variable and let CCamera decide what to do with it? // 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) void CBasicViewport::keyPressEvent(QKeyEvent *pEvent)

View File

@ -11,6 +11,10 @@ CModelEditorViewport::CModelEditorViewport(QWidget *pParent)
mpRenderer->SetViewportSize(width(), height()); mpRenderer->SetViewportSize(width(), height());
mpRenderer->SetClearColor(CColor::skBlack); mpRenderer->SetClearColor(CColor::skBlack);
mpRenderer->ToggleGrid(true); mpRenderer->ToggleGrid(true);
mViewInfo.pRenderer = mpRenderer;
mViewInfo.pScene = nullptr;
mViewInfo.GameMode = false;
} }
CModelEditorViewport::~CModelEditorViewport() CModelEditorViewport::~CModelEditorViewport()

View File

@ -818,14 +818,14 @@ void CModelEditorWindow::on_CameraModeButton_clicked()
if (pCam->MoveMode() == eOrbitCamera) if (pCam->MoveMode() == eOrbitCamera)
{ {
pCam->SetMoveMode(eFreeCamera); 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")); ui->CameraModeButton->setToolTip(QString("Free Camera"));
} }
else if (pCam->MoveMode() == eFreeCamera) else if (pCam->MoveMode() == eFreeCamera)
{ {
pCam->SetMoveMode(eOrbitCamera); 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")); ui->CameraModeButton->setToolTip(QString("Orbit Camera"));
CVector3f Pos = pCam->Position(); CVector3f Pos = pCam->Position();

View File

@ -64,6 +64,8 @@ CWorldEditor::CWorldEditor(QWidget *parent) :
// Connect signals and slots // Connect signals and slots
connect(ui->MainViewport, SIGNAL(GizmoMoved()), this, SLOT(OnGizmoMoved())); 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(ValueChanged(CVector3f)), this, SLOT(OnTransformSpinBoxModified(CVector3f)));
connect(ui->TransformSpinBox, SIGNAL(EditingDone(CVector3f)), this, SLOT(OnTransformSpinBoxEdited(CVector3f))); connect(ui->TransformSpinBox, SIGNAL(EditingDone(CVector3f)), this, SLOT(OnTransformSpinBoxEdited(CVector3f)));
connect(ui->CamSpeedSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnCameraSpeedChange(double))); connect(ui->CamSpeedSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnCameraSpeedChange(double)));
@ -198,16 +200,10 @@ void CWorldEditor::UpdateGizmoUI()
mGizmo.SetLocalRotation(mSelection.front()->AbsoluteRotation()); mGizmo.SetLocalRotation(mSelection.front()->AbsoluteRotation());
} }
} }
// Update camera orbit
UpdateCameraOrbit();
} }
void CWorldEditor::UpdateSelectionUI() void CWorldEditor::UpdateSelectionUI()
{ {
// Update camera orbit
UpdateCameraOrbit();
// Update sidebar // Update sidebar
ui->ModifyTabContents->GenerateUI(mSelection); 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 ************ // ************ PRIVATE SLOTS ************
void CWorldEditor::RefreshViewport() void CWorldEditor::RefreshViewport()
{ {
@ -295,6 +281,16 @@ void CWorldEditor::RefreshViewport()
ui->MainViewport->Render(); 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) void CWorldEditor::OnCameraSpeedChange(double speed)
{ {
static const double skDefaultSpeed = 1.0; static const double skDefaultSpeed = 1.0;

View File

@ -51,10 +51,10 @@ public:
protected: protected:
void GizmoModeChanged(CGizmo::EGizmoMode mode); void GizmoModeChanged(CGizmo::EGizmoMode mode);
void UpdateCursor(); void UpdateCursor();
void UpdateCameraOrbit();
private slots: private slots:
void RefreshViewport(); void RefreshViewport();
void UpdateCameraOrbit();
void OnCameraSpeedChange(double speed); void OnCameraSpeedChange(double speed);
void OnTransformSpinBoxModified(CVector3f value); void OnTransformSpinBoxModified(CVector3f value);
void OnTransformSpinBoxEdited(CVector3f value); void OnTransformSpinBoxEdited(CVector3f value);

View File

@ -134,18 +134,24 @@ void INodeEditor::SelectNode(CSceneNode *pNode)
{ {
if (!pNode->IsSelected()) if (!pNode->IsSelected())
mUndoStack.push(new CSelectNodeCommand(this, pNode, mSelection)); mUndoStack.push(new CSelectNodeCommand(this, pNode, mSelection));
emit SelectionModified();
} }
void INodeEditor::DeselectNode(CSceneNode *pNode) void INodeEditor::DeselectNode(CSceneNode *pNode)
{ {
if (pNode->IsSelected()) if (pNode->IsSelected())
mUndoStack.push(new CDeselectNodeCommand(this, pNode, mSelection)); mUndoStack.push(new CDeselectNodeCommand(this, pNode, mSelection));
emit SelectionModified();
} }
void INodeEditor::ClearSelection() void INodeEditor::ClearSelection()
{ {
if (!mSelection.empty()) if (!mSelection.empty())
mUndoStack.push(new CClearSelectionCommand(this, mSelection)); mUndoStack.push(new CClearSelectionCommand(this, mSelection));
emit SelectionModified();
} }
void INodeEditor::ClearAndSelectNode(CSceneNode *pNode) void INodeEditor::ClearAndSelectNode(CSceneNode *pNode)
@ -163,6 +169,8 @@ void INodeEditor::ClearAndSelectNode(CSceneNode *pNode)
mUndoStack.push(new CSelectNodeCommand(this, pNode, mSelection)); mUndoStack.push(new CSelectNodeCommand(this, pNode, mSelection));
mUndoStack.endMacro(); mUndoStack.endMacro();
} }
emit SelectionModified();
} }
// ************ PUBLIC SLOTS ************ // ************ PUBLIC SLOTS ************

View File

@ -60,6 +60,9 @@ public:
virtual void UpdateGizmoUI() = 0; virtual void UpdateGizmoUI() = 0;
virtual void UpdateSelectionUI() = 0; virtual void UpdateSelectionUI() = 0;
signals:
void SelectionModified();
public slots: public slots:
void OnGizmoMoved(); void OnGizmoMoved();