From 863c4012304191a4dfe5c1f038826ee3131c67ac Mon Sep 17 00:00:00 2001 From: Sergey Lapin Date: Thu, 16 Apr 2026 05:39:56 +0300 Subject: [PATCH] De-clutter the scene --- src/features/editScene/EditorApp.cpp | 2 ++ src/features/editScene/components/CellGridModule.cpp | 2 ++ .../editScene/components/GeneratedPhysicsTag.hpp | 11 +++++++++++ src/features/editScene/systems/CellGridSystem.cpp | 4 ++++ src/features/editScene/systems/EditorUISystem.cpp | 6 +++++- src/features/editScene/systems/SceneSerializer.cpp | 4 +++- 6 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/features/editScene/components/GeneratedPhysicsTag.hpp diff --git a/src/features/editScene/EditorApp.cpp b/src/features/editScene/EditorApp.cpp index 911d87d..0cd335f 100644 --- a/src/features/editScene/EditorApp.cpp +++ b/src/features/editScene/EditorApp.cpp @@ -18,6 +18,7 @@ #include "components/EditorMarker.hpp" #include "components/PhysicsCollider.hpp" #include "components/RigidBody.hpp" +#include "components/GeneratedPhysicsTag.hpp" #include "components/Light.hpp" #include "components/Camera.hpp" #include "components/Lod.hpp" @@ -246,6 +247,7 @@ void EditorApp::setupECS() // Register physics components m_world.component(); + m_world.component(); m_world.component(); // Register light and camera components diff --git a/src/features/editScene/components/CellGridModule.cpp b/src/features/editScene/components/CellGridModule.cpp index 6966bb7..a3f322c 100644 --- a/src/features/editScene/components/CellGridModule.cpp +++ b/src/features/editScene/components/CellGridModule.cpp @@ -1,5 +1,6 @@ #include "CellGridModule.hpp" #include "CellGrid.hpp" +#include "GeneratedPhysicsTag.hpp" #include #include @@ -41,6 +42,7 @@ void registerComponents(flecs::world& world) // FurnitureTemplateComponent world.component(); + world.component(); } } // namespace CellGridModule diff --git a/src/features/editScene/components/GeneratedPhysicsTag.hpp b/src/features/editScene/components/GeneratedPhysicsTag.hpp new file mode 100644 index 0000000..aec313f --- /dev/null +++ b/src/features/editScene/components/GeneratedPhysicsTag.hpp @@ -0,0 +1,11 @@ +#ifndef EDITSCENE_GENERATEDPHYSICSTAG_HPP +#define EDITSCENE_GENERATEDPHYSICSTAG_HPP +#pragma once + +/** + * Marker component for entities auto-generated by systems (e.g. physics colliders). + * Entities with this tag are hidden from the editor hierarchy and not serialized. + */ +struct GeneratedPhysicsTag {}; + +#endif // EDITSCENE_GENERATEDPHYSICSTAG_HPP diff --git a/src/features/editScene/systems/CellGridSystem.cpp b/src/features/editScene/systems/CellGridSystem.cpp index 0603f0b..775a160 100644 --- a/src/features/editScene/systems/CellGridSystem.cpp +++ b/src/features/editScene/systems/CellGridSystem.cpp @@ -10,6 +10,7 @@ #include #include "../components/ProceduralMaterial.hpp" #include "../components/ProceduralTexture.hpp" +#include "../components/GeneratedPhysicsTag.hpp" #include #include #include @@ -2670,6 +2671,7 @@ void CellGridSystem::buildPhysicsColliders(flecs::entity entity) physicsParent.set({nullptr, parentPos, parentRot, parentScale}); physicsParent.set(RigidBodyComponent()); + physicsParent.add(); meshData.physicsParentEntity = physicsParent; // Add colliders for main cell grid meshes (local to parent) @@ -2728,6 +2730,7 @@ void CellGridSystem::buildPhysicsColliders(flecs::entity entity) physicsParent.set({nullptr, parentPos, parentRot, parentScale}); physicsParent.set(RigidBodyComponent()); + physicsParent.add(); plazaIt->second.physicsParentEntity = physicsParent; addPhysicsCollider(physicsParent, plazaIt->second.meshName, Ogre::Vector3::ZERO, Ogre::Quaternion::IDENTITY); @@ -2746,6 +2749,7 @@ void CellGridSystem::buildPhysicsColliders(flecs::entity entity) physicsParent.set({nullptr, parentPos, parentRot, parentScale}); physicsParent.set(RigidBodyComponent()); + physicsParent.add(); lotIt->second.physicsParentEntity = physicsParent; addPhysicsCollider(physicsParent, lotIt->second.meshName, Ogre::Vector3::ZERO, Ogre::Quaternion::IDENTITY); diff --git a/src/features/editScene/systems/EditorUISystem.cpp b/src/features/editScene/systems/EditorUISystem.cpp index 1b37daa..98c4f2e 100644 --- a/src/features/editScene/systems/EditorUISystem.cpp +++ b/src/features/editScene/systems/EditorUISystem.cpp @@ -1,3 +1,4 @@ +#include "../components/GeneratedPhysicsTag.hpp" #include "EditorUISystem.hpp" #include "../components/EntityName.hpp" #include "../components/Transform.hpp" @@ -347,9 +348,12 @@ void EditorUISystem::renderEntityNode(flecs::entity entity, int depth) } // Collect children using flecs::ChildOf relationship + // (skip auto-generated physics entities) std::vector children; entity.children([&](flecs::entity child) { - children.push_back(child); + if (!child.has()) { + children.push_back(child); + } }); bool hasChildren = !children.empty(); diff --git a/src/features/editScene/systems/SceneSerializer.cpp b/src/features/editScene/systems/SceneSerializer.cpp index 20014a7..d5be8af 100644 --- a/src/features/editScene/systems/SceneSerializer.cpp +++ b/src/features/editScene/systems/SceneSerializer.cpp @@ -16,6 +16,7 @@ #include "../components/Primitive.hpp" #include "../components/TriangleBuffer.hpp" #include "../components/CellGrid.hpp" +#include "../components/GeneratedPhysicsTag.hpp" #include "EditorUISystem.hpp" #include #include @@ -206,7 +207,8 @@ nlohmann::json SceneSerializer::serializeEntity(flecs::entity entity) // Serialize children json["children"] = nlohmann::json::array(); entity.children([&](flecs::entity child) { - if (child.has()) { + if (child.has() && + !child.has()) { json["children"].push_back(serializeEntity(child)); } });