serialization: scene save/load (Unity-style YAML + UE-style GUID registry)
Engine-layer SceneSerializer (yaml-cpp submodule): entities/components
to versioned YAML, atomic clear-and-rebuild on load with per-entity
fault tolerance, missing-field defaults, unknown-component skip and
UUID dedup. Asset references are {Guid, Path} pairs resolved through
the new AssetManager GUID registry (assets/asset_registry.yaml) with
path fallback; procedural:// pseudo-paths rebuild from parameters.
Editor File menu gets Save/Load Scene modals; app re-resolves stale
entity handles via onSceneLoaded callback.
This commit is contained in:
@@ -172,14 +172,31 @@ namespace Engine
|
||||
|
||||
AssetCache<Model>& Models() { return m_Models; }
|
||||
|
||||
// ---- 资产 GUID 注册表(UE AssetRegistry 模式:中央注册表)----
|
||||
// 磁盘路径资产持久映射 GUID→路径(存 assets/asset_registry.yaml),
|
||||
// 场景文件以 GUID 为主键引用资产——重命名/移动资产不断引用,
|
||||
// Path 仅作人工可读提示与解析兜底。procedural:// 伪路径(参数
|
||||
// 确定性生成,无需稳定身份)不参与
|
||||
// 查询/分配(新路径分配 GUID 并立即持久化,崩溃安全)
|
||||
u64 GetOrCreateGUID(const std::string& path);
|
||||
// GUID → 路径;未登记返回空串
|
||||
std::string ResolveGUID(u64 guid) const;
|
||||
|
||||
// 后续扩展点:TextureHandle / MaterialHandle / ShaderHandle
|
||||
// 各自一个 AssetCache<T> + 便捷方法,模式与 Model 完全一致。
|
||||
|
||||
private:
|
||||
void LoadGUIDRegistry();
|
||||
void SaveGUIDRegistry() const;
|
||||
|
||||
IAssetUploader& m_Uploader;
|
||||
|
||||
AssetCache<Model> m_Models;
|
||||
AssetCache<Cubemap> m_Environments;
|
||||
|
||||
// GUID 注册表(双向);dirty 即时保存,无析构落盘依赖
|
||||
std::unordered_map<u64, std::string> m_GuidToPath;
|
||||
std::unordered_map<std::string, u64> m_PathToGuid;
|
||||
};
|
||||
} // namespace Assets
|
||||
} // namespace Engine
|
||||
|
||||
Reference in New Issue
Block a user