Move scene viewport shaders into editor resources

This commit is contained in:
2026-04-03 15:43:21 +08:00
parent f1981dd523
commit 24a200e126
22 changed files with 248 additions and 137 deletions

View File

@@ -1,5 +1,7 @@
#include "Passes/SceneViewportGridPass.h"
#include "Viewport/SceneViewportShaderPaths.h"
namespace XCEngine {
namespace Editor {
@@ -32,6 +34,10 @@ private:
} // namespace
SceneViewportGridPassRenderer::SceneViewportGridPassRenderer()
: m_gridPass(GetSceneViewportInfiniteGridShaderPath()) {
}
void SceneViewportGridPassRenderer::Shutdown() {
m_gridPass.Shutdown();
}

View File

@@ -12,6 +12,7 @@ namespace Editor {
class SceneViewportGridPassRenderer {
public:
SceneViewportGridPassRenderer();
~SceneViewportGridPassRenderer() = default;
void Shutdown();

View File

@@ -1,5 +1,7 @@
#include "Passes/SceneViewportSelectionOutlinePass.h"
#include "Viewport/SceneViewportShaderPaths.h"
namespace XCEngine {
namespace Editor {
@@ -40,6 +42,10 @@ private:
} // namespace
SceneViewportSelectionOutlinePassRenderer::SceneViewportSelectionOutlinePassRenderer()
: m_outlinePass(GetSceneViewportObjectIdOutlineShaderPath()) {
}
void SceneViewportSelectionOutlinePassRenderer::Shutdown() {
m_outlinePass.Shutdown();
}

View File

@@ -14,6 +14,7 @@ namespace Editor {
class SceneViewportSelectionOutlinePassRenderer {
public:
SceneViewportSelectionOutlinePassRenderer();
~SceneViewportSelectionOutlinePassRenderer() = default;
void Shutdown();

View File

@@ -0,0 +1,47 @@
#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