mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added test poles, minor improvements
This commit is contained in:
parent
da9b23d4f6
commit
3ee4245652
@ -125,6 +125,9 @@ impl Block {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn empty() -> Self { Self::air(SpriteKind::Empty) }
|
||||
|
||||
/// TODO: See if we can generalize this somehow.
|
||||
#[inline]
|
||||
pub const fn water(sprite: SpriteKind) -> Self {
|
||||
|
@ -18,6 +18,7 @@ pub mod login_provider;
|
||||
pub mod metrics;
|
||||
pub mod persistence;
|
||||
pub mod presence;
|
||||
pub mod rtsim;
|
||||
pub mod settings;
|
||||
pub mod state_ext;
|
||||
pub mod sys;
|
||||
@ -353,6 +354,9 @@ impl Server {
|
||||
block_on(network.listen(ProtocolAddr::Tcp(settings.gameserver_address)))?;
|
||||
let connection_handler = ConnectionHandler::new(network);
|
||||
|
||||
// Initiate real-time world simulation
|
||||
rtsim::init(&mut state, &world);
|
||||
|
||||
let this = Self {
|
||||
state,
|
||||
world: Arc::new(world),
|
||||
@ -513,6 +517,7 @@ impl Server {
|
||||
|
||||
// Tick the world
|
||||
self.world.tick(dt);
|
||||
rtsim::tick(&mut self.state);
|
||||
|
||||
let before_entity_cleanup = Instant::now();
|
||||
|
||||
|
14
server/src/rtsim/mod.rs
Normal file
14
server/src/rtsim/mod.rs
Normal file
@ -0,0 +1,14 @@
|
||||
pub mod state;
|
||||
|
||||
use common::state::State;
|
||||
|
||||
pub fn init(state: &mut State, world: &world::World) {
|
||||
state
|
||||
.ecs_mut()
|
||||
.insert(state::SimState::new(world.sim().get_size()));
|
||||
tracing::info!("Initiated real-time world simulation");
|
||||
}
|
||||
|
||||
pub fn tick(state: &mut State) {
|
||||
// TODO
|
||||
}
|
20
server/src/rtsim/state.rs
Normal file
20
server/src/rtsim/state.rs
Normal file
@ -0,0 +1,20 @@
|
||||
use vek::*;
|
||||
use world::util::Grid;
|
||||
|
||||
pub struct SimState {
|
||||
chunks: Grid<Chunk>,
|
||||
}
|
||||
|
||||
impl SimState {
|
||||
pub fn new(world_chunk_size: Vec2<u32>) -> Self {
|
||||
Self {
|
||||
chunks: Grid::populate_from(world_chunk_size.map(|e| e as i32), |_| Chunk {
|
||||
is_loaded: false,
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Chunk {
|
||||
is_loaded: bool,
|
||||
}
|
@ -244,7 +244,7 @@ pub fn block_from_structure(
|
||||
},
|
||||
StructureBlock::Chest => {
|
||||
if structure_seed % 10 < 7 {
|
||||
None
|
||||
Some(Block::empty())
|
||||
} else {
|
||||
Some(with_sprite(SpriteKind::Chest))
|
||||
}
|
||||
|
@ -93,6 +93,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
||||
let neighbor_chunk = sim.get(neighbor_pos)?;
|
||||
Some((neighbor_pos, neighbor_chunk, &neighbor_chunk.river))
|
||||
});
|
||||
|
||||
let lake_width = (TerrainChunkSize::RECT_SIZE.x as f64 * (2.0f64.sqrt())) + 12.0;
|
||||
let neighbor_river_data = neighbor_river_data.map(|(posj, chunkj, river)| {
|
||||
let kind = match river.river_kind {
|
||||
@ -747,10 +748,17 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
||||
.powf(3.0)
|
||||
.add(1.0)
|
||||
.mul(0.5);
|
||||
let marble_mid = (sim.gen_ctx.hill_nz.get((wposf3d.div(12.0)).into_array()) as f32)
|
||||
.mul(0.75)
|
||||
.add(1.0)
|
||||
.mul(0.5);
|
||||
//.add(marble_small.sub(0.5).mul(0.25));
|
||||
let marble = (sim.gen_ctx.hill_nz.get((wposf3d.div(48.0)).into_array()) as f32)
|
||||
.mul(0.75)
|
||||
.add(1.0)
|
||||
.mul(0.5)
|
||||
.mul(0.5);
|
||||
let marble_mixed = marble
|
||||
.add(marble_mid.sub(0.5).mul(0.5))
|
||||
.add(marble_small.sub(0.5).mul(0.25));
|
||||
|
||||
// Colours
|
||||
@ -793,20 +801,27 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
||||
let grass_high = grass_high.into();
|
||||
let tropical_high = tropical_high.into();
|
||||
|
||||
let dirt = Lerp::lerp(dirt_low, dirt_high, marble);
|
||||
let tundra = Lerp::lerp(snow, snow_high, 0.4 + marble * 0.6);
|
||||
let dead_tundra = Lerp::lerp(warm_stone, warm_stone_high, marble);
|
||||
let cliff = Rgb::lerp(cold_stone, hot_stone, marble);
|
||||
let dirt = Lerp::lerp(dirt_low, dirt_high, marble_mixed);
|
||||
let tundra = Lerp::lerp(snow, snow_high, 0.4 + marble_mixed * 0.6);
|
||||
let dead_tundra = Lerp::lerp(warm_stone, warm_stone_high, marble_mixed);
|
||||
let cliff = Rgb::lerp(cold_stone, hot_stone, marble_mixed);
|
||||
|
||||
let grass = Rgb::lerp(
|
||||
cold_grass,
|
||||
warm_grass,
|
||||
marble.sub(0.5).add(1.0.sub(humidity).mul(0.5)).powf(1.5),
|
||||
marble_mixed
|
||||
.sub(0.5)
|
||||
.add(1.0.sub(humidity).mul(0.5))
|
||||
.powf(1.5),
|
||||
);
|
||||
let snow_moss = Rgb::lerp(snow_moss.into(), cold_grass, 0.4 + marble.powf(1.5) * 0.6);
|
||||
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);
|
||||
let snow_moss = Rgb::lerp(
|
||||
snow_moss.into(),
|
||||
cold_grass,
|
||||
0.4 + marble_mixed.powf(1.5) * 0.6,
|
||||
);
|
||||
let moss = Rgb::lerp(dark_grass, cold_grass, marble_mixed.powf(1.5));
|
||||
let rainforest = Rgb::lerp(wet_grass, warm_grass, marble_mixed.powf(1.5));
|
||||
let sand = Rgb::lerp(beach_sand, desert_sand, marble_mixed);
|
||||
|
||||
let tropical = Rgb::lerp(
|
||||
Rgb::lerp(
|
||||
@ -819,7 +834,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
||||
.powf(0.667),
|
||||
),
|
||||
tropical_high,
|
||||
marble.powf(1.5).sub(0.5).mul(4.0),
|
||||
marble_mixed.powf(1.5).sub(0.5).mul(4.0),
|
||||
);
|
||||
|
||||
// For below desert humidity, we are always sand or rock, depending on altitude
|
||||
@ -945,9 +960,11 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
||||
let snow_cover = temp
|
||||
.sub(CONFIG.snow_temp)
|
||||
.max(-humidity.sub(CONFIG.desert_hum))
|
||||
.mul(16.0)
|
||||
.add((marble_small - 0.5) * 0.5);
|
||||
let (alt, ground, sub_surface_color, snow_cover) = if snow_cover <= 0.5 && alt > water_level
|
||||
.mul(4.0)
|
||||
.add(((marble - 0.5) / 0.5) * 0.5)
|
||||
.add(((marble_mid - 0.5) / 0.5) * 0.25)
|
||||
.add(((marble_small - 0.5) / 0.5) * 0.175);
|
||||
let (alt, ground, sub_surface_color, snow_cover) = if snow_cover <= 0.0 && alt > water_level
|
||||
{
|
||||
// Allow snow cover.
|
||||
(
|
||||
|
@ -2061,12 +2061,13 @@ impl SimChunk {
|
||||
|
||||
// We also correlate temperature negatively with altitude and absolute latitude,
|
||||
// using different weighting than we use for humidity.
|
||||
const TEMP_WEIGHTS: [f32; 2] = [/* 1.5, */ 1.0, 2.0];
|
||||
const TEMP_WEIGHTS: [f32; 3] = [/* 1.5, */ 1.0, 2.0, 1.0];
|
||||
let temp = cdf_irwin_hall(
|
||||
&TEMP_WEIGHTS,
|
||||
[
|
||||
temp_uniform,
|
||||
1.0 - alt_uniform, /* 1.0 - abs_lat_uniform*/
|
||||
(gen_ctx.rock_nz.get((wposf.div(50000.0)).into_array()) as f32 * 2.5 + 1.0) * 0.5,
|
||||
],
|
||||
)
|
||||
// Convert to [-1, 1]
|
||||
@ -2176,12 +2177,18 @@ impl SimChunk {
|
||||
0.0
|
||||
} else {
|
||||
let warp = Vec2::new(
|
||||
gen_ctx.turb_x_nz.get(wposf.div(256.0).into_array()) as f32,
|
||||
gen_ctx.turb_y_nz.get(wposf.div(256.0).into_array()) as f32,
|
||||
) * 192.0;
|
||||
let dune_nz = (wposf.map(|e| e as f32) + warp).sum().div(100.0).sin() * 0.5 + 0.5;
|
||||
let dune_scale = 16.0;
|
||||
dune_nz * dune_scale * (temp - 0.75).clamped(0.0, 0.25) * 4.0
|
||||
gen_ctx.turb_x_nz.get(wposf.div(350.0).into_array()) as f32,
|
||||
gen_ctx.turb_y_nz.get(wposf.div(350.0).into_array()) as f32,
|
||||
) * 200.0;
|
||||
const DUNE_SCALE: f32 = 24.0;
|
||||
const DUNE_LEN: f32 = 96.0;
|
||||
const DUNE_DIR: Vec2<f32> = Vec2::new(1.0, 1.0);
|
||||
let dune_dist = (wposf.map(|e| e as f32) + warp)
|
||||
.div(DUNE_LEN)
|
||||
.mul(DUNE_DIR.normalized())
|
||||
.sum();
|
||||
let dune_nz = 0.5 - dune_dist.sin().abs() + 0.5 * (dune_dist + 0.5).sin().abs();
|
||||
dune_nz * DUNE_SCALE * (temp - 0.75).clamped(0.0, 0.25) * 4.0
|
||||
};
|
||||
|
||||
Self {
|
||||
@ -2213,7 +2220,7 @@ impl SimChunk {
|
||||
(
|
||||
ForestKind::Palm,
|
||||
(CONFIG.desert_hum, 1.5),
|
||||
(CONFIG.tropical_temp, 1.5),
|
||||
((CONFIG.tropical_temp + CONFIG.desert_temp) / 2.0, 1.25),
|
||||
(1.0, 2.0),
|
||||
),
|
||||
(
|
||||
|
Loading…
Reference in New Issue
Block a user