Implemented grid toggle in the model editor

This commit is contained in:
parax0 2016-02-20 04:48:17 -07:00
parent 5fbdfc8298
commit 200918671b
5 changed files with 38 additions and 56 deletions

View File

@ -5,7 +5,8 @@ CModelEditorViewport::CModelEditorViewport(QWidget *pParent)
: CBasicViewport(pParent),
mMode(eDrawMesh),
mpActiveMaterial(nullptr),
mpModelNode(nullptr)
mpModelNode(nullptr),
mGridEnabled(true)
{
mpRenderer = new CRenderer();
mpRenderer->SetViewportSize(width(), height());
@ -42,17 +43,27 @@ void CModelEditorViewport::SetClearColor(CColor color)
mpRenderer->SetClearColor(color);
}
void CModelEditorViewport::SetGridEnabled(bool Enable)
{
mGridEnabled = Enable;
}
void CModelEditorViewport::Paint()
{
mpRenderer->BeginFrame();
mCamera.LoadMatrices();
if (!mpModelNode->Model())
CDrawUtil::DrawGrid();
{
if (mGridEnabled)
CDrawUtil::DrawGrid();
}
else if (mMode == eDrawMesh)
{
CDrawUtil::DrawGrid();
if (mGridEnabled)
CDrawUtil::DrawGrid();
mpModelNode->AddToRenderer(mpRenderer, mViewInfo);
mpRenderer->RenderBuckets(mViewInfo);
}

View File

@ -16,6 +16,7 @@ private:
CModelNode *mpModelNode;
CMaterial *mpActiveMaterial;
CRenderer *mpRenderer;
bool mGridEnabled;
public:
CModelEditorViewport(QWidget *pParent = 0);
@ -24,6 +25,7 @@ public:
void SetActiveMaterial(CMaterial *pMat);
void SetDrawMode(EDrawMode mode);
void SetClearColor(CColor color);
void SetGridEnabled(bool Enable);
void Paint();
void OnResize();
};

View File

@ -884,3 +884,8 @@ void CModelEditorWindow::on_actionConvert_DDS_to_TXTR_triggered()
}
}
}
void CModelEditorWindow::on_ToggleGridButton_toggled(bool checked)
{
ui->Viewport->SetGridEnabled(checked);
}

View File

@ -119,6 +119,8 @@ private slots:
void on_actionConvert_DDS_to_TXTR_triggered();
void on_ToggleGridButton_toggled(bool checked);
signals:
void Closed();
};

View File

@ -2140,7 +2140,7 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0,0,0,0,0,0,0">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0,0,0,0,0,0">
<property name="spacing">
<number>50</number>
</property>
@ -2167,7 +2167,7 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<widget class="QPushButton" name="ToggleGridButton">
<property name="toolTip">
<string>Grid</string>
</property>
@ -2195,38 +2195,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="toolTip">
<string>Selection Tint</string>
</property>
<property name="styleSheet">
<string notr="true">border: none;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../Icons.qrc">
<normaloff>:/icons/Highlight.png</normaloff>:/icons/Highlight.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="CameraModeButton">
<property name="toolTip">
@ -2418,6 +2386,19 @@
</item>
</layout>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionOpen"/>
<addaction name="actionSave"/>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
@ -2445,27 +2426,8 @@
<addaction name="actionConvert_to_DDS"/>
<addaction name="actionConvert_DDS_to_TXTR"/>
</widget>
<widget class="QMenu" name="menuWindow">
<property name="title">
<string>Window</string>
</property>
</widget>
<addaction name="menuFile"/>
<addaction name="menuTextures"/>
<addaction name="menuWindow"/>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionOpen"/>
<addaction name="actionSave"/>
</widget>
<action name="actionOpen">
<property name="text">