Skip to content

Commit

Permalink
#5532: polygonOffset binding
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Feb 19, 2021
1 parent a7352a9 commit 4627d6c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 22 deletions.
26 changes: 14 additions & 12 deletions install/ui/materialeditor.fbp
Expand Up @@ -992,7 +992,7 @@
<object class="notebookpage" expanded="0">
<property name="bitmap"></property>
<property name="label">Interaction</property>
<property name="select">0</property>
<property name="select">1</property>
<object class="wxPanel" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
Expand Down Expand Up @@ -1574,7 +1574,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">MaterialPolygonOffset</property>
<property name="name">MaterialFlagHasPolygonOffset</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
Expand All @@ -1597,11 +1597,11 @@
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">0</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxSpinCtrl" expanded="0">
<object class="wxSpinCtrlDouble" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
Expand All @@ -1619,6 +1619,7 @@
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="digits">1</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
Expand All @@ -1629,6 +1630,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="inc">0.1</property>
<property name="initial">0</property>
<property name="max">100</property>
<property name="max_size"></property>
Expand All @@ -1648,9 +1650,9 @@
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size">80,-1</property>
<property name="size"></property>
<property name="style">wxSP_ARROW_KEYS</property>
<property name="subclass"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="value"></property>
Expand Down Expand Up @@ -3361,7 +3363,7 @@
<object class="notebookpage" expanded="0">
<property name="bitmap"></property>
<property name="label">Light</property>
<property name="select">1</property>
<property name="select">0</property>
<object class="wxPanel" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
Expand Down Expand Up @@ -4443,7 +4445,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_checkBox8212</property>
<property name="name">MaterialFlagClamp</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
Expand Down Expand Up @@ -4507,7 +4509,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_checkBox612</property>
<property name="name">MaterialFlagZeroClamp</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
Expand Down Expand Up @@ -4571,7 +4573,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_checkBox8413</property>
<property name="name">MaterialFlagAlphaZeroClamp</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
Expand Down Expand Up @@ -12282,7 +12284,7 @@
<object class="notebookpage" expanded="0">
<property name="bitmap"></property>
<property name="label">Texture</property>
<property name="select">0</property>
<property name="select">1</property>
<object class="wxPanel" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
Expand Down Expand Up @@ -15103,7 +15105,7 @@
<object class="notebookpage" expanded="0">
<property name="bitmap"></property>
<property name="label">Vertex Colour</property>
<property name="select">1</property>
<property name="select">0</property>
<object class="wxPanel" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
Expand Down
21 changes: 11 additions & 10 deletions install/ui/materialeditor.xrc
Expand Up @@ -167,7 +167,7 @@
<object class="wxNotebook" name="m_notebook2">
<object class="notebookpage">
<label>Interaction</label>
<selected>0</selected>
<selected>1</selected>
<object class="wxPanel" name="InteractionPage">
<style>wxTAB_TRAVERSAL</style>
<object class="wxBoxSizer">
Expand Down Expand Up @@ -264,7 +264,7 @@
<option>0</option>
<flag>wxALIGN_CENTER_VERTICAL</flag>
<border>0</border>
<object class="wxCheckBox" name="MaterialPolygonOffset">
<object class="wxCheckBox" name="MaterialFlagHasPolygonOffset">
<label>polygonOffset</label>
<checked>0</checked>
</object>
Expand All @@ -273,12 +273,13 @@
<option>0</option>
<flag>wxALIGN_CENTER_VERTICAL</flag>
<border>0</border>
<object class="wxSpinCtrl" name="MaterialPolygonOffsetValue">
<object class="wxSpinCtrlDouble" name="MaterialPolygonOffsetValue">
<style>wxSP_ARROW_KEYS</style>
<size>80,-1</size>
<value>0</value>
<min>-100</min>
<max>100</max>
<inc>0.1</inc>
<digits>1</digits>
</object>
</object>
</object>
Expand Down Expand Up @@ -545,7 +546,7 @@
</object>
<object class="notebookpage">
<label>Light</label>
<selected>1</selected>
<selected>0</selected>
<object class="wxPanel" name="LightPage">
<style>wxTAB_TRAVERSAL</style>
<object class="wxBoxSizer">
Expand Down Expand Up @@ -711,7 +712,7 @@
<option>0</option>
<flag></flag>
<border>0</border>
<object class="wxCheckBox" name="m_checkBox8212">
<object class="wxCheckBox" name="MaterialFlagClamp">
<label>clamp</label>
<checked>0</checked>
</object>
Expand All @@ -720,7 +721,7 @@
<option>0</option>
<flag></flag>
<border>0</border>
<object class="wxCheckBox" name="m_checkBox612">
<object class="wxCheckBox" name="MaterialFlagZeroClamp">
<label>zeroClamp</label>
<checked>0</checked>
</object>
Expand All @@ -729,7 +730,7 @@
<option>0</option>
<flag></flag>
<border>0</border>
<object class="wxCheckBox" name="m_checkBox8413">
<object class="wxCheckBox" name="MaterialFlagAlphaZeroClamp">
<label>alphaZeroClamp</label>
<checked>0</checked>
</object>
Expand Down Expand Up @@ -2084,7 +2085,7 @@
</object>
<object class="notebookpage">
<label>Texture</label>
<selected>0</selected>
<selected>1</selected>
<object class="wxPanel" name="m_panel7">
<style>wxTAB_TRAVERSAL</style>
<object class="wxBoxSizer">
Expand Down Expand Up @@ -2555,7 +2556,7 @@
</object>
<object class="notebookpage">
<label>Vertex Colour</label>
<selected>1</selected>
<selected>0</selected>
<object class="wxPanel" name="m_panel611">
<style>wxTAB_TRAVERSAL</style>
<object class="wxBoxSizer">
Expand Down
31 changes: 31 additions & 0 deletions radiant/ui/materials/MaterialEditor.cpp
Expand Up @@ -6,6 +6,8 @@
#include <wx/splitter.h>
#include <wx/textctrl.h>
#include <wx/collpane.h>
#include <wx/spinctrl.h>

