mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-30 04:30:58 +02:00
added mask config values
This commit is contained in:
parent
fea7f9e666
commit
7c47b6eb1e
@ -56,6 +56,12 @@ local Config = {
|
|||||||
-- shows the mask on spawn
|
-- shows the mask on spawn
|
||||||
enable_mask_debug = false,
|
enable_mask_debug = false,
|
||||||
|
|
||||||
|
--the size of the mask used
|
||||||
|
mask_size = 9,
|
||||||
|
|
||||||
|
--how much the mask will effect tiles in the different rings of the mask
|
||||||
|
mask_relative_ring_weights = {2,3,4},
|
||||||
|
|
||||||
-- delay in seconds before the cave collapses
|
-- delay in seconds before the cave collapses
|
||||||
collapse_delay_min = 1.5,
|
collapse_delay_min = 1.5,
|
||||||
collapse_delay_max = 3,
|
collapse_delay_max = 3,
|
||||||
|
@ -259,9 +259,10 @@ end
|
|||||||
function DiggyCaveCollapse.initialize(global_config)
|
function DiggyCaveCollapse.initialize(global_config)
|
||||||
config = global_config.features.DiggyCaveCollapse
|
config = global_config.features.DiggyCaveCollapse
|
||||||
|
|
||||||
|
Mask.init(config)
|
||||||
if (config.enable_mask_debug) then
|
if (config.enable_mask_debug) then
|
||||||
local surface = game.surfaces.nauvis
|
local surface = game.surfaces.nauvis
|
||||||
Mask.disc_blur(0, 0, 1, function (x, y, fraction)
|
Mask.disc_blur(0, 0, 10, function (x, y, fraction)
|
||||||
Debug.print_grid_value(fraction, surface, {x=x, y=y})
|
Debug.print_grid_value(fraction, surface, {x=x, y=y})
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -45,40 +45,53 @@ local Mask = {}
|
|||||||
{0.000853, 0.001842, 0.003353, 0.005143, 0.006648, 0.007242, 0.006648, 0.005143, 0.003353, 0.001842, 0.000853},
|
{0.000853, 0.001842, 0.003353, 0.005143, 0.006648, 0.007242, 0.006648, 0.005143, 0.003353, 0.001842, 0.000853},
|
||||||
{0.000395, 0.000853, 0.001552, 0.002381, 0.003078, 0.003353, 0.003078, 0.002381, 0.001552, 0.000853, 0.000395}
|
{0.000395, 0.000853, 0.001552, 0.002381, 0.003078, 0.003353, 0.003078, 0.002381, 0.001552, 0.000853, 0.000395}
|
||||||
}
|
}
|
||||||
local n = 9;
|
local n
|
||||||
local radius = math.floor(n / 2)
|
local radius
|
||||||
local radius_sq = (radius + 0.2) * (radius + 0.2)
|
local radius_sq
|
||||||
local center_radius_sq = radius_sq / 9
|
local center_radius_sq
|
||||||
local disc_radius_sq = radius_sq * 4 / 9
|
local disc_radius_sq
|
||||||
|
|
||||||
|
local center_weight
|
||||||
|
local disc_weight
|
||||||
|
local ring_weight
|
||||||
|
|
||||||
local middle = radius + 1
|
|
||||||
local disc_blur_sum = 0
|
local disc_blur_sum = 0
|
||||||
local points_in_circle = 0
|
|
||||||
|
|
||||||
local center_value
|
local center_value
|
||||||
local disc_value
|
local disc_value
|
||||||
local ring_value
|
local ring_value
|
||||||
|
|
||||||
|
|
||||||
function init()
|
function Mask.init(config)
|
||||||
|
n = config.mask_size
|
||||||
|
|
||||||
|
ring_weight = config.mask_relative_ring_weights[1]
|
||||||
|
disc_weight = config.mask_relative_ring_weights[2]
|
||||||
|
center_weight = config.mask_relative_ring_weights[3]
|
||||||
|
|
||||||
|
radius = math.floor(n / 2)
|
||||||
|
radius_sq = (radius + 0.2) * (radius + 0.2)
|
||||||
|
center_radius_sq = radius_sq / 9
|
||||||
|
disc_radius_sq = radius_sq * 4 / 9
|
||||||
|
|
||||||
|
|
||||||
for x = -radius, radius do
|
for x = -radius, radius do
|
||||||
for y = -radius, radius do
|
for y = -radius, radius do
|
||||||
local distance_sq = x * x + y * y
|
local distance_sq = x * x + y * y
|
||||||
if distance_sq <= center_radius_sq then
|
if distance_sq <= center_radius_sq then
|
||||||
disc_blur_sum = disc_blur_sum + 1
|
disc_blur_sum = disc_blur_sum + center_weight
|
||||||
elseif distance_sq <= disc_radius_sq then
|
elseif distance_sq <= disc_radius_sq then
|
||||||
disc_blur_sum = disc_blur_sum + 2 /3
|
disc_blur_sum = disc_blur_sum + disc_weight
|
||||||
elseif distance_sq <= radius_sq then
|
elseif distance_sq <= radius_sq then
|
||||||
disc_blur_sum = disc_blur_sum + 1/3
|
disc_blur_sum = disc_blur_sum + ring_weight
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
center_value = 1 / disc_blur_sum
|
center_value = center_weight / disc_blur_sum
|
||||||
ring_value = center_value / 3
|
disc_value = disc_weight / disc_blur_sum
|
||||||
disc_value = ring_value * 2
|
ring_value = ring_weight / disc_blur_sum
|
||||||
end
|
end
|
||||||
|
|
||||||
init()
|
|
||||||
|
|
||||||
--[[--
|
--[[--
|
||||||
Applies a blur filter.
|
Applies a blur filter.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user