De-clutter the scene
This commit is contained in:
@@ -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<PhysicsColliderComponent>();
|
||||
m_world.component<GeneratedPhysicsTag>();
|
||||
m_world.component<RigidBodyComponent>();
|
||||
|
||||
// Register light and camera components
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "CellGridModule.hpp"
|
||||
#include "CellGrid.hpp"
|
||||
#include "GeneratedPhysicsTag.hpp"
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <Ogre.h>
|
||||
|
||||
@@ -41,6 +42,7 @@ void registerComponents(flecs::world& world)
|
||||
|
||||
// FurnitureTemplateComponent
|
||||
world.component<FurnitureTemplateComponent>();
|
||||
world.component<GeneratedPhysicsTag>();
|
||||
}
|
||||
|
||||
} // namespace CellGridModule
|
||||
|
||||
11
src/features/editScene/components/GeneratedPhysicsTag.hpp
Normal file
11
src/features/editScene/components/GeneratedPhysicsTag.hpp
Normal file
@@ -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
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <OgreStaticGeometry.h>
|
||||
#include "../components/ProceduralMaterial.hpp"
|
||||
#include "../components/ProceduralTexture.hpp"
|
||||
#include "../components/GeneratedPhysicsTag.hpp"
|
||||
#include <OgreSceneManager.h>
|
||||
#include <OgreMeshManager.h>
|
||||
#include <OgreEntity.h>
|
||||
@@ -2670,6 +2671,7 @@ void CellGridSystem::buildPhysicsColliders(flecs::entity entity)
|
||||
physicsParent.set<TransformComponent>({nullptr, parentPos, parentRot,
|
||||
parentScale});
|
||||
physicsParent.set<RigidBodyComponent>(RigidBodyComponent());
|
||||
physicsParent.add<GeneratedPhysicsTag>();
|
||||
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<TransformComponent>({nullptr, parentPos, parentRot,
|
||||
parentScale});
|
||||
physicsParent.set<RigidBodyComponent>(RigidBodyComponent());
|
||||
physicsParent.add<GeneratedPhysicsTag>();
|
||||
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<TransformComponent>({nullptr, parentPos, parentRot,
|
||||
parentScale});
|
||||
physicsParent.set<RigidBodyComponent>(RigidBodyComponent());
|
||||
physicsParent.add<GeneratedPhysicsTag>();
|
||||
lotIt->second.physicsParentEntity = physicsParent;
|
||||
addPhysicsCollider(physicsParent, lotIt->second.meshName,
|
||||
Ogre::Vector3::ZERO, Ogre::Quaternion::IDENTITY);
|
||||
|
||||
@@ -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<flecs::entity> children;
|
||||
entity.children([&](flecs::entity child) {
|
||||
children.push_back(child);
|
||||
if (!child.has<GeneratedPhysicsTag>()) {
|
||||
children.push_back(child);
|
||||
}
|
||||
});
|
||||
bool hasChildren = !children.empty();
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "../components/Primitive.hpp"
|
||||
#include "../components/TriangleBuffer.hpp"
|
||||
#include "../components/CellGrid.hpp"
|
||||
#include "../components/GeneratedPhysicsTag.hpp"
|
||||
#include "EditorUISystem.hpp"
|
||||
#include <random>
|
||||
#include <fstream>
|
||||
@@ -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<EditorMarkerComponent>()) {
|
||||
if (child.has<EditorMarkerComponent>() &&
|
||||
!child.has<GeneratedPhysicsTag>()) {
|
||||
json["children"].push_back(serializeEntity(child));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user