#include "wxutil/SourceView.h"
#include "fmt/format.h"
#include "materials/ParseLib.h"
Expand Down Expand Up @@ -192,6 +194,7 @@ void MaterialEditor::setupMaterialShaderFlags()
setupMaterialFlag("MaterialFlagNoPortalFog", Material::FLAG_NOPORTALFOG);
setupMaterialFlag("MaterialFlagUnsmoothedTangents", Material::FLAG_UNSMOOTHEDTANGENTS);
setupMaterialFlag("MaterialFlagMirror", Material::FLAG_MIRROR);
setupMaterialFlag("MaterialFlagHasPolygonOffset", Material::FLAG_POLYGONOFFSET);

// Cull types
_bindings.emplace(std::make_shared<CheckBoxBinding>(getControl<wxCheckBox>("MaterialTwoSided"),
Expand All @@ -205,6 +208,25 @@ void MaterialEditor::setupMaterialShaderFlags()
{
return material->getCullType() == Material::CULL_FRONT;
}));

// Global Clamping
_bindings.emplace(std::make_shared<CheckBoxBinding>(getControl<wxCheckBox>("MaterialFlagClamp"),
[](const MaterialPtr& material)
{
return material->getClampType() == CLAMP_NOREPEAT;
}));

_bindings.emplace(std::make_shared<CheckBoxBinding>(getControl<wxCheckBox>("MaterialFlagZeroClamp"),
[](const MaterialPtr& material)
{
return material->getClampType() == CLAMP_ZEROCLAMP;
}));

_bindings.emplace(std::make_shared<CheckBoxBinding>(getControl<wxCheckBox>("MaterialFlagAlphaZeroClamp"),
[](const MaterialPtr& material)
{
return material->getClampType() == CLAMP_ALPHAZEROCLAMP;
}));
}

void MaterialEditor::setupMaterialSurfaceFlags()
Expand Down Expand Up @@ -293,6 +315,15 @@ void MaterialEditor::updateMaterialPropertiesFromMaterial()
materialTypeDropdown->Select(materialTypeDropdown->FindString(surfType));
}

if (_material->getMaterialFlags() & Material::FLAG_POLYGONOFFSET)
{
getControl<wxSpinCtrlDouble>("MaterialPolygonOffsetValue")->SetValue(_material->getPolygonOffset());
}
else
{
getControl<wxSpinCtrlDouble>("MaterialPolygonOffsetValue")->SetValue(0.0);
}

// Surround the definition with curly braces, these are not included
auto definition = fmt::format("{0}\n{{{1}}}", _material->getName(), _material->getDefinition());
_sourceView->SetValue(definition);
Expand Down

0 comments on commit 4627d6c

Please sign in to comment.