]> git.lizzy.rs Git - minetest.git/commitdiff
Sky: transmit body_orbit_tilt to client. (#13193)
authorsofar <sofar@foo-projects.org>
Sun, 26 Feb 2023 00:08:33 +0000 (16:08 -0800)
committerGitHub <noreply@github.com>
Sun, 26 Feb 2023 00:08:33 +0000 (01:08 +0100)
This obsoletes the current client-side setting entirely. The server can
transmit the tilt to the client directly and will send 0.0f as default
value.

Co-authored-by: x2048 <codeforsmile@gmail.com>
Co-authored-by: sfan5 <sfan5@live.de>
12 files changed:
builtin/settingtypes.txt
doc/lua_api.txt
minetest.conf.example
src/client/game.cpp
src/client/sky.cpp
src/client/sky.h
src/defaultsettings.cpp
src/network/clientpackethandler.cpp
src/network/networkprotocol.h
src/script/lua_api/l_object.cpp
src/server.cpp
src/skyparams.h

index 14cfdbc0b63e0840c344a9a56596c27d47aef44d..3645c16cd47ba7542a00b72b6cc63a7dfc2eb40d 100644 (file)
@@ -443,11 +443,6 @@ shadow_update_frames (Map shadows update frames) int 8 1 16
 #    Minimum value: 1.0; maximum value: 15.0
 shadow_soft_radius (Soft shadow radius) float 5.0 1.0 15.0
 
-#    Set the tilt of Sun/Moon orbit in degrees.
-#    Value of 0 means no tilt / vertical orbit.
-#    Minimum value: 0.0; maximum value: 60.0
-shadow_sky_body_orbit_tilt (Sky Body Orbit Tilt) float 0.0 -60.0 60.0
-
 [**Post processing]
 
 #    Set the exposure compensation in EV units.
index 85f88db335448aa449ec8da4662fd7646b92f6ed..19e87b368c0a510e8aa36f77083001754a26bb90 100644 (file)
@@ -7316,6 +7316,8 @@ child will follow movement and rotation of that bone.
     * `sky_parameters` is a table with the following optional fields:
         * `base_color`: ColorSpec, changes fog in "skybox" and "plain".
           (default: `#ffffff`)
+        * `body_orbit_tilt`: Float, angle of sun/moon orbit in degrees, relative to Y axis.
+           Valid range [-60.0,60.0] (default: 0.0)
         * `type`: Available types:
             * `"regular"`: Uses 0 textures, `base_color` ignored
             * `"skybox"`: Uses 6 textures, `base_color` used as fog.
index 38a102e7535338894fdf2e6a56a77be24fdc649b..bbabf98d55264133ed0e8c8f7695fa1be97a3a89 100644 (file)
 #    type: float min: 1 max: 15
 # shadow_soft_radius = 5.0
 
-#    Set the tilt of Sun/Moon orbit in degrees.
-#    Value of 0 means no tilt / vertical orbit.
-#    Minimum value: 0.0; maximum value: 60.0
-#    type: float min: -60 max: 60
-# shadow_sky_body_orbit_tilt = 0.0
-
 ### Post processing
 
 #    Set the exposure compensation factor.
index 833093673514f032cd48ebcd8fbd1480b0530459..cd0e67b42105f42305addfbbd387a15c1ac57e85 100644 (file)
@@ -2976,6 +2976,9 @@ void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam)
                );
        }
 
+       // Orbit Tilt:
+       sky->setBodyOrbitTilt(event->set_sky->body_orbit_tilt);
+
        delete event->set_sky;
 }
 
index aacc47250eaf66798745dd8409d965cd94525733..eb7db36d48d989d8537d7762452aebf98b909268 100644 (file)
@@ -98,9 +98,6 @@ Sky::Sky(s32 id, RenderingEngine *rendering_engine, ITextureSource *tsrc, IShade
 
        m_directional_colored_fog = g_settings->getBool("directional_colored_fog");
 
-       if (g_settings->getBool("enable_dynamic_shadows"))
-               m_sky_body_orbit_tilt = g_settings->getFloat("shadow_sky_body_orbit_tilt", -60.0f, 60.0f);
-
        setStarCount(1000);
 }
 
