使用lambda函数和模板函数重构Copy组件功能

This commit is contained in:
2025-07-06 12:58:48 +08:00
parent fadb73243d
commit 37c17bdb5c
4 changed files with 47 additions and 20 deletions

View File

@ -146,7 +146,6 @@ namespace Hazel
if (m_ShowPhysicsColliders)
{
// box collider
auto bcview = m_ActiveScene->GetAllEntitiesWith<TransformComponent, BoxCollider2DComponent>();
for (auto entity : bcview)
{
@ -169,7 +168,7 @@ namespace Hazel
Renderer2D::DrawRect(transform, glm::vec4(0.2f, 1.0f, 0.2f, 1.0f));
}
// circle collider
auto ccview = m_ActiveScene->GetAllEntitiesWith<TransformComponent, CircleCollider2DComponent>();
for (auto entity : ccview)
{
@ -562,7 +561,7 @@ namespace Hazel
m_CameraController.OnEvent(e);
m_EditorCamera.OnEvent(e);
}
if (e.button.clicks && m_ViewportHovered && !ImGuizmo::IsOver() && Input::IsMouseButtonPressed(SDL_BUTTON_LEFT) && !Input::IsKeyPressed(SDL_SCANCODE_LALT))
if (e.button.clicks && m_ViewportHovered && !ImGuizmo::IsOver() && Input::IsMouseButtonPressed(BUTTON_LEFT) && !Input::IsKeyPressed(SDL_SCANCODE_LALT))
m_SceneHierachyPanel.SetSelectedEntity(m_HoveredEntity);
#define SHORTCUT_EXIT (SDL_KMOD_CTRL + SDLK_W)