Formalize scene viewport resource path resolution

This commit is contained in:
2026-04-04 16:40:52 +08:00
parent ee8b5e8c44
commit 65d55c8536
3 changed files with 68 additions and 59 deletions

View File

@@ -1,47 +1,3 @@
#pragma once
#include <XCEngine/Core/Containers/String.h>
#include <filesystem>
namespace XCEngine {
namespace Editor {
namespace Detail {
inline Containers::String NormalizeSceneViewportShaderPath(const std::filesystem::path& path) {
return Containers::String(path.lexically_normal().generic_string().c_str());
}
inline std::filesystem::path GetSceneViewportShaderRepoRootPath() {
#ifdef XCENGINE_EDITOR_REPO_ROOT
return std::filesystem::path(XCENGINE_EDITOR_REPO_ROOT);
#else
return std::filesystem::path(__FILE__).parent_path().parent_path().parent_path();
#endif
}
inline Containers::String BuildSceneViewportShaderPath(const std::filesystem::path& relativePath) {
return NormalizeSceneViewportShaderPath(
GetSceneViewportShaderRepoRootPath() /
"editor" /
"resources" /
"shaders" /
"scene-viewport" /
relativePath);
}
} // namespace Detail
inline Containers::String GetSceneViewportInfiniteGridShaderPath() {
return Detail::BuildSceneViewportShaderPath(
std::filesystem::path("infinite-grid") / "infinite-grid.shader");
}
inline Containers::String GetSceneViewportObjectIdOutlineShaderPath() {
return Detail::BuildSceneViewportShaderPath(
std::filesystem::path("object-id-outline") / "object-id-outline.shader");
}
} // namespace Editor
} // namespace XCEngine
#include "SceneViewportResourcePaths.h"