Files
Seele/docs/subsystems/scene-ecs-components-actors.md
coding-agent 1324d903cb docs: add per-subsystem deep-dives + cross-repo orientation (for coding agents)
Adds docs/ — a navigation layer on top of AGENTS.md for future coding
agents working on the Seele engine and the MeshShadingDemo harness.

- docs/README.md: index + 30-second orientation + how-to-use workflow.
- docs/cross-repo.md: the engine<->demo contract (2-symbol ABI, the
  ComponentSystem<...> demo pattern with the FlyCamSystem example, the
  CMake in-tree vs install(EXPORT) split, a where-to-look task map).
- docs/subsystems/*.md: 16 per-subsystem deep-dives (scene/ECS, systems,
  game-interface, window, graphics backends, render graph, materials,
  physics, UI, assets, platform, core utils). Each maps public types to
  their defining headers and gives file:line pointers + gotchas.

All cross-links verified resolving. This is documentation only — no source
changes.
2026-11-07 22:08:50 +00:00

6.8 KiB

Scene / ECS / Components / Actors

The entt-based ECS: entities, components, the scene update loop, actors, and the light/fluid/physics subsystems embedded in the scene.

This is a navigation doc: it tells you where things live, how data actually flows, and the sharp edges — so you can orient in minutes instead of hours. It complements the repository's AGENTS.md (map + rules) and the cross-repo guide (engine ↔ demo contract). Everything below is grounded in the checked-out source at commit d3ed573.

Key types & where they live

Type Defined in
Scene src/Engine/Scene/Scene.h
Entity src/Engine/Actor/Entity.h
Actor src/Engine/Actor/Actor.h
CameraActor src/Engine/Actor/CameraActor.h
DirectionalLightActor src/Engine/Actor/DirectionalLightActor.h
PointLightActor src/Engine/Actor/PointLightActor.h
StaticMeshActor src/Engine/Actor/StaticMeshActor.h
Component::Component src/Engine/Component/Component.h
Component::Transform src/Engine/Component/Transform.h
Component::Camera src/Engine/Component/Camera.h
Component::Mesh src/Engine/Component/Mesh.h
Component::Collider src/Engine/Component/Collider.h
Component::RigidBody src/Engine/Component/RigidBody.h
Component::DirectionalLight src/Engine/Component/DirectionalLight.h
Component::PointLight src/Engine/Component/PointLight.h
Component::Skybox src/Engine/Component/Skybox.h
Component::FluidGrid src/Engine/Component/FluidGrid.h
Component::TerrainTile src/Engine/Component/TerrainTile.h
Component::WaterTile src/Engine/Component/WaterTile.h
Component::ShapeBase src/Engine/Component/ShapeBase.h
Component::BoxCollider/MeshCollider/SphereCollider src/Engine/Component/BoxCollider.h
LightEnvironment src/Engine/Scene/LightEnvironment.h
FluidScene src/Engine/Scene/FluidScene.h

Paths above are resolved against the actual source tree (namespace ≈ directory in this codebase). A (search) marker means the file contains the name but may also define others — open it and grep. git grep is always a fallback. The full per-file map is in Where to look below.

Data flow / lifecycle

Scene (src/Engine/Scene/Scene.h) wraps an entt::registry (public member 'registry'). API: createEntity(), destroyEntity(entity), attachComponent(entity, args...), accessComponent(entity), view<Components...>(func) (C++20 constrained template requiring std::is_invocable_v), constructCallback()/destroyCallback() (entt on_construct/on_destroy hooks), getLightEnvironment(), getFluidScene(), getGraphics(), update(deltaTime), bakeLighting(). Private: OFluidScene fluidScene, OLightEnvironment lightEnv, PhysicsSystem physics, ArrayGfx::OTexture2D lightMaps. Scene constructor takes Gfx::PGraphics. Components are plain structs registered with entt (Component.h defines the base Component struct). Actor (src/Engine/Actor/Actor.h) is an Entity wrapper — DEFINE_REF(Actor) gives PActor. CameraActor/DirectionalLightActor/PointLightActor/StaticMeshActor are convenience subclasses that attach their component in the constructor (CameraActor::getCameraComponent() returns Component::Camera&). CameraActor is the only actor that GameView uses to extract the active camera (GameView::render() iterates view<Camera,Transform> and picks the one with c.mainCamera==true). FluidScene (src/Engine/Scene/FluidScene.h) is a standalone fluid simulation scene (NOT in a Fluid/ directory — it lives in Scene/). LightEnvironment (Scene/LightEnvironment.h) manages baked lightmaps and commit(). PhysicsSystem (src/Engine/Physics/PhysicsSystem.h) is embedded in Scene and updated in Scene::update().

Where to look

Path What's there
src/Engine/Scene/Scene.h + Scene.cpp entt registry wrapper
src/Engine/Actor/Actor.h + Actor.cpp base actor
src/Engine/Actor/CameraActor.h + .cpp
src/Engine/Actor/DirectionalLightActor.h + .cpp attaches DirectionalLight component, registers with LightEnvironment
src/Engine/Actor/PointLightActor.h + .cpp
src/Engine/Actor/StaticMeshActor.h + .cpp
src/Engine/Component/Component.h base component struct
src/Engine/Component/Transform.h + .cpp position/rotation/scale, world matrix
src/Engine/Component/Camera.h mainCamera flag, fov, near/far, projection params
src/Engine/Component/Mesh.h references Graphics::Mesh asset
src/Engine/Component/ShapeBase.h + .cpp collision shape base, 8.9KB impl — shape serialization, mesh import
src/Engine/Component/FluidGrid.h fluid simulation grid component
src/Engine/Scene/FluidScene.h + .cpp standalone fluid sim scene, 11.5KB impl
src/Engine/Scene/LightEnvironment.h + .cpp baked lighting, lightmap commit
src/Engine/Physics/PhysicsSystem.h + .cpp embedded physics, 18.5KB impl
src/Engine/Physics/BVH.h + .cpp bounding volume hierarchy for collision

Gotchas & sharp edges

  • FluidScene is at src/Engine/Scene/FluidScene.h — there is NO Fluid/ directory. Do not look for it under Engine/Fluid/.
  • Component::Mesh, Component::Collider, Component::BoxCollider, Component::MeshCollider, Component::SphereCollider exist as files but some are EMPTY (0 bytes: BoxCollider.h, MeshCollider.h, SphereCollider.h). Only ShapeBase.cpp (8.9KB) has actual collision shape logic.
  • The entt::registry is a PUBLIC member of Scene — you can access entities directly via scene.registry without going through the accessComponent/attachComponent helpers (though the helpers are the intended API).
  • GameView::render() finds the main camera by iterating ALL Camera+Transform components and checking the mainCamera boolean flag. If no component has mainCamera=true, cam/transform remain default-constructed and the render will use an identity camera.
  • Scene has NO explicit render method — rendering is driven externally by GameView::render() which calls renderGraph.render(cam, transform) directly. Scene::update() only runs ECS systems and physics.
  • bakeLighting() on Scene bakes lightmaps into the LightEnvironment; the results are committed via lightEnv->commit() in GameView::update().
  • PhysicsSystem is a VALUE member of Scene (not a pointer) — it is constructed/destroyed with the Scene.
  • DirectionalLightActor and PointLightActor register their light with the scene's LightEnvironment in their constructor — deleting the actor does NOT unregister the light from the environment (check LightEnvironment.cpp for the actual lifecycle).

Generated from a full read of the checked-out source at commit d3ed573. If a path has moved, git grep for the type name — the engine is small enough to find anything in seconds.