9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-30 04:29:05 +00:00
This commit is contained in:
Dan Macbook
2020-08-14 08:18:10 -04:00
parent 31bd6a0c0d
commit a1d6431348
9 changed files with 163 additions and 66 deletions

View File

@@ -51,6 +51,7 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator {
public void onHotload() {
super.onHotload();
loadGenerators();
glBiome = new GenLayerBiome(this, masterRandom.nextParallelRNG(1));
}
public void registerGenerator(IrisGenerator g, IrisDimension dim) {

View File

@@ -1,5 +1,6 @@
package com.volmit.iris.gen;
import java.awt.Color;
import java.io.IOException;
import java.lang.reflect.Method;
@@ -16,6 +17,7 @@ import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.object.IrisEffect;
import com.volmit.iris.object.IrisRegion;
import com.volmit.iris.util.BiomeResult;
import com.volmit.iris.util.Function2;
import com.volmit.iris.util.IrisLock;
import com.volmit.iris.util.KMap;
import com.volmit.iris.util.RNG;
@@ -203,4 +205,23 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
return getDimension().isVanillaStructures();
}
public Function2<Double, Double, Color> createRenderer() {
return (x, z) -> render(x, z);
}
private Color render(double x, double z) {
int ix = (int) x;
int iz = (int) z;
double height = getTerrainHeight(ix, iz);
IrisRegion region = sampleRegion(ix, iz);
IrisBiome biome = sampleTrueBiome(ix, iz, height).getBiome();
float shift = (biome.hashCode() % 32)/32f/14f;
float shift2 = (region.hashCode() % 9)/9f/14f;
shift-= shift2;
return Color.getHSBColor((biome.isLand() ? 0.233f : 0.644f)-shift, 0.25f+shift,
(float) (Math.max(0, Math.min(height + getFluidHeight(), 255)) / 255));
}
}

View File

@@ -131,14 +131,7 @@ public abstract class PostBlockChunkGenerator extends ParallaxChunkGenerator imp
@Override
public void updateHeight(int x, int z, int h) {
if (x >> 4 == currentPostX && z >> 4 == currentPostZ) {
//cacheHeight(x, z, h);
}
else {
Iris.error("Invalid Heightmap set! Chunk Currently at " + currentPostX + "," + currentPostZ
+ ". Attempted to place at " + (x >> 4) + " " + (z >> 4) + " which is bad.");
}
getCache().updateHeight(x, z, h);
}
@Override

View File

@@ -3,10 +3,8 @@ package com.volmit.iris.gen.atomics;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
import com.volmit.iris.Iris;
import com.volmit.iris.object.IrisRegion;
import com.volmit.iris.util.BiomeResult;
import com.volmit.iris.util.Form;
import com.volmit.iris.util.KMap;
public class AtomicMulticache {
@@ -32,12 +30,10 @@ public class AtomicMulticache {
public void targetChunk(int x, int z) {
this.x.set(x);
this.z.set(z);
Iris.info("R: " + Form.f(r) + " W: " + Form.f(w) + " M: " + Form.f(m) + " (" + Form.pc(r / (double) (r + m), 1)
+ "), SIZE: " + Form.f(height.size() + biome.size() + region.size()));
height.clear();
region.size();
biome.size();
region.clear();
biome.clear();
rawBiome.clear();
r = 0;
w = 0;
m = 0;
@@ -102,4 +98,8 @@ public class AtomicMulticache {
private long pos(int x, int z) {
return (((long) x) << 32) | (z & 0xffffffffL);
}
public void updateHeight(int x, int z, int h) {
height.put(pos(x, z), (double) h);
}
}