From 0bbfe41117e32b045d230a1263ed73c6ed445020 Mon Sep 17 00:00:00 2001 From: Erris Date: Mon, 23 Feb 2026 01:40:05 +0100 Subject: [PATCH] adding entity stats. Added security to prevent mouse picking selection when dragging --- editor/include/editor.hpp | 22 +++++++++++++++---- .../opengl/opengl_vertex_array.cpp | 1 - 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/editor/include/editor.hpp b/editor/include/editor.hpp index 780460e..e3ccfe6 100755 --- a/editor/include/editor.hpp +++ b/editor/include/editor.hpp @@ -136,12 +136,19 @@ namespace OpenEngine { int mouse_y = (int)my; static bool clicked = false; - if (Input::IsMouseButtonPressed(MouseCode::ButtonLeft) && mouse_x >= 0 && mouse_y >= 0 && mouse_x < (int)viewport_size.x && (int)viewport_size.y) { + // Mouse Picking + if (Input::IsMouseButtonPressed(MouseCode::ButtonLeft) + && mouse_x >= 0 && mouse_y >= 0 + && mouse_x < (int)viewport_size.x && (int)viewport_size.y && + !ImGuizmo::IsOver() && !Input::IsKeyPressed(KeyCode::LeftAlt)) { if (!clicked) { int id = framebuffer->ReadPixel(1, mouse_x, mouse_y); - if (id != -1) - scene_hierarchy.SetSelectedEntity({ (entt::entity)id, scene.get() }); + selected_entity = id == -1 ? + Entity() : Entity((entt::entity)id, scene.get()); + + scene_hierarchy.SetSelectedEntity(selected_entity); + } clicked = true; @@ -276,12 +283,19 @@ namespace OpenEngine { } ImGui::Begin("Statistics"); + ImGui::SeparatorText("Performance"); ImGui::Text("FPS: %0.0f", 1 / Time::DeltaTime()); ImGui::Text("Renderer2D:"); ImGui::Text("\t\tDraw calls: %d", stats.draw_calls); ImGui::Text("\t\tQuad count: %d", stats.quad_count); ImGui::Text("\t\tVertices count: %d", stats.GetTotalVertexCount()); ImGui::Text("\t\tIndices count: %d", stats.GetTotalIndexCount()); + if (selected_entity) { + ImGui::SeparatorText("Entities"); + ImGui::Text("Selected entity:"); + ImGui::Text("\t\tname: %s", selected_entity.GetComponents().tag.c_str()); + ImGui::Text("\t\tid: %d", (uint32_t)selected_entity); + } ImGui::End(); }; @@ -396,7 +410,7 @@ namespace OpenEngine { int guizmo_operation = -1; Ref scene; - std::vector entities; + Entity selected_entity; }; } diff --git a/open_engine/src/open_engine/opengl/opengl_vertex_array.cpp b/open_engine/src/open_engine/opengl/opengl_vertex_array.cpp index b96a7d5..439eedd 100644 --- a/open_engine/src/open_engine/opengl/opengl_vertex_array.cpp +++ b/open_engine/src/open_engine/opengl/opengl_vertex_array.cpp @@ -79,7 +79,6 @@ namespace OpenEngine { element.normalized? GL_TRUE : GL_FALSE, layout.GetStride(), (const void*)(intptr_t)element.offset); - } index++; }