add WeatherPreset

This commit is contained in:
MihailRis
2025-02-26 02:24:16 +03:00
parent 787011d164
commit 35cf07b0f0
3 changed files with 99 additions and 46 deletions
+26
View File
@@ -0,0 +1,26 @@
#include "WeatherPreset.hpp"
#include "data/dv_util.hpp"
dv::value WeatherPreset::serialize() const {
auto root = dv::object();
auto froot = dv::object();
froot["texture"] = fall.texture;
froot["vspeed"] = fall.vspeed;
froot["hspeed"] = fall.hspeed;
froot["scale"] = fall.scale;
root["fall"] = froot;
return root;
}
void WeatherPreset::deserialize(const dv::value& src) {
if (src.has("fall")) {
const auto& froot = src["fall"];
froot.at("texture").get(fall.texture);
froot.at("vspeed").get(fall.vspeed);
froot.at("hspeed").get(fall.hspeed);
froot.at("scale").get(fall.scale);
}
}
+19
View File
@@ -0,0 +1,19 @@
#pragma once
#include "interfaces/Serializable.hpp"
struct WeatherPreset : Serializable {
struct {
/// @brief Precipitation texture
std::string texture;
/// @brief Vertical speed
float vspeed = 1.0f;
/// @brief Max horizontal speed
float hspeed = 0.1f;
/// @brief UV scaling
float scale = 0.1f;
} fall {};
dv::value serialize() const override;
void deserialize(const dv::value& src) override;
};