rain_renderer.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include "../i_render_pass.h"
  3. #include "rain_gpu.h"
  4. #include <QVector3D>
  5. #include <cstdint>
  6. #include <memory>
  7. #include <vector>
  8. namespace Game::Systems {
  9. class RainManager;
  10. }
  11. namespace Render::GL {
  12. class Buffer;
  13. class Renderer;
  14. class RainRenderer : public IRenderPass {
  15. public:
  16. RainRenderer();
  17. ~RainRenderer() override;
  18. void set_enabled(bool enabled) { m_enabled = enabled; }
  19. [[nodiscard]] auto is_enabled() const -> bool { return m_enabled; }
  20. void configure(float world_width, float world_height,
  21. std::uint32_t seed = 12345U,
  22. Game::Map::WeatherType type = Game::Map::WeatherType::Rain);
  23. void set_intensity(float intensity);
  24. void set_weather_type(Game::Map::WeatherType type);
  25. void set_wind_strength(float strength);
  26. void set_camera_position(const QVector3D &position);
  27. void submit(Renderer &renderer, ResourceManager *resources) override;
  28. void clear();
  29. private:
  30. void generate_rain_drops();
  31. void update_weather_params();
  32. bool m_enabled = false;
  33. float m_world_width = 100.0F;
  34. float m_world_height = 100.0F;
  35. float m_intensity = 0.0F;
  36. float m_target_intensity = 0.0F;
  37. std::uint32_t m_seed = 12345U;
  38. QVector3D m_camera_position{0.0F, 0.0F, 0.0F};
  39. float m_rain_area_radius = 50.0F;
  40. float m_rain_height = 30.0F;
  41. std::vector<RainDropInstanceGpu> m_rain_drops;
  42. std::unique_ptr<Buffer> m_instance_buffer;
  43. std::size_t m_instance_count = 0;
  44. RainBatchParams m_params;
  45. static constexpr std::size_t k_max_rain_drops = 5000;
  46. static constexpr std::size_t k_max_snow_drops = 3000;
  47. static constexpr float k_intensity_lerp_speed = 2.0F;
  48. };
  49. } // namespace Render::GL