Commit Graph
6 Commits
Author SHA1 Message Date
Cursor Agentand西风逍遥游 d80df444aa refactor(scene): register link kinds instead of hard-coding them
A scene link keeps an external object in step with the node it hangs off. The
kinds were a closed enum with a switch in TransformSystem, so scene had to
include graphics, physics and audio to do the casts, and no other module could
ever attach to the tree without editing SceneHost.h -- particles, voxel,
spritestack, avatar and weather all had to stay outside it.

Kinds are registered now (scene/SceneLink.h). The module owning the target type
supplies pushWorld / pullWorld / alive, keeps the casts on its own side where
the type is complete, and scene never learns what a Renderable3D is. Dispatch is
a function-pointer table rather than virtual calls, since link sync runs for
every dirty node every frame.

The six typed helpers (linkRenderable2D and friends) stay as conveniences and
now resolve their kind by name, so they return false rather than crash when the
module that registers it was trimmed out. The script API already named kinds
with strings, which is exactly the registry key, so it is unchanged.

Direction is now the right way round: graphics, physics and audio depend on
scene rather than scene on them, and scene drops from L5 to L1. What remains is
scene -> graphics from pickScreenAt / collectFrustumIdsAt, which take a Camera3D
and read its projection; that is recorded in the back-edge whitelist as the next
thing to move.

Each provider lives in a SceneLinks.cpp, sharing the basename so the three come
out of the build together when scene is disabled.

Co-authored-by: 西风逍遥游 <sunxfancy@gmail.com>
2026-08-18 13:46:25 +00:00
西风逍遥游 fb5ea51e26 fix(sceneloader): migrate merged SceneLoader to SceneLink API
The scene-ecs-integration merge left SceneLoader.cpp and its tests
referencing the removed SceneNode::linkTarget/linkKind fields, and mount()
referenced out-of-scope linkRenderables/slots. Move linking onto the new
SceneLink/links API (findLink + links.push_back), drop the obsolete
linkAllMeshNodes path, and fix mount() to use d.slots.
2026-08-18 14:26:43 +08:00
西风逍遥游 011b8b7b5e Merge branch 'main' into codex/scene-ecs-integration 2026-08-18 10:55:33 +08:00
西风逍遥游 6199d94b9e feat(scene): optimize 3d scene loading pipeline 2026-08-18 09:47:19 +08:00
西风逍遥游 1c755f8940 feat(scene): scene/script-ECS integration, generic links, serialization & picking
Scene module overhaul: per-node script entities (SceneObject/SceneEntity/NodeRef), script ECS view-cache perf, generic multi-link system (renderable/physics/camera/audio), API completeness (transform getters, hierarchy ops, quaternions, tags/layer), incremental transforms, id index, reconcile moves, node events, JSON serialization, ray/frustum picking, spatial-index sync and SceneLoader auto AABB. Includes Cmdline/PhysFS argv0 robustness fix for unit tests.
2026-08-17 22:45:18 +08:00
西风逍遥游 115e14c069 Add SceneLoader module: 3D scene loading + fast-diff hot reload
Adds a new EVSceneLoader module that decodes a 3D model (glTF/OBJ/FBX/GLB
via Assimp) into an ECS SceneHost tree of GameObjects and provides a
hot-reload that only updates the objects that changed.

- load(path): builds one SceneNode (GameObject) per aiNode, plus a child
  GameObject per aiMesh linked to a graphics::Renderable3D (mesh uploaded
  once, diffuse material resolved).
- reload(path)/diff(path): diffTree produces a SceneDiff of Add/Remove/
  Modify/Move; applyTreeDiff updates only those objects. Unchanged
  GameObjects keep their Renderable3D (no re-upload / no rebuild); only
  newly added mesh nodes get a fresh mesh, removed ones are destroyed.
- Registered as EVSceneLoader in the engine, module, and test builds.
- Adds test/sceneloader.cpp covering diff/apply logic, renderable identity
  preservation, and a load + hot-reload integration test.
2026-08-16 03:56:38 +08:00