mesh generation

This commit is contained in:
2024-03-26 19:30:28 -04:00
parent aada52a45b
commit ad1c3e5370
11 changed files with 218 additions and 64 deletions

View File

@@ -1,12 +1,8 @@
mod data;
use data::*;
use crate::prelude::*;
use bevy::math::IVec2;
use noise::{NoiseFn, SuperSimplex};
pub fn generate_heightmap(
height: usize,
width: usize,
cfg: &GenerationConfig,
seed: u32,
) -> Map {
pub fn generate_heightmap(height: usize, width: usize, cfg: &GenerationConfig, seed: u32) -> Map {
let mut chunks: Vec<Chunk> = Vec::with_capacity(height * width);
for z in 0..height {
for x in 0..width {
@@ -42,6 +38,7 @@ pub fn generate_chunk(
return Chunk {
points: result,
size: size,
chunk_offset: IVec2::new(chunk_x as i32, chunk_z as i32),
};
}
@@ -108,4 +105,4 @@ fn sample_rigid(x: f64, z: f64, cfg: &GeneratorLayer, noise: &SuperSimplex) -> f
}
value -= cfg.min_value;
return value * cfg.strength;
}
}