mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix iteration area.
I'm pretty sure this bug already existed on master, so if the performance degradation is unacceptable, we can revert.
This commit is contained in:
parent
c2410c6303
commit
32fdcc1c1c
@ -305,8 +305,8 @@ fn dungeon(c: &mut Criterion) {
|
|||||||
// let chunk_pos = Vec2::new(842, 839);
|
// let chunk_pos = Vec2::new(842, 839);
|
||||||
// let chunk_pos = Vec2::new(24507/32, 20682/32);
|
// let chunk_pos = Vec2::new(24507/32, 20682/32);
|
||||||
// let chunk_pos = Vec2::new(19638/32, 19621/32);
|
// let chunk_pos = Vec2::new(19638/32, 19621/32);
|
||||||
let chunk_pos = Vec2::new(21488/32, 13584/32);
|
// let chunk_pos = Vec2::new(21488/32, 13584/32);
|
||||||
// let chunk_pos = Vec2::new(21488/32 + 5, 13584/32 + 5);
|
let chunk_pos = Vec2::new(21488/32 + 5, 13584/32 + 5);
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
black_box(world.generate_chunk(index.as_index_ref(), chunk_pos, || false, None));
|
black_box(world.generate_chunk(index.as_index_ref(), chunk_pos, || false, None));
|
||||||
});
|
});
|
||||||
@ -319,8 +319,8 @@ fn dungeon(c: &mut Criterion) {
|
|||||||
// let chunk_pos = Vec2::new(842, 839);
|
// let chunk_pos = Vec2::new(842, 839);
|
||||||
// let chunk_pos = Vec2::new(24507/32, 20682/32);
|
// let chunk_pos = Vec2::new(24507/32, 20682/32);
|
||||||
// let chunk_pos = Vec2::new(19638/32, 19621/32);
|
// let chunk_pos = Vec2::new(19638/32, 19621/32);
|
||||||
let chunk_pos = Vec2::new(21488/32, 13584/32);
|
// let chunk_pos = Vec2::new(21488/32, 13584/32);
|
||||||
// let chunk_pos = Vec2::new(21488/32 + 5, 13584/32 + 5);
|
let chunk_pos = Vec2::new(21488/32 + 5, 13584/32 + 5);
|
||||||
let chunk = world.generate_chunk(index.as_index_ref(), chunk_pos, || false, None).unwrap().0;
|
let chunk = world.generate_chunk(index.as_index_ref(), chunk_pos, || false, None).unwrap().0;
|
||||||
/* println!("{:?}", chunk.sub_chunks_len());
|
/* println!("{:?}", chunk.sub_chunks_len());
|
||||||
let chunk = chunk.sub_chunks().next().unwrap(); */
|
let chunk = chunk.sub_chunks().next().unwrap(); */
|
||||||
|
@ -122,17 +122,27 @@ pub fn apply_trees_to(
|
|||||||
let calendar = info.calendar();
|
let calendar = info.calendar();
|
||||||
/* let mut tree_cache = StructureGenCache::new(info.chunks().gen_ctx.structure_gen.clone()); */
|
/* let mut tree_cache = StructureGenCache::new(info.chunks().gen_ctx.structure_gen.clone()); */
|
||||||
|
|
||||||
|
let area_size = Vec2::from(info.area().size().map(|e| e as i32));
|
||||||
|
|
||||||
// Get all the trees in range.
|
// Get all the trees in range.
|
||||||
let render_area = Aabr {
|
let render_area = Aabr {
|
||||||
min: info.wpos(),
|
min: info.wpos(),
|
||||||
max: info.wpos() + Vec2::from(info.area().size().map(|e| e as i32)),
|
max: info.wpos() + area_size,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Maximum area we have to check for tree origins.
|
||||||
|
let witness_area = Aabr {
|
||||||
|
min: info.wpos() - area_size,
|
||||||
|
max: info.wpos() + Vec2::from(info.area().size().map(|e| e as i32)) + area_size,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut arena = bumpalo::Bump::new();
|
let mut arena = bumpalo::Bump::new();
|
||||||
|
|
||||||
/*canvas.foreach_col(|canvas, wpos2d, col| {*/
|
/*canvas.foreach_col(|canvas, wpos2d, col| {*/
|
||||||
info.chunks()
|
info.chunks()
|
||||||
.get_area_trees(render_area.min + 15, render_area.max + 16)
|
// TODO: These should be in terms of some combination of frequency and chunk size.
|
||||||
|
.get_area_trees(render_area.min - 8, render_area.max + 16)
|
||||||
|
.filter(|attr| witness_area.contains_point(attr.pos))
|
||||||
.filter_map(|attr| {
|
.filter_map(|attr| {
|
||||||
info.col_or_gen(attr.pos)
|
info.col_or_gen(attr.pos)
|
||||||
.filter(|col| tree_valid_at(col, attr.seed))
|
.filter(|col| tree_valid_at(col, attr.seed))
|
||||||
|
Loading…
Reference in New Issue
Block a user