select picked entity in hierarchy panel

This commit is contained in:
Sri Sham Haran 2022-10-18 19:08:31 +08:00
parent 9ce5a4a47b
commit 15a17deaf0
7 changed files with 37 additions and 14 deletions

2
.gitignore vendored
View File

@ -362,3 +362,5 @@ MigrationBackup/
*.csproj *.csproj
*.filters *.filters
Assets/Editor/Layouts/UserLayout.ini

View File

@ -130,14 +130,19 @@ namespace Sandbox
void SBApplication::Update(void) void SBApplication::Update(void)
{ {
SHGraphicsSystem* graphicsSystem = SHADE::SHSystemManager::GetSystem<SHGraphicsSystem>(); SHGraphicsSystem* graphicsSystem = SHADE::SHSystemManager::GetSystem<SHGraphicsSystem>();
SHEditor* editor = SHADE::SHSystemManager::GetSystem<SHEditor>();
//TODO: Change true to window is open //TODO: Change true to window is open
while (!window.WindowShouldClose()) while (!window.WindowShouldClose())
{ {
SHFrameRateController::UpdateFRC(); SHFrameRateController::UpdateFRC();
SHInputManager::UpdateInput(SHFrameRateController::GetRawDeltaTime()); SHInputManager::UpdateInput(SHFrameRateController::GetRawDeltaTime());
SHSceneManager::UpdateSceneManager(); SHSceneManager::UpdateSceneManager();
#ifdef SHEDITOR
if(editor->editorState == SHEditor::State::PLAY)
SHSceneManager::SceneUpdate(0.016f); SHSceneManager::SceneUpdate(0.016f);
SHSystemManager::RunRoutines(false, 0.016f); #endif
SHSystemManager::RunRoutines(editor->editorState != SHEditor::State::PLAY, 0.016f);
editor->PollPicking();
} }
// Finish all graphics jobs first // Finish all graphics jobs first

View File

@ -54,6 +54,7 @@ namespace SHADE
windowPos = {wndPos.x, wndPos.y}; windowPos = {wndPos.x, wndPos.y};
OnPosChange(); OnPosChange();
} }
isWindowHovered = ImGui::IsWindowHovered();
return result; return result;
} }

View File

@ -24,6 +24,7 @@ namespace SHADE
virtual void Update(); virtual void Update();
virtual void Exit(); virtual void Exit();
bool isOpen; bool isOpen;
bool isWindowHovered;
std::string_view windowName; std::string_view windowName;
protected: protected:
virtual bool Begin(); virtual bool Begin();

View File

@ -2,6 +2,8 @@
#include "SHEditorViewport.h" #include "SHEditorViewport.h"
#include "ECS_Base/Managers/SHSystemManager.h" #include "ECS_Base/Managers/SHSystemManager.h"
#include "Editor/SHEditor.hpp"
#include "Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.h"
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h" #include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
#include "Graphics/Descriptors/SHVkDescriptorSetGroup.h" #include "Graphics/Descriptors/SHVkDescriptorSetGroup.h"
#include "Graphics/MiddleEnd/Interface/SHMousePickSystem.h" #include "Graphics/MiddleEnd/Interface/SHMousePickSystem.h"
@ -27,14 +29,25 @@ namespace SHADE
DrawMenuBar(); DrawMenuBar();
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>(); auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
auto const& descriptorSet = gfxSystem->GetPostOffscreenRenderSystem()->GetDescriptorSetGroup()->GetVkHandle()[0]; auto const& descriptorSet = gfxSystem->GetPostOffscreenRenderSystem()->GetDescriptorSetGroup()->GetVkHandle()[0];
if (ImGui::IsWindowHovered() && ImGui::IsMouseReleased(ImGuiMouseButton_Left))
{
auto mousePos = ImGui::GetMousePos(); auto mousePos = ImGui::GetMousePos();
auto cursorPos = ImGui::GetCursorScreenPos(); auto cursorPos = ImGui::GetCursorScreenPos();
viewportMousePos = {mousePos.x - cursorPos.x, mousePos.y - cursorPos.y}; viewportMousePos = {mousePos.x - cursorPos.x, mousePos.y - cursorPos.y};
gfxSystem->GetMousePickSystem ()->SetViewportMousePos (viewportMousePos); gfxSystem->GetMousePickSystem ()->SetViewportMousePos (viewportMousePos);
} //if (ImGui::IsMouseReleased(ImGuiMouseButton_Left))
//{
// auto eid = gfxSystem->GetMousePickSystem ()->GetPickedEntity();
// if(eid != MAX_EID)
// {
// auto editor = SHSystemManager::GetSystem<SHEditor>();
// editor->selectedEntities.clear();
// editor->selectedEntities.push_back(eid);
// if (const auto hierarchyPanel = SHEditorWindowManager::GetEditorWindow<SHHierarchyPanel>())
// {
// hierarchyPanel->SetScrollTo(eid);
// }
// }
//}
ImGui::Image((ImTextureID)descriptorSet, ImGui::GetWindowSize()); ImGui::Image((ImTextureID)descriptorSet, ImGui::GetWindowSize());
} }
ImGui::End(); ImGui::End();

