2
3
4
5
9#include "Systems/SlateSystem.h"
10#include "Slate/Imgui/ViewPort/ImguiViewport.h"
11#include "Render/Vulkan/VulkanRenderBackend.h"
12#include "Core/Input/MouseButtonCodes.h"
13#include "Core/Input/Input.h"
14#include "Core/Input/KeyCodes.h"
15#include "World/Entity.h"
16#include "World/World/World.h"
32
33
34 if (!SlateSystem::GetRegister())
return false;
37
38
39 if (!m_ViewPort.lock()) m_ViewPort = SlateSystem::GetRegister()->GetViewPort();
41 if (!m_ViewPort.lock()->IsHovered() || m_ViewPort.lock()->GetGizmo()->IsOver())
return false;
43 if (m_ViewPort.lock()->GetMousePosInViewport().first < 0 ||
44 m_ViewPort.lock()->GetMousePosInViewport().first > m_ViewPort.lock()->GetPanelSize().x ||
45 m_ViewPort.lock()->GetMousePosInViewport().second < 0 ||
46 m_ViewPort.lock()->GetMousePosInViewport().second > m_ViewPort.lock()->GetPanelSize().y
55
56
59 auto pair = m_ViewPort.lock()->GetMousePosInViewport();
61 VulkanRenderBackend::GetRendererResourcePool()
62 ->AccessRowResource(
"EntityID")
63 ->CopyImageTexelToBuffer(
66 reinterpret_cast<
void*>(&m_WorldPickID[0])
69 Entity entity((entt::entity)m_WorldPickID[0], FrameInfo::Get().m_World.get());
70 std::string entityName = *entity.GetComponent<
TagComponent>().GetTag().begin();
75 ss <<
"Select entity: " << entityName;
77 SPICES_CORE_TRACE(ss.str())
81
82
85 auto pair = m_ViewPort.lock()->GetMousePosInViewport();
87 VulkanRenderBackend::GetRendererResourcePool()
88 ->AccessRowResource(
"EntityID")
89 ->CopyImageTexelToBuffer(
92 reinterpret_cast<
void*>(&m_WorldPickID[0])
99 ss <<
"Deselect entity: " << *ptr;
101 SPICES_CORE_TRACE(ss.str())
108
109
114 auto pair = m_ViewPort.lock()->GetMousePosInViewport();
116 VulkanRenderBackend::GetRendererResourcePool()
117 ->AccessRowResource(
"EntityID")
118 ->CopyImageTexelToBuffer(
121 reinterpret_cast<
void*>(&m_WorldPickID[0])
124 Entity entity((entt::entity)m_WorldPickID[0], FrameInfo::Get().m_World.get());
125 std::string entityName = *entity.GetComponent<
TagComponent>().GetTag().begin();
129 std::stringstream ss;
130 ss <<
"Select entity: " << entityName;
132 SPICES_CORE_TRACE(ss.str())
137
138
143 SPICES_CORE_TRACE(
"Cancel all selected entity")
#define BIND_EVENT_FN(x)
Bind Event.
#define SPICES_PROFILE_ZONE
Entity Class. This class defines the specific behaves of Entity.
EventDispatcher(Event &event)
Constructor Function.
This Class store a Specific Event type first and Dispatch a event handle function to it.
This Class is the basic Event Class. Inherit from it and create specific event class.
static FrameInfo & Get()
Get FrameInfo.
FrameInfo Class. This class defines the FrameInfo data.
TagComponent Class. This class defines the specific behaves of TagComponent.
bool OnMouseButtonPressed(MouseButtonPressedEvent &e)
Event OnKeyPressed.
float m_WorldPickID[4]
World Picked entity id (only use channel 0).
virtual void OnEvent(Event &e) override
This interface defines the behave on specific component event happened.
Script of handle world entity pick.