Try to reduce spawn star memory leak near spawn

Use grid-aligned pixel locaiton for calculating
opacity so each star pixel position has only one
opacity level associated with it, rather than the
multiple that can currently occupy that opacity
range.
This commit is contained in:
Aaron Suen 2021-03-16 20:51:33 -04:00
parent 8f452a48fe
commit 0251a7d023

View File

@ -63,13 +63,12 @@ nodecore.register_playerstep({
local dist = vector.length(pos)
local log = math_log(dist + 1) * posscale
pos = vector.multiply(pos, log / dist)
local px = pos.z
local py = -pos.x
local px = math_ceil(pos.z)
local py = math_ceil(-pos.x)
local opac = (px * px + py * py) / 8 - 200
if opac > 0 then
if opac > 255 then opac = 255 end
top = top .. ":" .. (123 + math_ceil(px))
.. "," .. (123 + math_ceil(py))
top = top .. ":" .. (123 + px) .. "," .. (123 + py)
.. "=" .. esc("nc_player_sky_star.png^[resize:11x11"
.. "^[opacity:" .. math_ceil(opac))
data.sky.textures[1] = top .. data.sky.darken