Replace Math with FastMath for improved performance.

FastMath is a drop in replacement for the native Java math class with improved performance and fall backs to the native Java math class if necessary.

https://commons.apache.org/proper/commons-math/javadocs/api-3.3/org/apache/commons/math3/util/FastMath.html

This requires further testing and might cause chunk borders due the FastMath giving slightly different results than the native Java math class.

I also added .idea/Terra.iml to the .gitignore
This commit is contained in:
Bud Gidiere
2020-11-18 17:23:09 -06:00
parent 19162a1924
commit 0a77487399
21 changed files with 73 additions and 52 deletions

View File

@@ -5,6 +5,7 @@ import com.dfsek.terra.biome.BiomeZone;
import com.dfsek.terra.biome.grid.TerraBiomeGrid;
import com.dfsek.terra.config.base.ConfigUtil;
import com.dfsek.terra.debug.gui.DebugGUI;
import org.apache.commons.math3.util.FastMath;
import org.bukkit.World;
import org.polydev.gaea.biome.NormalizationUtil;
@@ -108,12 +109,12 @@ public class ImageLoader {
NONE {
@Override
public int getRGB(BufferedImage image, int x, int y) {
return image.getRGB(Math.floorMod(x, image.getWidth()), Math.floorMod(y, image.getHeight()));
return image.getRGB(FastMath.floorMod(x, image.getWidth()), FastMath.floorMod(y, image.getHeight()));
}
};
private static int getRGBNoAlign(BufferedImage image, int x, int y) {
return image.getRGB(Math.floorMod(x, image.getWidth()), Math.floorMod(y, image.getHeight()));
return image.getRGB(FastMath.floorMod(x, image.getWidth()), FastMath.floorMod(y, image.getHeight()));
}
public abstract int getRGB(BufferedImage image, int x, int y);