# Conflicts:
# core/src/mindustry/mod/ClassMap.java
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package mindustry.maps.filters;
|
||||
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
@@ -13,12 +12,12 @@ public class BlendFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
return Structs.arr(
|
||||
new SliderOption("radius", () -> radius, f -> radius = f, 1f, 10f),
|
||||
new BlockOption("block", () -> block, b -> block = b, anyOptional),
|
||||
new BlockOption("floor", () -> floor, b -> floor = b, anyOptional),
|
||||
new BlockOption("ignore", () -> ignore, b -> ignore = b, floorsOptional)
|
||||
);
|
||||
return new FilterOption[]{
|
||||
new SliderOption("radius", () -> radius, f -> radius = f, 1f, 10f),
|
||||
new BlockOption("block", () -> block, b -> block = b, anyOptional),
|
||||
new BlockOption("floor", () -> floor, b -> floor = b, anyOptional),
|
||||
new BlockOption("ignore", () -> ignore, b -> ignore = b, floorsOptional)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,7 +31,7 @@ public class BlendFilter extends GenerateFilter{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
public void apply(GenerateInput in){
|
||||
if(in.floor == block || block == Blocks.air || in.floor == ignore || (!floor.isFloor() && (in.block == block || in.block == ignore))) return;
|
||||
|
||||
int rad = (int)radius;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.maps.filters;
|
||||
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
@@ -12,7 +11,9 @@ public class ClearFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
return Structs.arr(new BlockOption("block", () -> block, b -> block = b, b -> oresOnly.get(b) || wallsOnly.get(b)));
|
||||
return new BlockOption[]{
|
||||
new BlockOption("block", () -> block, b -> block = b, b -> oresOnly.get(b) || wallsOnly.get(b))
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -21,7 +22,7 @@ public class ClearFilter extends GenerateFilter{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
public void apply(GenerateInput in){
|
||||
|
||||
if(in.block == block){
|
||||
in.block = Blocks.air;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package mindustry.maps.filters;
|
||||
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
@@ -14,10 +13,9 @@ public class CoreSpawnFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
return Structs.arr(
|
||||
//disabled until necessary
|
||||
// SliderOption("amount", () -> amount, f -> amount = (int)f, 1, 10).display()
|
||||
);
|
||||
return new FilterOption[]{};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.maps.filters;
|
||||
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.maps.filters.FilterOption.*;
|
||||
import mindustry.world.*;
|
||||
@@ -10,10 +9,10 @@ public class DistortFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
return Structs.arr(
|
||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 200f),
|
||||
new SliderOption("mag", () -> mag, f -> mag = f, 0.5f, 100f)
|
||||
);
|
||||
return new SliderOption[]{
|
||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 200f),
|
||||
new SliderOption("mag", () -> mag, f -> mag = f, 0.5f, 100f)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,8 +26,8 @@ public class DistortFilter extends GenerateFilter{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
Tile tile = in.tile(in.x + noise(in.x, in.y, scl, mag) - mag / 2f, in.y + noise(in.x, in.y + o, scl, mag) - mag / 2f);
|
||||
public void apply(GenerateInput in){
|
||||
Tile tile = in.tile(in.x + noise(in, scl, mag) - mag / 2f, in.y + noise(in, scl, mag) - mag / 2f);
|
||||
|
||||
in.floor = tile.floor();
|
||||
if(!tile.block().synthetic() && !in.block.synthetic()) in.block = tile.block();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package mindustry.maps.filters;
|
||||
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.maps.filters.FilterOption.*;
|
||||
@@ -13,9 +12,9 @@ public class EnemySpawnFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
return Structs.arr(
|
||||
new SliderOption("amount", () -> amount, f -> amount = (int)f, 1, 10).display()
|
||||
);
|
||||
return new SliderOption[]{
|
||||
new SliderOption("amount", () -> amount, f -> amount = (int)f, 1, 10).display()
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,12 +12,9 @@ import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public abstract class GenerateFilter{
|
||||
protected transient float o = (float)(Math.random() * 10000000.0);
|
||||
protected transient int seed;
|
||||
protected transient GenerateInput in;
|
||||
public int seed = 0;
|
||||
|
||||
public void apply(Tiles tiles, GenerateInput in){
|
||||
this.in = in;
|
||||
|
||||
if(isBuffered()){
|
||||
//buffer of tiles used, each tile packed into a long struct
|
||||
@@ -26,8 +23,8 @@ public abstract class GenerateFilter{
|
||||
for(int i = 0; i < tiles.width * tiles.height; i++){
|
||||
Tile tile = tiles.geti(i);
|
||||
|
||||
in.apply(tile.x, tile.y, tile.block(), tile.floor(), tile.overlay());
|
||||
apply();
|
||||
in.set(tile.x, tile.y, tile.block(), tile.floor(), tile.overlay());
|
||||
apply(in);
|
||||
|
||||
buffer[i] = PackTile.get(in.block.id, in.floor.id, in.overlay.id);
|
||||
}
|
||||
@@ -48,8 +45,8 @@ public abstract class GenerateFilter{
|
||||
}
|
||||
}else{
|
||||
for(Tile tile : tiles){
|
||||
in.apply(tile.x, tile.y, tile.block(), tile.floor(), tile.overlay());
|
||||
apply();
|
||||
in.set(tile.x, tile.y, tile.block(), tile.floor(), tile.overlay());
|
||||
apply(in);
|
||||
|
||||
tile.setFloor(in.floor.asFloor());
|
||||
tile.setOverlay(!in.floor.asFloor().hasSurface() && in.overlay.asFloor().needsSurface ? Blocks.air : in.overlay);
|
||||
@@ -61,16 +58,11 @@ public abstract class GenerateFilter{
|
||||
}
|
||||
}
|
||||
|
||||
public final void apply(GenerateInput in){
|
||||
this.in = in;
|
||||
apply();
|
||||
}
|
||||
|
||||
/** @return a new array of options for configuring this filter */
|
||||
public abstract FilterOption[] options();
|
||||
|
||||
/** apply the actual filter on the input */
|
||||
protected void apply(){}
|
||||
public void apply(GenerateInput in){}
|
||||
|
||||
/** draw any additional guides */
|
||||
public void draw(Image image){}
|
||||
@@ -93,7 +85,7 @@ public abstract class GenerateFilter{
|
||||
|
||||
/** set the seed to a random number */
|
||||
public void randomize(){
|
||||
seed = Mathf.random(99999999);
|
||||
seed = Mathf.random(999999999);
|
||||
}
|
||||
|
||||
/** @return whether this filter needs a read/write buffer (e.g. not a 1:1 tile mapping). */
|
||||
@@ -108,24 +100,26 @@ public abstract class GenerateFilter{
|
||||
|
||||
//utility generation functions
|
||||
|
||||
protected float noise(float x, float y, float scl, float mag){
|
||||
return (float)in.noise.octaveNoise2D(1f, 0f, 1f / scl, x + o, y + o) * mag;
|
||||
//TODO would be nice if these functions used the seed and ditched "in" completely; simplex should be stateless
|
||||
|
||||
protected float noise(GenerateInput in, float scl, float mag){
|
||||
return (float)Simplex.noise2d(seed, 1f, 0f, 1f / scl, in.x, in.y) * mag;
|
||||
}
|
||||
|
||||
protected float noise(float x, float y, float scl, float mag, float octaves, float persistence){
|
||||
return (float)in.noise.octaveNoise2D(octaves, persistence, 1f / scl, x + o, y + o) * mag;
|
||||
protected float noise(GenerateInput in, float scl, float mag, float octaves, float persistence){
|
||||
return (float)Simplex.noise2d(seed, octaves, persistence, 1f / scl, in.x, in.y) * mag;
|
||||
}
|
||||
|
||||
protected float rnoise(float x, float y, float scl, float mag){
|
||||
return RidgedPerlin.noise2d(seed + 1, (int)(x + o), (int)(y + o), 1f / scl) * mag;
|
||||
return Ridged.noise2d(seed + 1, (int)(x), (int)(y), 1f / scl) * mag;
|
||||
}
|
||||
|
||||
protected float rnoise(float x, float y, int octaves, float scl, float falloff, float mag){
|
||||
return RidgedPerlin.noise2d(seed + 1, (int)(x + o), (int)(y + o), octaves, falloff, 1f / scl) * mag;
|
||||
return Ridged.noise2d(seed + 1, (int)(x), (int)(y), octaves, falloff, 1f / scl) * mag;
|
||||
}
|
||||
|
||||
protected float chance(){
|
||||
return Mathf.randomSeed(Pack.longInt(in.x, in.y + seed));
|
||||
protected float chance(int x, int y){
|
||||
return Mathf.randomSeed(Pack.longInt(x, y + seed));
|
||||
}
|
||||
|
||||
/** an input for generating at a certain coordinate. should only be instantiated once. */
|
||||
@@ -137,10 +131,9 @@ public abstract class GenerateFilter{
|
||||
/** output parameters */
|
||||
public Block floor, block, overlay;
|
||||
|
||||
Simplex noise = new Simplex();
|
||||
TileProvider buffer;
|
||||
|
||||
public void apply(int x, int y, Block block, Block floor, Block overlay){
|
||||
public void set(int x, int y, Block block, Block floor, Block overlay){
|
||||
this.floor = floor;
|
||||
this.block = block;
|
||||
this.overlay = overlay;
|
||||
@@ -152,7 +145,6 @@ public abstract class GenerateFilter{
|
||||
this.buffer = buffer;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
noise.setSeed(filter.seed);
|
||||
}
|
||||
|
||||
Tile tile(float x, float y){
|
||||
|
||||
@@ -2,7 +2,6 @@ package mindustry.maps.filters;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.maps.filters.FilterOption.*;
|
||||
import mindustry.world.*;
|
||||
@@ -17,10 +16,10 @@ public class MedianFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
return Structs.arr(
|
||||
new SliderOption("radius", () -> radius, f -> radius = f, 1f, 10f),
|
||||
new SliderOption("percentile", () -> percentile, f -> percentile = f, 0f, 1f)
|
||||
);
|
||||
return new SliderOption[]{
|
||||
new SliderOption("radius", () -> radius, f -> radius = f, 1f, 10f),
|
||||
new SliderOption("percentile", () -> percentile, f -> percentile = f, 0f, 1f)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,7 +33,7 @@ public class MedianFilter extends GenerateFilter{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
public void apply(GenerateInput in){
|
||||
int rad = (int)radius;
|
||||
blocks.clear();
|
||||
floors.clear();
|
||||
|
||||
@@ -12,17 +12,17 @@ import mindustry.maps.filters.FilterOption.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class MirrorFilter extends GenerateFilter{
|
||||
private final Vec2 v1 = new Vec2(), v2 = new Vec2(), v3 = new Vec2();
|
||||
private static final Vec2 v1 = new Vec2(), v2 = new Vec2(), v3 = new Vec2();
|
||||
|
||||
int angle = 45;
|
||||
boolean rotate = false;
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
return Structs.arr(
|
||||
new SliderOption("angle", () -> angle, f -> angle = (int)f, 0, 360, 45),
|
||||
new ToggleOption("rotate", () -> rotate, f -> rotate = f)
|
||||
);
|
||||
return new FilterOption[]{
|
||||
new SliderOption("angle", () -> angle, f -> angle = (int)f, 0, 360, 45),
|
||||
new ToggleOption("rotate", () -> rotate, f -> rotate = f)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -31,7 +31,7 @@ public class MirrorFilter extends GenerateFilter{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void apply(){
|
||||
public void apply(GenerateInput in){
|
||||
v1.trnsExact(angle - 90, 1f);
|
||||
v2.set(v1).scl(-1f);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class MirrorFilter extends GenerateFilter{
|
||||
v3.set(in.x, in.y);
|
||||
|
||||
if(!left(v1, v2, v3)){
|
||||
mirror(v3, v1.x, v1.y, v2.x, v2.y);
|
||||
mirror(in.width, in.height, v3, v1.x, v1.y, v2.x, v2.y);
|
||||
Tile tile = in.tile(v3.x, v3.y);
|
||||
in.floor = tile.floor();
|
||||
if(!tile.block().synthetic()){
|
||||
@@ -73,11 +73,11 @@ public class MirrorFilter extends GenerateFilter{
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
void mirror(Vec2 p, float x0, float y0, float x1, float y1){
|
||||
void mirror(int width, int height, Vec2 p, float x0, float y0, float x1, float y1){
|
||||
//special case: uneven map mirrored at 45 degree angle (or someone might just want rotational symmetry)
|
||||
if((in.width != in.height && angle % 90 != 0) || rotate){
|
||||
p.x = in.width - p.x - 1;
|
||||
p.y = in.height - p.y - 1;
|
||||
if((width != height && angle % 90 != 0) || rotate){
|
||||
p.x = width - p.x - 1;
|
||||
p.y = height - p.y - 1;
|
||||
}else{
|
||||
float dx = x1 - x0;
|
||||
float dy = y1 - y0;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.maps.filters;
|
||||
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
@@ -13,15 +12,15 @@ public class NoiseFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
return Structs.arr(
|
||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
|
||||
new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f),
|
||||
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
|
||||
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
|
||||
new BlockOption("target", () -> target, b -> target = b, anyOptional),
|
||||
new BlockOption("floor", () -> floor, b -> floor = b, floorsOptional),
|
||||
new BlockOption("wall", () -> block, b -> block = b, wallsOptional)
|
||||
);
|
||||
return new FilterOption[]{
|
||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
|
||||
new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f),
|
||||
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
|
||||
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
|
||||
new BlockOption("target", () -> target, b -> target = b, anyOptional),
|
||||
new BlockOption("floor", () -> floor, b -> floor = b, floorsOptional),
|
||||
new BlockOption("wall", () -> block, b -> block = b, wallsOptional)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,8 +29,8 @@ public class NoiseFilter extends GenerateFilter{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
float noise = noise(in.x, in.y, scl, 1f, octaves, falloff);
|
||||
public void apply(GenerateInput in){
|
||||
float noise = noise(in, scl, 1f, octaves, falloff);
|
||||
|
||||
if(noise > threshold && (target == Blocks.air || in.floor == target || in.block == target)){
|
||||
if(floor != Blocks.air) in.floor = floor;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.maps.filters;
|
||||
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
@@ -13,14 +12,14 @@ public class OreFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
return Structs.arr(
|
||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
|
||||
new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f),
|
||||
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
|
||||
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
|
||||
new BlockOption("ore", () -> ore, b -> ore = b, oresOnly),
|
||||
new BlockOption("target", () -> target, b -> target = b, oresFloorsOptional)
|
||||
);
|
||||
return new FilterOption[]{
|
||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
|
||||
new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f),
|
||||
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
|
||||
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
|
||||
new BlockOption("ore", () -> ore, b -> ore = b, oresOnly),
|
||||
new BlockOption("target", () -> target, b -> target = b, oresFloorsOptional)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,8 +28,8 @@ public class OreFilter extends GenerateFilter{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
float noise = noise(in.x, in.y, scl, 1f, octaves, falloff);
|
||||
public void apply(GenerateInput in){
|
||||
float noise = noise(in, scl, 1f, octaves, falloff);
|
||||
|
||||
if(noise > threshold && in.overlay != Blocks.spawn && (target == Blocks.air || in.floor == target || in.overlay == target) && in.floor.asFloor().hasSurface()){
|
||||
in.overlay = ore;
|
||||
|
||||
@@ -2,7 +2,6 @@ package mindustry.maps.filters;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
@@ -17,10 +16,10 @@ public class OreMedianFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
return Structs.arr(
|
||||
new SliderOption("radius", () -> radius, f -> radius = f, 1f, 12f),
|
||||
new SliderOption("percentile", () -> percentile, f -> percentile = f, 0f, 1f)
|
||||
);
|
||||
return new SliderOption[]{
|
||||
new SliderOption("radius", () -> radius, f -> radius = f, 1f, 12f),
|
||||
new SliderOption("percentile", () -> percentile, f -> percentile = f, 0f, 1f)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,7 +33,7 @@ public class OreMedianFilter extends GenerateFilter{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
public void apply(GenerateInput in){
|
||||
if(in.overlay == Blocks.spawn) return;
|
||||
|
||||
int cx = (in.x / 2) * 2;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.maps.filters;
|
||||
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
@@ -13,16 +12,16 @@ public class RiverNoiseFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
return Structs.arr(
|
||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
|
||||
new SliderOption("threshold", () -> threshold, f -> threshold = f, -1f, 1f),
|
||||
new SliderOption("threshold2", () -> threshold2, f -> threshold2 = f, -1f, 1f),
|
||||
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
|
||||
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
|
||||
new BlockOption("block", () -> block, b -> block = b, wallsOnly),
|
||||
new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly),
|
||||
new BlockOption("floor2", () -> floor2, b -> floor2 = b, floorsOnly)
|
||||
);
|
||||
return new FilterOption[]{
|
||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
|
||||
new SliderOption("threshold", () -> threshold, f -> threshold = f, -1f, 1f),
|
||||
new SliderOption("threshold2", () -> threshold2, f -> threshold2 = f, -1f, 1f),
|
||||
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
|
||||
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
|
||||
new BlockOption("block", () -> block, b -> block = b, wallsOnly),
|
||||
new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly),
|
||||
new BlockOption("floor2", () -> floor2, b -> floor2 = b, floorsOnly)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -31,7 +30,7 @@ public class RiverNoiseFilter extends GenerateFilter{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
public void apply(GenerateInput in){
|
||||
float noise = rnoise(in.x, in.y, (int)octaves, scl, falloff, 1f);
|
||||
|
||||
if(noise >= threshold){
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.maps.filters;
|
||||
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
@@ -13,12 +12,12 @@ public class ScatterFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
return Structs.arr(
|
||||
new SliderOption("chance", () -> chance, f -> chance = f, 0f, 1f),
|
||||
new BlockOption("flooronto", () -> flooronto, b -> flooronto = b, floorsOptional),
|
||||
new BlockOption("floor", () -> floor, b -> floor = b, floorsOptional),
|
||||
new BlockOption("block", () -> block, b -> block = b, wallsOresOptional)
|
||||
);
|
||||
return new FilterOption[]{
|
||||
new SliderOption("chance", () -> chance, f -> chance = f, 0f, 1f),
|
||||
new BlockOption("flooronto", () -> flooronto, b -> flooronto = b, floorsOptional),
|
||||
new BlockOption("floor", () -> floor, b -> floor = b, floorsOptional),
|
||||
new BlockOption("block", () -> block, b -> block = b, wallsOresOptional)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,9 +26,9 @@ public class ScatterFilter extends GenerateFilter{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
public void apply(GenerateInput in){
|
||||
|
||||
if(block != Blocks.air && (in.floor == flooronto || flooronto == Blocks.air) && in.block == Blocks.air && chance() <= chance){
|
||||
if(block != Blocks.air && (in.floor == flooronto || flooronto == Blocks.air) && in.block == Blocks.air && chance(in.x, in.y) <= chance){
|
||||
if(!block.isOverlay()){
|
||||
in.block = block;
|
||||
}else{
|
||||
@@ -37,7 +36,7 @@ public class ScatterFilter extends GenerateFilter{
|
||||
}
|
||||
}
|
||||
|
||||
if(floor != Blocks.air && (in.floor == flooronto || flooronto == Blocks.air) && chance() <= chance){
|
||||
if(floor != Blocks.air && (in.floor == flooronto || flooronto == Blocks.air) && chance(in.x, in.y) <= chance){
|
||||
in.floor = floor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ public class SpawnPathFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
return Structs.arr(
|
||||
new SliderOption("radius", () -> radius, f -> radius = (int)f, 1, 20).display()
|
||||
);
|
||||
return new SliderOption[]{
|
||||
new SliderOption("radius", () -> radius, f -> radius = (int)f, 1, 20).display()
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package mindustry.maps.filters;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
@@ -14,16 +13,16 @@ public class TerrainFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
return Structs.arr(
|
||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
|
||||
new SliderOption("mag", () -> magnitude, f -> magnitude = f, 0f, 2f),
|
||||
new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f),
|
||||
new SliderOption("circle-scale", () -> circleScl, f -> circleScl = f, 0f, 3f),
|
||||
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
|
||||
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
|
||||
new BlockOption("floor", () -> floor, b -> floor = b, floorsOptional),
|
||||
new BlockOption("wall", () -> block, b -> block = b, wallsOnly)
|
||||
);
|
||||
return new FilterOption[]{
|
||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
|
||||
new SliderOption("mag", () -> magnitude, f -> magnitude = f, 0f, 2f),
|
||||
new SliderOption("threshold", () -> threshold, f -> threshold = f, 0f, 1f),
|
||||
new SliderOption("circle-scale", () -> circleScl, f -> circleScl = f, 0f, 3f),
|
||||
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
|
||||
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
|
||||
new BlockOption("floor", () -> floor, b -> floor = b, floorsOptional),
|
||||
new BlockOption("wall", () -> block, b -> block = b, wallsOnly)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,8 +31,8 @@ public class TerrainFilter extends GenerateFilter{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
float noise = noise(in.x, in.y, scl, magnitude, octaves, falloff) + Mathf.dst((float)in.x / in.width, (float)in.y / in.height, 0.5f, 0.5f) * circleScl;
|
||||
public void apply(GenerateInput in){
|
||||
float noise = noise(in, scl, magnitude, octaves, falloff) + Mathf.dst((float)in.x / in.width, (float)in.y / in.height, 0.5f, 0.5f) * circleScl;
|
||||
|
||||
if(floor != Blocks.air){
|
||||
in.floor = floor;
|
||||
|
||||
@@ -18,7 +18,6 @@ import static mindustry.Vars.*;
|
||||
public abstract class PlanetGenerator extends BasicGenerator implements HexMesher{
|
||||
protected IntSeq ints = new IntSeq();
|
||||
protected Sector sector;
|
||||
protected Simplex noise = new Simplex();
|
||||
|
||||
/** Should generate sector bases for a planet. */
|
||||
public void generateSector(Sector sector){
|
||||
@@ -116,7 +115,7 @@ public abstract class PlanetGenerator extends BasicGenerator implements HexMeshe
|
||||
@Override
|
||||
protected float noise(float x, float y, double octaves, double falloff, double scl, double mag){
|
||||
Vec3 v = sector.rect.project(x, y);
|
||||
return (float)noise.octaveNoise3D(octaves, falloff, 1f / scl, v.x, v.y, v.z) * (float)mag;
|
||||
return (float)Simplex.noise3d(0, octaves, falloff, 1f / scl, v.x, v.y, v.z) * (float)mag;
|
||||
}
|
||||
|
||||
/** @return the scaling factor for sector rects. */
|
||||
|
||||
@@ -18,6 +18,8 @@ import mindustry.world.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
static final int seed = 0;
|
||||
|
||||
BaseGenerator basegen = new BaseGenerator();
|
||||
float scl = 5f;
|
||||
float waterOffset = 0.07f;
|
||||
@@ -55,7 +57,7 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
|
||||
float rawHeight(Vec3 position){
|
||||
position = Tmp.v33.set(position).scl(scl);
|
||||
return (Mathf.pow((float)noise.octaveNoise3D(7, 0.5f, 1f/3f, position.x, position.y, position.z), 2.3f) + waterOffset) / (1f + waterOffset);
|
||||
return (Mathf.pow((float)Simplex.noise3d(seed, 7, 0.5f, 1f/3f, position.x, position.y, position.z), 2.3f) + waterOffset) / (1f + waterOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,7 +116,7 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
tile.floor = getBlock(position);
|
||||
tile.block = tile.floor.asFloor().wall;
|
||||
|
||||
if(RidgedPerlin.noise3d(1, position.x, position.y, position.z, 2, 22) > 0.31){
|
||||
if(Ridged.noise3d(1, position.x, position.y, position.z, 2, 22) > 0.31){
|
||||
tile.block = Blocks.air;
|
||||
}
|
||||
}
|
||||
@@ -125,12 +127,12 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
position = Tmp.v33.set(position).scl(scl);
|
||||
float rad = scl;
|
||||
float temp = Mathf.clamp(Math.abs(position.y * 2f) / (rad));
|
||||
float tnoise = (float)noise.octaveNoise3D(7, 0.56, 1f/3f, position.x, position.y + 999f, position.z);
|
||||
float tnoise = (float)Simplex.noise3d(seed, 7, 0.56, 1f/3f, position.x, position.y + 999f, position.z);
|
||||
temp = Mathf.lerp(temp, tnoise, 0.5f);
|
||||
height *= 1.2f;
|
||||
height = Mathf.clamp(height);
|
||||
|
||||
float tar = (float)noise.octaveNoise3D(4, 0.55f, 1f/2f, position.x, position.y + 999f, position.z) * 0.3f + Tmp.v31.dst(0, 0, 1f) * 0.2f;
|
||||
float tar = (float)Simplex.noise3d(seed, 4, 0.55f, 1f/2f, position.x, position.y + 999f, position.z) * 0.3f + Tmp.v31.dst(0, 0, 1f) * 0.2f;
|
||||
|
||||
Block res = arr[Mathf.clamp((int)(temp * arr.length), 0, arr[0].length - 1)][Mathf.clamp((int)(height * arr[0].length), 0, arr[0].length - 1)];
|
||||
if(tar > 0.5f){
|
||||
@@ -143,7 +145,7 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
@Override
|
||||
protected float noise(float x, float y, double octaves, double falloff, double scl, double mag){
|
||||
Vec3 v = sector.rect.project(x, y).scl(5f);
|
||||
return (float)noise.octaveNoise3D(octaves, falloff, 1f / scl, v.x, v.y, v.z) * (float)mag;
|
||||
return (float)Simplex.noise3d(seed, octaves, falloff, 1f / scl, v.x, v.y, v.z) * (float)mag;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -250,15 +252,15 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
float scl = 1f;
|
||||
float addscl = 1.3f;
|
||||
|
||||
if(noise.octaveNoise3D(2, 0.5, scl, sector.tile.v.x, sector.tile.v.y, sector.tile.v.z)*nmag + poles > 0.25f*addscl){
|
||||
if(Simplex.noise3d(seed, 2, 0.5, scl, sector.tile.v.x, sector.tile.v.y, sector.tile.v.z)*nmag + poles > 0.25f*addscl){
|
||||
ores.add(Blocks.oreCoal);
|
||||
}
|
||||
|
||||
if(noise.octaveNoise3D(2, 0.5, scl, sector.tile.v.x + 1, sector.tile.v.y, sector.tile.v.z)*nmag + poles > 0.5f*addscl){
|
||||
if(Simplex.noise3d(seed, 2, 0.5, scl, sector.tile.v.x + 1, sector.tile.v.y, sector.tile.v.z)*nmag + poles > 0.5f*addscl){
|
||||
ores.add(Blocks.oreTitanium);
|
||||
}
|
||||
|
||||
if(noise.octaveNoise3D(2, 0.5, scl, sector.tile.v.x + 2, sector.tile.v.y, sector.tile.v.z)*nmag + poles > 0.7f*addscl){
|
||||
if(Simplex.noise3d(seed, 2, 0.5, scl, sector.tile.v.x + 2, sector.tile.v.y, sector.tile.v.z)*nmag + poles > 0.7f*addscl){
|
||||
ores.add(Blocks.oreThorium);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user