You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Where in the original C code, modulo should take precedence.
For values of n between k * 1073741824 and k * 1073741824 + 536870912 for integer k >= 1 (and similar for negative range) this just happens to output the same values, but otherwise for n > 1073741824 the result will be always negative (and similarly for n < -1073741824 the result will be always positive) instead of repeating the entire range from -1073741824 to 1073741824.
Changing this now may be considered a breaking change as there could be terrain generators that would generate different terrain with this fixed.
The text was updated successfully, but these errors were encountered:
One solution is to deprecate the existing method, and introduce a new one with the proper implementation. Another is to change this on a breaking version.
We already have the beginnings of a 'compatibility mode' in #20 -- that needs to be changed to not modify global state, and the compatibility mode could additionally include this behaviour change.
This has been found by DaPorkchop_ while working on another project
This method:
noise/src/main/java/org/spongepowered/noise/Utils.java
Lines 114 to 122 in 213f04e
has been originally ported from the following C code in libnoise:
But because of operator precedence in java, the java code is actually equivalent to this
Where in the original C code, modulo should take precedence.
For values of
n
betweenk * 1073741824
andk * 1073741824 + 536870912
for integerk >= 1
(and similar for negative range) this just happens to output the same values, but otherwise forn > 1073741824
the result will be always negative (and similarly forn < -1073741824
the result will be always positive) instead of repeating the entire range from-1073741824
to1073741824
.Changing this now may be considered a breaking change as there could be terrain generators that would generate different terrain with this fixed.
The text was updated successfully, but these errors were encountered: