diff --git a/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp b/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp index ef4ad35e..a7e85ad4 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp @@ -57,9 +57,13 @@ namespace SHADE skipFrame = false; return; } - DrawMenuBar(); auto const& sceneGraph = SHSceneManager::GetCurrentSceneGraph(); - + DrawMenuBar(); + if(wasFilterChanged && !filter.empty()) + { + filterHighlightedEntities.clear(); + filterOpenEntities.clear(); + } if (const auto root = sceneGraph.GetRoot()) { auto const& children = root->GetChildren(); @@ -67,7 +71,13 @@ namespace SHADE for (const auto child : children) { if (child) + { + if(wasFilterChanged && !filter.empty()) + { + EntityFilterCheck(child); + } RecursivelyDrawEntityNode(child); + } if (skipFrame) { ImGui::End(); @@ -177,9 +187,10 @@ namespace SHADE void SHHierarchyPanel::DrawHierarchyPanelFilter() noexcept { + wasFilterChanged = false; if(ImGui::InputTextWithHint("##hierarchyPanelFilter", "Filter", &filter)) { - + wasFilterChanged = true; } ImGui::SameLine(); if(ImGui::Button("x")) @@ -199,29 +210,70 @@ namespace SHADE bool result = false; result |= SHStringUtilities::StringFindInsensitive(entity->name, filter) != std::string::npos; - + if(SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos) { result |= SHComponentManager::HasComponent(eid); } - //result |= SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos; - //result |= SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos; - //result |= SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos; - //result |= SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos; - //result |= SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos; - //result |= SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos; - //result |= SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos; - //result |= SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos; - //result |= SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos; - //result |= SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos; + if(SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos) + { + result |= SHComponentManager::HasComponent(eid); + } + if(SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos) + { + result |= SHComponentManager::HasComponent(eid); + } + if(SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos) + { + result |= SHComponentManager::HasComponent(eid); + } + if(SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos) + { + result |= SHComponentManager::HasComponent(eid); + } + if(SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos) + { + result |= SHComponentManager::HasComponent(eid); + } + if(SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos) + { + result |= SHComponentManager::HasComponent(eid); + } + if(SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos) + { + result |= SHComponentManager::HasComponent(eid); + } + if(SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos) + { + result |= SHComponentManager::HasComponent(eid); + } + if(SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos) + { + result |= SHComponentManager::HasComponent(eid); + } + if(SHStringUtilities::StringFindInsensitive(rttr::type::get().get_name().data(), filter) != std::string::npos) + { + result |= SHComponentManager::HasComponent(eid); + } - //std::vector const& children = entityNode->GetChildren(); - - //for (auto const& child : children) - //{ - // result |= EntityFilterCheck(child); - //} + if(result) + { + filterHighlightedEntities.push_back(eid); + } + std::vector const& children = entityNode->GetChildren(); + + bool open = false; + for (auto const& child : children) + { + open |= EntityFilterCheck(child); + } + result |= open; + + if(open) + { + filterOpenEntities.push_back(eid); + } return result; } @@ -245,31 +297,27 @@ namespace SHADE const bool isSelected = (std::ranges::find(editor->selectedEntities, eid) != editor->selectedEntities.end()); - bool highlighted = false; - //if(!filter.empty()) - //{ - // highlighted = EntityFilterCheck(currentNode); - // if (highlighted) - // { - // ImGui::PushStyleColor(ImGuiCol_Text, highlightedColor); - // - // ImGui::SetNextItemOpen(true); - // - // - // } - // else - // { - // - // } - //} + bool highlighted = false, open = false; + if(!filter.empty()) + { + highlighted = (std::ranges::find(filterHighlightedEntities, eid) != filterHighlightedEntities.end()); + if(open = std::ranges::find(filterOpenEntities, eid) != filterOpenEntities.end()) + { + ImGui::SetNextItemOpen(true); + } + + if(!open && !highlighted) + { + return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); + } + ImGui::PushStyleColor(ImGuiCol_Text, highlighted ? highlightedColor : ImVec4(0.5f, 0.5f, 0.5f, 1.f )); + } const ImGuiTreeNodeFlags nodeFlags = ((isSelected) ? ImGuiTreeNodeFlags_Selected : 0) | ((children.empty()) ? ImGuiTreeNodeFlags_Leaf : ImGuiTreeNodeFlags_OpenOnArrow); - - //Draw Node bool isNodeOpen = ImGui::TreeNodeEx(reinterpret_cast(eid), nodeFlags, "%u: %s", SHEntityManager::GetEntityIndex(eid), entity->name.c_str()); - if (highlighted) + if(!filter.empty()) { ImGui::PopStyleColor(); } diff --git a/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.h b/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.h index c6670948..d217a307 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.h +++ b/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.h @@ -44,7 +44,8 @@ namespace SHADE std::string filter; bool isAnyNodeSelected = false; EntityID scrollTo = MAX_EID; - std::vector draggingEntities; + std::vector draggingEntities, filterOpenEntities, filterHighlightedEntities; + bool wasFilterChanged = false; };//class SHHierarchyPanel diff --git a/SHADE_Engine/src/Editor/SHEditor.cpp b/SHADE_Engine/src/Editor/SHEditor.cpp index 2276164f..4d180635 100644 --- a/SHADE_Engine/src/Editor/SHEditor.cpp +++ b/SHADE_Engine/src/Editor/SHEditor.cpp @@ -106,8 +106,8 @@ namespace SHADE SHEditorWindowManager::CreateEditorWindow(); SHEditorWindowManager::CreateEditorWindow(); SHEditorWindowManager::CreateEditorWindow(); - SHEditorWindowManager::CreateEditorWindow(); SHEditorWindowManager::CreateEditorWindow(); + SHEditorWindowManager::CreateEditorWindow(); SHEditorWindowManager::CreateEditorWindow(); diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index b10ca123..18dcbd42 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -577,14 +577,14 @@ namespace SHADE #endif } - if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::B)) - { - auto& lightComps = SHComponentManager::GetDense(); - for (auto& comp : lightComps) - { - comp.SetEnableShadow(true); - } - } + //if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::B)) + //{ + // auto& lightComps = SHComponentManager::GetDense(); + // for (auto& comp : lightComps) + // { + // comp.SetEnableShadow(true); + // } + //} renderGraph->Begin(frameIndex); auto cmdBuffer = renderGraph->GetCommandBuffer(frameIndex);