forked from VoxeLibre/VoxeLibre
Merge pull request 'Fix fog tint in overworld, apply memory leak fix, fix rain->clear clouds' (#4669) from weather-fixes into master
Reviewed-on: VoxeLibre/VoxeLibre#4669 Reviewed-by: kno10 <kno10@noreply.git.minetest.land>
This commit is contained in:
commit
fd6cac5f0c
|
@ -157,6 +157,7 @@ function mcl_weather.rain.clear()
|
||||||
mcl_weather.rain.remove_sound(player)
|
mcl_weather.rain.remove_sound(player)
|
||||||
mcl_weather.rain.remove_player(player)
|
mcl_weather.rain.remove_player(player)
|
||||||
mcl_weather.remove_spawners_player(player)
|
mcl_weather.remove_spawners_player(player)
|
||||||
|
player:set_clouds({color="#FFF0EF"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
local modname = minetest.get_current_modname()
|
local modname = minetest.get_current_modname()
|
||||||
local modpath = minetest.get_modpath(modname)
|
local modpath = minetest.get_modpath(modname)
|
||||||
local NIGHT_VISION_RATIO = 0.45
|
local NIGHT_VISION_RATIO = 0.45
|
||||||
|
local DEBUG = false
|
||||||
|
|
||||||
-- Settings
|
-- Settings
|
||||||
local minimum_update_interval = { 250e3 }
|
local minimum_update_interval = { 250e3 }
|
||||||
|
@ -190,8 +191,8 @@ end
|
||||||
|
|
||||||
function skycolor_utils.convert_to_rgb(minval, maxval, current_val, colors)
|
function skycolor_utils.convert_to_rgb(minval, maxval, current_val, colors)
|
||||||
-- Clamp current_val to valid range
|
-- Clamp current_val to valid range
|
||||||
current_val = math.min(minval, current_val)
|
current_val = math.max(minval, current_val)
|
||||||
current_val = math.max(maxval, current_val)
|
current_val = math.min(maxval, current_val)
|
||||||
|
|
||||||
-- Rescale current_val from a number between minval and maxval to a number between 1 and #colors
|
-- Rescale current_val from a number between minval and maxval to a number between 1 and #colors
|
||||||
local scaled_value = (current_val - minval) / (maxval - minval) * (#colors - 1) + 1.0
|
local scaled_value = (current_val - minval) / (maxval - minval) * (#colors - 1) + 1.0
|
||||||
|
@ -199,7 +200,7 @@ function skycolor_utils.convert_to_rgb(minval, maxval, current_val, colors)
|
||||||
-- Get the first color's values
|
-- Get the first color's values
|
||||||
local index1 = math.floor(scaled_value)
|
local index1 = math.floor(scaled_value)
|
||||||
local color1 = colors[index1]
|
local color1 = colors[index1]
|
||||||
local frac1 = scaled_value - index1
|
local frac1 = 1.0 - (scaled_value - index1)
|
||||||
|
|
||||||
-- Get the second color's values
|
-- Get the second color's values
|
||||||
local index2 = math.min(index1 + 1, #colors) -- clamp to maximum color index (will occur if index1 == #colors)
|
local index2 = math.min(index1 + 1, #colors) -- clamp to maximum color index (will occur if index1 == #colors)
|
||||||
|
@ -207,11 +208,32 @@ function skycolor_utils.convert_to_rgb(minval, maxval, current_val, colors)
|
||||||
local color2 = colors[index2]
|
local color2 = colors[index2]
|
||||||
|
|
||||||
-- Interpolate between color1 and color2
|
-- Interpolate between color1 and color2
|
||||||
return {
|
local res = {
|
||||||
r = math.floor(frac1 * color1.r + frac2 * color2.r),
|
r = math.floor(frac1 * color1.r + frac2 * color2.r),
|
||||||
g = math.floor(frac1 * color1.g + frac2 * color2.g),
|
g = math.floor(frac1 * color1.g + frac2 * color2.g),
|
||||||
b = math.floor(frac1 * color1.b + frac2 * color2.b),
|
b = math.floor(frac1 * color1.b + frac2 * color2.b),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if DEBUG then
|
||||||
|
minetest.log(dump({
|
||||||
|
minval = minval,
|
||||||
|
maxval = maxval,
|
||||||
|
current_val = current_val,
|
||||||
|
colors = colors,
|
||||||
|
res = res,
|
||||||
|
scaled_value = scaled_value,
|
||||||
|
|
||||||
|
frac1 = frac1,
|
||||||
|
index1 = index1,
|
||||||
|
color1 = color1,
|
||||||
|
|
||||||
|
frac2 = frac2,
|
||||||
|
index2 = index2,
|
||||||
|
color2 = color2,
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
|
||||||
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Simple getter. Either returns user given players list or get all connected players if none provided
|
-- Simple getter. Either returns user given players list or get all connected players if none provided
|
||||||
|
|
|
@ -40,18 +40,21 @@ function dimension_handlers.overworld(player, sky_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Use overworld defaults
|
-- Use overworld defaults
|
||||||
local day_color = mcl_weather.skycolor.get_sky_layer_color(0.15)
|
local day_color = mcl_weather.skycolor.get_sky_layer_color(0.5)
|
||||||
local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.27)
|
local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.27)
|
||||||
local night_color = mcl_weather.skycolor.get_sky_layer_color(0.1)
|
local night_color = mcl_weather.skycolor.get_sky_layer_color(0.1)
|
||||||
sky_data.sky = {
|
sky_data.sky = {
|
||||||
type = "regular",
|
type = "regular",
|
||||||
sky_color = {
|
sky_color = {
|
||||||
day_sky = day_color,
|
day_sky = day_color or "#7BA4FF",
|
||||||
day_horizon = day_color,
|
day_horizon = day_color or "#C0D8FF",
|
||||||
dawn_sky = dawn_color,
|
dawn_sky = dawn_color or "7BA4FF",
|
||||||
dawn_horizon = dawn_color,
|
dawn_horizon = dawn_color or "#C0D8FF",
|
||||||
night_sky = night_color,
|
night_sky = night_color or "000000",
|
||||||
night_horizon = night_color,
|
night_horizon = night_color or "4A6790",
|
||||||
|
fog_sun_tint = "#ff5f33",
|
||||||
|
fog_moon_tint = nil,
|
||||||
|
fog_tint_type = "custom",
|
||||||
},
|
},
|
||||||
clouds = true,
|
clouds = true,
|
||||||
}
|
}
|
||||||
|
@ -75,18 +78,15 @@ function dimension_handlers.overworld(player, sky_data)
|
||||||
local day_color = mcl_weather.skycolor.get_sky_layer_color(0.5)
|
local day_color = mcl_weather.skycolor.get_sky_layer_color(0.5)
|
||||||
local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.75)
|
local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.75)
|
||||||
local night_color = mcl_weather.skycolor.get_sky_layer_color(0)
|
local night_color = mcl_weather.skycolor.get_sky_layer_color(0)
|
||||||
sky_data.sky = {
|
table.update(sky_data.sky.sky_color,{
|
||||||
type = "regular",
|
day_sky = day_color or "#7BA4FF",
|
||||||
sky_color = {
|
day_horizon = day_color or "#C0D8FF",
|
||||||
day_sky = day_color,
|
dawn_sky = dawn_color or "7BA4FF",
|
||||||
day_horizon = day_color,
|
dawn_horizon = dawn_color or "#C0D8FF",
|
||||||
dawn_sky = dawn_color,
|
night_sky = night_color or "000000",
|
||||||
dawn_horizon = dawn_color,
|
night_horizon = night_color or "4A6790",
|
||||||
night_sky = night_color,
|
fog_tint_type = "default",
|
||||||
night_horizon = night_color,
|
})
|
||||||
},
|
|
||||||
clouds = true,
|
|
||||||
}
|
|
||||||
sky_data.sun = {visible = false, sunrise_visible = false}
|
sky_data.sun = {visible = false, sunrise_visible = false}
|
||||||
sky_data.moon = {visible = false}
|
sky_data.moon = {visible = false}
|
||||||
sky_data.stars = {visible = false}
|
sky_data.stars = {visible = false}
|
||||||
|
@ -164,7 +164,8 @@ function dimension_handlers.nether(player, sky_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
function dimension_handlers.void(player, sky_data)
|
function dimension_handlers.void(player, sky_data)
|
||||||
sky_data.sky = { type = "plain",
|
sky_data.sky = {
|
||||||
|
type = "plain",
|
||||||
base_color = "#000000",
|
base_color = "#000000",
|
||||||
clouds = false,
|
clouds = false,
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,13 +75,15 @@ function mcl_weather.has_snow(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_weather.snow.set_sky_box()
|
function mcl_weather.snow.set_sky_box()
|
||||||
mcl_weather.skycolor.add_layer(
|
if mcl_weather.skycolor.current_layer_name() ~= "weather-pack-snow-sky" then
|
||||||
"weather-pack-snow-sky",
|
mcl_weather.skycolor.add_layer(
|
||||||
{{r=0, g=0, b=0},
|
"weather-pack-snow-sky",
|
||||||
{r=85, g=86, b=86},
|
{{r=0, g=0, b=0},
|
||||||
{r=135, g=135, b=135},
|
{r=85, g=86, b=86},
|
||||||
{r=85, g=86, b=86},
|
{r=135, g=135, b=135},
|
||||||
{r=0, g=0, b=0}})
|
{r=85, g=86, b=86},
|
||||||
|
{r=0, g=0, b=0}})
|
||||||
|
end
|
||||||
mcl_weather.skycolor.active = true
|
mcl_weather.skycolor.active = true
|
||||||
for _, player in pairs(get_connected_players()) do
|
for _, player in pairs(get_connected_players()) do
|
||||||
player:set_clouds({color="#ADADADE8"})
|
player:set_clouds({color="#ADADADE8"})
|
||||||
|
|
|
@ -23,13 +23,15 @@ minetest.register_globalstep(function(dtime)
|
||||||
mcl_weather.rain.make_weather()
|
mcl_weather.rain.make_weather()
|
||||||
|
|
||||||
if mcl_weather.thunder.init_done == false then
|
if mcl_weather.thunder.init_done == false then
|
||||||
mcl_weather.skycolor.add_layer("weather-pack-thunder-sky", {
|
if mcl_weather.skycolor.current_layer_name() ~= "weather-pack-thunder-sky" then
|
||||||
{r=0, g=0, b=0},
|
mcl_weather.skycolor.add_layer("weather-pack-thunder-sky", {
|
||||||
{r=40, g=40, b=40},
|
{r=0, g=0, b=0},
|
||||||
{r=85, g=86, b=86},
|
{r=40, g=40, b=40},
|
||||||
{r=40, g=40, b=40},
|
{r=85, g=86, b=86},
|
||||||
{r=0, g=0, b=0},
|
{r=40, g=40, b=40},
|
||||||
})
|
{r=0, g=0, b=0},
|
||||||
|
})
|
||||||
|
end
|
||||||
mcl_weather.skycolor.active = true
|
mcl_weather.skycolor.active = true
|
||||||
for _, player in pairs(get_connected_players()) do
|
for _, player in pairs(get_connected_players()) do
|
||||||
player:set_clouds({color="#3D3D3FE8"})
|
player:set_clouds({color="#3D3D3FE8"})
|
||||||
|
|
Loading…
Reference in New Issue