collision fixes
generator changes
This commit is contained in:
@@ -134,6 +134,15 @@ impl BiomeMap {
|
||||
return chunk.get_biome_id(x - (cx * Chunk::SIZE), y - (cy * Chunk::SIZE));
|
||||
}
|
||||
|
||||
pub fn get_biome_id_dithered(&self, x: usize, y: usize, noise: &impl NoiseFn<f64, 2>, scale: f64) -> usize {
|
||||
let cx = (x as f32 / Chunk::SIZE as f32).floor() as usize;
|
||||
let cy = (y as f32 / Chunk::SIZE as f32).floor() as usize;
|
||||
|
||||
let chunk = &self.chunks[cx + cy * self.size.x as usize];
|
||||
|
||||
return chunk.get_biome_id_dithered(x - (cx * Chunk::SIZE), y - (cy * Chunk::SIZE), noise, scale);
|
||||
}
|
||||
|
||||
pub fn get_biome_data(&self, x: usize, y: usize) -> &BiomeData {
|
||||
let cx = (x as f32 / Chunk::SIZE as f32).floor() as usize;
|
||||
let cy = (y as f32 / Chunk::SIZE as f32).floor() as usize;
|
||||
@@ -175,16 +184,18 @@ impl BiomeChunk {
|
||||
}
|
||||
|
||||
pub fn get_biome_id_dithered(&self, x: usize, y: usize, noise: &impl NoiseFn<f64, 2>, scale: f64) -> usize {
|
||||
let cur_id = self.get_biome_id(x, y);
|
||||
let mut cur_id = self.get_biome_id(x, y);
|
||||
let b = self.get_biome(x, y);
|
||||
let n = (noise.get([x as f64 / scale, y as f64 / scale]) as f32) * b[cur_id];
|
||||
let n = (noise.get([x as f64 / scale, y as f64 / scale]) as f32 - 0.5)/ 2.0;
|
||||
let mut max = b[cur_id] + n;
|
||||
for i in 0..b.len() {
|
||||
let blend = b[i];
|
||||
if blend == 0. {
|
||||
continue;
|
||||
}
|
||||
if n < blend {
|
||||
return i;
|
||||
if blend > max {
|
||||
max = blend + n;
|
||||
cur_id = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user