@@ -556,12 +553,12 @@ static v3f getSkyBodyPosition(float horizon_position, float day_position, float
 
 v3f Sky::getSunDirection()
 {
-       return getSkyBodyPosition(90, getWickedTimeOfDay(m_time_of_day) * 360 - 90, m_sky_body_orbit_tilt);
+       return getSkyBodyPosition(90, getWickedTimeOfDay(m_time_of_day) * 360 - 90, m_sky_params.body_orbit_tilt);
 }
 
 v3f Sky::getMoonDirection()
 {
-       return getSkyBodyPosition(270, getWickedTimeOfDay(m_time_of_day) * 360 - 90, m_sky_body_orbit_tilt);
+       return getSkyBodyPosition(270, getWickedTimeOfDay(m_time_of_day) * 360 - 90, m_sky_params.body_orbit_tilt);
 }
 
 void Sky::draw_sun(video::IVideoDriver *driver, const video::SColor &suncolor,
@@ -721,7 +718,7 @@ void Sky::place_sky_body(
        * day_position: turn the body around the Z axis, to place it depending of the time of the day
        */
 {
-       v3f centrum = getSkyBodyPosition(horizon_position, day_position, m_sky_body_orbit_tilt);
+       v3f centrum = getSkyBodyPosition(horizon_position, day_position, m_sky_params.body_orbit_tilt);
        v3f untilted_centrum = getSkyBodyPosition(horizon_position, day_position, 0.f);
        for (video::S3DVertex &vertex : vertices) {
                // Body is directed to -Z (south) by default
index 79c478f679dc0a2f4c291c1fd5e2f67cdc244488..602876797de1e0eabfc8d7647dd1d90aea1318be 100644 (file)
@@ -96,6 +96,10 @@ class Sky : public scene::ISceneNode
        {
                m_fallback_bg_color = fallback_bg_color;
        }
+       void setBodyOrbitTilt(float body_orbit_tilt)
+       {
+               m_sky_params.body_orbit_tilt = body_orbit_tilt;
+       }
        void overrideColors(video::SColor bgcolor, video::SColor skycolor)
        {
                m_bgcolor = bgcolor;
@@ -164,7 +168,6 @@ class Sky : public scene::ISceneNode
        bool m_directional_colored_fog;
        bool m_in_clouds = true; // Prevent duplicating bools to remember old values
        bool m_enable_shaders = false;
-       float m_sky_body_orbit_tilt = 0.0f;
 
        video::SColorf m_bgcolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
        video::SColorf m_skycolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
index 0296967a5f56f0e169ca17e11d95a1a08b1d4af5..659bb157e0c2e689d498ee53f791231d2704e60e 100644 (file)
@@ -297,7 +297,6 @@ void set_default_settings()
        settings->setDefault("shadow_poisson_filter", "true");
        settings->setDefault("shadow_update_frames", "8");
        settings->setDefault("shadow_soft_radius", "5.0");
-       settings->setDefault("shadow_sky_body_orbit_tilt", "0.0");
 
        // Input
        settings->setDefault("invert_mouse", "false");
index 9c9d8276e834ea3600c598f78a111ab18b3229ca..c64541d7789e7a9591c2eaa79df0655c036bf2ec 100644 (file)
@@ -1367,6 +1367,10 @@ void Client::handleCommand_HudSetSky(NetworkPacket* pkt)
                                >> skybox.sky_color.indoors;
                }
 
+               try {
+                       *pkt >> skybox.body_orbit_tilt;
+               } catch (PacketError &e) {}
+
                ClientEvent *event = new ClientEvent();
                event->type = CE_SET_SKY;
                event->set_sky = new SkyboxParams(skybox);
index 4e50ef53307ab11f3870dd4fc9630c11e1e48f84..d456f19bf9e4270a618847bd217537c68f51da77 100644 (file)
@@ -701,6 +701,7 @@ enum ToClientCommand
                u8[4] fog_sun_tint (ARGB)
                u8[4] fog_moon_tint (ARGB)
                std::string fog_tint_type
+               float body_orbit_tilt
        */
 
        TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO = 0x50,
index fc2c1254b5f36eda44a99c1152417a9dcee33976..c754785905dd36dc9ae0f7a46ec45543f5370b9f 100644 (file)
@@ -1724,6 +1724,12 @@ int ObjectRef::l_set_sky(lua_State *L)
                        read_color(L, -1, &sky_params.bgcolor);
                lua_pop(L, 1);
 
+               lua_getfield(L, 2, "body_orbit_tilt");
+               if (!lua_isnil(L, -1)) {
+                       sky_params.body_orbit_tilt = rangelim(readParam<float>(L, -1), -60.0f, 60.0f);
+               }
+               lua_pop(L, 1);
+
                lua_getfield(L, 2, "type");
                if (!lua_isnil(L, -1))
                        sky_params.type = luaL_checkstring(L, -1);
@@ -1913,6 +1919,9 @@ int ObjectRef::l_get_sky(lua_State *L)
        lua_pushlstring(L, skybox_params.type.c_str(), skybox_params.type.size());
        lua_setfield(L, -2, "type");
 
+       lua_pushnumber(L, skybox_params.body_orbit_tilt);
+       lua_setfield(L, -2, "body_orbit_tilt");
+
        lua_newtable(L);
        s16 i = 1;
        for (const std::string &texture : skybox_params.textures) {
index bced71afa3b67998af6bf81ce3092046bc8633b4..3e0ce3189e32646617ceb3e567485be848c32213 100644 (file)
@@ -1808,6 +1808,8 @@ void Server::SendSetSky(session_t peer_id, const SkyboxParams &params)
                                << params.sky_color.night_sky << params.sky_color.night_horizon
                                << params.sky_color.indoors;
                }
+
+               pkt << params.body_orbit_tilt;
        }
 
        Send(&pkt);
index 07068634bbc16554c62fa4535e1d21957345809f..6c904d2a1ecd8d013fd4526254763adf0355e2ea 100644 (file)
@@ -40,6 +40,7 @@ struct SkyboxParams
        video::SColor fog_sun_tint;
        video::SColor fog_moon_tint;
        std::string fog_tint_type;
+       float body_orbit_tilt;
 };
 
 struct SunParams
@@ -95,6 +96,7 @@ class SkyboxDefaults
                sky.fog_sun_tint = video::SColor(255, 244, 125, 29);
                sky.fog_moon_tint = video::SColorf(0.5, 0.6, 0.8, 1).toSColor();
                sky.fog_tint_type = "default";
+               sky.body_orbit_tilt = 0.0f;
                return sky;
        }