From d3be8127cdd629a883a35c3f3b75143ad12ec8d4 Mon Sep 17 00:00:00 2001 From: Sri Sham Haran Date: Tue, 15 Nov 2022 16:22:48 +0800 Subject: [PATCH] [FIXED] Parenting of entities selected using Shift+Select [FIXED] Component Active Checkbox not working for non reflected components --- .../EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp | 10 +++++++++- .../EditorWindow/Inspector/SHEditorComponentView.hpp | 11 +++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp b/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp index 2a24ad0e..cf545223 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp @@ -345,10 +345,18 @@ namespace SHADE void SHHierarchyPanel::ParentSelectedEntities(EntityID parentEID, std::vector const& entities) const noexcept { auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph(); + + std::vector entitiesToParent{}; + std::ranges::copy_if(entities, std::back_inserter(entitiesToParent), [&sceneGraph](EntityID const& eid) + { + if (sceneGraph.GetParent(eid)->GetEntityID() == MAX_EID) + return true; + return false; + }); //auto const editor = SHSystemManager::GetSystem(); SHEntityParentCommand::EntityParentData entityParentData; std::vector parentedEIDS; - for (auto const& eid : entities) + for (auto const& eid : entitiesToParent) { if(eid == parentEID) continue; diff --git a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp index 6091556e..146e36c3 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp +++ b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp @@ -68,10 +68,10 @@ namespace SHADE { if (!component) return; + const auto componentType = rttr::type::get(); ImGui::PushID(SHFamilyID::GetID()); SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active"); - ImGui::PopID(); ImGui::SameLine(); if (ImGui::CollapsingHeader(componentType.get_name().data())) { @@ -216,6 +216,8 @@ namespace SHADE } } else DrawContextMenu(component); + ImGui::PopID(); + } template<> @@ -223,7 +225,8 @@ namespace SHADE { if (!component) return; - ImGui::PushID(component); + ImGui::PushID(SHFamilyID::GetID()); + const auto componentType = rttr::type::get(*component); SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active"); ImGui::SameLine(); @@ -330,6 +333,7 @@ namespace SHADE { if (!component) return; + ImGui::PushID(SHFamilyID::GetID()); const auto componentType = rttr::type::get(*component); SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active"); ImGui::SameLine(); @@ -353,6 +357,7 @@ namespace SHADE { DrawContextMenu(component); } + ImGui::PopID(); } template<> @@ -360,6 +365,7 @@ namespace SHADE { if (!component) return; + ImGui::PushID(SHFamilyID::GetID()); const auto componentType = rttr::type::get(*component); SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active"); ImGui::SameLine(); @@ -397,5 +403,6 @@ namespace SHADE { DrawContextMenu(component); } + ImGui::PopID(); } }