engine: sync editor rendering and ui changes

This commit is contained in:
2026-04-08 16:09:15 +08:00
parent 31756847ab
commit 162f1cc12e
153 changed files with 4454 additions and 2990 deletions

View File

@@ -4,6 +4,7 @@
#include "Viewport/SceneViewportShaderPaths.h"
#include <XCEngine/Core/Asset/ResourceManager.h>
#include <XCEngine/Resources/BuiltinResources.h>
#include <XCEngine/Resources/Shader/ShaderLoader.h>
#include <filesystem>
@@ -12,9 +13,11 @@
namespace {
using XCEngine::Editor::GetSceneViewportCameraGizmoIconPath;
using XCEngine::Editor::GetSceneViewportDirectionalLightGizmoIconPath;
using XCEngine::Editor::GetSceneViewportInfiniteGridShaderPath;
using XCEngine::Editor::GetSceneViewportMainLightGizmoIconPath;
using XCEngine::Editor::GetSceneViewportObjectIdOutlineShaderPath;
using XCEngine::Editor::GetSceneViewportPointLightGizmoIconPath;
using XCEngine::Editor::GetSceneViewportSpotLightGizmoIconPath;
using XCEngine::Resources::GetBuiltinObjectIdOutlineShaderPath;
using XCEngine::Resources::LoadResult;
using XCEngine::Resources::ResourceHandle;
using XCEngine::Resources::ResourceManager;
@@ -27,22 +30,29 @@ using XCEngine::Resources::ShaderType;
TEST(SceneViewportShaderPathsTest, ResolvePathsUnderEditorResources) {
const std::filesystem::path gridPath(GetSceneViewportInfiniteGridShaderPath().CStr());
const std::filesystem::path outlinePath(GetSceneViewportObjectIdOutlineShaderPath().CStr());
const std::filesystem::path cameraIconPath(GetSceneViewportCameraGizmoIconPath().CStr());
const std::filesystem::path lightIconPath(GetSceneViewportMainLightGizmoIconPath().CStr());
const std::filesystem::path directionalLightIconPath(GetSceneViewportDirectionalLightGizmoIconPath().CStr());
const std::filesystem::path pointLightIconPath(GetSceneViewportPointLightGizmoIconPath().CStr());
const std::filesystem::path spotLightIconPath(GetSceneViewportSpotLightGizmoIconPath().CStr());
EXPECT_TRUE(gridPath.is_absolute());
EXPECT_TRUE(outlinePath.is_absolute());
EXPECT_TRUE(cameraIconPath.is_absolute());
EXPECT_TRUE(lightIconPath.is_absolute());
EXPECT_TRUE(directionalLightIconPath.is_absolute());
EXPECT_TRUE(pointLightIconPath.is_absolute());
EXPECT_TRUE(spotLightIconPath.is_absolute());
EXPECT_TRUE(std::filesystem::exists(gridPath));
EXPECT_TRUE(std::filesystem::exists(outlinePath));
EXPECT_TRUE(std::filesystem::exists(cameraIconPath));
EXPECT_TRUE(std::filesystem::exists(lightIconPath));
EXPECT_TRUE(std::filesystem::exists(directionalLightIconPath));
EXPECT_TRUE(std::filesystem::exists(pointLightIconPath));
EXPECT_TRUE(std::filesystem::exists(spotLightIconPath));
EXPECT_NE(gridPath.generic_string().find("editor/resources/shaders/scene-viewport"), std::string::npos);
EXPECT_NE(outlinePath.generic_string().find("editor/resources/shaders/scene-viewport"), std::string::npos);
EXPECT_NE(cameraIconPath.generic_string().find("editor/resources/Icons"), std::string::npos);
EXPECT_NE(lightIconPath.generic_string().find("editor/resources/Icons"), std::string::npos);
EXPECT_NE(directionalLightIconPath.generic_string().find("editor/resources/Icons"), std::string::npos);
EXPECT_NE(pointLightIconPath.generic_string().find("editor/resources/Icons"), std::string::npos);
EXPECT_NE(spotLightIconPath.generic_string().find("editor/resources/Icons"), std::string::npos);
EXPECT_EQ(directionalLightIconPath.filename().generic_string(), "directional_light_gizmo.png");
EXPECT_EQ(pointLightIconPath.filename().generic_string(), "point_light_gizmo.png");
EXPECT_EQ(spotLightIconPath.filename().generic_string(), "spot_light_gizmo.png");
}
TEST(SceneViewportShaderPathsTest, ShaderLoaderLoadsSceneViewportInfiniteGridShader) {
@@ -81,7 +91,7 @@ TEST(SceneViewportShaderPathsTest, ResourceManagerLoadsSceneViewportOutlineShade
ResourceManager& manager = ResourceManager::Get();
manager.Shutdown();
const ResourceHandle<Shader> shaderHandle = manager.Load<Shader>(GetSceneViewportObjectIdOutlineShaderPath());
const ResourceHandle<Shader> shaderHandle = manager.Load<Shader>(GetBuiltinObjectIdOutlineShaderPath());
ASSERT_TRUE(shaderHandle.IsValid());
const ShaderPass* pass = shaderHandle->FindPass("ObjectIdOutline");
@@ -94,7 +104,7 @@ TEST(SceneViewportShaderPathsTest, ResourceManagerLoadsSceneViewportOutlineShade
ShaderBackend::D3D12);
ASSERT_NE(fragment, nullptr);
EXPECT_NE(
std::string(fragment->sourceCode.CStr()).find("XC_EDITOR_SCENE_VIEW_OBJECT_ID_OUTLINE_D3D12_PS"),
std::string(fragment->sourceCode.CStr()).find("XC_BUILTIN_OBJECT_ID_OUTLINE_D3D12_PS"),
std::string::npos);
manager.Shutdown();