biome_renderer.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include "../../game/map/terrain.h"
  3. #include "../i_render_pass.h"
  4. #include "grass_gpu.h"
  5. #include <QVector3D>
  6. #include <cstdint>
  7. #include <memory>
  8. #include <vector>
  9. namespace Render::GL {
  10. class Buffer;
  11. class Renderer;
  12. class BiomeRenderer : public IRenderPass {
  13. public:
  14. BiomeRenderer();
  15. ~BiomeRenderer() override;
  16. void configure(const Game::Map::TerrainHeightMap &height_map,
  17. const Game::Map::BiomeSettings &biome_settings);
  18. void submit(Renderer &renderer, ResourceManager *resources) override;
  19. void refresh_grass();
  20. void clear();
  21. [[nodiscard]] bool is_gpu_ready() const {
  22. return m_grassInstanceBuffer != nullptr || m_grassInstanceCount == 0;
  23. }
  24. private:
  25. void generate_grass_instances();
  26. int m_width = 0;
  27. int m_height = 0;
  28. float m_tile_size = 1.0F;
  29. std::vector<float> m_heightData;
  30. std::vector<Game::Map::TerrainType> m_terrain_types;
  31. Game::Map::BiomeSettings m_biome_settings;
  32. std::uint32_t m_noiseSeed = 0U;
  33. std::vector<GrassInstanceGpu> m_grassInstances;
  34. std::unique_ptr<Buffer> m_grassInstanceBuffer;
  35. std::size_t m_grassInstanceCount = 0;
  36. GrassBatchParams m_grassParams;
  37. bool m_grassInstancesDirty = false;
  38. };
  39. } // namespace Render::GL