Skip to content

Commit

Permalink
[Editor] Fixed erratic behaviour of material multiplier sliders when …
Browse files Browse the repository at this point in the history
…selecting different entities in the world
  • Loading branch information
PanosK92 committed Dec 1, 2023
1 parent 7bc1f52 commit ae934ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion editor/ImGui/ImGuiExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ namespace ImGuiSp
static bool needs_to_wrap = false;
ImGuiIO& imgui_io = ImGui::GetIO();

// Wrap
// wrap
if (ImGui::IsMouseDragging(ImGuiMouseButton_Left))
{
ImVec2 position_cursor = imgui_io.MousePos;
Expand Down Expand Up @@ -376,7 +376,9 @@ namespace ImGuiSp
}
}

ImGui::PushID(static_cast<int>(ImGui::GetCursorPosX() + ImGui::GetCursorPosY()));
ImGui::DragFloat(label, v, v_speed, v_min, v_max, format, flags);
ImGui::PopID();
}

static bool combo_box(const char* label, const std::vector<std::string>& options, uint32_t* selection_index)
Expand Down
10 changes: 5 additions & 5 deletions editor/Widgets/Properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ void Properties::ShowMaterial(Material* material) const

if (material->GetProperty(MaterialProperty::CanBeEdited) == 1.0f)
{
// Texture slots
// texture slots
{
const auto show_property = [this, &material](const char* name, const char* tooltip, const MaterialTexture mat_tex, const MaterialProperty mat_property)
{
Expand All @@ -697,7 +697,7 @@ void Properties::ShowMaterial(Material* material) const
}
}

// Texture
// texture
if (show_texture)
{
auto setter = [&material, &mat_tex](const shared_ptr<RHI_Texture>& texture) { material->SetTexture(mat_tex, texture); };
Expand All @@ -723,7 +723,7 @@ void Properties::ShowMaterial(Material* material) const
}
}

// Modifier
// modifier/multiplier
if (show_modifier)
{
if (mat_property == MaterialProperty::ColorTint)
Expand All @@ -732,7 +732,6 @@ void Properties::ShowMaterial(Material* material) const
}
else
{
ImGui::PushID(static_cast<int>(ImGui::GetCursorPosX() + ImGui::GetCursorPosY()));
float value = material->GetProperty(mat_property);

if (mat_property != MaterialProperty::MultiplierMetalness)
Expand All @@ -751,12 +750,13 @@ void Properties::ShowMaterial(Material* material) const
else
{
bool is_metallic = value != 0.0f;
ImGui::PushID(static_cast<int>(ImGui::GetCursorPosX() + ImGui::GetCursorPosY()));
ImGui::Checkbox("##metalness", &is_metallic);
ImGui::PopID();
value = is_metallic ? 1.0f : 0.0f;
}

material->SetProperty(mat_property, value);
ImGui::PopID();
}
}
};
Expand Down

0 comments on commit ae934ef

Please sign in to comment.