From cda703b0f4a3fb58062c2cd6979f8db5cd1923c6 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 11 Mar 2026 11:32:08 -0700 Subject: [PATCH] refactor: consolidate duplicate ShadowPush structure definition Move ShadowPush from 4 separate rendering modules (character_renderer, m2_renderer, terrain_renderer, wmo_renderer) into shared vk_frame_data.hpp header. This eliminates 4 identical local struct definitions and ensures consistency across all shadow rendering passes. Add vk_frame_data.hpp include to character_renderer.cpp. --- include/rendering/vk_frame_data.hpp | 6 ++++++ src/rendering/character_renderer.cpp | 3 +-- src/rendering/m2_renderer.cpp | 1 - src/rendering/terrain_renderer.cpp | 1 - src/rendering/wmo_renderer.cpp | 2 -- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/rendering/vk_frame_data.hpp b/include/rendering/vk_frame_data.hpp index 595b76ac..76f9cc29 100644 --- a/include/rendering/vk_frame_data.hpp +++ b/include/rendering/vk_frame_data.hpp @@ -25,5 +25,11 @@ struct GPUPushConstants { glm::mat4 model; }; +// Push constants for shadow rendering passes +struct ShadowPush { + glm::mat4 lightSpaceMatrix; + glm::mat4 model; +}; + } // namespace rendering } // namespace wowee diff --git a/src/rendering/character_renderer.cpp b/src/rendering/character_renderer.cpp index 59efa577..c4d930b4 100644 --- a/src/rendering/character_renderer.cpp +++ b/src/rendering/character_renderer.cpp @@ -21,6 +21,7 @@ #include "rendering/vk_shader.hpp" #include "rendering/vk_buffer.hpp" #include "rendering/vk_utils.hpp" +#include "rendering/vk_frame_data.hpp" #include "rendering/camera.hpp" #include "pipeline/asset_manager.hpp" #include "pipeline/blp_loader.hpp" @@ -2678,8 +2679,6 @@ void CharacterRenderer::renderShadow(VkCommandBuffer cmd, const glm::mat4& light vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, shadowPipelineLayout_, 1, 1, &shadowParamsSet_, 0, nullptr); - struct ShadowPush { glm::mat4 lightSpaceMatrix; glm::mat4 model; }; - const float shadowRadiusSq = shadowRadius * shadowRadius; for (auto& pair : instances) { auto& inst = pair.second; diff --git a/src/rendering/m2_renderer.cpp b/src/rendering/m2_renderer.cpp index 6f93147c..b39b8f8c 100644 --- a/src/rendering/m2_renderer.cpp +++ b/src/rendering/m2_renderer.cpp @@ -3070,7 +3070,6 @@ void M2Renderer::renderShadow(VkCommandBuffer cmd, const glm::mat4& lightSpaceMa if (!shadowPipeline_ || !shadowParamsSet_) return; if (instances.empty() || models.empty()) return; - struct ShadowPush { glm::mat4 lightSpaceMatrix; glm::mat4 model; }; struct ShadowParamsUBO { int32_t useBones = 0; int32_t useTexture = 0; diff --git a/src/rendering/terrain_renderer.cpp b/src/rendering/terrain_renderer.cpp index 3af644cf..8ed7ba65 100644 --- a/src/rendering/terrain_renderer.cpp +++ b/src/rendering/terrain_renderer.cpp @@ -965,7 +965,6 @@ void TerrainRenderer::renderShadow(VkCommandBuffer cmd, const glm::mat4& lightSp // Identity model matrix — terrain vertices are already in world space static const glm::mat4 identity(1.0f); - struct ShadowPush { glm::mat4 lightSpaceMatrix; glm::mat4 model; }; ShadowPush push{ lightSpaceMatrix, identity }; vkCmdPushConstants(cmd, shadowPipelineLayout_, VK_SHADER_STAGE_VERTEX_BIT, 0, 128, &push); diff --git a/src/rendering/wmo_renderer.cpp b/src/rendering/wmo_renderer.cpp index 84c7f956..ab08f2a3 100644 --- a/src/rendering/wmo_renderer.cpp +++ b/src/rendering/wmo_renderer.cpp @@ -1715,8 +1715,6 @@ void WMORenderer::renderShadow(VkCommandBuffer cmd, const glm::mat4& lightSpaceM vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, shadowPipelineLayout_, 0, 1, &shadowParamsSet_, 0, nullptr); - struct ShadowPush { glm::mat4 lightSpaceMatrix; glm::mat4 model; }; - // WMO shadow cull uses the ortho half-extent (shadow map coverage) rather than // the proximity radius so that distant buildings whose shadows reach the player // are still rendered into the shadow map.