mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix various builds.
This commit is contained in:
parent
ebe76abc54
commit
35deaae540
@ -6,6 +6,7 @@ use std::{
|
||||
type Result = std::io::Result<()>;
|
||||
|
||||
use common::{
|
||||
generation::EntityInfo,
|
||||
terrain::{Block, BlockKind, SpriteKind},
|
||||
vol::{BaseVol, ReadVol, RectSizedVol, WriteVol},
|
||||
};
|
||||
@ -13,7 +14,7 @@ use rayon::ThreadPoolBuilder;
|
||||
use vek::{Vec2, Vec3};
|
||||
use veloren_world::{
|
||||
sim::{FileOpts, WorldOpts, DEFAULT_WORLD_MAP},
|
||||
site2::{plot::PlotKind, Fill, Structure},
|
||||
site2::{plot::PlotKind, Fill, Filler, Structure},
|
||||
CanvasInfo, Land, World,
|
||||
};
|
||||
|
||||
@ -41,12 +42,16 @@ fn main() -> Result {
|
||||
let wpos = volume.size_xy().map(|p| p as i32 / 2);
|
||||
let site =
|
||||
veloren_world::site2::Site::generate_dungeon(&Land::empty(), &mut rand::thread_rng(), wpos);
|
||||
CanvasInfo::with_mock_canvas_info(index.as_index_ref(), world.sim(), |canvas| {
|
||||
let mut arena = bumpalo::Bump::new();
|
||||
CanvasInfo::with_mock_canvas_info(index.as_index_ref(), world.sim(), |&canvas| {
|
||||
for plot in site.plots() {
|
||||
let render_area = plot.find_bounds();
|
||||
if let PlotKind::Dungeon(dungeon) = plot.kind() {
|
||||
let (prim_tree, fills, _entities) = dungeon.render_collect(&site, canvas);
|
||||
/*let (prim_tree, fills, _entities) = */
|
||||
(dungeon as &dyn Structure<_>).render_collect(&site, &mut arena, canvas, render_area, &mut volume);
|
||||
arena.reset();
|
||||
|
||||
for (prim, fill) in fills {
|
||||
/* for (prim, fill) in fills {
|
||||
let aabb = Fill::get_bounds(&prim_tree, prim);
|
||||
|
||||
for x in aabb.min.x..aabb.max.x {
|
||||
@ -66,7 +71,7 @@ fn main() -> Result {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} */
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -259,3 +264,15 @@ impl WriteVol for ExportVol {
|
||||
Ok(vox)
|
||||
}
|
||||
}
|
||||
|
||||
impl Filler for ExportVol {
|
||||
#[inline]
|
||||
fn map<F: Fill>(&mut self, pos: Vec3<i32>, f: F) {
|
||||
let _ = WriteVol::map(self, pos, |block| f.sample_at(pos, block).unwrap_or(block));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn spawn(&mut self, _entity: EntityInfo) {
|
||||
// No-op
|
||||
}
|
||||
}
|
||||
|
@ -1,67 +0,0 @@
|
||||
use rand::thread_rng;
|
||||
use vek::*;
|
||||
use veloren_world::{index::Index, site::Settlement, IndexRef};
|
||||
|
||||
const W: usize = 640;
|
||||
const H: usize = 480;
|
||||
|
||||
fn main() {
|
||||
let seed = 1337;
|
||||
let index = &Index::new(seed);
|
||||
|
||||
let mut win =
|
||||
minifb::Window::new("Settlement Viewer", W, H, minifb::WindowOptions::default()).unwrap();
|
||||
|
||||
let settlement = Settlement::generate(Vec2::zero(), None, &mut thread_rng());
|
||||
|
||||
let mut focus = Vec2::<f32>::zero();
|
||||
let mut zoom = 1.0;
|
||||
let colors = &*index.colors();
|
||||
let features = &*index.features();
|
||||
let index = IndexRef {
|
||||
colors,
|
||||
features,
|
||||
index,
|
||||
};
|
||||
|
||||
while win.is_open() {
|
||||
let mut buf = vec![0; W * H];
|
||||
|
||||
let win_to_pos =
|
||||
|wp: Vec2<usize>| (wp.map(|e| e as f32) - Vec2::new(W as f32, H as f32) * 0.5) * zoom;
|
||||
|
||||
for i in 0..W {
|
||||
for j in 0..H {
|
||||
let pos = focus + win_to_pos(Vec2::new(i, j)) * zoom;
|
||||
|
||||
let color = settlement
|
||||
.get_color(index, pos.map(|e| e.floor() as i32))
|
||||
.unwrap_or_else(|| Rgb::new(35, 50, 20));
|
||||
|
||||
buf[j * W + i] = u32::from_le_bytes([color.b, color.g, color.r, 255]);
|
||||
}
|
||||
}
|
||||
|
||||
let spd = 20.0;
|
||||
if win.is_key_down(minifb::Key::W) {
|
||||
focus.y -= spd * zoom;
|
||||
}
|
||||
if win.is_key_down(minifb::Key::A) {
|
||||
focus.x -= spd * zoom;
|
||||
}
|
||||
if win.is_key_down(minifb::Key::S) {
|
||||
focus.y += spd * zoom;
|
||||
}
|
||||
if win.is_key_down(minifb::Key::D) {
|
||||
focus.x += spd * zoom;
|
||||
}
|
||||
if win.is_key_down(minifb::Key::Q) {
|
||||
zoom *= 1.05;
|
||||
}
|
||||
if win.is_key_down(minifb::Key::E) {
|
||||
zoom /= 1.05;
|
||||
}
|
||||
|
||||
win.update_with_buffer(&buf, W, H).unwrap();
|
||||
}
|
||||
}
|
@ -18,8 +18,6 @@ fn main() {
|
||||
|
||||
let index = index.as_index_ref();
|
||||
|
||||
let sampler = world.sample_columns();
|
||||
|
||||
let mut win =
|
||||
minifb::Window::new("World Viewer", W, H, minifb::WindowOptions::default()).unwrap();
|
||||
|
||||
@ -34,12 +32,13 @@ fn main() {
|
||||
for j in 0..H {
|
||||
let pos = focus + Vec2::new(i as i32, j as i32) * scale;
|
||||
|
||||
let sampler = world.sample_blocks(pos >> common::terrain::TERRAIN_CHUNK_BLOCKS_LG as i32, index);
|
||||
let (alt, place) = sampler
|
||||
.get((pos, index, None))
|
||||
.map(|sample| {
|
||||
.map(|sampler| {
|
||||
let sample = sampler.column_gen.get(pos);
|
||||
(
|
||||
sample.alt.sub(64.0).add(gain).mul(0.7).max(0.0).min(255.0) as u8,
|
||||
sample.chunk.place,
|
||||
sampler.column_gen.sim_chunk.place,
|
||||
)
|
||||
})
|
||||
.unwrap_or((0, None));
|
||||
|
@ -60,16 +60,17 @@ fn main() {
|
||||
let map_size_lg = sampler.map_size_lg();
|
||||
|
||||
let samples_data = {
|
||||
let column_sample = world.sample_columns();
|
||||
(0..map_size_lg.chunks_len())
|
||||
.into_par_iter()
|
||||
.map(|posi| {
|
||||
column_sample.get((
|
||||
uniform_idx_as_vec2(map_size_lg, posi)
|
||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as i32),
|
||||
index,
|
||||
None,
|
||||
))
|
||||
let chunk_pos = uniform_idx_as_vec2(map_size_lg, posi);
|
||||
world.sample_columns(chunk_pos, index)
|
||||
.map(|column_sample| {
|
||||
column_sample.get(
|
||||
chunk_pos
|
||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as i32)
|
||||
)
|
||||
})
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.into_boxed_slice()
|
||||
|
@ -75,7 +75,7 @@ pub struct ColumnGen<'a> {
|
||||
pub(crate) cliff_height_spline: CatmullRom2D<f32>,
|
||||
|
||||
/// Chunk data
|
||||
pub(crate) sim_chunk: &'a SimChunk,
|
||||
pub sim_chunk: &'a SimChunk,
|
||||
pub(crate) catmull_rom_gen: SplineGen2D<&'a SimChunk>,
|
||||
pub(crate) neighbor_river_data: Vec<(Vec2<i32>, &'a SimChunk, &'a RiverData)>,
|
||||
pub(crate) homogeneous_water_level: Option<f32>,
|
||||
|
@ -1016,7 +1016,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
|
||||
return None;
|
||||
}
|
||||
let (density, patch) = f(canvas.chunk(), col);
|
||||
let density = /* patch
|
||||
let density = patch
|
||||
.map(|(base_density_prop, wavelen, threshold)| {
|
||||
if canvas
|
||||
.index()
|
||||
@ -1035,7 +1035,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) {
|
||||
density * base_density_prop
|
||||
}
|
||||
})
|
||||
.unwrap_or(*/density/*)*/;
|
||||
.unwrap_or(density);
|
||||
if density > 0.0
|
||||
&& rng.gen::<f32>() < density //RandomField::new(i as u32).chance(Vec3::new(wpos2d.x, wpos2d.y, 0), density)
|
||||
&& matches!(&water_mode, Underwater | Floating) == underwater
|
||||
|
@ -428,8 +428,8 @@ mod tests {
|
||||
))
|
||||
},
|
||||
// common::terrain::site::SitesKind::Settlement |
|
||||
_ => crate::site::Site::settlement(crate::site::Settlement::generate(
|
||||
wpos, None, &mut rng,
|
||||
_ => crate::site::Site::refactor(crate::site2::Site::generate_city(
|
||||
&crate::Land::empty(), &mut rng, wpos,
|
||||
)),
|
||||
};
|
||||
for g in i.resources.iter() {
|
||||
@ -467,9 +467,11 @@ mod tests {
|
||||
rng: ChaChaRng,
|
||||
targets: HashMap<Id<crate::site::Site>, f32>,
|
||||
names: HashMap<Id<crate::site::Site>, String>,
|
||||
sim: sim::WorldSim,
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
/// test whether a site in moderate climate can survive on its own
|
||||
fn test_economy_moderate_standalone() {
|
||||
fn add_settlement(
|
||||
@ -479,10 +481,8 @@ mod tests {
|
||||
resources: &[(Good, f32)],
|
||||
) -> Id<crate::site::Site> {
|
||||
let wpos = Vec2 { x: 42, y: 42 };
|
||||
let mut settlement = crate::site::Site::settlement(crate::site::Settlement::generate(
|
||||
wpos,
|
||||
None,
|
||||
&mut env.rng,
|
||||
let mut settlement = crate::site::Site::refactor(crate::site2::Site::generate_city(
|
||||
&crate::Land::empty(), &mut env.rng, wpos,
|
||||
));
|
||||
for (good, amount) in resources.iter() {
|
||||
settlement.economy.natural_resources.chunks_per_resource
|
||||
@ -507,7 +507,7 @@ mod tests {
|
||||
};
|
||||
let index = crate::index::Index::new(seed);
|
||||
info!("Index created");
|
||||
let mut sim = sim::WorldSim::generate(seed, opts, &threadpool);
|
||||
let sim = sim::WorldSim::generate(seed, opts, &threadpool);
|
||||
info!("World loaded");
|
||||
let rng = ChaChaRng::from_seed(seed_expan::rng_state(seed));
|
||||
let mut env = Simenv {
|
||||
@ -515,6 +515,7 @@ mod tests {
|
||||
rng,
|
||||
targets: HashMap::new(),
|
||||
names: HashMap::new(),
|
||||
sim,
|
||||
};
|
||||
add_settlement(&mut env, "Forest", 5000.0, &[(
|
||||
Good::Terrain(BiomeKind::Forest),
|
||||
@ -560,7 +561,7 @@ mod tests {
|
||||
.add_neighbor(center, i as usize);
|
||||
});
|
||||
}
|
||||
crate::sim2::simulate(&mut env.index, &mut sim);
|
||||
crate::sim2::simulate(&mut env.index, &mut env.sim);
|
||||
show_economy(&env.index.sites, &Some(env.names));
|
||||
// check population (shrinks if economy gets broken)
|
||||
for (id, site) in env.index.sites.iter() {
|
||||
|
Loading…
Reference in New Issue
Block a user