adding entity stats. Added security to prevent mouse picking selection when dragging
This commit is contained in:
@@ -136,12 +136,19 @@ namespace OpenEngine {
|
|||||||
int mouse_y = (int)my;
|
int mouse_y = (int)my;
|
||||||
|
|
||||||
static bool clicked = false;
|
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) {
|
if (!clicked) {
|
||||||
int id = framebuffer->ReadPixel(1, mouse_x, mouse_y);
|
int id = framebuffer->ReadPixel(1, mouse_x, mouse_y);
|
||||||
|
|
||||||
if (id != -1)
|
selected_entity = id == -1 ?
|
||||||
scene_hierarchy.SetSelectedEntity({ (entt::entity)id, scene.get() });
|
Entity() : Entity((entt::entity)id, scene.get());
|
||||||
|
|
||||||
|
scene_hierarchy.SetSelectedEntity(selected_entity);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clicked = true;
|
clicked = true;
|
||||||
@@ -276,12 +283,19 @@ namespace OpenEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Begin("Statistics");
|
ImGui::Begin("Statistics");
|
||||||
|
ImGui::SeparatorText("Performance");
|
||||||
ImGui::Text("FPS: %0.0f", 1 / Time::DeltaTime());
|
ImGui::Text("FPS: %0.0f", 1 / Time::DeltaTime());
|
||||||
ImGui::Text("Renderer2D:");
|
ImGui::Text("Renderer2D:");
|
||||||
ImGui::Text("\t\tDraw calls: %d", stats.draw_calls);
|
ImGui::Text("\t\tDraw calls: %d", stats.draw_calls);
|
||||||
ImGui::Text("\t\tQuad count: %d", stats.quad_count);
|
ImGui::Text("\t\tQuad count: %d", stats.quad_count);
|
||||||
ImGui::Text("\t\tVertices count: %d", stats.GetTotalVertexCount());
|
ImGui::Text("\t\tVertices count: %d", stats.GetTotalVertexCount());
|
||||||
ImGui::Text("\t\tIndices count: %d", stats.GetTotalIndexCount());
|
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<TagComponent>().tag.c_str());
|
||||||
|
ImGui::Text("\t\tid: %d", (uint32_t)selected_entity);
|
||||||
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -396,7 +410,7 @@ namespace OpenEngine {
|
|||||||
int guizmo_operation = -1;
|
int guizmo_operation = -1;
|
||||||
|
|
||||||
Ref<Scene> scene;
|
Ref<Scene> scene;
|
||||||
std::vector<Entity> entities;
|
Entity selected_entity;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ namespace OpenEngine {
|
|||||||
element.normalized? GL_TRUE : GL_FALSE,
|
element.normalized? GL_TRUE : GL_FALSE,
|
||||||
layout.GetStride(),
|
layout.GetStride(),
|
||||||
(const void*)(intptr_t)element.offset);
|
(const void*)(intptr_t)element.offset);
|
||||||
|
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user