upgrade atmos2 to prevent even more memory leakage
This commit is contained in:
parent
d22c21f003
commit
0fd9129988
2
.gitignore
vendored
2
.gitignore
vendored
@ -24,3 +24,5 @@ Icon
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
.vs/slnx.sqlite
|
||||
.vs
|
@ -2,3 +2,4 @@ time_speed = 60
|
||||
|
||||
#mapgen_settings_here
|
||||
|
||||
#time_speed = 60
|
@ -87,6 +87,22 @@ for line in io.lines(storage.."skybox_clear_gradient"..".atm") do
|
||||
|
||||
end
|
||||
|
||||
local function atmos_ratio(current, next, ctime2)
|
||||
|
||||
if current < next then -- check if we're darker than the next skybox frame
|
||||
|
||||
local ratio = (next - current) * ctime2
|
||||
return (current + ratio)
|
||||
|
||||
else -- we darken instead, this repeats for the next two if, else statements
|
||||
|
||||
local ratio = (current - next) * ctime2
|
||||
return (current - ratio)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function atmos.set_skybox(player)
|
||||
|
||||
--local skybox = atmos.get_weather_skybox()
|
||||
@ -94,9 +110,15 @@ function atmos.set_skybox(player)
|
||||
|
||||
-- figure out our multiplier since get_timeofday returns 0->1, we can use the sig figs as a 0-100 percentage multiplier
|
||||
|
||||
local ctime2 = ctime - math.floor(ctime)
|
||||
-- contributed by @rubenwardy
|
||||
|
||||
local fade_factor = 255 * ctime2
|
||||
local ctime2 = math.floor((ctime - math.floor(ctime)) * 100) / 100
|
||||
|
||||
if ctime2 == 0 then ctime2 = 0.01 end -- anti sudden skybox change syndrome
|
||||
|
||||
local fade_factor = math.floor(255 * ctime2)
|
||||
|
||||
print (ctime2, fade_factor)
|
||||
|
||||
ctime = math.floor(ctime) -- remove the sig figs, since we're accessing table points
|
||||
|
||||
@ -146,41 +168,9 @@ function atmos.set_skybox(player)
|
||||
|
||||
-- we compare colours the same way we do it for the light level
|
||||
|
||||
if fog.current.red < fog.next.red then -- check if we're darker than the next skybox frame
|
||||
|
||||
local ratio = (fog.next.red - fog.current.red) * ctime2
|
||||
fog.result.red = fog.current.red + ratio
|
||||
|
||||
else -- we darken instead, this repeats for the next two if, else statements
|
||||
|
||||
local ratio = (fog.current.red - fog.next.red) * ctime2
|
||||
fog.result.red = fog.current.red - ratio
|
||||
|
||||
end
|
||||
|
||||
if fog.current.grn < fog.next.grn then
|
||||
|
||||
local ratio = (fog.next.grn - fog.current.grn) * ctime2
|
||||
fog.result.grn = fog.current.grn + ratio
|
||||
|
||||
else
|
||||
|
||||
local ratio = (fog.current.grn - fog.next.grn) * ctime2
|
||||
fog.result.grn = fog.current.grn - ratio
|
||||
|
||||
end
|
||||
|
||||
if fog.current.blu < fog.next.blu then
|
||||
|
||||
local ratio = (fog.next.blu - fog.current.blu) * ctime2
|
||||
fog.result.blu = fog.current.blu + ratio
|
||||
|
||||
else
|
||||
|
||||
local ratio = (fog.current.blu - fog.next.blu) * ctime2
|
||||
fog.result.blu = fog.current.blu - ratio
|
||||
|
||||
end
|
||||
fog.result.red = atmos_ratio(fog.current.red, fog.next.red, ctime2)
|
||||
fog.result.grn = atmos_ratio(fog.current.grn, fog.next.grn, ctime2)
|
||||
fog.result.blu = atmos_ratio(fog.current.blu, fog.next.blu, ctime2)
|
||||
|
||||
else
|
||||
|
||||
@ -190,6 +180,12 @@ function atmos.set_skybox(player)
|
||||
|
||||
end
|
||||
|
||||
if atmos_clear_weather[ctime].bottom == atmos_clear_weather[ctime+1].bottom then -- prevent more leakage
|
||||
if atmos_clear_weather[ctime].top == atmos_clear_weather[ctime+1].top then
|
||||
fade_factor = 0
|
||||
end
|
||||
end
|
||||
|
||||
player:set_sky(minetest.rgba(fog.result.red, fog.result.grn, fog.result.blu), "skybox", {
|
||||
|
||||
sky_top .. "^(" .. sky_top_new .. "^[opacity:" .. fade_factor .. ")",
|
||||
@ -214,21 +210,13 @@ function atmos.set_skybox(player)
|
||||
local light_ratio = 0
|
||||
local light_level = 0
|
||||
|
||||
if atmos_clear_weather[ctime].light < atmos_clear_weather[ctime+1].light then -- we do dark to light fade
|
||||
|
||||
light_ratio = (atmos_clear_weather[ctime+1].light - atmos_clear_weather[ctime].light) * ctime2
|
||||
|
||||
light_level = atmos_clear_weather[ctime].light + light_ratio
|
||||
|
||||
elseif atmos_clear_weather[ctime].light == atmos_clear_weather[ctime+1].light then -- we do nothing, because there's nothing worth doing
|
||||
if atmos_clear_weather[ctime].light == atmos_clear_weather[ctime+1].light then -- we do nothing, because there's nothing worth doing
|
||||
|
||||
light_level = atmos_clear_weather[ctime].light
|
||||
|
||||
else -- we do the light to dark fade
|
||||
|
||||
light_ratio = (atmos_clear_weather[ctime].light - atmos_clear_weather[ctime+1].light) * ctime2
|
||||
|
||||
light_level = atmos_clear_weather[ctime].light - light_ratio
|
||||
light_level = atmos_ratio(atmos_clear_weather[ctime].light, atmos_clear_weather[ctime+1].light, ctime2)
|
||||
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user