Terra/src/main/java/com/dfsek/terra/structure/StructureInfo.java
Bud Gidiere 0a77487399
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
2020-11-18 17:23:09 -06:00

48 lines
1.1 KiB
Java

package com.dfsek.terra.structure;
import com.dfsek.terra.procgen.math.Vector2;
import org.apache.commons.math3.util.FastMath;
import java.io.Serializable;
public class StructureInfo implements Serializable {
private static final long serialVersionUID = -175639605885943678L;
private final int sizeX;
private final int sizeY;
private final int sizeZ;
private final int centerX;
private final int centerZ;
public StructureInfo(int sizeX, int sizeY, int sizeZ, Vector2 center) {
this.sizeX = sizeX;
this.sizeY = sizeY;
this.sizeZ = sizeZ;
this.centerX = (int) center.getX();
this.centerZ = (int) center.getZ();
}
public int getSizeX() {
return sizeX;
}
public int getSizeZ() {
return sizeZ;
}
public int getSizeY() {
return sizeY;
}
public int getCenterX() {
return centerX;
}
public int getCenterZ() {
return centerZ;
}
public double getMaxHorizontal() {
return FastMath.sqrt(FastMath.pow(sizeX, 2) + FastMath.pow(sizeZ, 2));
}
}