cleanup
This commit is contained in:
parent
bf5a5b243f
commit
a1860ff668
@ -116,7 +116,8 @@ void Decorator::updateRandom(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
float intensity = weather.intensity * weather.fall.maxIntensity;
|
float intensity = weather.intensity * weather.fall.maxIntensity;
|
||||||
if (dst2 < 128 && random.randFloat() < glm::pow(intensity, 2.0f) && rainSplash.has_value()) {
|
if (rainSplash.has_value() && dst2 < 128 &&
|
||||||
|
random.randFloat() < glm::pow(intensity, 2.0f)) {
|
||||||
auto treg = util::get_texture_region(
|
auto treg = util::get_texture_region(
|
||||||
assets, "particles:rain_splash_0", ""
|
assets, "particles:rain_splash_0", ""
|
||||||
);
|
);
|
||||||
@ -239,13 +240,11 @@ void Decorator::updateTextNotes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Decorator::updateRandomSounds(float delta, const Weather& weather) {
|
void Decorator::updateRandomSounds(float delta, const Weather& weather) {
|
||||||
float thunderRate = weather.a.thunderRate * weather.a.intensity +
|
|
||||||
weather.b.thunderRate * weather.b.intensity;
|
|
||||||
thunderTimer += delta;
|
thunderTimer += delta;
|
||||||
util::PseudoRandom random(rand());
|
util::PseudoRandom random(rand());
|
||||||
if (thunderTimer >= 1.0f) {
|
if (thunderTimer >= 1.0f) {
|
||||||
thunderTimer = 0.0f;
|
thunderTimer = 0.0f;
|
||||||
if (random.randFloat() < thunderRate) {
|
if (random.randFloat() < weather.thunderRate()) {
|
||||||
audio::play(
|
audio::play(
|
||||||
assets.get<audio::Sound>("ambient/thunder"),
|
assets.get<audio::Sound>("ambient/thunder"),
|
||||||
glm::vec3(),
|
glm::vec3(),
|
||||||
|
|||||||
@ -388,7 +388,7 @@ void WorldRenderer::draw(
|
|||||||
renderBlockOverlay(wctx);
|
renderBlockOverlay(wctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rendering fullscreen quad with
|
// Rendering fullscreen quad
|
||||||
auto screenShader = assets.get<Shader>("screen");
|
auto screenShader = assets.get<Shader>("screen");
|
||||||
screenShader->use();
|
screenShader->use();
|
||||||
screenShader->uniform1f("u_timer", timer);
|
screenShader->uniform1f("u_timer", timer);
|
||||||
|
|||||||
@ -10,21 +10,34 @@ struct WeatherPreset : Serializable {
|
|||||||
struct {
|
struct {
|
||||||
/// @brief Precipitation texture
|
/// @brief Precipitation texture
|
||||||
std::string texture;
|
std::string texture;
|
||||||
|
|
||||||
/// @brief Fall sound
|
/// @brief Fall sound
|
||||||
std::string noise;
|
std::string noise;
|
||||||
|
|
||||||
/// @brief Vertical speed
|
/// @brief Vertical speed
|
||||||
float vspeed = 1.0f;
|
float vspeed = 1.0f;
|
||||||
|
|
||||||
/// @brief Max horizontal speed
|
/// @brief Max horizontal speed
|
||||||
float hspeed = 0.1f;
|
float hspeed = 0.1f;
|
||||||
|
|
||||||
/// @brief UV scaling
|
/// @brief UV scaling
|
||||||
float scale = 0.1f;
|
float scale = 0.1f;
|
||||||
|
|
||||||
/// @brief Fall opacity interpreted as zero.
|
/// @brief Fall opacity interpreted as zero.
|
||||||
/// @example if 0.8 then opacity range is 0.8-1.0 for 0.0-1.0 intensity
|
/// @example if 0.8 then opacity range is 0.8-max for 0.0-1.0 intensity
|
||||||
float minOpacity = 0.0f;
|
float minOpacity = 0.0f;
|
||||||
|
|
||||||
|
/// @brief Fall opacity interpreted as one.
|
||||||
|
/// @example if 0.8 then opacity range is min-0.8 for 0.0-1.0 intensity
|
||||||
float maxOpacity = 1.0f;
|
float maxOpacity = 1.0f;
|
||||||
|
|
||||||
|
/// @brief Max fall intencity
|
||||||
|
/// (influences opacity, noise volume and splashes frequency)
|
||||||
float maxIntensity = 1.0f;
|
float maxIntensity = 1.0f;
|
||||||
|
|
||||||
/// @brief Clip texture by alpha channel
|
/// @brief Clip texture by alpha channel
|
||||||
bool opaque = false;
|
bool opaque = false;
|
||||||
|
|
||||||
/// @brief Fall splash
|
/// @brief Fall splash
|
||||||
std::optional<ParticlesPreset> splash;
|
std::optional<ParticlesPreset> splash;
|
||||||
} fall {};
|
} fall {};
|
||||||
@ -38,8 +51,10 @@ struct WeatherPreset : Serializable {
|
|||||||
/// @brief Weather fog curve
|
/// @brief Weather fog curve
|
||||||
float fogCurve = 1.0f;
|
float fogCurve = 1.0f;
|
||||||
|
|
||||||
|
/// @brief Clouds opacity
|
||||||
float clouds = 0.0f;
|
float clouds = 0.0f;
|
||||||
|
|
||||||
|
/// @brief Thunder rate in range 0.0-1.0 (1.0 is 100% - every second)
|
||||||
float thunderRate = 0.0f;
|
float thunderRate = 0.0f;
|
||||||
|
|
||||||
/// @brief Weather effects intensity
|
/// @brief Weather effects intensity
|
||||||
|
|||||||
@ -41,6 +41,10 @@ struct Weather : Serializable {
|
|||||||
return b.fogCurve * t + a.fogCurve * (1.0f - t);
|
return b.fogCurve * t + a.fogCurve * (1.0f - t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float thunderRate() const {
|
||||||
|
return b.thunderRate * t + a.thunderRate * (1.0f - t);
|
||||||
|
}
|
||||||
|
|
||||||
dv::value serialize() const override {
|
dv::value serialize() const override {
|
||||||
return dv::object({
|
return dv::object({
|
||||||
{"a", a.serialize()},
|
{"a", a.serialize()},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user