refactor: drive scene view outline from object id

This commit is contained in:
2026-04-01 17:33:07 +08:00
parent 409e08d03c
commit b85571d9d4
8 changed files with 168 additions and 710 deletions

View File

@@ -2,7 +2,6 @@
#include <XCEngine/Core/Math/Vector3.h>
#include <XCEngine/Core/Math/Vector4.h>
#include <XCEngine/Rendering/RenderCameraData.h>
#include <XCEngine/Rendering/RenderContext.h>
#include <XCEngine/Rendering/RenderSurface.h>
@@ -12,9 +11,10 @@
#include <XCEngine/RHI/RHIPipelineLayout.h>
#include <XCEngine/RHI/RHIPipelineState.h>
#include <XCEngine/RHI/RHIResourceView.h>
#include <XCEngine/RHI/RHISampler.h>
#include <array>
#include <cstdint>
#include <vector>
namespace XCEngine {
namespace Editor {
@@ -23,17 +23,23 @@ class SceneViewportSelectionOutlinePass {
public:
~SceneViewportSelectionOutlinePass() = default;
static constexpr uint32_t kMaxSelectedObjectCount = 256u;
void Shutdown();
bool Render(
const Rendering::RenderContext& renderContext,
const Rendering::RenderSurface& surface,
RHI::RHIResourceView* maskTextureView);
RHI::RHIResourceView* objectIdTextureView,
const std::vector<uint64_t>& selectedObjectIds,
bool debugSelectionMask = false);
private:
struct OutlineConstants {
Math::Vector4 viewportSizeAndTexelSize = Math::Vector4::Zero();
Math::Vector4 outlineColorAndWidth = Math::Vector4::Zero();
Math::Vector4 selectedInfo = Math::Vector4::Zero();
std::array<Math::Vector4, kMaxSelectedObjectCount> selectedObjectColors = {};
};
bool EnsureInitialized(const Rendering::RenderContext& renderContext);
@@ -48,9 +54,6 @@ private:
RHI::RHIDescriptorSet* m_constantSet = nullptr;
RHI::RHIDescriptorPool* m_texturePool = nullptr;
RHI::RHIDescriptorSet* m_textureSet = nullptr;
RHI::RHIDescriptorPool* m_samplerPool = nullptr;
RHI::RHIDescriptorSet* m_samplerSet = nullptr;
RHI::RHISampler* m_sampler = nullptr;
};
} // namespace Editor