#include "ecs_inspector_panel.hpp" #include #include namespace sophia { void EcsInspectorPanel::onUpdate(const FrameInfo&) { ImGui::Begin("ECS Inspector"); entityScratch.clear(); for (entt::entity entity : registry.storage()) { entityScratch.push_back(entity); } ImGui::BeginChild("EntityList", ImVec2(0, 200), true); ImGuiListClipper clipper; clipper.Begin(static_cast(entityScratch.size())); while (clipper.Step()) { for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { entt::entity entity = entityScratch[static_cast(i)]; const TagComponent* tag = registry.try_get(entity); std::string label = tag ? tag->tag : "Entity"; ImGui::PushID(static_cast(entt::to_integral(entity))); if (ImGui::Selectable(label.c_str(), selected == entity)) { selected = entity; } ImGui::PopID(); } } ImGui::EndChild(); ImGui::Separator(); if (registry.valid(selected)) { if (auto* transform = registry.try_get(selected)) { ImGui::DragFloat3("Position", &transform->position.x, 0.1f); ImGui::DragFloat3("Scale", &transform->scale.x, 0.1f); ImGui::Text("Rotation: %.2f, %.2f, %.2f, %.2f", transform->rotation.w, transform->rotation.x, transform->rotation.y, transform->rotation.z); } if (auto* mesh = registry.try_get(selected)) { ImGui::Text("Mesh: index=%u generation=%u", mesh->handle.index, mesh->handle.generation); } } else { ImGui::TextDisabled("No entity selected"); } ImGui::End(); } } // namespace sophia