mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-07 00:06:12 +00:00
Noise context api
This commit is contained in:
@@ -13,17 +13,39 @@ import com.dfsek.terra.api.util.vector.Vector2Int;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface NoiseSampler {
|
||||
static NoiseSampler zero() {
|
||||
return new NoiseSampler() {
|
||||
|
||||
|
||||
@Override
|
||||
public double noise(long seed, double x, double y) {
|
||||
public double noise(long seed, double x, double y, List<double[]> context, int contextLayer, int contextRadius) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(long seed, double x, double y, double z) {
|
||||
public double noise(long seed, double x, double y, double z, List<double[]> context, int contextLayer, int contextRadius) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateContext(long seed, double x, double y, List<double[]> context, int contextLayer, int contextRadius) {
|
||||
//no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateContext(long seed, double x, double y, double z, List<double[]> context, int contextLayer,
|
||||
int contextRadius) {
|
||||
//no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContextRadius() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
@@ -46,15 +68,76 @@ public interface NoiseSampler {
|
||||
return noise(seed, vector2.getX(), vector2.getZ());
|
||||
}
|
||||
|
||||
double noise(long seed, double x, double y);
|
||||
default double noise(Vector3 vector3, long seed, List<double[]> context, int contextLayer, int contextRadius) {
|
||||
return noise(seed, vector3.getX(), vector3.getY(), vector3.getZ(), context, contextLayer, contextRadius);
|
||||
}
|
||||
|
||||
default double noise(Vector3Int vector3, long seed, List<double[]> context, int contextLayer, int contextRadius) {
|
||||
return noise(seed, vector3.getX(), vector3.getY(), vector3.getZ(), context, contextLayer, contextRadius);
|
||||
}
|
||||
|
||||
|
||||
default double noise(Vector2 vector2, long seed, List<double[]> context, int contextLayer, int contextRadius) {
|
||||
return noise(seed, vector2.getX(), vector2.getZ(), context, contextLayer, contextRadius);
|
||||
}
|
||||
|
||||
default double noise(Vector2Int vector2, long seed, List<double[]> context, int contextLayer, int contextRadius) {
|
||||
return noise(seed, vector2.getX(), vector2.getZ(), context, contextLayer, contextRadius);
|
||||
}
|
||||
|
||||
default double noise(long seed, double x, double y) {
|
||||
int contextRadius = getContextRadius();
|
||||
|
||||
ArrayList<double[]> list = new ArrayList<>();
|
||||
generateContext(seed, x, y, list, 0, contextRadius);
|
||||
return noise(seed, x, y, list, 0, contextRadius);
|
||||
}
|
||||
|
||||
default double noise(long seed, int x, int y) {
|
||||
return noise(seed, (double) x, y);
|
||||
}
|
||||
|
||||
double noise(long seed, double x, double y, double z);
|
||||
default double noise(long seed, double x, double y, double z) {
|
||||
int contextRadius = getContextRadius();
|
||||
|
||||
ArrayList<double[]> list = new ArrayList<>();
|
||||
generateContext(seed, x, y, z, list, 0, contextRadius);
|
||||
return noise(seed, x, y, z, list, 0, contextRadius);
|
||||
}
|
||||
|
||||
default double noise(long seed, int x, int y, int z) {
|
||||
return noise(seed, (double) x, y, z);
|
||||
}
|
||||
|
||||
double noise(long seed, double x, double y, List<double[]> context, int contextLayer, int contextRadius);
|
||||
|
||||
default double noise(long seed, int x, int y, List<double[]> context, int contextLayer, int contextRadius) {
|
||||
return noise(seed, (double) x, y, context, contextLayer, contextRadius);
|
||||
}
|
||||
|
||||
double noise(long seed, double x, double y, double z, List<double[]> context, int contextLayer, int contextRadius);
|
||||
|
||||
default double noise(long seed, int x, int y, int z, List<double[]> context, int contextLayer, int contextRadius) {
|
||||
return noise(seed, (double) x, y, z, context, contextLayer, contextRadius);
|
||||
}
|
||||
|
||||
default void generateContext(long seed, double x, double y, List<double[]> context, int contextLayer, int contextRadius) {
|
||||
//no-op
|
||||
}
|
||||
|
||||
default void generateContext(long seed, int x, int y, List<double[]> context, int contextLayer, int contextRadius) {
|
||||
generateContext(seed, (double) x, y, context, contextLayer, contextRadius);
|
||||
}
|
||||
|
||||
default void generateContext(long seed, double x, double y, double z, List<double[]> context, int contextLayer, int contextRadius) {
|
||||
//no-op
|
||||
}
|
||||
|
||||
default void generateContext(long seed, int x, int y, int z, List<double[]> context, int contextLayer, int contextRadius) {
|
||||
generateContext(seed, (double) x, y, z, context, contextLayer, contextRadius);
|
||||
}
|
||||
|
||||
default int getContextRadius() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user