Kelsidavis-WoWee/include/rendering/overlay_system.hpp

74 lines
2.4 KiB
C++
Raw Normal View History

#pragma once
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <glm/mat4x4.hpp>
#include <vulkan/vulkan.h>
#include <vk_mem_alloc.h>
#include <functional>
#include <optional>
namespace wowee {
namespace rendering {
class VkContext;
/// Manages selection circle and fullscreen overlay Vulkan pipelines.
/// Extracted from Renderer to isolate overlay rendering resources.
class OverlaySystem {
public:
/// Height query callable: returns floor height at (x, y) or (x, y, probeZ).
using HeightQuery2D = std::function<std::optional<float>(float x, float y)>;
using HeightQuery3D = std::function<std::optional<float>(float x, float y, float probeZ)>;
explicit OverlaySystem(VkContext* ctx);
~OverlaySystem();
OverlaySystem(const OverlaySystem&) = delete;
OverlaySystem& operator=(const OverlaySystem&) = delete;
// Selection circle
void setSelectionCircle(const glm::vec3& pos, float radius, const glm::vec3& color);
void clearSelectionCircle();
void renderSelectionCircle(const glm::mat4& view, const glm::mat4& projection,
VkCommandBuffer cmd,
HeightQuery2D terrainHeight,
HeightQuery3D wmoHeight,
HeightQuery3D m2Height);
// Fullscreen color overlay (underwater tint, etc.)
void renderOverlay(const glm::vec4& color, VkCommandBuffer cmd);
/// Destroy all Vulkan resources (called before VkContext teardown).
void cleanup();
/// Recreate pipelines after swapchain resize / MSAA change.
void recreatePipelines();
private:
void initSelectionCircle();
void initOverlayPipeline();
VkContext* vkCtx_ = nullptr;
// Selection circle resources
VkPipeline selCirclePipeline_ = VK_NULL_HANDLE;
VkPipelineLayout selCirclePipelineLayout_ = VK_NULL_HANDLE;
::VkBuffer selCircleVertBuf_ = VK_NULL_HANDLE;
VmaAllocation selCircleVertAlloc_ = VK_NULL_HANDLE;
::VkBuffer selCircleIdxBuf_ = VK_NULL_HANDLE;
VmaAllocation selCircleIdxAlloc_ = VK_NULL_HANDLE;
int selCircleVertCount_ = 0;
glm::vec3 selCirclePos_{0.0f};
glm::vec3 selCircleColor_{1.0f, 0.0f, 0.0f};
float selCircleRadius_ = 1.5f;
bool selCircleVisible_ = false;
// Fullscreen overlay resources
VkPipeline overlayPipeline_ = VK_NULL_HANDLE;
VkPipelineLayout overlayPipelineLayout_ = VK_NULL_HANDLE;
};
} // namespace rendering
} // namespace wowee