Fix wrong analysis if persistence < 0 and absvalue

master
Wuzzy 2022-05-12 12:37:53 +02:00
parent e84f99166d
commit 320905826b
1 changed files with 15 additions and 10 deletions

View File

@ -349,7 +349,15 @@ local analyze_noiseparams = function(noiseparams)
-- Calculate the two possible extreme values
-- with the octave value being either at 1 or -1.
local limit1 = (1 * np.persistence ^ exp)
local limit2 = (-1 * np.persistence ^ exp)
local limit2
if not is_absolute then
limit2 = (-1 * np.persistence ^ exp)
else
-- If absvalue is set, one of the
-- limits is always 0 because we
-- can't get lower.
limit2 = 0
end
-- To add to the maximum, pick the higher value
if limit1 > limit2 then
@ -357,15 +365,12 @@ local analyze_noiseparams = function(noiseparams)
else
o_max = o_max + limit2
end
if not is_absolute then
-- To add to the minimum, pick the LOWER value
if limit1 > limit2 then
o_min = o_min + limit2
else
o_min = o_min + limit1
end
-- Note: If absvalue flag is set, the sum of the octaves
-- is always 0, so we don't need to calculate it
-- To add to the minimum, pick the LOWER value
if limit1 > limit2 then
o_min = o_min + limit2
else
o_min = o_min + limit1
end
end
-- Add offset and scale to min/max value (final step)