Viewport #94
|
@ -1,16 +1,16 @@
|
||||||
[Window][MainStatusBar]
|
[Window][MainStatusBar]
|
||||||
Pos=0,1167
|
Pos=0,1060
|
||||||
Size=2314,20
|
Size=1920,20
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][SHEditorMenuBar]
|
[Window][SHEditorMenuBar]
|
||||||
Pos=0,48
|
Pos=0,48
|
||||||
Size=2314,1119
|
Size=1920,1012
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Hierarchy Panel]
|
[Window][Hierarchy Panel]
|
||||||
Pos=0,152
|
Pos=0,142
|
||||||
Size=208,1015
|
Size=321,918
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000004,0
|
DockId=0x00000004,0
|
||||||
|
|
||||||
|
@ -20,29 +20,29 @@ Size=400,400
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Inspector]
|
[Window][Inspector]
|
||||||
Pos=2044,48
|
Pos=1649,48
|
||||||
Size=270,1119
|
Size=271,1012
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,0
|
DockId=0x00000006,0
|
||||||
|
|
||||||
[Window][Profiler]
|
[Window][Profiler]
|
||||||
Pos=0,48
|
Pos=0,48
|
||||||
Size=208,102
|
Size=321,92
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000003,0
|
DockId=0x00000003,0
|
||||||
|
|
||||||
[Window][Viewport]
|
[Window][Viewport]
|
||||||
Pos=210,48
|
Pos=323,48
|
||||||
Size=1832,1119
|
Size=1324,1012
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000002,0
|
DockId=0x00000002,0
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=-7,358 Size=2314,1119 Split=X
|
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=617,298 Size=1920,1012 Split=X
|
||||||
DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=2042,1036 Split=X
|
DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=1992,1036 Split=X
|
||||||
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=208,1036 Split=Y Selected=0x1E6EB881
|
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=321,1036 Split=Y Selected=0x1E6EB881
|
||||||
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=225,94 Selected=0x1E6EB881
|
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=225,94 Selected=0x1E6EB881
|
||||||
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=225,940 Selected=0xE096E5AE
|
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=225,940 Selected=0xE096E5AE
|
||||||
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1832,1036 CentralNode=1 Selected=0x13926F0B
|
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1324,1036 CentralNode=1 Selected=0x13926F0B
|
||||||
DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=270,1036 Selected=0xE7039252
|
DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=271,1036 Selected=0xE7039252
|
||||||
|
|
||||||
|
|
|
@ -34,5 +34,6 @@ namespace SHADE
|
||||||
ImGuiIO& io;
|
ImGuiIO& io;
|
||||||
SHVec2 windowSize;
|
SHVec2 windowSize;
|
||||||
SHVec2 windowPos;
|
SHVec2 windowPos;
|
||||||
|
SHVec2 viewportMousePos;
|
||||||
};//class SHEditorWindow
|
};//class SHEditorWindow
|
||||||
}//namespace SHADE
|
}//namespace SHADE
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "ECS_Base/Managers/SHSystemManager.h"
|
#include "ECS_Base/Managers/SHSystemManager.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"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -26,6 +27,14 @@ 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 cursorPos = ImGui::GetCursorScreenPos();
|
||||||
|
viewportMousePos = {mousePos.x - cursorPos.x, mousePos.y - cursorPos.y};
|
||||||
|
gfxSystem->GetMousePickSystem ()->SetViewportMousePos (viewportMousePos);
|
||||||
|
}
|
||||||
ImGui::Image((ImTextureID)descriptorSet, ImGui::GetWindowSize());
|
ImGui::Image((ImTextureID)descriptorSet, ImGui::GetWindowSize());
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
@ -42,6 +51,8 @@ namespace SHADE
|
||||||
//Get graphics system to resize swapchain image
|
//Get graphics system to resize swapchain image
|
||||||
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
|
||||||
|
|
||||||
|
//auto pos = ImGui::GetCursorPos();
|
||||||
|
//windowCursorPos = {}
|
||||||
gfxSystem->PrepareResize(static_cast<uint32_t>(windowSize.x), static_cast<uint32_t>(windowSize.y));
|
gfxSystem->PrepareResize(static_cast<uint32_t>(windowSize.x), static_cast<uint32_t>(windowSize.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,15 @@ namespace SHADE
|
||||||
if (width == 0 || height == 0)
|
if (width == 0 || height == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PrepareResize(resizeWidth, resizeHeight);
|
#ifdef SHEDITOR
|
||||||
|
|
||||||
|
//PrepareResize(1, 1, SHVec2(0, 0));
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
PrepareResize(resizeWidth, resizeHeight, SHVec2(0, 0));
|
||||||
|
|
||||||
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
window->RegisterWindowCloseCallback([&](void)
|
window->RegisterWindowCloseCallback([&](void)
|
||||||
|
@ -130,7 +138,7 @@ namespace SHADE
|
||||||
worldCamera->SetPerspective(90.0f, static_cast<float>(windowDims.first), static_cast<float>(windowDims.second), 0.0f, 100.0f);
|
worldCamera->SetPerspective(90.0f, static_cast<float>(windowDims.first), static_cast<float>(windowDims.second), 0.0f, 100.0f);
|
||||||
|
|
||||||
// Create Default Viewport
|
// Create Default Viewport
|
||||||
defaultViewport = AddViewport(vk::Viewport(0.0f, 0.0f, static_cast<float>(window->GetWindowSize().first), static_cast<float>(window->GetWindowSize().second), 0.0f, 1.0f));
|
worldViewport = AddViewport(vk::Viewport(0.0f, 0.0f, static_cast<float>(window->GetWindowSize().first), static_cast<float>(window->GetWindowSize().second), 0.0f, 1.0f));
|
||||||
|
|
||||||
// Get render graph from default viewport world renderer
|
// Get render graph from default viewport world renderer
|
||||||
worldRenderGraph = resourceManager.Create<SHRenderGraph>();
|
worldRenderGraph = resourceManager.Create<SHRenderGraph>();
|
||||||
|
@ -163,7 +171,7 @@ namespace SHADE
|
||||||
worldRenderGraph->Generate();
|
worldRenderGraph->Generate();
|
||||||
|
|
||||||
// Add world renderer to default viewport
|
// Add world renderer to default viewport
|
||||||
worldRenderer = defaultViewport->AddRenderer(resourceManager, swapchain->GetNumImages(), renderContextCmdPools, descPool, SHGraphicsGlobalData::GetDescSetLayouts()[SHGraphicsConstants::DescriptorSetIndex::HIGH_FREQUENCY_GLOBALS], worldRenderGraph);
|
worldRenderer = worldViewport->AddRenderer(resourceManager, swapchain->GetNumImages(), renderContextCmdPools, descPool, SHGraphicsGlobalData::GetDescSetLayouts()[SHGraphicsConstants::DescriptorSetIndex::HIGH_FREQUENCY_GLOBALS], worldRenderGraph);
|
||||||
worldRenderer->SetCamera(worldCamera);
|
worldRenderer->SetCamera(worldCamera);
|
||||||
|
|
||||||
|
|
||||||
|
@ -691,8 +699,8 @@ namespace SHADE
|
||||||
mousePickSystem->HandleResize();
|
mousePickSystem->HandleResize();
|
||||||
postOffscreenRender->HandleResize();
|
postOffscreenRender->HandleResize();
|
||||||
|
|
||||||
defaultViewport->SetWidth(static_cast<float>(resizeWidth));
|
worldViewport->SetWidth(static_cast<float>(resizeWidth));
|
||||||
defaultViewport->SetHeight(static_cast<float>(resizeHeight));
|
worldViewport->SetHeight(static_cast<float>(resizeHeight));
|
||||||
|
|
||||||
worldCamera->SetPerspective(90.0f, static_cast<float>(resizeWidth), static_cast<float>(resizeHeight), 0.0f, 100.0f);
|
worldCamera->SetPerspective(90.0f, static_cast<float>(resizeWidth), static_cast<float>(resizeHeight), 0.0f, 100.0f);
|
||||||
|
|
||||||
|
|
|
@ -280,7 +280,7 @@ namespace SHADE
|
||||||
Handle<SHVkPhysicalDevice> GetPhysicalDevice() const { return physicalDevice; }
|
Handle<SHVkPhysicalDevice> GetPhysicalDevice() const { return physicalDevice; }
|
||||||
Handle<SHVkQueue> GetQueue() const { return graphicsQueue; }
|
Handle<SHVkQueue> GetQueue() const { return graphicsQueue; }
|
||||||
Handle<SHVkDescriptorPool> GetDescriptorPool() const { return descPool; }
|
Handle<SHVkDescriptorPool> GetDescriptorPool() const { return descPool; }
|
||||||
Handle<SHViewport> GetDefaultViewport() const {return defaultViewport;}
|
Handle<SHViewport> GetDefaultViewport() const {return worldViewport;}
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
Handle<SHViewport> GetEditorViewport () const {return editorViewport;};
|
Handle<SHViewport> GetEditorViewport () const {return editorViewport;};
|
||||||
#endif
|
#endif
|
||||||
|
@ -325,7 +325,7 @@ namespace SHADE
|
||||||
Handle<SHRenderGraph> editorRenderGraph;
|
Handle<SHRenderGraph> editorRenderGraph;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Handle<SHViewport> defaultViewport; // Whole screen
|
Handle<SHViewport> worldViewport; // Whole screen
|
||||||
std::vector<Handle<SHViewport>> viewports; // Additional viewports
|
std::vector<Handle<SHViewport>> viewports; // Additional viewports
|
||||||
|
|
||||||
// Debug Renderers
|
// Debug Renderers
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "Graphics/Synchronization/SHVkFence.h"
|
#include "Graphics/Synchronization/SHVkFence.h"
|
||||||
#include "Graphics/Buffers/SHVkBuffer.h"
|
#include "Graphics/Buffers/SHVkBuffer.h"
|
||||||
#include "Graphics/SHVkUtil.h"
|
#include "Graphics/SHVkUtil.h"
|
||||||
|
#include "Graphics/MiddleEnd/Interface/SHViewport.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -13,7 +14,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
logicalDevice = device;
|
logicalDevice = device;
|
||||||
|
|
||||||
pickedEID = 0;
|
pickedEID = MAX_EID;
|
||||||
|
|
||||||
// Create command buffers
|
// Create command buffers
|
||||||
for (auto& pool : cmdPools)
|
for (auto& pool : cmdPools)
|
||||||
|
@ -30,7 +31,7 @@ namespace SHADE
|
||||||
void SHMousePickSystem::Run(Handle<SHVkQueue> queue, uint32_t frameIndex) noexcept
|
void SHMousePickSystem::Run(Handle<SHVkQueue> queue, uint32_t frameIndex) noexcept
|
||||||
{
|
{
|
||||||
// if input detected
|
// if input detected
|
||||||
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::LEFT_CTRL) && SHInputManager::GetKeyUp(SHInputManager::SH_KEYCODE::LMB))
|
if (SHInputManager::GetKeyUp(SHInputManager::SH_KEYCODE::LMB))
|
||||||
{
|
{
|
||||||
afterCopyFence->Reset();
|
afterCopyFence->Reset();
|
||||||
|
|
||||||
|
@ -52,10 +53,8 @@ namespace SHADE
|
||||||
// wait for the copy to be done
|
// wait for the copy to be done
|
||||||
afterCopyFence->Wait(true, std::numeric_limits<uint64_t>::max());
|
afterCopyFence->Wait(true, std::numeric_limits<uint64_t>::max());
|
||||||
|
|
||||||
int mouseX = 0, mouseY = 0;
|
pickedEID = imageDataDstBuffer->GetDataFromMappedPointer<uint32_t>(static_cast<uint32_t>(viewportMousePos.y) * entityIDAttachment->GetWidth() + static_cast<uint32_t>(viewportMousePos.x));
|
||||||
SHInputManager::GetMouseWindowPosition(&mouseX, &mouseY);
|
|
||||||
|
|
||||||
pickedEID = imageDataDstBuffer->GetDataFromMappedPointer<uint32_t>(mouseY * entityIDAttachment->GetWidth() + mouseX);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,6 +78,11 @@ namespace SHADE
|
||||||
imageDataDstBuffer = logicalDevice->CreateBuffer(bufferSize, nullptr, bufferSize, vk::BufferUsageFlagBits::eTransferDst, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT);
|
imageDataDstBuffer = logicalDevice->CreateBuffer(bufferSize, nullptr, bufferSize, vk::BufferUsageFlagBits::eTransferDst, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHMousePickSystem::SetViewportMousePos(SHVec2 vpMousePos) noexcept
|
||||||
|
{
|
||||||
|
viewportMousePos = vpMousePos;
|
||||||
|
}
|
||||||
|
|
||||||
EntityID SHMousePickSystem::GetPickedEntity(void) const noexcept
|
EntityID SHMousePickSystem::GetPickedEntity(void) const noexcept
|
||||||
{
|
{
|
||||||
return pickedEID;
|
return pickedEID;
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace SHADE
|
||||||
class SHVkFence;
|
class SHVkFence;
|
||||||
class SHVkQueue;
|
class SHVkQueue;
|
||||||
class SHVkBuffer;
|
class SHVkBuffer;
|
||||||
|
class SHViewport;
|
||||||
|
|
||||||
class SHMousePickSystem
|
class SHMousePickSystem
|
||||||
{
|
{
|
||||||
|
@ -33,6 +34,10 @@ namespace SHADE
|
||||||
|
|
||||||
//! eid picked from screen
|
//! eid picked from screen
|
||||||
EntityID pickedEID;
|
EntityID pickedEID;
|
||||||
|
|
||||||
|
//! mouse position relative to the viewport window displaying the world
|
||||||
|
SHVec2 viewportMousePos;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* PUBLIC MEMBER FUNCTIONS */
|
/* PUBLIC MEMBER FUNCTIONS */
|
||||||
|
@ -44,6 +49,8 @@ namespace SHADE
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* SETTERS AND GETTERS */
|
/* SETTERS AND GETTERS */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
void SetViewportMousePos (SHVec2 vpMousePos) noexcept;
|
||||||
|
|
||||||
EntityID GetPickedEntity (void) const noexcept;
|
EntityID GetPickedEntity (void) const noexcept;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -85,4 +85,14 @@ namespace SHADE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHViewport::SetX(float x) noexcept
|
||||||
|
{
|
||||||
|
viewport.x = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHViewport::SetY(float y) noexcept
|
||||||
|
{
|
||||||
|
viewport.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,8 @@ namespace SHADE
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
void SetWidth(float w) noexcept;
|
void SetWidth(float w) noexcept;
|
||||||
void SetHeight (float h) noexcept;
|
void SetHeight (float h) noexcept;
|
||||||
|
void SetX (float x) noexcept;
|
||||||
|
void SetY (float y) noexcept;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Getters */
|
/* Getters */
|
||||||
|
|
Loading…
Reference in New Issue