feat: add camera viewport rect render areas

This commit is contained in:
2026-04-01 13:01:11 +08:00
parent 0fe02fd1b4
commit f80fb9860e
9 changed files with 219 additions and 12 deletions

View File

@@ -2,6 +2,7 @@
#include <XCEngine/Components/Component.h>
#include <XCEngine/Core/Math/Color.h>
#include <XCEngine/Core/Math/Rect.h>
namespace XCEngine {
namespace Components {
@@ -49,6 +50,9 @@ public:
uint32_t GetCullingMask() const { return m_cullingMask; }
void SetCullingMask(uint32_t value) { m_cullingMask = value; }
const Math::Rect& GetViewportRect() const { return m_viewportRect; }
void SetViewportRect(const Math::Rect& value);
const Math::Color& GetClearColor() const { return m_clearColor; }
void SetClearColor(const Math::Color& value) { m_clearColor = value; }
@@ -65,6 +69,7 @@ private:
bool m_primary = true;
CameraClearMode m_clearMode = CameraClearMode::Auto;
uint32_t m_cullingMask = 0xFFFFFFFFu;
Math::Rect m_viewportRect = Math::Rect(0.0f, 0.0f, 1.0f, 1.0f);
Math::Color m_clearColor = Math::Color(0.192f, 0.302f, 0.475f, 1.0f);
};

View File

@@ -1,6 +1,7 @@
#pragma once
#include <XCEngine/Core/Math/Color.h>
#include <XCEngine/Core/Math/Rect.h>
#include <XCEngine/RHI/RHIEnums.h>
#include <cstdint>
@@ -29,6 +30,13 @@ public:
void SetDepthAttachment(RHI::RHIResourceView* depthAttachment) { m_depthAttachment = depthAttachment; }
RHI::RHIResourceView* GetDepthAttachment() const { return m_depthAttachment; }
void SetRenderArea(const Math::RectInt& renderArea);
void ResetRenderArea();
bool HasCustomRenderArea() const { return m_hasCustomRenderArea; }
Math::RectInt GetRenderArea() const;
uint32_t GetRenderAreaWidth() const;
uint32_t GetRenderAreaHeight() const;
void SetClearColorOverride(const Math::Color& clearColor);
void ClearClearColorOverride();
bool HasClearColorOverride() const { return m_hasClearColorOverride; }
@@ -48,6 +56,8 @@ private:
uint32_t m_height = 0;
std::vector<RHI::RHIResourceView*> m_colorAttachments;
RHI::RHIResourceView* m_depthAttachment = nullptr;
bool m_hasCustomRenderArea = false;
Math::RectInt m_renderArea;
bool m_hasClearColorOverride = false;
Math::Color m_clearColorOverride = Math::Color::Black();
bool m_autoTransition = true;