From d599380f1d0b23df931f32abd9c456406c69ca11 Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Wed, 2 Jul 2025 00:09:39 +0300 Subject: [PATCH] More fixes suggested by sfan5 --- doc/lua_api.md | 4 ++-- src/client/game.cpp | 6 +++--- src/client/sky.h | 4 ++-- src/skyparams.h | 4 +++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/doc/lua_api.md b/doc/lua_api.md index de0688cfdf..bb5853084a 100644 --- a/doc/lua_api.md +++ b/doc/lua_api.md @@ -8843,9 +8843,9 @@ child will follow movement and rotation of that bone. bottom texture and the bottom edge of the top texture touch the east face). Some top and bottom textures expect to be aligned with the north face and will need to be rotated by -90 and 90 degrees, respectively, to fit the eastward orientation. + For `"skybox_back"` and `"skybox_front"` types, the textures should have an alpha channel. * `clouds`: Boolean for whether clouds appear. (default: `true`) - * `sky_color`: A table used in `"regular"`, `"skybox_back"`, `"skybox_front"` types only. For a skybox - the `textures` should have an alpha channel. Contains the following values (alpha is ignored): + * `sky_color`: A table used in `"regular"` `"skybox_back"` `"skybox_front"` types, containing the following values: * `day_sky`: ColorSpec, for the top half of the sky during the day. (default: `#61b5f5`) * `day_horizon`: ColorSpec, for the bottom half of the sky during the day. diff --git a/src/client/game.cpp b/src/client/game.cpp index 40892125d6..a4c7de1336 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -2858,7 +2858,6 @@ void Game::handleClientEvent_HudChange(ClientEvent *event, CameraOrientation *ca void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam) { - // Handle invalid sky type. if (!event->set_sky->isTextured() && !event->set_sky->hasAlpha() && event->set_sky->type != "plain") infostream << "Unknown sky type: " << (event->set_sky->type) << std::endl; @@ -2875,18 +2874,19 @@ void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam) sky->setFallbackBgColor(event->set_sky->bgcolor); // Use horizon tint for regular or skybox skies. - if (event->set_sky->isTextured() || event->set_sky->hasAlpha()) + if (event->set_sky->isTextured() || event->set_sky->hasAlpha()) { sky->setHorizonTint( event->set_sky->fog_sun_tint, event->set_sky->fog_moon_tint, event->set_sky->fog_tint_type ); - else + } else { sky->setHorizonTint( event->set_sky->bgcolor, event->set_sky->bgcolor, "custom" ); + } // Clear the old textures out in case we switch rendering type. sky->clearSkyboxTextures(); diff --git a/src/client/sky.h b/src/client/sky.h index f10cb203f6..63818235aa 100644 --- a/src/client/sky.h +++ b/src/client/sky.h @@ -82,7 +82,7 @@ public: const video::SColorf &getCloudColor() const { return m_cloudcolor_f; } void setVisible(bool visible) { m_visible = visible; } - void setType(std::string type) { m_sky_params.type = type; } + void setType(const std::string &type) { m_sky_params.type = type; } // Set only from set_sky API void setCloudsEnabled(bool clouds_enabled) { m_clouds_enabled = clouds_enabled; } @@ -125,7 +125,7 @@ public: private: aabb3f m_box{{0.0f, 0.0f, 0.0f}}; video::SMaterial m_materials[SKY_MATERIAL_COUNT]; - virtual void renderTextures(video::IVideoDriver *driver); + void renderTextures(video::IVideoDriver *driver); // How much sun & moon transition should affect horizon color float m_horizon_blend() diff --git a/src/skyparams.h b/src/skyparams.h index f89a28acac..a09de7bd9c 100644 --- a/src/skyparams.h +++ b/src/skyparams.h @@ -39,11 +39,13 @@ struct SkyboxParams float fog_start { -1.0f }; video::SColor fog_color { 0 }; // override, only used if alpha > 0 - // Check if this is a textured skybox and whether transparency is used + // Check if this is a textured skybox bool isTextured() const { return type == "skybox" || type == "skybox_back" || type == "skybox_front"; } + + // Check whether transparency is used bool hasAlpha() const { return type == "regular" || type == "skybox_back" || type == "skybox_front";