From a5da17dc8644db9b951ae5400b3676381905ccf9 Mon Sep 17 00:00:00 2001 From: turanszkij Date: Wed, 23 Oct 2019 19:15:52 +0100 Subject: [PATCH] minor updates, fixes --- Editor/DecalWindow.cpp | 8 +--- Editor/Editor.cpp | 23 ++++++----- Editor/EmitterWindow.cpp | 9 ----- Editor/EnvProbeWindow.cpp | 1 - Editor/ForceFieldWindow.cpp | 35 +++++++++++++---- Editor/HairParticleWindow.cpp | 4 -- Editor/LightWindow.cpp | 25 ++++++------ Editor/MaterialWindow.cpp | 4 -- Editor/MeshWindow.cpp | 1 - Editor/ObjectWindow.cpp | 12 +++--- Editor/RendererWindow.cpp | 1 - Editor/SoundWindow.cpp | 4 -- WickedEngine/wiVersion.cpp | 2 +- WickedEngine/wiWidget.cpp | 72 ++++++++++++++++++----------------- WickedEngine/wiWidget.h | 4 +- 15 files changed, 101 insertions(+), 104 deletions(-) diff --git a/Editor/DecalWindow.cpp b/Editor/DecalWindow.cpp index 49d3c6a81..80981f523 100644 --- a/Editor/DecalWindow.cpp +++ b/Editor/DecalWindow.cpp @@ -14,7 +14,6 @@ DecalWindow::DecalWindow(wiGUI* gui) : GUI(gui) decalWindow = new wiWindow(GUI, "Decal Window"); decalWindow->SetSize(XMFLOAT2(400, 300)); - decalWindow->SetEnabled(false); GUI->AddWidget(decalWindow); float x = 200; @@ -48,9 +47,6 @@ DecalWindow::~DecalWindow() void DecalWindow::SetEntity(Entity entity) { - if (this->entity == entity) - return; - this->entity = entity; Scene& scene = wiSceneSystem::GetScene(); @@ -61,11 +57,11 @@ void DecalWindow::SetEntity(Entity entity) const NameComponent& name = *scene.names.GetComponent(entity); decalNameField->SetValue(name.name); - decalWindow->SetEnabled(true); + decalNameField->SetEnabled(true); } else { decalNameField->SetValue("No decal selected"); - decalWindow->SetEnabled(false); + decalNameField->SetEnabled(false); } } diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index 7eb21d555..fb716f715 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -1558,7 +1558,7 @@ void EditorComponent::Render() const fx.enableFullScreen(); fx.stencilComp = STENCILMODE::STENCILMODE_EQUAL; - // We will specify the stencil ref in user-space, don't cae about engine stencil refs here: + // We will specify the stencil ref in user-space, don't care about engine stencil refs here: // Otherwise would need to take into account engine ref and draw multiple permutations of stencil refs. fx.stencilRefMode = STENCILREFMODE_USER; @@ -1615,11 +1615,12 @@ void EditorComponent::Compose(CommandList cmd) const } // Compose the selection outline to the screen: + const float selectionColorIntensity = std::sinf(selectionOutlineTimer * XM_2PI * 0.8f) * 0.5f + 0.5f; if (!selected.empty()) { wiImageParams fx; fx.enableFullScreen(); - fx.opacity = wiMath::Lerp(0.4f, 1.0f, std::sinf(selectionOutlineTimer * XM_2PI * 0.8f) * 0.5f + 0.5f);; + fx.opacity = wiMath::Lerp(0.4f, 1.0f, selectionColorIntensity); wiImage::Draw(&rt_selectionOutline[1], fx, cmd); } @@ -1627,6 +1628,8 @@ void EditorComponent::Compose(CommandList cmd) const Scene& scene = wiSceneSystem::GetScene(); + const XMFLOAT4 selectedEntityColor = wiMath::Lerp(wiMath::Lerp(XMFLOAT4(1, 1, 1, 1), selectionColor, 0.4f), selectionColor, selectionColorIntensity); + if (rendererWnd->GetPickType() & PICK_LIGHT) { for (size_t i = 0; i < scene.lights.GetCount(); ++i) @@ -1652,7 +1655,7 @@ void EditorComponent::Compose(CommandList cmd) const { if (picked.entity == entity) { - fx.col = selectionColor; + fx.col = selectedEntityColor; break; } } @@ -1700,7 +1703,7 @@ void EditorComponent::Compose(CommandList cmd) const { if (picked.entity == entity) { - fx.col = selectionColor; + fx.col = selectedEntityColor; break; } } @@ -1735,7 +1738,7 @@ void EditorComponent::Compose(CommandList cmd) const { if (picked.entity == entity) { - fx.col = selectionColor; + fx.col = selectedEntityColor; break; } } @@ -1770,7 +1773,7 @@ void EditorComponent::Compose(CommandList cmd) const { if (picked.entity == entity) { - fx.col = selectionColor; + fx.col = selectedEntityColor; break; } } @@ -1804,7 +1807,7 @@ void EditorComponent::Compose(CommandList cmd) const { if (picked.entity == entity) { - fx.col = selectionColor; + fx.col = selectedEntityColor; break; } } @@ -1838,7 +1841,7 @@ void EditorComponent::Compose(CommandList cmd) const { if (picked.entity == entity) { - fx.col = selectionColor; + fx.col = selectedEntityColor; break; } } @@ -1872,7 +1875,7 @@ void EditorComponent::Compose(CommandList cmd) const { if (picked.entity == entity) { - fx.col = selectionColor; + fx.col = selectedEntityColor; break; } } @@ -1906,7 +1909,7 @@ void EditorComponent::Compose(CommandList cmd) const { if (picked.entity == entity) { - fx.col = selectionColor; + fx.col = selectedEntityColor; break; } } diff --git a/Editor/EmitterWindow.cpp b/Editor/EmitterWindow.cpp index 01ab0cad9..a4dc34492 100644 --- a/Editor/EmitterWindow.cpp +++ b/Editor/EmitterWindow.cpp @@ -17,7 +17,6 @@ EmitterWindow::EmitterWindow(wiGUI* gui) : GUI(gui) emitterWindow = new wiWindow(GUI, "Emitter Window"); emitterWindow->SetSize(XMFLOAT2(800, 1100)); - emitterWindow->SetEnabled(false); GUI->AddWidget(emitterWindow); float x = 150; @@ -434,10 +433,6 @@ EmitterWindow::~EmitterWindow() void EmitterWindow::SetEntity(Entity entity) { - if (this->entity == entity) - return; - - // first try to turn off any debug readbacks for emitters: if (GetEmitter() != nullptr) { @@ -473,14 +468,10 @@ void EmitterWindow::SetEntity(Entity entity) sph_K_Slider->SetValue(emitter->SPH_K); sph_p0_Slider->SetValue(emitter->SPH_p0); sph_e_Slider->SetValue(emitter->SPH_e); - - //emitterWindow->SetEnabled(true); } else { infoLabel->SetText("No emitter object selected."); - - //emitterWindow->SetEnabled(false); } } diff --git a/Editor/EnvProbeWindow.cpp b/Editor/EnvProbeWindow.cpp index 69a853fb1..917434156 100644 --- a/Editor/EnvProbeWindow.cpp +++ b/Editor/EnvProbeWindow.cpp @@ -13,7 +13,6 @@ EnvProbeWindow::EnvProbeWindow(wiGUI* gui) : GUI(gui) envProbeWindow = new wiWindow(GUI, "Environment Probe Window"); envProbeWindow->SetSize(XMFLOAT2(600, 400)); - envProbeWindow->SetEnabled(true); GUI->AddWidget(envProbeWindow); float x = 250, y = 0, step = 45; diff --git a/Editor/ForceFieldWindow.cpp b/Editor/ForceFieldWindow.cpp index 73cc8072a..d09f2bca0 100644 --- a/Editor/ForceFieldWindow.cpp +++ b/Editor/ForceFieldWindow.cpp @@ -15,7 +15,6 @@ ForceFieldWindow::ForceFieldWindow(wiGUI* gui) : GUI(gui) forceFieldWindow = new wiWindow(GUI, "Force Field Window"); forceFieldWindow->SetSize(XMFLOAT2(600, 300)); - forceFieldWindow->SetEnabled(false); GUI->AddWidget(forceFieldWindow); float x = 150; @@ -83,8 +82,28 @@ ForceFieldWindow::ForceFieldWindow(wiGUI* gui) : GUI(gui) addButton = new wiButton("Add Force Field"); addButton->SetSize(XMFLOAT2(150, 30)); addButton->SetPos(XMFLOAT2(x, y += step * 2)); - addButton->OnClick([](wiEventArgs args) { - wiSceneSystem::GetScene().Entity_CreateForce("editorForce"); + addButton->OnClick([&](wiEventArgs args) { + Entity entity = wiSceneSystem::GetScene().Entity_CreateForce("editorForce"); + ForceFieldComponent* force = wiSceneSystem::GetScene().forces.GetComponent(entity); + if (force != nullptr) + { + switch (typeComboBox->GetSelected()) + { + case 0: + force->type = ENTITY_TYPE_FORCEFIELD_POINT; + break; + case 1: + force->type = ENTITY_TYPE_FORCEFIELD_PLANE; + break; + default: + assert(0); + break; + } + } + else + { + assert(0); + } }); addButton->SetEnabled(true); addButton->SetTooltip("Add new Force Field to the simulation."); @@ -108,9 +127,6 @@ ForceFieldWindow::~ForceFieldWindow() void ForceFieldWindow::SetEntity(Entity entity) { - if (this->entity == entity) - return; - this->entity = entity; const ForceFieldComponent* force = wiSceneSystem::GetScene().forces.GetComponent(entity); @@ -121,11 +137,14 @@ void ForceFieldWindow::SetEntity(Entity entity) gravitySlider->SetValue(force->gravity); rangeSlider->SetValue(force->range_local); - forceFieldWindow->SetEnabled(true); + gravitySlider->SetEnabled(true); + rangeSlider->SetEnabled(true); + } else { - forceFieldWindow->SetEnabled(false); + gravitySlider->SetEnabled(false); + rangeSlider->SetEnabled(false); } addButton->SetEnabled(true); diff --git a/Editor/HairParticleWindow.cpp b/Editor/HairParticleWindow.cpp index 6ef261fb3..79a3c996d 100644 --- a/Editor/HairParticleWindow.cpp +++ b/Editor/HairParticleWindow.cpp @@ -15,7 +15,6 @@ HairParticleWindow::HairParticleWindow(wiGUI* gui) : GUI(gui) hairWindow = new wiWindow(GUI, "Hair Particle System Window"); hairWindow->SetSize(XMFLOAT2(800, 600)); - hairWindow->SetEnabled(false); GUI->AddWidget(hairWindow); float x = 150; @@ -155,9 +154,6 @@ HairParticleWindow::~HairParticleWindow() void HairParticleWindow::SetEntity(Entity entity) { - if (this->entity == entity) - return; - this->entity = entity; auto hair = GetHair(); diff --git a/Editor/LightWindow.cpp b/Editor/LightWindow.cpp index a53a184a5..c1f7e5d47 100644 --- a/Editor/LightWindow.cpp +++ b/Editor/LightWindow.cpp @@ -17,7 +17,6 @@ LightWindow::LightWindow(wiGUI* gui) : GUI(gui) lightWindow = new wiWindow(GUI, "Light Window"); lightWindow->SetSize(XMFLOAT2(650, 520)); - //lightWindow->SetEnabled(false); GUI->AddWidget(lightWindow); float x = 450; @@ -178,7 +177,16 @@ LightWindow::LightWindow(wiGUI* gui) : GUI(gui) addLightButton->SetPos(XMFLOAT2(x, y += step)); addLightButton->SetSize(XMFLOAT2(150, 30)); addLightButton->OnClick([&](wiEventArgs args) { - wiSceneSystem::GetScene().Entity_CreateLight("editorLight", XMFLOAT3(0, 3, 0), XMFLOAT3(1, 1, 1), 2, 60); + Entity entity = wiSceneSystem::GetScene().Entity_CreateLight("editorLight", XMFLOAT3(0, 3, 0), XMFLOAT3(1, 1, 1), 2, 60); + LightComponent* light = wiSceneSystem::GetScene().lights.GetComponent(entity); + if (light != nullptr) + { + light->type = (LightComponent::LightType)typeSelectorComboBox->GetSelected(); + } + else + { + assert(0); + } }); addLightButton->SetTooltip("Add a light to the scene."); lightWindow->AddWidget(addLightButton); @@ -188,7 +196,7 @@ LightWindow::LightWindow(wiGUI* gui) : GUI(gui) colorPicker->SetPos(XMFLOAT2(10, 30)); colorPicker->RemoveWidgets(); colorPicker->SetVisible(true); - colorPicker->SetEnabled(true); + colorPicker->SetEnabled(false); colorPicker->OnColorChanged([&](wiEventArgs args) { LightComponent* light = wiSceneSystem::GetScene().lights.GetComponent(entity); if (light != nullptr) @@ -209,7 +217,6 @@ LightWindow::LightWindow(wiGUI* gui) : GUI(gui) biasSlider->SetValue(light->shadowBias); } }); - typeSelectorComboBox->SetEnabled(false); typeSelectorComboBox->AddItem("Directional"); typeSelectorComboBox->AddItem("Point"); typeSelectorComboBox->AddItem("Spot"); @@ -218,6 +225,7 @@ LightWindow::LightWindow(wiGUI* gui) : GUI(gui) typeSelectorComboBox->AddItem("Rectangle"); typeSelectorComboBox->AddItem("Tube"); typeSelectorComboBox->SetTooltip("Choose the light source type..."); + typeSelectorComboBox->SetSelected((int)LightComponent::POINT); lightWindow->AddWidget(typeSelectorComboBox); @@ -228,7 +236,7 @@ LightWindow::LightWindow(wiGUI* gui) : GUI(gui) lensflare_Label = new wiLabel("Lens flare textures: "); lensflare_Label->SetPos(XMFLOAT2(x, y += step)); - lensflare_Label->SetSize(XMFLOAT2(120, 20)); + lensflare_Label->SetSize(XMFLOAT2(140, 20)); lightWindow->AddWidget(lensflare_Label); for (size_t i = 0; i < ARRAYSIZE(lensflare_Button); ++i) @@ -296,16 +304,12 @@ LightWindow::~LightWindow() void LightWindow::SetEntity(Entity entity) { - if (this->entity == entity) - return; - this->entity = entity; const LightComponent* light = wiSceneSystem::GetScene().lights.GetComponent(entity); if (light != nullptr) { - //lightWindow->SetEnabled(true); energySlider->SetEnabled(true); energySlider->SetValue(light->energy); rangeSlider->SetValue(light->range_local); @@ -324,7 +328,6 @@ void LightWindow::SetEntity(Entity entity) staticCheckBox->SetEnabled(true); staticCheckBox->SetCheck(light->IsStatic()); colorPicker->SetEnabled(true); - typeSelectorComboBox->SetEnabled(true); typeSelectorComboBox->SetSelected((int)light->GetType()); SetLightType(light->GetType()); @@ -356,8 +359,6 @@ void LightWindow::SetEntity(Entity entity) staticCheckBox->SetEnabled(false); energySlider->SetEnabled(false); colorPicker->SetEnabled(false); - typeSelectorComboBox->SetEnabled(false); - //lightWindow->SetEnabled(false); for (size_t i = 0; i < ARRAYSIZE(lensflare_Button); ++i) { diff --git a/Editor/MaterialWindow.cpp b/Editor/MaterialWindow.cpp index a73fe05fc..53f93b3a9 100644 --- a/Editor/MaterialWindow.cpp +++ b/Editor/MaterialWindow.cpp @@ -17,7 +17,6 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui) materialWindow = new wiWindow(GUI, "Material Window"); materialWindow->SetSize(XMFLOAT2(760, 890)); - materialWindow->SetEnabled(false); GUI->AddWidget(materialWindow); materialNameField = new wiTextInputField("MaterialName"); @@ -773,9 +772,6 @@ MaterialWindow::~MaterialWindow() void MaterialWindow::SetEntity(Entity entity) { - if (this->entity == entity) - return; - this->entity = entity; Scene& scene = wiSceneSystem::GetScene(); diff --git a/Editor/MeshWindow.cpp b/Editor/MeshWindow.cpp index 1b14fe438..34215009d 100644 --- a/Editor/MeshWindow.cpp +++ b/Editor/MeshWindow.cpp @@ -17,7 +17,6 @@ MeshWindow::MeshWindow(wiGUI* gui) : GUI(gui) meshWindow = new wiWindow(GUI, "Mesh Window"); meshWindow->SetSize(XMFLOAT2(800, 700)); - meshWindow->SetEnabled(false); GUI->AddWidget(meshWindow); float x = 200; diff --git a/Editor/ObjectWindow.cpp b/Editor/ObjectWindow.cpp index 263b65eaf..3bd92bc62 100644 --- a/Editor/ObjectWindow.cpp +++ b/Editor/ObjectWindow.cpp @@ -254,7 +254,6 @@ ObjectWindow::ObjectWindow(EditorComponent* editor) : editor(editor) objectWindow = new wiWindow(GUI, "Object Window"); objectWindow->SetSize(XMFLOAT2(600, 520)); - objectWindow->SetEnabled(false); GUI->AddWidget(objectWindow); float x = 450; @@ -593,9 +592,6 @@ ObjectWindow::~ObjectWindow() void ObjectWindow::SetEntity(Entity entity) { - if (this->entity == entity) - return; - this->entity = entity; Scene& scene = wiSceneSystem::GetScene(); @@ -604,6 +600,8 @@ void ObjectWindow::SetEntity(Entity entity) if (object != nullptr) { + objectWindow->SetEnabled(true); + const NameComponent* name = scene.names.GetComponent(entity); if (name != nullptr) { @@ -654,7 +652,9 @@ void ObjectWindow::SetEntity(Entity entity) } } - - objectWindow->SetEnabled(!editor->selected.empty()); + else + { + objectWindow->SetEnabled(false); + } } diff --git a/Editor/RendererWindow.cpp b/Editor/RendererWindow.cpp index 2ee1cca58..3b93d9f71 100644 --- a/Editor/RendererWindow.cpp +++ b/Editor/RendererWindow.cpp @@ -16,7 +16,6 @@ RendererWindow::RendererWindow(wiGUI* gui, RenderPath3D* path) : GUI(gui) rendererWindow = new wiWindow(GUI, "Renderer Window"); rendererWindow->SetSize(XMFLOAT2(640, 790)); - rendererWindow->SetEnabled(true); GUI->AddWidget(rendererWindow); float x = 260, y = 20, step = 30; diff --git a/Editor/SoundWindow.cpp b/Editor/SoundWindow.cpp index 3048d69de..8bd89cbb4 100644 --- a/Editor/SoundWindow.cpp +++ b/Editor/SoundWindow.cpp @@ -18,7 +18,6 @@ SoundWindow::SoundWindow(wiGUI* gui) : GUI(gui) soundWindow = new wiWindow(GUI, "Sound Window"); soundWindow->SetSize(XMFLOAT2(440, 340)); - soundWindow->SetEnabled(false); GUI->AddWidget(soundWindow); float x = 20; @@ -173,9 +172,6 @@ SoundWindow::~SoundWindow() void SoundWindow::SetEntity(Entity entity) { - if (this->entity == entity) - return; - this->entity = entity; Scene& scene = wiSceneSystem::GetScene(); diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 5aad91444..d4227dde2 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates const int minor = 30; // minor bug fixes, alterations, refactors, updates - const int revision = 10; + const int revision = 11; long GetVersion() diff --git a/WickedEngine/wiWidget.cpp b/WickedEngine/wiWidget.cpp index 3f837603a..8e17a2fb4 100644 --- a/WickedEngine/wiWidget.cpp +++ b/WickedEngine/wiWidget.cpp @@ -1478,7 +1478,7 @@ void wiWindow::SetVisible(bool value) } void wiWindow::SetEnabled(bool value) { - //wiWidget::SetEnabled(value); + wiWidget::SetEnabled(value); for (auto& x : childrenWidgets) { if (x == moveDragger) @@ -1610,7 +1610,7 @@ void wiColorPicker::Update(wiGUI* gui, float dt) { if (state == ACTIVE) { - // continue drag if already grabbed wheter it is intersecting or not + // continue drag if already grabbed whether it is intersecting or not dragged = true; } } @@ -1645,7 +1645,7 @@ void wiColorPicker::Update(wiGUI* gui, float dt) wiEventArgs args; args.clickPos = pointer; args.fValue = angle; - args.color = wiColor::fromFloat4(final_color); + args.color = GetPickColor(); onColorChanged(args); } } @@ -1669,7 +1669,7 @@ void wiColorPicker::Render(const wiGUI* gui, CommandList cmd) const static wiGraphics::GPUBuffer vb_picker; static wiGraphics::GPUBuffer vb_preview; - static std::vector vertices_saturation(0); + static std::vector vertices_saturation; static bool buffersComplete = false; if (!buffersComplete) @@ -1697,7 +1697,7 @@ void wiColorPicker::Render(const wiGUI* gui, CommandList cmd) const } // hue { - std::vector vertices(0); + std::vector vertices; for (float i = 0; i <= 100; i += 1.0f) { float p = i / 100; @@ -1712,10 +1712,10 @@ void wiColorPicker::Render(const wiGUI* gui, CommandList cmd) const GPUBufferDesc desc; desc.BindFlags = BIND_VERTEX_BUFFER; desc.ByteWidth = (UINT)(vertices.size() * sizeof(Vertex)); - desc.CPUAccessFlags = CPU_ACCESS_WRITE; + desc.CPUAccessFlags = 0; desc.MiscFlags = 0; desc.StructureByteStride = 0; - desc.Usage = USAGE_DYNAMIC; + desc.Usage = USAGE_IMMUTABLE; SubresourceData data; data.pSysMem = vertices.data(); hr = wiRenderer::GetDevice()->CreateBuffer(&desc, &data, &vb_hue); @@ -1724,7 +1724,7 @@ void wiColorPicker::Render(const wiGUI* gui, CommandList cmd) const { float _radius = 3; float _width = 3; - std::vector vertices(0); + std::vector vertices; for (float i = 0; i <= 100; i += 1.0f) { float p = i / 100; @@ -1749,31 +1749,31 @@ void wiColorPicker::Render(const wiGUI* gui, CommandList cmd) const // preview { float _width = 20; - - std::vector vertices(0); - vertices.push_back({ XMFLOAT4(-_width, -_width, 0, 1),XMFLOAT4(1,1,1,1) }); - vertices.push_back({ XMFLOAT4(-_width, _width, 0, 1),XMFLOAT4(1,1,1,1) }); - vertices.push_back({ XMFLOAT4(_width, _width, 0, 1),XMFLOAT4(1,1,1,1) }); - vertices.push_back({ XMFLOAT4(-_width, -_width, 0, 1),XMFLOAT4(1,1,1,1) }); - vertices.push_back({ XMFLOAT4(_width, _width, 0, 1),XMFLOAT4(1,1,1,1) }); - vertices.push_back({ XMFLOAT4(_width, -_width, 0, 1),XMFLOAT4(1,1,1,1) }); + Vertex vertices[] = { + { XMFLOAT4(-_width, -_width, 0, 1),XMFLOAT4(1,1,1,1) }, + { XMFLOAT4(-_width, _width, 0, 1),XMFLOAT4(1,1,1,1) }, + { XMFLOAT4(_width, _width, 0, 1),XMFLOAT4(1,1,1,1) }, + { XMFLOAT4(-_width, -_width, 0, 1),XMFLOAT4(1,1,1,1) }, + { XMFLOAT4(_width, _width, 0, 1),XMFLOAT4(1,1,1,1) }, + { XMFLOAT4(_width, -_width, 0, 1),XMFLOAT4(1,1,1,1) }, + }; GPUBufferDesc desc; desc.BindFlags = BIND_VERTEX_BUFFER; - desc.ByteWidth = (UINT)(vertices.size() * sizeof(Vertex)); + desc.ByteWidth = (UINT)(ARRAYSIZE(vertices) * sizeof(Vertex)); desc.CPUAccessFlags = 0; desc.MiscFlags = 0; desc.StructureByteStride = 0; desc.Usage = USAGE_IMMUTABLE; SubresourceData data; - data.pSysMem = vertices.data(); + data.pSysMem = vertices; hr = wiRenderer::GetDevice()->CreateBuffer(&desc, &data, &vb_preview); } } - XMMATRIX __cam = wiRenderer::GetDevice()->GetScreenProjection(); + const XMMATRIX Projection = wiRenderer::GetDevice()->GetScreenProjection(); wiRenderer::GetDevice()->BindConstantBuffer(VS, wiRenderer::GetConstantBuffer(CBTYPE_MISC), CBSLOT_RENDERER_MISC, cmd); wiRenderer::GetDevice()->BindPipelineState(&PSO_colorpicker, cmd); @@ -1791,11 +1791,11 @@ void wiColorPicker::Render(const wiGUI* gui, CommandList cmd) const XMStoreFloat4x4(&cb.g_xTransform, XMMatrixRotationZ(-angle) * XMMatrixTranslation(translation.x + __colorpicker_center, translation.y + __colorpicker_center, 0) * - __cam + Projection ); - cb.g_xColor = XMFLOAT4(1, 1, 1, 1); + cb.g_xColor = IsEnabled() ? float4(1, 1, 1, 1) : float4(0.5f, 0.5f, 0.5f, 1); wiRenderer::GetDevice()->UpdateBuffer(wiRenderer::GetConstantBuffer(CBTYPE_MISC), &cb, cmd); - GPUBuffer* vbs[] = { + const GPUBuffer* vbs[] = { &vb_saturation, }; const UINT strides[] = { @@ -1809,11 +1809,11 @@ void wiColorPicker::Render(const wiGUI* gui, CommandList cmd) const { XMStoreFloat4x4(&cb.g_xTransform, XMMatrixTranslation(translation.x + __colorpicker_center, translation.y + __colorpicker_center, 0) * - __cam + Projection ); - cb.g_xColor = float4(1, 1, 1, 1); + cb.g_xColor = IsEnabled() ? float4(1, 1, 1, 1) : float4(0.5f, 0.5f, 0.5f, 1); wiRenderer::GetDevice()->UpdateBuffer(wiRenderer::GetConstantBuffer(CBTYPE_MISC), &cb, cmd); - GPUBuffer* vbs[] = { + const GPUBuffer* vbs[] = { &vb_hue, }; const UINT strides[] = { @@ -1824,14 +1824,15 @@ void wiColorPicker::Render(const wiGUI* gui, CommandList cmd) const } // render hue picker + if(IsEnabled()) { XMStoreFloat4x4(&cb.g_xTransform, XMMatrixTranslation(hue_picker.x, hue_picker.y, 0) * - __cam + Projection ); cb.g_xColor = float4(1 - hue_color.x, 1 - hue_color.y, 1 - hue_color.z, 1); wiRenderer::GetDevice()->UpdateBuffer(wiRenderer::GetConstantBuffer(CBTYPE_MISC), &cb, cmd); - GPUBuffer* vbs[] = { + const GPUBuffer* vbs[] = { &vb_picker, }; const UINT strides[] = { @@ -1842,14 +1843,15 @@ void wiColorPicker::Render(const wiGUI* gui, CommandList cmd) const } // render saturation picker + if (IsEnabled()) { XMStoreFloat4x4(&cb.g_xTransform, XMMatrixTranslation(saturation_picker.x, saturation_picker.y, 0) * - __cam + Projection ); cb.g_xColor = float4(1 - final_color.x, 1 - final_color.y, 1 - final_color.z, 1); wiRenderer::GetDevice()->UpdateBuffer(wiRenderer::GetConstantBuffer(CBTYPE_MISC), &cb, cmd); - GPUBuffer* vbs[] = { + const GPUBuffer* vbs[] = { &vb_picker, }; const UINT strides[] = { @@ -1863,11 +1865,11 @@ void wiColorPicker::Render(const wiGUI* gui, CommandList cmd) const { XMStoreFloat4x4(&cb.g_xTransform, XMMatrixTranslation(translation.x + 260, translation.y + 40, 0) * - __cam + Projection ); - cb.g_xColor = GetPickColor(); + cb.g_xColor = GetPickColor().toFloat4(); wiRenderer::GetDevice()->UpdateBuffer(wiRenderer::GetConstantBuffer(CBTYPE_MISC), &cb, cmd); - GPUBuffer* vbs[] = { + const GPUBuffer* vbs[] = { &vb_preview, }; const UINT strides[] = { @@ -1886,11 +1888,11 @@ void wiColorPicker::Render(const wiGUI* gui, CommandList cmd) const textColor, textShadowColor)).Draw(cmd); } -const XMFLOAT4& wiColorPicker::GetPickColor() const +const wiColor& wiColorPicker::GetPickColor() const { - return final_color; + return wiColor::fromFloat4(final_color); } -void wiColorPicker::SetPickColor(const XMFLOAT4& value) +void wiColorPicker::SetPickColor(const wiColor& value) { // TODO } diff --git a/WickedEngine/wiWidget.h b/WickedEngine/wiWidget.h index 18e6b19e9..aa86f96c3 100644 --- a/WickedEngine/wiWidget.h +++ b/WickedEngine/wiWidget.h @@ -302,8 +302,8 @@ public: virtual void Update(wiGUI* gui, float dt ) override; virtual void Render(const wiGUI* gui, wiGraphics::CommandList cmd) const override; - const XMFLOAT4& GetPickColor() const; - void SetPickColor(const XMFLOAT4& value); + const wiColor& GetPickColor() const; + void SetPickColor(const wiColor& value); void OnColorChanged(std::function func); };