veloren/world/src/column/mod.rs

552 lines
18 KiB
Rust
Raw Normal View History

2019-07-09 23:51:54 +00:00
use crate::{
all::ForestKind,
block::StructureMeta,
sim::{LocationInfo, SimChunk},
2019-08-04 09:09:51 +00:00
util::{RandomPerm, Sampler, UnitChooser},
2019-07-09 23:51:54 +00:00
World, CONFIG,
};
2019-08-03 20:44:51 +00:00
use common::{
assets,
terrain::{BlockKind, Structure, TerrainChunkSize},
2019-08-03 20:44:51 +00:00
vol::VolSize,
};
use lazy_static::lazy_static;
2019-06-15 10:36:26 +00:00
use noise::NoiseFn;
2019-06-18 21:22:31 +00:00
use std::{
2019-06-19 19:58:56 +00:00
f32,
2019-06-18 21:22:31 +00:00
ops::{Add, Div, Mul, Neg, Sub},
2019-08-03 20:44:51 +00:00
sync::Arc,
2019-06-18 21:22:31 +00:00
};
2019-06-15 10:36:26 +00:00
use vek::*;
2019-06-09 10:24:18 +00:00
pub struct ColumnGen<'a> {
world: &'a World,
}
2019-08-03 21:11:31 +00:00
static UNIT_CHOOSER: UnitChooser = UnitChooser::new(0x700F4EC7);
2019-08-04 09:09:51 +00:00
static DUNGEON_RAND: RandomPerm = RandomPerm::new(0x42782335);
2019-08-03 21:11:31 +00:00
2019-08-03 20:44:51 +00:00
lazy_static! {
pub static ref DUNGEONS: Vec<Arc<Structure>> = vec![
2019-08-06 06:31:48 +00:00
assets::load_map("world.structure.dungeon.ruins", |s: Structure| s
.with_center(Vec3::new(57, 58, 61))
.with_default_kind(BlockKind::Dense))
2019-08-03 20:44:51 +00:00
.unwrap(),
assets::load_map("world.structure.dungeon.ruins_2", |s: Structure| s
.with_center(Vec3::new(53, 57, 60))
.with_default_kind(BlockKind::Dense))
2019-08-04 09:09:51 +00:00
.unwrap(),
assets::load_map("world.structure.dungeon.ruins_3", |s: Structure| s
.with_center(Vec3::new(58, 45, 72))
.with_default_kind(BlockKind::Dense))
.unwrap(),
2019-08-16 16:13:06 +00:00
assets::load_map(
"world.structure.dungeon.meso_sewer_temple",
|s: Structure| s
2019-08-17 06:28:34 +00:00
.with_center(Vec3::new(63, 62, 60))
.with_default_kind(BlockKind::Dense)
2019-08-16 16:13:06 +00:00
)
.unwrap(),
assets::load_map("world.structure.dungeon.ruins_maze", |s: Structure| s
2019-08-17 06:28:34 +00:00
.with_center(Vec3::new(60, 60, 116))
.with_default_kind(BlockKind::Dense))
2019-08-16 16:13:06 +00:00
.unwrap(),
2019-08-03 20:44:51 +00:00
];
}
2019-06-09 10:24:18 +00:00
impl<'a> ColumnGen<'a> {
pub fn new(world: &'a World) -> Self {
2019-06-15 10:36:26 +00:00
Self { world }
2019-06-09 10:24:18 +00:00
}
2019-07-09 23:51:54 +00:00
2019-07-10 11:57:29 +00:00
fn get_local_structure(&self, wpos: Vec2<i32>) -> Option<StructureData> {
2019-07-09 23:51:54 +00:00
let (pos, seed) = self
.world
.sim()
.gen_ctx
.region_gen
.get(wpos)
.iter()
.copied()
.min_by_key(|(pos, _)| pos.distance_squared(wpos))
.unwrap();
2019-07-16 20:32:13 +00:00
let chunk_pos = pos.map2(Vec2::from(TerrainChunkSize::SIZE), |e, sz: u32| {
e / sz as i32
});
let chunk = self.world.sim().get(chunk_pos)?;
2019-07-10 11:57:29 +00:00
2019-08-22 21:25:17 +00:00
if seed % 5 == 2
&& chunk.temp > CONFIG.desert_temp
&& chunk.alt > CONFIG.sea_level + 5.0
&& chunk.chaos <= 0.35
2019-08-22 21:25:17 +00:00
{
2019-07-09 23:51:54 +00:00
Some(StructureData {
pos,
seed,
meta: Some(StructureMeta::Pyramid { height: 140 }),
})
2019-08-03 20:44:51 +00:00
} else if seed % 17 == 2 && chunk.chaos < 0.2 {
Some(StructureData {
pos,
seed,
meta: Some(StructureMeta::Volume {
2019-08-03 21:11:31 +00:00
units: UNIT_CHOOSER.get(seed),
2019-08-04 09:09:51 +00:00
volume: &DUNGEONS[DUNGEON_RAND.get(seed) as usize % DUNGEONS.len()],
2019-08-03 20:44:51 +00:00
}),
})
2019-07-09 23:51:54 +00:00
} else {
None
}
}
2019-07-10 11:57:29 +00:00
fn gen_close_structures(&self, wpos: Vec2<i32>) -> [Option<StructureData>; 9] {
2019-07-09 23:51:54 +00:00
let mut metas = [None; 9];
self.world
.sim()
.gen_ctx
.structure_gen
.get(wpos)
.into_iter()
.copied()
.enumerate()
.for_each(|(i, (pos, seed))| {
2019-07-10 11:57:29 +00:00
metas[i] = self.get_local_structure(pos).or(Some(StructureData {
2019-07-09 23:51:54 +00:00
pos,
seed,
meta: None,
}));
});
metas
}
2019-06-09 10:24:18 +00:00
}
impl<'a> Sampler for ColumnGen<'a> {
type Index = Vec2<i32>;
2019-06-18 21:22:31 +00:00
type Sample = Option<ColumnSample<'a>>;
2019-06-09 10:24:18 +00:00
2019-06-18 21:22:31 +00:00
fn get(&self, wpos: Vec2<i32>) -> Option<ColumnSample<'a>> {
2019-06-09 10:24:18 +00:00
let wposf = wpos.map(|e| e as f64);
2019-06-15 10:36:26 +00:00
let chunk_pos = wpos.map2(Vec2::from(TerrainChunkSize::SIZE), |e, sz: u32| {
2019-06-18 21:22:31 +00:00
e / sz as i32
2019-06-15 10:36:26 +00:00
});
2019-06-09 10:24:18 +00:00
let sim = self.world.sim();
2019-06-22 23:08:21 +00:00
let turb = Vec2::new(
2019-06-22 23:13:59 +00:00
sim.gen_ctx.turb_x_nz.get((wposf.div(48.0)).into_array()) as f32,
sim.gen_ctx.turb_y_nz.get((wposf.div(48.0)).into_array()) as f32,
2019-06-22 23:08:21 +00:00
) * 12.0;
2019-06-22 23:13:59 +00:00
let wposf_turb = wposf + turb.map(|e| e as f64);
2019-06-22 23:08:21 +00:00
2019-06-09 10:24:18 +00:00
let alt_base = sim.get_interpolated(wpos, |chunk| chunk.alt_base)?;
let chaos = sim.get_interpolated(wpos, |chunk| chunk.chaos)?;
let temp = sim.get_interpolated(wpos, |chunk| chunk.temp)?;
2019-08-18 23:52:26 +00:00
let humidity = sim.get_interpolated(wpos, |chunk| chunk.humidity)?;
2019-06-09 10:24:18 +00:00
let rockiness = sim.get_interpolated(wpos, |chunk| chunk.rockiness)?;
let tree_density = sim.get_interpolated(wpos, |chunk| chunk.tree_density)?;
2019-06-25 15:59:09 +00:00
let spawn_rate = sim.get_interpolated(wpos, |chunk| chunk.spawn_rate)?;
2019-06-09 10:24:18 +00:00
2019-06-18 21:22:31 +00:00
let sim_chunk = sim.get(chunk_pos)?;
2019-06-11 18:39:25 +00:00
2019-06-19 19:58:56 +00:00
const RIVER_PROPORTION: f32 = 0.025;
2019-07-08 21:10:48 +00:00
/*
2019-06-19 19:58:56 +00:00
let river = dryness
.abs()
.neg()
.add(RIVER_PROPORTION)
.div(RIVER_PROPORTION)
.max(0.0)
.mul((1.0 - (chaos - 0.15) * 20.0).max(0.0).min(1.0));
2019-07-08 21:10:48 +00:00
*/
let river = 0.0;
2019-06-19 19:58:56 +00:00
2019-08-22 23:09:14 +00:00
let cliff_hill = (sim
.gen_ctx
.small_nz
.get((wposf_turb.div(128.0)).into_array()) as f32)
.mul(24.0);
2019-06-21 00:53:11 +00:00
2019-06-19 19:58:56 +00:00
let riverless_alt = sim.get_interpolated(wpos, |chunk| chunk.alt)?
2019-08-22 23:09:14 +00:00
+ (sim
.gen_ctx
.small_nz
.get((wposf_turb.div(150.0)).into_array()) as f32)
2019-06-18 11:33:18 +00:00
.abs()
2019-08-23 14:12:27 +00:00
.mul(chaos.max(0.025))
.mul(64.0)
+ (sim
.gen_ctx
.small_nz
.get((wposf_turb.div(450.0)).into_array()) as f32)
.abs()
.mul(1.0 - chaos)
.mul(1.0 - humidity)
.mul(96.0);
2019-06-19 19:58:56 +00:00
let is_cliffs = sim_chunk.is_cliffs;
let near_cliffs = sim_chunk.near_cliffs;
2019-06-21 00:53:11 +00:00
2019-06-19 19:58:56 +00:00
let alt = riverless_alt
- (1.0 - river)
.mul(f32::consts::PI)
.cos()
.add(1.0)
.mul(0.5)
.mul(24.0);
2019-07-08 19:08:08 +00:00
let water_level = riverless_alt - 4.0 - 5.0 * chaos;
2019-06-09 10:24:18 +00:00
2019-06-15 10:36:26 +00:00
let rock = (sim.gen_ctx.small_nz.get(
Vec3::new(wposf.x, wposf.y, alt as f64)
2019-06-15 10:36:26 +00:00
.div(100.0)
.into_array(),
) as f32)
2019-06-09 10:24:18 +00:00
.mul(rockiness)
2019-06-10 10:50:48 +00:00
.sub(0.4)
2019-06-09 10:24:18 +00:00
.max(0.0)
2019-06-10 10:50:48 +00:00
.mul(8.0);
2019-06-09 10:24:18 +00:00
let wposf3d = Vec3::new(wposf.x, wposf.y, alt as f64);
2019-06-23 13:55:54 +00:00
let marble_small = (sim.gen_ctx.hill_nz.get((wposf3d.div(3.0)).into_array()) as f32)
.add(1.0)
.mul(0.5);
2019-06-23 19:43:02 +00:00
let marble = (sim.gen_ctx.hill_nz.get((wposf3d.div(48.0)).into_array()) as f32)
.mul(0.75)
2019-06-23 13:55:54 +00:00
.add(1.0)
.mul(0.5)
2019-07-03 09:47:23 +00:00
.add(marble_small.sub(0.5).mul(0.25));
2019-06-09 10:24:18 +00:00
2019-08-22 23:09:14 +00:00
let temp = temp.add((marble - 0.5) * 0.25);
let humidity = humidity.add((marble - 0.5) * 0.25);
2019-08-22 21:25:17 +00:00
2019-06-09 10:24:18 +00:00
// Colours
2019-08-22 21:25:17 +00:00
let cold_grass = Rgb::new(0.0, 0.5, 0.25);
2019-08-14 02:43:27 +00:00
let warm_grass = Rgb::new(0.03, 0.8, 0.0);
2019-08-19 17:20:54 +00:00
let dark_grass = Rgb::new(0.01, 0.3, 0.0);
let wet_grass = Rgb::new(0.1, 0.8, 0.2);
2019-08-14 02:43:27 +00:00
let cold_stone = Rgb::new(0.57, 0.67, 0.8);
let warm_stone = Rgb::new(0.77, 0.77, 0.64);
let beach_sand = Rgb::new(0.89, 0.87, 0.64);
let desert_sand = Rgb::new(0.93, 0.80, 0.54);
2019-08-22 21:25:17 +00:00
let snow = Rgb::new(0.8, 0.85, 1.0);
2019-08-12 01:53:48 +00:00
let dirt = Lerp::lerp(
2019-08-14 02:43:27 +00:00
Rgb::new(0.078, 0.078, 0.20),
Rgb::new(0.61, 0.49, 0.0),
2019-08-12 01:53:48 +00:00
marble,
);
2019-08-22 21:25:17 +00:00
let tundra = Lerp::lerp(snow, Rgb::new(0.01, 0.3, 0.0), 0.4 + marble * 0.6);
let dead_tundra = Lerp::lerp(warm_stone, Rgb::new(0.3, 0.12, 0.2), marble);
2019-06-09 10:24:18 +00:00
let cliff = Rgb::lerp(cold_stone, warm_stone, marble);
2019-08-21 22:15:24 +00:00
let grass = Rgb::lerp(
cold_grass,
warm_grass,
2019-08-22 21:25:17 +00:00
marble.sub(0.5).add(1.0.sub(humidity).mul(0.5)).powf(1.5),
2019-08-21 22:15:24 +00:00
);
2019-08-22 21:25:17 +00:00
let snow_moss = Rgb::lerp(snow, cold_grass, 0.4 + marble.powf(1.5) * 0.6);
2019-08-21 22:15:24 +00:00
let moss = Rgb::lerp(dark_grass, cold_grass, marble.powf(1.5));
let rainforest = Rgb::lerp(wet_grass, warm_grass, marble.powf(1.5));
let sand = Rgb::lerp(beach_sand, desert_sand, marble);
2019-06-23 13:55:54 +00:00
let tropical = Rgb::lerp(
2019-08-21 18:41:32 +00:00
Rgb::lerp(
grass,
Rgb::new(0.15, 0.2, 0.15),
2019-08-22 21:25:17 +00:00
marble_small
.sub(0.5)
.mul(0.2)
.add(0.75.mul(1.0.sub(humidity)))
.powf(0.667),
2019-08-21 18:41:32 +00:00
),
2019-08-14 02:43:27 +00:00
Rgb::new(0.87, 0.62, 0.56),
2019-08-22 21:25:17 +00:00
marble.powf(1.5).sub(0.5).mul(4.0),
);
2019-06-23 13:55:54 +00:00
2019-08-20 20:48:22 +00:00
// For below desert humidity, we are always sand or rock, depending on altitude and
// temperature.
let ground = Rgb::lerp(
Rgb::lerp(
2019-08-21 18:41:32 +00:00
dead_tundra,
2019-08-20 20:48:22 +00:00
sand,
2019-08-21 18:41:32 +00:00
temp.sub(CONFIG.snow_temp)
.div(CONFIG.desert_temp.sub(CONFIG.snow_temp))
2019-08-22 21:25:17 +00:00
.mul(0.5),
2019-08-20 20:48:22 +00:00
),
cliff,
2019-08-22 21:25:17 +00:00
alt.sub(CONFIG.mountain_scale * 0.25)
.div(CONFIG.mountain_scale * 0.125),
2019-08-20 20:48:22 +00:00
);
// From desert to forest humidity, we go from tundra to dirt to grass to moss to sand,
2019-08-19 17:20:54 +00:00
// depending on temperature.
2019-08-18 23:52:26 +00:00
let ground = Rgb::lerp(
ground,
Rgb::lerp(
Rgb::lerp(
2019-08-19 01:01:11 +00:00
Rgb::lerp(
2019-08-19 17:20:54 +00:00
Rgb::lerp(
2019-08-22 21:25:17 +00:00
tundra,
2019-08-19 17:20:54 +00:00
// snow_temp to 0
2019-08-20 20:48:22 +00:00
dirt,
temp.sub(CONFIG.snow_temp)
.div(CONFIG.snow_temp.neg())
/*.sub((marble - 0.5) * 0.05)
.mul(256.0)*/
2019-08-22 21:25:17 +00:00
.mul(1.0),
2019-08-19 17:20:54 +00:00
),
// 0 to tropical_temp
2019-08-19 01:01:11 +00:00
grass,
2019-08-22 21:25:17 +00:00
temp.div(CONFIG.tropical_temp).mul(4.0),
2019-08-19 01:01:11 +00:00
),
2019-08-19 17:20:54 +00:00
// tropical_temp to desert_temp
2019-08-19 01:01:11 +00:00
moss,
2019-08-19 17:20:54 +00:00
temp.sub(CONFIG.tropical_temp)
.div(CONFIG.desert_temp.sub(CONFIG.tropical_temp))
2019-08-22 21:25:17 +00:00
.mul(1.0),
2019-08-18 23:52:26 +00:00
),
2019-08-19 17:20:54 +00:00
// above desert_temp
2019-08-19 01:01:11 +00:00
sand,
2019-08-21 21:36:43 +00:00
temp.sub(CONFIG.desert_temp)
.div(1.0 - CONFIG.desert_temp)
2019-08-22 21:25:17 +00:00
.mul(4.0),
2019-08-18 23:52:26 +00:00
),
2019-08-22 21:25:17 +00:00
humidity
.sub(CONFIG.desert_hum)
.div(CONFIG.forest_hum.sub(CONFIG.desert_hum))
.mul(1.0),
2019-08-18 23:52:26 +00:00
);
2019-08-20 20:48:22 +00:00
// From forest to jungle humidity, we go from snow to dark grass to grass to tropics to sand
2019-08-19 17:20:54 +00:00
// depending on temperature.
2019-06-09 10:24:18 +00:00
let ground = Rgb::lerp(
2019-08-18 23:52:26 +00:00
ground,
Rgb::lerp(
Rgb::lerp(
2019-08-19 01:01:11 +00:00
Rgb::lerp(
2019-08-22 21:25:17 +00:00
snow_moss,
2019-08-19 17:20:54 +00:00
// 0 to tropical_temp
grass,
2019-08-22 21:25:17 +00:00
temp.div(CONFIG.tropical_temp).mul(4.0),
2019-08-19 01:01:11 +00:00
),
2019-08-19 17:20:54 +00:00
// tropical_temp to desert_temp
tropical,
temp.sub(CONFIG.tropical_temp)
.div(CONFIG.desert_temp.sub(CONFIG.tropical_temp))
2019-08-22 21:25:17 +00:00
.mul(1.0),
2019-08-19 17:20:54 +00:00
),
// above desert_temp
sand,
2019-08-21 21:36:43 +00:00
temp.sub(CONFIG.desert_temp)
.div(1.0 - CONFIG.desert_temp)
.mul(4.0),
2019-08-19 17:20:54 +00:00
),
2019-08-22 21:25:17 +00:00
humidity
.sub(CONFIG.forest_hum)
.div(CONFIG.jungle_hum.sub(CONFIG.forest_hum))
.mul(1.0),
2019-08-19 17:20:54 +00:00
);
// From jungle humidity upwards, we go from snow to grass to rainforest to tropics to sand.
let ground = Rgb::lerp(
ground,
Rgb::lerp(
Rgb::lerp(
Rgb::lerp(
2019-08-22 21:25:17 +00:00
snow_moss,
2019-08-19 17:20:54 +00:00
// 0 to tropical_temp
rainforest,
2019-08-22 21:25:17 +00:00
temp.div(CONFIG.tropical_temp).mul(4.0),
2019-08-19 17:20:54 +00:00
),
// tropical_temp to desert_temp
tropical,
temp.sub(CONFIG.tropical_temp)
.div(CONFIG.desert_temp.sub(CONFIG.tropical_temp))
2019-08-22 21:25:17 +00:00
.mul(4.0),
2019-08-18 23:52:26 +00:00
),
2019-08-19 17:20:54 +00:00
// above desert_temp
2019-08-19 01:01:11 +00:00
sand,
2019-08-21 21:36:43 +00:00
temp.sub(CONFIG.desert_temp)
.div(1.0 - CONFIG.desert_temp)
.mul(4.0),
2019-08-18 23:52:26 +00:00
),
2019-08-22 21:25:17 +00:00
humidity.sub(CONFIG.jungle_hum).mul(1.0),
);
// Snow covering
let ground = Rgb::lerp(
snow,
ground,
temp.sub(CONFIG.snow_temp)
.max(-humidity.sub(CONFIG.desert_hum))
.mul(16.0)
2019-08-22 23:31:27 +00:00
.add((marble_small - 0.5) * 0.5),
2019-08-18 23:52:26 +00:00
);
2019-06-23 13:55:54 +00:00
// Work out if we're on a path or near a town
2019-06-25 15:59:09 +00:00
let dist_to_path = match &sim_chunk.location {
Some(loc) => {
let this_loc = &sim.locations[loc.loc_idx];
2019-06-26 00:27:41 +00:00
this_loc
.neighbours
2019-06-25 15:59:09 +00:00
.iter()
.map(|j| {
let other_loc = &sim.locations[*j];
// Find the two location centers
let near_0 = this_loc.center.map(|e| e as f32);
let near_1 = other_loc.center.map(|e| e as f32);
// Calculate distance to path between them
(0.0 + (near_1.y - near_0.y) * wposf_turb.x as f32
- (near_1.x - near_0.x) * wposf_turb.y as f32
+ near_1.x * near_0.y
- near_0.x * near_1.y)
.abs()
.div(near_0.distance(near_1))
})
.filter(|x| x.is_finite())
.min_by(|a, b| a.partial_cmp(b).unwrap())
.unwrap_or(f32::INFINITY)
2019-06-26 00:27:41 +00:00
}
2019-06-25 15:59:09 +00:00
None => f32::INFINITY,
};
2019-06-22 21:44:27 +00:00
2019-06-26 18:32:26 +00:00
let on_path = dist_to_path < 5.0 && !sim_chunk.near_cliffs; // || near_0.distance(wposf_turb.map(|e| e as f32)) < 150.0;
2019-06-23 13:55:54 +00:00
let (alt, ground) = if on_path {
(alt - 1.0, dirt)
2019-06-22 21:44:27 +00:00
} else {
2019-06-22 22:40:41 +00:00
(alt, ground)
2019-06-22 21:44:27 +00:00
};
2019-06-25 15:59:09 +00:00
// Cities
2019-06-26 18:32:26 +00:00
// TODO: In a later MR
2019-06-25 15:59:09 +00:00
let building = match &sim_chunk.location {
Some(loc) => {
let loc = &sim.locations[loc.loc_idx];
let rpos = wposf.map2(loc.center, |a, b| a as f32 - b as f32) / 256.0 + 0.5;
if rpos.map(|e| e >= 0.0 && e < 1.0).reduce_and() {
2019-06-26 00:27:41 +00:00
(loc.settlement
.get_at(rpos)
.map(|b| b.seed % 20 + 10)
.unwrap_or(0)) as f32
2019-06-25 15:59:09 +00:00
} else {
0.0
}
2019-06-26 00:27:41 +00:00
}
2019-06-25 15:59:09 +00:00
None => 0.0,
};
let alt = alt + building;
2019-06-09 10:24:18 +00:00
// Caves
let cave_at = |wposf: Vec2<f64>| {
(sim.gen_ctx.cave_0_nz.get(
Vec3::new(wposf.x, wposf.y, alt as f64 * 8.0)
.div(800.0)
.into_array(),
) as f32)
.powf(2.0)
.neg()
.add(1.0)
.mul((1.15 - chaos).min(1.0))
};
let cave_xy = cave_at(wposf);
let cave_alt = alt - 24.0
2019-06-09 10:24:18 +00:00
+ (sim
.gen_ctx
.cave_1_nz
.get(Vec2::new(wposf.x, wposf.y).div(48.0).into_array()) as f32)
* 8.0
+ (sim
.gen_ctx
.cave_1_nz
.get(Vec2::new(wposf.x, wposf.y).div(500.0).into_array()) as f32)
2019-06-09 10:24:18 +00:00
.add(1.0)
.mul(0.5)
.powf(15.0)
.mul(150.0);
2019-06-09 10:24:18 +00:00
Some(ColumnSample {
alt,
chaos,
2019-06-19 19:58:56 +00:00
water_level,
river,
2019-06-09 10:24:18 +00:00
surface_color: Rgb::lerp(
2019-06-10 14:22:59 +00:00
sand,
2019-06-09 10:24:18 +00:00
// Land
Rgb::lerp(
ground,
// Mountain
Rgb::lerp(
cliff,
snow,
(alt - CONFIG.sea_level
2019-07-08 19:08:08 +00:00
- 0.4 * CONFIG.mountain_scale
2019-06-09 10:24:18 +00:00
- alt_base
- temp * 96.0
- marble * 24.0)
/ 12.0,
),
2019-07-08 19:08:08 +00:00
(alt - CONFIG.sea_level - 0.25 * CONFIG.mountain_scale + marble * 128.0)
2019-08-19 03:22:39 +00:00
/ (0.25 * CONFIG.mountain_scale),
2019-06-09 10:24:18 +00:00
),
// Beach
((alt - CONFIG.sea_level - 1.0) / 2.0)
.min(1.0 - river * 2.0)
.max(0.0),
2019-06-09 10:24:18 +00:00
),
2019-06-23 13:55:54 +00:00
sub_surface_color: dirt,
2019-06-09 10:24:18 +00:00
tree_density,
2019-06-18 21:22:31 +00:00
forest_kind: sim_chunk.forest_kind,
2019-07-10 11:57:29 +00:00
close_structures: self.gen_close_structures(wpos),
2019-06-09 10:24:18 +00:00
cave_xy,
cave_alt,
2019-08-20 09:59:15 +00:00
marble,
2019-08-21 17:22:05 +00:00
marble_small,
2019-06-09 10:24:18 +00:00
rock,
is_cliffs,
near_cliffs,
2019-06-21 00:53:11 +00:00
cliff_hill,
close_cliffs: sim.gen_ctx.cliff_gen.get(wpos),
2019-06-12 20:22:16 +00:00
temp,
2019-06-25 15:59:09 +00:00
spawn_rate,
2019-06-18 21:22:31 +00:00
location: sim_chunk.location.as_ref(),
2019-06-09 10:24:18 +00:00
})
}
}
#[derive(Clone)]
2019-06-18 21:22:31 +00:00
pub struct ColumnSample<'a> {
2019-06-09 10:24:18 +00:00
pub alt: f32,
pub chaos: f32,
2019-06-19 19:58:56 +00:00
pub water_level: f32,
pub river: f32,
2019-06-09 10:24:18 +00:00
pub surface_color: Rgb<f32>,
2019-06-23 13:55:54 +00:00
pub sub_surface_color: Rgb<f32>,
2019-06-09 10:24:18 +00:00
pub tree_density: f32,
2019-06-11 18:39:25 +00:00
pub forest_kind: ForestKind,
2019-07-09 23:51:54 +00:00
pub close_structures: [Option<StructureData>; 9],
2019-06-09 10:24:18 +00:00
pub cave_xy: f32,
pub cave_alt: f32,
2019-08-20 09:59:15 +00:00
pub marble: f32,
2019-08-21 17:22:05 +00:00
pub marble_small: f32,
2019-06-09 10:24:18 +00:00
pub rock: f32,
pub is_cliffs: bool,
pub near_cliffs: bool,
2019-06-21 00:53:11 +00:00
pub cliff_hill: f32,
pub close_cliffs: [(Vec2<i32>, u32); 9],
2019-06-12 20:22:16 +00:00
pub temp: f32,
2019-06-25 15:59:09 +00:00
pub spawn_rate: f32,
2019-06-22 21:44:27 +00:00
pub location: Option<&'a LocationInfo>,
2019-06-09 10:24:18 +00:00
}
2019-07-09 23:51:54 +00:00
#[derive(Copy, Clone)]
pub struct StructureData {
pub pos: Vec2<i32>,
pub seed: u32,
pub meta: Option<StructureMeta>,
}