Skip to content

Instantly share code, notes, and snippets.

@sofar
Created February 7, 2023 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sofar/70f1480f3bae3ddae8b917e0cab02d79 to your computer and use it in GitHub Desktop.
Save sofar/70f1480f3bae3ddae8b917e0cab02d79 to your computer and use it in GitHub Desktop.
diff --git a/src/client/sky.cpp b/src/client/sky.cpp
index 0ab7398f2..b19c89618 100644
--- a/src/client/sky.cpp
+++ b/src/client/sky.cpp
@@ -103,9 +103,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);
}
@@ -561,12 +558,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,
@@ -726,7 +723,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
diff --git a/src/client/sky.h b/src/client/sky.h
index 79c478f67..96c1d0454 100644
--- a/src/client/sky.h
+++ b/src/client/sky.h
@@ -164,7 +164,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);
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp
index 8a323872a..2ee869d43 100644
--- a/src/network/clientpackethandler.cpp
+++ b/src/network/clientpackethandler.cpp
@@ -1367,6 +1367,9 @@ void Client::handleCommand_HudSetSky(NetworkPacket* pkt)
>> skybox.sky_color.indoors;
}
+ *pkt >> skybox.body_orbit_tilt;
+ std::cout << "RECV" << skybox.body_orbit_tilt << std::endl;
+
ClientEvent *event = new ClientEvent();
event->type = CE_SET_SKY;
event->set_sky = new SkyboxParams(skybox);
diff --git a/src/network/networkprotocol.h b/src/network/networkprotocol.h
index 4e50ef533..d456f19bf 100644
--- a/src/network/networkprotocol.h
+++ b/src/network/networkprotocol.h
@@ -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,
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index fc2c1254b..b80a60831 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -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");
+ //FIXME limit to 60 degrees
+ if (!lua_isnil(L, -1))
+ sky_params.body_orbit_tilt = static_cast<float>(luaL_checknumber(L, -1));
+ 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) {
diff --git a/src/server.cpp b/src/server.cpp
index bced71afa..b49ec297e 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -1808,6 +1808,9 @@ 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;
+ std::cout << "SEND" << params.body_orbit_tilt << std::endl;
}
Send(&pkt);
diff --git a/src/skyparams.h b/src/skyparams.h
index 07068634b..6c904d2a1 100644
--- a/src/skyparams.h
+++ b/src/skyparams.h
@@ -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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment