#pragma once #include #include #include #include #include #include #include "typedefs.hpp" #include "presets/WeatherPreset.hpp" class Level; class Player; class Camera; class Batch3D; class LineBatch; class ChunksRenderer; class ParticlesRenderer; class BlockWrapsRenderer; class PrecipitationRenderer; class GuidesRenderer; class TextsRenderer; class Shader; class Frustum; class Engine; class LevelFrontend; class Skybox; class PostProcessing; class DrawContext; class ModelBatch; class Assets; struct EngineSettings; struct Weather { WeatherPreset a {}; WeatherPreset b {}; float t = 1.0f; float speed = 0.0f; void update(float delta) { t += delta * speed; t = std::min(t, 1.0f); b.intensity = t; a.intensity = 1.0f - t; } float fogOpacity() const { return b.fogOpacity * t + a.fogOpacity * (1.0f - t); } float fogDencity() const { return b.fogDencity * t + a.fogDencity * (1.0f - t); } float fogCurve() const { return b.fogCurve * t + a.fogCurve * (1.0f - t); } }; class WorldRenderer { Engine& engine; const Level& level; Player& player; const Assets& assets; std::unique_ptr frustumCulling; std::unique_ptr lineBatch; std::unique_ptr batch3d; std::unique_ptr chunks; std::unique_ptr guides; std::unique_ptr skybox; std::unique_ptr modelBatch; float timer = 0.0f; bool debug = false; /// @brief Render block selection lines void renderBlockSelection(); void renderHands(const Camera& camera, float delta); /// @brief Render lines (selection and debug) /// @param camera active camera /// @param linesShader shader used void renderLines( const Camera& camera, Shader& linesShader, const DrawContext& pctx ); void renderBlockOverlay(const DrawContext& context); void setupWorldShader( Shader& shader, const Camera& camera, const EngineSettings& settings, float fogFactor ); public: std::unique_ptr texts; std::unique_ptr particles; std::unique_ptr blockWraps; std::unique_ptr precipitation; Weather weather {}; static bool showChunkBorders; static bool showEntitiesDebug; WorldRenderer(Engine& engine, LevelFrontend& frontend, Player& player); ~WorldRenderer(); void draw( const DrawContext& context, Camera& camera, bool hudVisible, bool pause, float delta, PostProcessing* postProcessing ); /// @brief Render level without diegetic interface /// @param context graphics context /// @param camera active camera /// @param settings engine settings void renderLevel( const DrawContext& context, const Camera& camera, const EngineSettings& settings, float delta, bool pause, bool hudVisible ); void clear(); void setDebug(bool flag); };