Fix meshing benchmark.

This commit is contained in:
Joshua Yanovski 2020-08-20 07:29:06 +02:00
parent c95e07db3b
commit 051cd4934e

View File

@ -15,7 +15,7 @@ const GEN_SIZE: i32 = 4;
pub fn criterion_benchmark(c: &mut Criterion) {
// Generate chunks here to test
let mut terrain = TerrainGrid::new().unwrap();
let world = World::generate(42, sim::WorldOpts {
let (world, index) = World::generate(42, sim::WorldOpts {
// NOTE: If this gets too expensive, we can turn it off.
// TODO: Consider an option to turn off all erosion as well, or even provide altitude
// directly with a closure.
@ -23,10 +23,11 @@ pub fn criterion_benchmark(c: &mut Criterion) {
world_file: sim::FileOpts::LoadAsset(sim::DEFAULT_WORLD_MAP.into()),
..Default::default()
});
let index = index.as_index_ref();
(0..GEN_SIZE)
.flat_map(|x| (0..GEN_SIZE).map(move |y| Vec2::new(x, y)))
.map(|offset| offset + CENTER)
.map(|pos| (pos, world.generate_chunk(pos, || false).unwrap()))
.map(|pos| (pos, world.generate_chunk(index, pos, || false).unwrap()))
.for_each(|(key, chunk)| {
terrain.insert(key, Arc::new(chunk.0));
});