mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-10 14:53:51 +00:00
Magic number elimination: - Create protocol_constants.hpp, warden_constants.hpp, render_constants.hpp, ui_constants.hpp - Replace ~55 magic numbers across game_handler, warden_handler, m2_renderer_render Reduce nesting depth: - Extract 5 parseEffect* methods from handleSpellLogExecute (max indent 52 → 16 cols) - Extract resolveSpellSchool/playSpellCastSound/playSpellImpactSound from 3× duplicate audio blocks in handleSpellGo - Flatten SMSG_INVENTORY_CHANGE_FAILURE with early-return guards - Extract drawScreenEdgeVignette() for 3 duplicate vignette blocks DRY extract patterns: - Replace 12 compound expansion checks with isPreWotlk() across movement_handler (9), chat_handler (1), social_handler (1) const to constexpr: - Promote 23+ static const arrays/scalars to static constexpr across 12 source files Error handling: - Convert PIN auth from exceptions to std::optional<PinProof> - Add [[nodiscard]] to 15+ initialize/parse methods - Wrap ~20 unchecked initialize() calls with LOG_WARNING/LOG_ERROR Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
104 lines
3.2 KiB
C++
104 lines
3.2 KiB
C++
#pragma once
|
|
|
|
#include <vulkan/vulkan.h>
|
|
#include <vk_mem_alloc.h>
|
|
#include <glm/glm.hpp>
|
|
#include <vector>
|
|
|
|
namespace wowee {
|
|
namespace rendering {
|
|
|
|
class Camera;
|
|
class CameraController;
|
|
class WaterRenderer;
|
|
class M2Renderer;
|
|
class VkContext;
|
|
|
|
class SwimEffects {
|
|
public:
|
|
SwimEffects();
|
|
~SwimEffects();
|
|
|
|
[[nodiscard]] bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout);
|
|
void shutdown();
|
|
void recreatePipelines();
|
|
void update(const Camera& camera, const CameraController& cc,
|
|
const WaterRenderer& water, float deltaTime);
|
|
void render(VkCommandBuffer cmd, VkDescriptorSet perFrameSet);
|
|
void spawnFootSplash(const glm::vec3& footPos, float waterH);
|
|
void setM2Renderer(M2Renderer* renderer) { m2Renderer = renderer; }
|
|
|
|
private:
|
|
struct Particle {
|
|
glm::vec3 position;
|
|
glm::vec3 velocity;
|
|
float lifetime;
|
|
float maxLifetime;
|
|
float size;
|
|
float alpha;
|
|
};
|
|
|
|
struct InsectParticle {
|
|
glm::vec3 position;
|
|
glm::vec3 orbitCenter; // vegetation position to orbit around
|
|
float lifetime;
|
|
float maxLifetime;
|
|
float size;
|
|
float alpha;
|
|
float phase; // random phase offset for erratic motion
|
|
float orbitRadius;
|
|
float orbitSpeed;
|
|
float heightOffset; // height above plant
|
|
};
|
|
|
|
static constexpr int MAX_RIPPLE_PARTICLES = 200;
|
|
static constexpr int MAX_BUBBLE_PARTICLES = 150;
|
|
static constexpr int MAX_INSECT_PARTICLES = 50;
|
|
|
|
std::vector<Particle> ripples;
|
|
std::vector<Particle> bubbles;
|
|
std::vector<InsectParticle> insects;
|
|
|
|
// Vulkan objects
|
|
VkContext* vkCtx = nullptr;
|
|
M2Renderer* m2Renderer = nullptr;
|
|
|
|
// Ripple pipeline + dynamic buffer
|
|
VkPipeline ripplePipeline = VK_NULL_HANDLE;
|
|
VkPipelineLayout ripplePipelineLayout = VK_NULL_HANDLE;
|
|
::VkBuffer rippleDynamicVB = VK_NULL_HANDLE;
|
|
VmaAllocation rippleDynamicVBAlloc = VK_NULL_HANDLE;
|
|
VmaAllocationInfo rippleDynamicVBAllocInfo{};
|
|
VkDeviceSize rippleDynamicVBSize = 0;
|
|
|
|
// Bubble pipeline + dynamic buffer
|
|
VkPipeline bubblePipeline = VK_NULL_HANDLE;
|
|
VkPipelineLayout bubblePipelineLayout = VK_NULL_HANDLE;
|
|
::VkBuffer bubbleDynamicVB = VK_NULL_HANDLE;
|
|
VmaAllocation bubbleDynamicVBAlloc = VK_NULL_HANDLE;
|
|
VmaAllocationInfo bubbleDynamicVBAllocInfo{};
|
|
VkDeviceSize bubbleDynamicVBSize = 0;
|
|
|
|
// Insect pipeline + dynamic buffer
|
|
VkPipeline insectPipeline = VK_NULL_HANDLE;
|
|
VkPipelineLayout insectPipelineLayout = VK_NULL_HANDLE;
|
|
::VkBuffer insectDynamicVB = VK_NULL_HANDLE;
|
|
VmaAllocation insectDynamicVBAlloc = VK_NULL_HANDLE;
|
|
VmaAllocationInfo insectDynamicVBAllocInfo{};
|
|
VkDeviceSize insectDynamicVBSize = 0;
|
|
|
|
std::vector<float> rippleVertexData;
|
|
std::vector<float> bubbleVertexData;
|
|
std::vector<float> insectVertexData;
|
|
|
|
float rippleSpawnAccum = 0.0f;
|
|
float bubbleSpawnAccum = 0.0f;
|
|
float insectSpawnAccum = 0.0f;
|
|
|
|
void spawnRipple(const glm::vec3& pos, const glm::vec3& moveDir, float waterH);
|
|
void spawnBubble(const glm::vec3& pos, float waterH);
|
|
void spawnInsect(const glm::vec3& vegPos);
|
|
};
|
|
|
|
} // namespace rendering
|
|
} // namespace wowee
|