Refactor editor rendering contracts

This commit is contained in:
2026-04-28 02:57:49 +08:00
parent 3bc0cfcf08
commit b1ae6c462d
47 changed files with 798 additions and 377 deletions

View File

@@ -1,33 +1,20 @@
#include "Scene/SceneViewportFeature.h"
#include "Panels/EditorPanelIds.h"
#include "UiTextureHost.h"
#include "Viewport/SceneViewportResourcePaths.h"
#include "Viewport/ViewportHostService.h"
#include "EditorSceneRuntime.h"
#include "State/EditorCommandFocusService.h"
namespace XCEngine::UI::Editor::App {
void SceneViewportFeature::Initialize(
const std::filesystem::path& repoRoot,
Rendering::Host::UiTextureHost& textureHost,
const BuiltInIcons* builtInIcons,
ViewportHostService& viewportHostService) {
m_renderService.Initialize(BuildSceneViewportShaderPaths(repoRoot));
viewportHostService.SetContentRenderer(
kScenePanelId,
&m_renderService,
SceneViewportRenderService::GetViewportResourceRequirements());
m_controller.Initialize(repoRoot, textureHost, builtInIcons);
const EditorIconService* iconService,
EditorSceneViewportRuntime& sceneViewportRuntime) {
m_sceneViewportRuntime = &sceneViewportRuntime;
m_controller.Initialize(iconService);
}
void SceneViewportFeature::Shutdown(
Rendering::Host::UiTextureHost& textureHost,
ViewportHostService& viewportHostService) {
viewportHostService.SetContentRenderer(kScenePanelId, nullptr, {});
m_controller.Shutdown(textureHost);
m_renderService.Shutdown();
void SceneViewportFeature::Shutdown() {
m_controller.Shutdown();
m_sceneViewportRuntime = nullptr;
}
void SceneViewportFeature::ResetInteractionState() {
@@ -40,17 +27,23 @@ void SceneViewportFeature::SetCommandFocusService(
}
void SceneViewportFeature::SyncRenderRequest(EditorSceneRuntime& sceneRuntime) {
m_renderService.SetRenderRequest(
sceneRuntime.BuildSceneViewportRenderRequest());
if (m_sceneViewportRuntime != nullptr) {
m_sceneViewportRuntime->SetRenderRequest(
sceneRuntime.BuildSceneViewportRenderRequest());
}
}
void SceneViewportFeature::Update(
EditorSceneRuntime& sceneRuntime,
const UIEditorWorkspaceComposeState& composeState,
const UIEditorWorkspaceComposeFrame& composeFrame) {
if (m_sceneViewportRuntime == nullptr) {
return;
}
m_controller.Update(
sceneRuntime,
m_renderService,
m_sceneViewportRuntime->GetObjectPicker(),
composeState,
composeFrame);
SyncRenderRequest(sceneRuntime);