View File

@ -337,7 +337,8 @@ namespace SHADE
{ {
if (auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>()) if (auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>())
{ {
if (!ImGui::IsAnyItemHovered() && ImGui::IsMouseReleased(ImGuiMouseButton_Left)) auto viewportWindow = SHEditorWindowManager::GetEditorWindow<SHEditorViewport>();
if (viewportWindow->isWindowHovered && ImGui::IsMouseReleased(ImGuiMouseButton_Left))
{ {
EntityID pickedEID = gfxSystem->GetMousePickSystem()->GetPickedEntity(); EntityID pickedEID = gfxSystem->GetMousePickSystem()->GetPickedEntity();
if(pickedEID == MAX_EID) if(pickedEID == MAX_EID)

View File

@ -597,7 +597,7 @@ namespace SHADE
/* System Routine Functions - BeginRoutine */ /* System Routine Functions - BeginRoutine */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
SHGraphicsSystem::BeginRoutine::BeginRoutine() SHGraphicsSystem::BeginRoutine::BeginRoutine()
: SHSystemRoutine("Graphics System Frame Set Up", false) : SHSystemRoutine("Graphics System Frame Set Up", true)
{} {}
void SHGraphicsSystem::BeginRoutine::Execute(double) noexcept void SHGraphicsSystem::BeginRoutine::Execute(double) noexcept
@ -609,7 +609,7 @@ namespace SHADE
/* System Routine Functions - RenderRoutine */ /* System Routine Functions - RenderRoutine */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
SHGraphicsSystem::RenderRoutine::RenderRoutine() SHGraphicsSystem::RenderRoutine::RenderRoutine()
: SHSystemRoutine("Graphics System Render", false) : SHSystemRoutine("Graphics System Render", true)
{} {}
void SHGraphicsSystem::RenderRoutine::Execute(double dt) noexcept void SHGraphicsSystem::RenderRoutine::Execute(double dt) noexcept
@ -621,7 +621,7 @@ namespace SHADE
/* System Routine Functions - EndRoutine */ /* System Routine Functions - EndRoutine */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
SHGraphicsSystem::EndRoutine::EndRoutine() SHGraphicsSystem::EndRoutine::EndRoutine()
: SHSystemRoutine("Graphics System Frame Clean Up", false) : SHSystemRoutine("Graphics System Frame Clean Up", true)
{} {}
void SHGraphicsSystem::EndRoutine::Execute(double) noexcept void SHGraphicsSystem::EndRoutine::Execute(double) noexcept
@ -633,7 +633,7 @@ namespace SHADE
/* System Routine Functions - BatcherDispatcherRoutine */ /* System Routine Functions - BatcherDispatcherRoutine */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
SHGraphicsSystem::BatcherDispatcherRoutine::BatcherDispatcherRoutine() SHGraphicsSystem::BatcherDispatcherRoutine::BatcherDispatcherRoutine()
: SHSystemRoutine("Graphics System Batcher Dispatcher", false) : SHSystemRoutine("Graphics System Batcher Dispatcher", true)
{} {}
void SHGraphicsSystem::BatcherDispatcherRoutine::Execute(double) noexcept void SHGraphicsSystem::BatcherDispatcherRoutine::Execute(double) noexcept