mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-12 18:56:04 +00:00
Performance improvements
This commit is contained in:
@@ -10,6 +10,8 @@ import org.polydev.gaea.generation.GenerationPhase;
|
||||
import org.polydev.gaea.world.carving.Carver;
|
||||
import org.polydev.gaea.world.carving.Worm;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class UserDefinedCarver extends Carver {
|
||||
@@ -21,6 +23,7 @@ public class UserDefinedCarver extends Carver {
|
||||
private final int hash;
|
||||
private final int topCut;
|
||||
private final int bottomCut;
|
||||
|
||||
public UserDefinedCarver(Range height, Range radius, Range length, double[] start, double[] mutate, double[] radiusMultiplier, int hash, int topCut, int bottomCut) {
|
||||
super(height.getMin(), height.getMax());
|
||||
this.radius = radius;
|
||||
@@ -36,7 +39,7 @@ public class UserDefinedCarver extends Carver {
|
||||
@Override
|
||||
public Worm getWorm(long l, Vector vector) {
|
||||
Random r = new Random(l+hash);
|
||||
return new UserDefinedWorm(length.get(r), r, vector, radius.getMax(), topCut, bottomCut);
|
||||
return new UserDefinedWorm((int) (length.get(r)/2), r, vector, radius.getMax(), topCut, bottomCut);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,7 +57,7 @@ public class UserDefinedCarver extends Carver {
|
||||
super.setBottomCut(bottomCut);
|
||||
runningRadius = radius.get(r);
|
||||
this.maxRad = maxRad;
|
||||
direction = new Vector((r.nextDouble()-0.5D)*start[0], (r.nextDouble()-0.5D)*start[1], (r.nextDouble()-0.5D)*start[2]).normalize();
|
||||
direction = new Vector((r.nextDouble()-0.5D)*start[0], (r.nextDouble()-0.5D)*start[1], (r.nextDouble()-0.5D)*start[2]).normalize().multiply(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,9 +65,9 @@ public class UserDefinedCarver extends Carver {
|
||||
setRadius(new int[] {(int) (runningRadius*radiusMultiplier[0]), (int) (runningRadius*radiusMultiplier[1]), (int) (runningRadius*radiusMultiplier[2])});
|
||||
runningRadius += (getRandom().nextDouble()-0.5)*mutate[3];
|
||||
runningRadius = Math.max(Math.min(runningRadius, maxRad), 1);
|
||||
direction.rotateAroundX(Math.toRadians(getRandom().nextDouble()*mutate[0]));
|
||||
direction.rotateAroundY(Math.toRadians(getRandom().nextDouble()*mutate[1]));
|
||||
direction.rotateAroundZ(Math.toRadians(getRandom().nextDouble()*mutate[2]));
|
||||
direction.rotateAroundX(Math.toRadians(getRandom().nextDouble()*mutate[0]*2));
|
||||
direction.rotateAroundY(Math.toRadians(getRandom().nextDouble()*mutate[1]*2));
|
||||
direction.rotateAroundZ(Math.toRadians(getRandom().nextDouble()*mutate[2]*2));
|
||||
getRunning().add(direction);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user