mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 05:51:51 +00:00
move weather from WorldRenderer to LevelFrontend
This commit is contained in:
parent
22f09d3659
commit
ac00c561ee
7 changed files with 26 additions and 10 deletions
|
|
@ -147,3 +147,7 @@ const ContentGfxCache& LevelFrontend::getContentGfxCache() const {
|
||||||
LevelController& LevelFrontend::getController() const {
|
LevelController& LevelFrontend::getController() const {
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Weather& LevelFrontend::getWeather() {
|
||||||
|
return weather;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "world/Weather.hpp"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class Assets;
|
class Assets;
|
||||||
|
|
@ -15,6 +17,7 @@ class LevelFrontend {
|
||||||
LevelController& controller;
|
LevelController& controller;
|
||||||
Assets& assets;
|
Assets& assets;
|
||||||
std::unique_ptr<ContentGfxCache> contentCache;
|
std::unique_ptr<ContentGfxCache> contentCache;
|
||||||
|
Weather weather {};
|
||||||
public:
|
public:
|
||||||
LevelFrontend(
|
LevelFrontend(
|
||||||
Engine& engine,
|
Engine& engine,
|
||||||
|
|
@ -28,4 +31,5 @@ public:
|
||||||
const ContentGfxCache& getContentGfxCache() const;
|
const ContentGfxCache& getContentGfxCache() const;
|
||||||
ContentGfxCache& getContentGfxCache();
|
ContentGfxCache& getContentGfxCache();
|
||||||
LevelController& getController() const;
|
LevelController& getController() const;
|
||||||
|
Weather& getWeather();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ LevelScreen::LevelScreen(
|
||||||
|
|
||||||
auto resetChunks = [=](bool) {
|
auto resetChunks = [=](bool) {
|
||||||
player->chunks->saveAndClear();
|
player->chunks->saveAndClear();
|
||||||
renderer->clear();
|
renderer->resetCache();
|
||||||
};
|
};
|
||||||
keepAlive(settings.graphics.backlight.observe(resetChunks));
|
keepAlive(settings.graphics.backlight.observe(resetChunks));
|
||||||
keepAlive(settings.graphics.softLighting.observe(resetChunks));
|
keepAlive(settings.graphics.softLighting.observe(resetChunks));
|
||||||
|
|
@ -94,7 +94,7 @@ LevelScreen::LevelScreen(
|
||||||
}));
|
}));
|
||||||
keepAlive(input.addCallback(BIND_CHUNKS_RELOAD, [=]() {
|
keepAlive(input.addCallback(BIND_CHUNKS_RELOAD, [=]() {
|
||||||
player->chunks->saveAndClear();
|
player->chunks->saveAndClear();
|
||||||
renderer->clear();
|
renderer->resetCache();
|
||||||
return false;
|
return false;
|
||||||
}));
|
}));
|
||||||
controller->preQuitCallbacks.listen([this]() {
|
controller->preQuitCallbacks.listen([this]() {
|
||||||
|
|
@ -153,7 +153,7 @@ void LevelScreen::loadDecorations() {
|
||||||
}
|
}
|
||||||
auto data = io::read_object(CLIENT_FILE);
|
auto data = io::read_object(CLIENT_FILE);
|
||||||
if (data.has("weather")) {
|
if (data.has("weather")) {
|
||||||
renderer->getWeather().deserialize(data["weather"]);
|
frontend->getWeather().deserialize(data["weather"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,7 +161,7 @@ void LevelScreen::saveDecorations() {
|
||||||
io::create_directory("world:client");
|
io::create_directory("world:client");
|
||||||
|
|
||||||
auto data = dv::object();
|
auto data = dv::object();
|
||||||
data["weather"] = renderer->getWeather().serialize();
|
data["weather"] = frontend->getWeather().serialize();
|
||||||
io::write_json(CLIENT_FILE, data, true);
|
io::write_json(CLIENT_FILE, data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,7 +257,7 @@ void LevelScreen::update(float delta) {
|
||||||
|
|
||||||
hud->update(hudVisible);
|
hud->update(hudVisible);
|
||||||
|
|
||||||
const Weather& weather = renderer->getWeather();
|
const Weather& weather = frontend->getWeather();
|
||||||
const Player& player = playerController->getPlayer();
|
const Player& player = playerController->getPlayer();
|
||||||
const Camera& camera = *player.currentCamera;
|
const Camera& camera = *player.currentCamera;
|
||||||
decorator->update(paused ? 0.0f : delta, camera, weather);
|
decorator->update(paused ? 0.0f : delta, camera, weather);
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include "voxels/Chunks.hpp"
|
#include "voxels/Chunks.hpp"
|
||||||
#include "window/Camera.hpp"
|
#include "window/Camera.hpp"
|
||||||
#include "world/Level.hpp"
|
#include "world/Level.hpp"
|
||||||
|
#include "world/Weather.hpp"
|
||||||
#include "WorldRenderer.hpp"
|
#include "WorldRenderer.hpp"
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@
|
||||||
#include "window/Window.hpp"
|
#include "window/Window.hpp"
|
||||||
#include "world/Level.hpp"
|
#include "world/Level.hpp"
|
||||||
#include "world/LevelEvents.hpp"
|
#include "world/LevelEvents.hpp"
|
||||||
|
#include "world/Weather.hpp"
|
||||||
#include "world/World.hpp"
|
#include "world/World.hpp"
|
||||||
#include "debug/Logger.hpp"
|
#include "debug/Logger.hpp"
|
||||||
|
|
||||||
|
|
@ -84,6 +85,7 @@ WorldRenderer::WorldRenderer(
|
||||||
level(frontend.getLevel()),
|
level(frontend.getLevel()),
|
||||||
player(player),
|
player(player),
|
||||||
assets(*engine.getAssets()),
|
assets(*engine.getAssets()),
|
||||||
|
weather(frontend.getWeather()),
|
||||||
frustumCulling(std::make_unique<Frustum>()),
|
frustumCulling(std::make_unique<Frustum>()),
|
||||||
lineBatch(std::make_unique<LineBatch>()),
|
lineBatch(std::make_unique<LineBatch>()),
|
||||||
batch3d(std::make_unique<Batch3D>(BATCH3D_CAPACITY)),
|
batch3d(std::make_unique<Batch3D>(BATCH3D_CAPACITY)),
|
||||||
|
|
@ -590,7 +592,7 @@ void WorldRenderer::renderBlockOverlay(const DrawContext& wctx) {
|
||||||
batch3d->flush();
|
batch3d->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldRenderer::clear() {
|
void WorldRenderer::resetCache() {
|
||||||
chunksRenderer->clear();
|
chunksRenderer->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
#include "typedefs.hpp"
|
#include "typedefs.hpp"
|
||||||
|
|
||||||
#include "presets/WeatherPreset.hpp"
|
#include "presets/WeatherPreset.hpp"
|
||||||
#include "world/Weather.hpp"
|
|
||||||
#include "window/Camera.hpp"
|
#include "window/Camera.hpp"
|
||||||
#include "util/ObjectsKeeper.hpp"
|
#include "util/ObjectsKeeper.hpp"
|
||||||
|
|
||||||
|
|
@ -36,6 +35,7 @@ class Skybox;
|
||||||
class TextsRenderer;
|
class TextsRenderer;
|
||||||
class CloudsRenderer;
|
class CloudsRenderer;
|
||||||
struct EngineSettings;
|
struct EngineSettings;
|
||||||
|
struct Weather;
|
||||||
|
|
||||||
class WorldRenderer final : public util::ObjectsKeeper {
|
class WorldRenderer final : public util::ObjectsKeeper {
|
||||||
public:
|
public:
|
||||||
|
|
@ -54,7 +54,7 @@ public:
|
||||||
PostProcessing& postProcessing
|
PostProcessing& postProcessing
|
||||||
);
|
);
|
||||||
|
|
||||||
void clear();
|
void resetCache();
|
||||||
|
|
||||||
void setDebug(bool flag);
|
void setDebug(bool flag);
|
||||||
|
|
||||||
|
|
@ -66,6 +66,7 @@ private:
|
||||||
const Level& level;
|
const Level& level;
|
||||||
Player& player;
|
Player& player;
|
||||||
const Assets& assets;
|
const Assets& assets;
|
||||||
|
Weather& weather;
|
||||||
std::unique_ptr<Frustum> frustumCulling;
|
std::unique_ptr<Frustum> frustumCulling;
|
||||||
std::unique_ptr<LineBatch> lineBatch;
|
std::unique_ptr<LineBatch> lineBatch;
|
||||||
std::unique_ptr<Batch3D> batch3d;
|
std::unique_ptr<Batch3D> batch3d;
|
||||||
|
|
@ -77,13 +78,11 @@ private:
|
||||||
std::unique_ptr<DebugLinesRenderer> debugLines;
|
std::unique_ptr<DebugLinesRenderer> debugLines;
|
||||||
std::unique_ptr<PrecipitationRenderer> precipitation;
|
std::unique_ptr<PrecipitationRenderer> precipitation;
|
||||||
std::unique_ptr<CloudsRenderer> cloudsRenderer;
|
std::unique_ptr<CloudsRenderer> cloudsRenderer;
|
||||||
Weather weather {};
|
|
||||||
|
|
||||||
float timer = 0.0f;
|
float timer = 0.0f;
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
bool lightsDebug = false;
|
bool lightsDebug = false;
|
||||||
bool gbufferPipeline = false;
|
bool gbufferPipeline = false;
|
||||||
|
|
||||||
bool dirtySettings = false;
|
bool dirtySettings = false;
|
||||||
|
|
||||||
/// @brief Render block selection lines
|
/// @brief Render block selection lines
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "world/Level.hpp"
|
#include "world/Level.hpp"
|
||||||
#include "world/World.hpp"
|
#include "world/World.hpp"
|
||||||
|
#include "world/Weather.hpp"
|
||||||
|
|
||||||
using namespace scripting;
|
using namespace scripting;
|
||||||
|
|
||||||
|
|
@ -9,6 +10,11 @@ static Weather& require_weather() {
|
||||||
if (level == nullptr) {
|
if (level == nullptr) {
|
||||||
throw std::runtime_error("world is not open");
|
throw std::runtime_error("world is not open");
|
||||||
}
|
}
|
||||||
|
if (renderer == nullptr) {
|
||||||
|
throw std::runtime_error(
|
||||||
|
"world frontend is not initialized yet (wait for on_hud_open event)"
|
||||||
|
);
|
||||||
|
}
|
||||||
return renderer->getWeather();
|
return renderer->getWeather();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue