collision fixes
generator changes
This commit is contained in:
@@ -43,7 +43,7 @@ fn create_tile_collider(pos: Vec3, verts: &mut Vec<Vec3>, indices: &mut Vec<[u32
|
|||||||
create_tile_wall_collider(
|
create_tile_wall_collider(
|
||||||
idx,
|
idx,
|
||||||
Vec3::new(pos.x, n_height.min(pos.y - OUTER_RADIUS / 2.), pos.z),
|
Vec3::new(pos.x, n_height.min(pos.y - OUTER_RADIUS / 2.), pos.z),
|
||||||
(i + 1) % 6,
|
i,
|
||||||
verts,
|
verts,
|
||||||
indices,
|
indices,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -217,7 +217,6 @@ fn sample_point(
|
|||||||
let z_s = z / cfg.scale;
|
let z_s = z / cfg.scale;
|
||||||
|
|
||||||
let mut elevation: f64 = 0.;
|
let mut elevation: f64 = 0.;
|
||||||
let mut first_layer: f64 = 0.;
|
|
||||||
for i in 0..cfg.layers.len() {
|
for i in 0..cfg.layers.len() {
|
||||||
let value: f64;
|
let value: f64;
|
||||||
let layer = &cfg.layers[i];
|
let layer = &cfg.layers[i];
|
||||||
@@ -226,14 +225,7 @@ fn sample_point(
|
|||||||
} else {
|
} else {
|
||||||
value = sample_simple(x_s, z_s, layer, noise);
|
value = sample_simple(x_s, z_s, layer, noise);
|
||||||
}
|
}
|
||||||
if i == 0 {
|
elevation += value;
|
||||||
first_layer = value;
|
|
||||||
}
|
|
||||||
if layer.first_layer_mask {
|
|
||||||
elevation += mask(first_layer, value);
|
|
||||||
} else {
|
|
||||||
elevation += value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if border_size == 0.0 {
|
if border_size == 0.0 {
|
||||||
@@ -251,10 +243,6 @@ fn sample_point(
|
|||||||
return border_value.lerp(elevation as f32, d);
|
return border_value.lerp(elevation as f32, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mask(mask: f64, value: f64) -> f64 {
|
|
||||||
return value * mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn sample_simple(x: f64, z: f64, cfg: &GeneratorLayer, noise: &impl NoiseFn<f64, 2>) -> f64 {
|
fn sample_simple(x: f64, z: f64, cfg: &GeneratorLayer, noise: &impl NoiseFn<f64, 2>) -> f64 {
|
||||||
let mut freq: f64 = cfg.base_roughness;
|
let mut freq: f64 = cfg.base_roughness;
|
||||||
let mut amp: f64 = 1.;
|
let mut amp: f64 = 1.;
|
||||||
|
|||||||
@@ -134,6 +134,15 @@ impl BiomeMap {
|
|||||||
return chunk.get_biome_id(x - (cx * Chunk::SIZE), y - (cy * Chunk::SIZE));
|
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 {
|
pub fn get_biome_data(&self, x: usize, y: usize) -> &BiomeData {
|
||||||
let cx = (x as f32 / Chunk::SIZE as f32).floor() as 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 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 {
|
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 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() {
|
for i in 0..b.len() {
|
||||||
let blend = b[i];
|
let blend = b[i];
|
||||||
if blend == 0. {
|
if blend == 0. {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if n < blend {
|
if blend > max {
|
||||||
return i;
|
max = blend + n;
|
||||||
|
cur_id = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,5 +44,4 @@ pub struct GeneratorLayer {
|
|||||||
pub weight: f64,
|
pub weight: f64,
|
||||||
pub weight_multi: f64,
|
pub weight_multi: f64,
|
||||||
pub layers: usize,
|
pub layers: usize,
|
||||||
pub first_layer_mask: bool,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ impl Map {
|
|||||||
let chunk = &self.chunks[chunk_index];
|
let chunk = &self.chunks[chunk_index];
|
||||||
|
|
||||||
return MeshChunkData {
|
return MeshChunkData {
|
||||||
|
min_height: self.min_level,
|
||||||
heights: chunk.heights.clone(),
|
heights: chunk.heights.clone(),
|
||||||
textures: chunk.textures.clone(),
|
textures: chunk.textures.clone(),
|
||||||
};
|
};
|
||||||
@@ -73,7 +74,6 @@ impl Map {
|
|||||||
return pos.is_in_bounds(self.height * Chunk::SIZE, self.width * Chunk::SIZE);
|
return pos.is_in_bounds(self.height * Chunk::SIZE, self.width * Chunk::SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn get_biome_id(&self, pos: &HexCoord) -> usize {
|
pub fn get_biome_id(&self, pos: &HexCoord) -> usize {
|
||||||
assert!(
|
assert!(
|
||||||
self.is_in_bounds(pos),
|
self.is_in_bounds(pos),
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ use super::chunk::Chunk;
|
|||||||
pub struct MeshChunkData {
|
pub struct MeshChunkData {
|
||||||
pub heights: [f32; Chunk::AREA],
|
pub heights: [f32; Chunk::AREA],
|
||||||
pub textures: [[u32; 2]; Chunk::AREA],
|
pub textures: [[u32; 2]; Chunk::AREA],
|
||||||
|
pub min_height: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MeshChunkData {
|
impl MeshChunkData {
|
||||||
pub fn get_neighbors(&self, coord: &HexCoord) -> [f32; 6] {
|
pub fn get_neighbors(&self, coord: &HexCoord) -> [f32; 6] {
|
||||||
let mut data = [0.; 6];
|
let mut data = [self.min_height; 6];
|
||||||
let n_tiles = coord.get_neighbors();
|
let n_tiles = coord.get_neighbors();
|
||||||
for i in 0..6 {
|
for i in 0..6 {
|
||||||
let n = n_tiles[i];
|
let n = n_tiles[i];
|
||||||
|
|||||||
@@ -12,7 +12,11 @@ bevy-inspector-egui = "0.25.0"
|
|||||||
iyes_perf_ui = "0.3.0"
|
iyes_perf_ui = "0.3.0"
|
||||||
noise = "0.8.2"
|
noise = "0.8.2"
|
||||||
world_generation = { path = "../../engine/world_generation" }
|
world_generation = { path = "../../engine/world_generation" }
|
||||||
bevy_rapier3d = { version = "0.27.0", features = ["simd-stable", "parallel"] }
|
bevy_rapier3d = { version = "0.27.0", features = [
|
||||||
|
"simd-stable",
|
||||||
|
"parallel",
|
||||||
|
"debug-render-3d",
|
||||||
|
] }
|
||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
buildings = { path = "../buildings" }
|
buildings = { path = "../buildings" }
|
||||||
units = { path = "../units" }
|
units = { path = "../units" }
|
||||||
|
|||||||
Submodule game/main/assets updated: f8f4375919...5e5c821eb1
@@ -163,7 +163,7 @@ fn create_heightmap(
|
|||||||
) {
|
) {
|
||||||
let config = GenerationConfig {
|
let config = GenerationConfig {
|
||||||
biome_blend: 32,
|
biome_blend: 32,
|
||||||
biome_dither: 16.,
|
biome_dither: 10.,
|
||||||
continent_noise: NoiseConfig {
|
continent_noise: NoiseConfig {
|
||||||
scale: 800.,
|
scale: 800.,
|
||||||
layers: vec![GeneratorLayer {
|
layers: vec![GeneratorLayer {
|
||||||
@@ -176,7 +176,6 @@ fn create_heightmap(
|
|||||||
weight: 0.,
|
weight: 0.,
|
||||||
weight_multi: 0.,
|
weight_multi: 0.,
|
||||||
layers: 1,
|
layers: 1,
|
||||||
first_layer_mask: false,
|
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
moisture_noise: NoiseConfig {
|
moisture_noise: NoiseConfig {
|
||||||
@@ -191,7 +190,6 @@ fn create_heightmap(
|
|||||||
weight: 0.,
|
weight: 0.,
|
||||||
weight_multi: 0.,
|
weight_multi: 0.,
|
||||||
layers: 1,
|
layers: 1,
|
||||||
first_layer_mask: false,
|
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
temperature_noise: NoiseConfig {
|
temperature_noise: NoiseConfig {
|
||||||
@@ -206,7 +204,6 @@ fn create_heightmap(
|
|||||||
weight: 0.,
|
weight: 0.,
|
||||||
weight_multi: 0.,
|
weight_multi: 0.,
|
||||||
layers: 1,
|
layers: 1,
|
||||||
first_layer_mask: false,
|
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
sea_level: 8.5,
|
sea_level: 8.5,
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ impl Plugin for RenderDistancePlugin {
|
|||||||
app.register_type::<RenderDistanceSettings>();
|
app.register_type::<RenderDistanceSettings>();
|
||||||
app.add_systems(PostUpdate, render_distance_system)
|
app.add_systems(PostUpdate, render_distance_system)
|
||||||
.insert_resource(RenderDistanceSettings::default());
|
.insert_resource(RenderDistanceSettings::default());
|
||||||
|
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
app.insert_resource(RenderDistanceSettings::new(f32::MAX));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user