1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-30 19:22:14 +00:00

Minor fixes

This commit is contained in:
MirceaKitsune 2025-07-01 23:16:40 +03:00
parent 770ead7624
commit b3317fbe66
7 changed files with 21 additions and 21 deletions

View file

@ -8832,9 +8832,9 @@ child will follow movement and rotation of that bone.
* `"regular"`: Uses 0 textures, `base_color` ignored
* `"skybox"`: Uses 6 textures, `base_color` used as fog.
* `"skybox_back"`: Uses 6 textures, `sky_color` used as fog, stars / sun / moon in foreground.
Note: Requires Luanti client version 5.13 or greater.
Note: Requires Luanti client version 5.13 or greater.
* `"skybox_front"`: Uses 6 textures, `sky_color` used as fog, stars / sun / moon in background.
Note: Requires Luanti client version 5.13 or greater.
Note: Requires Luanti client version 5.13 or greater.
* `"plain"`: Uses 0 textures, `base_color` used as both fog and sky.
(default: `"regular"`)
* `textures`: A table containing up to six textures in the following

View file

@ -2859,23 +2859,23 @@ void Game::handleClientEvent_HudChange(ClientEvent *event, CameraOrientation *ca
void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam)
{
// Handle invalid sky type.
if (!event->set_sky->isSkybox() && !event->set_sky->isTransparent() && event->set_sky->type != "plain")
if (!event->set_sky->isTextured() && !event->set_sky->hasAlpha() && event->set_sky->type != "plain")
infostream << "Unknown sky type: " << (event->set_sky->type) << std::endl;
// Show the mesh sky if transparent.
sky->setVisible(event->set_sky->isTransparent());
sky->setVisible(event->set_sky->hasAlpha());
sky->setType(event->set_sky->type);
// Whether clouds are visible in front of a custom skybox.
sky->setCloudsEnabled(event->set_sky->clouds);
// Show the mesh sky and use skybox colours if transparent.
if (event->set_sky->isTransparent())
if (event->set_sky->hasAlpha())
sky->setSkyColors(event->set_sky->sky_color);
else
sky->setFallbackBgColor(event->set_sky->bgcolor);
// Use horizon tint for regular or skybox skies.
if (event->set_sky->isSkybox() || event->set_sky->isTransparent())
if (event->set_sky->isTextured() || event->set_sky->hasAlpha())
sky->setHorizonTint(
event->set_sky->fog_sun_tint,
event->set_sky->fog_moon_tint,
@ -2891,9 +2891,9 @@ void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam)
// Clear the old textures out in case we switch rendering type.
sky->clearSkyboxTextures();
// Add textures to skybox.
if(event->set_sky->isSkybox()) {
if (event->set_sky->isTextured()) {
for (int i = 0; i < 6; i++)
sky->addTextureToSkybox(event->set_sky->textures[i], i, texture_src, event->set_sky->isTransparent());
sky->addTextureToSkybox(event->set_sky->textures[i], i, texture_src, event->set_sky->hasAlpha());
}
// Orbit Tilt:

View file

@ -215,7 +215,7 @@ void Sky::render()
// Draw far cloudy fog thing blended with skycolor
// Disabled when using a textured skybox to prevent clipping
if (m_visible && !m_sky_params.isSkybox()) {
if (m_visible && !m_sky_params.isTextured()) {
driver->setMaterial(m_materials[1]);
for (u32 j = 0; j < 4; j++) {
vertices[0] = video::S3DVertex(-1, -0.02, -1, 0, 0, 1, m_bgcolor, t, t);
@ -280,7 +280,7 @@ void Sky::render()
// Draw far cloudy fog thing below all horizons in front of sun, moon and stars.
// Disabled when using a textured skybox to prevent clipping
if (m_visible && !m_sky_params.isSkybox()) {
if (m_visible && !m_sky_params.isTextured()) {
driver->setMaterial(m_materials[1]);
for (u32 j = 0; j < 4; j++) {

View file

@ -1304,7 +1304,7 @@ void Client::handleCommand_HudSetSky(NetworkPacket* pkt)
StarParams stars = SkyboxDefaults::getStarDefaults();
// Fix for "regular", "skybox_back", "skybox_front" skies as color isn't kept:
if (skybox.isTransparent()) {
if (skybox.hasAlpha()) {
skybox.sky_color = SkyboxDefaults::getSkyColorDefaults();
skybox.fog_tint_type = "default";
skybox.fog_moon_tint = video::SColor(255, 255, 255, 255);
@ -1344,7 +1344,7 @@ void Client::handleCommand_HudSetSky(NetworkPacket* pkt)
*pkt >> skybox.bgcolor >> skybox.type >> skybox.clouds >>
skybox.fog_sun_tint >> skybox.fog_moon_tint >> skybox.fog_tint_type;
if (skybox.isSkybox()) {
if (skybox.isTextured()) {
u16 texture_count;
std::string texture;
*pkt >> texture_count;
@ -1353,7 +1353,7 @@ void Client::handleCommand_HudSetSky(NetworkPacket* pkt)
skybox.textures.emplace_back(texture);
}
}
if (skybox.isTransparent()) {
if (skybox.hasAlpha()) {
auto &c = skybox.sky_color;
*pkt >> c.day_sky >> c.day_horizon >> c.dawn_sky >> c.dawn_horizon
>> c.night_sky >> c.night_horizon >> c.indoors;

View file

@ -2067,7 +2067,7 @@ int ObjectRef::l_set_sky(lua_State *L)
lua_getfield(L, 2, "textures");
sky_params.textures.clear();
if (lua_istable(L, -1) && sky_params.isSkybox()) {
if (lua_istable(L, -1) && sky_params.isTextured()) {
lua_pushnil(L);
while (lua_next(L, -2) != 0) {
// Key is at index -2 and value at index -1
@ -2161,7 +2161,7 @@ int ObjectRef::l_set_sky(lua_State *L)
// Preserve old behavior of the sun, moon and stars
// when using the old set_sky call.
if (sky_params.isTransparent()) {
if (sky_params.hasAlpha()) {
sun_params.visible = true;
sun_params.sunrise_visible = true;
moon_params.visible = true;
@ -2183,7 +2183,7 @@ int ObjectRef::l_set_sky(lua_State *L)
lua_pop(L, 1);
}
}
if (sky_params.isSkybox() && sky_params.textures.size() != 6)
if (sky_params.isTextured() && sky_params.textures.size() != 6)
throw LuaError("Skybox expects 6 textures.");
sky_params.clouds = true;
@ -2202,7 +2202,7 @@ int ObjectRef::l_set_sky(lua_State *L)
static void push_sky_color(lua_State *L, const SkyboxParams &params)
{
lua_newtable(L);
if (params.isTransparent()) {
if (params.hasAlpha()) {
push_ARGB8(L, params.sky_color.day_sky);
lua_setfield(L, -2, "day_sky");
push_ARGB8(L, params.sky_color.day_horizon);

View file

@ -1868,12 +1868,12 @@ void Server::SendSetSky(session_t peer_id, const SkyboxParams &params)
<< params.clouds << params.fog_sun_tint
<< params.fog_moon_tint << params.fog_tint_type;
if (params.isSkybox()) {
if (params.isTextured()) {
pkt << (u16) params.textures.size();
for (const std::string &texture : params.textures)
pkt << texture;
}
if (params.isTransparent()) {
if (params.hasAlpha()) {
auto &c = params.sky_color;
pkt << c.day_sky << c.day_horizon << c.dawn_sky << c.dawn_horizon
<< c.night_sky << c.night_horizon << c.indoors;

View file

@ -40,11 +40,11 @@ struct SkyboxParams
video::SColor fog_color { 0 }; // override, only used if alpha > 0
// Check if this is a textured skybox and whether transparency is used
bool isSkybox() const
bool isTextured() const
{
return type == "skybox" || type == "skybox_back" || type == "skybox_front";
}
bool isTransparent() const
bool hasAlpha() const
{
return type == "regular" || type == "skybox_back" || type == "skybox_front";
}