Files
XCEngine/editor/app/Rendering/Viewport/SceneViewportResourcePaths.h

63 lines
2.1 KiB
C++

#pragma once
#include "Environment/EditorRuntimePaths.h"
#include <XCEngine/Core/Containers/String.h>
#include <filesystem>
namespace XCEngine::UI::Editor::App {
struct SceneViewportShaderPaths {
::XCEngine::Containers::String infiniteGridShaderPath = {};
::XCEngine::Containers::String selectionMaskShaderPath = {};
::XCEngine::Containers::String selectionOutlineShaderPath = {};
bool IsComplete() const {
return !infiniteGridShaderPath.Empty() &&
!selectionMaskShaderPath.Empty() &&
!selectionOutlineShaderPath.Empty();
}
};
inline ::XCEngine::Containers::String NormalizeSceneViewportResourcePath(
const std::filesystem::path& path) {
return ::XCEngine::Containers::String(
path.lexically_normal().generic_string().c_str());
}
inline std::filesystem::path GetSceneViewportResourceRootPath(
const EditorRuntimePaths& runtimePaths) {
return runtimePaths.resourceRoot.lexically_normal();
}
inline ::XCEngine::Containers::String BuildSceneViewportResourcePath(
const std::filesystem::path& resourceRoot,
const std::filesystem::path& relativePath) {
return NormalizeSceneViewportResourcePath(
resourceRoot / relativePath);
}
inline SceneViewportShaderPaths BuildSceneViewportShaderPaths(
const EditorRuntimePaths& runtimePaths) {
const std::filesystem::path resourceRoot =
GetSceneViewportResourceRootPath(runtimePaths);
SceneViewportShaderPaths paths = {};
paths.infiniteGridShaderPath = BuildSceneViewportResourcePath(
resourceRoot,
std::filesystem::path("shaders") / "scene-viewport" /
"infinite-grid" / "infinite-grid.shader");
paths.selectionMaskShaderPath = BuildSceneViewportResourcePath(
resourceRoot,
std::filesystem::path("shaders") / "scene-viewport" /
"selection-mask" / "selection-mask.shader");
paths.selectionOutlineShaderPath = BuildSceneViewportResourcePath(
resourceRoot,
std::filesystem::path("shaders") / "scene-viewport" /
"selection-outline" / "selection-outline.shader");
return paths;
}
} // namespace XCEngine::UI::Editor::App