mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Don't pessimise worldgen fast paths for rtsim resources
This commit is contained in:
parent
c6a7d7aa9b
commit
308ee2f674
@ -159,6 +159,9 @@ impl<'a> Canvas<'a> {
|
||||
.unwrap_or_else(Block::empty)
|
||||
}
|
||||
|
||||
/// Set a block in the canvas chunk. Note that if the block is a resource
|
||||
/// (see [`Block::get_rtsim_resource`]) then [`Canvas::map_resource`] should
|
||||
/// be used instead.
|
||||
pub fn set(&mut self, pos: Vec3<i32>, block: Block) {
|
||||
if block.get_rtsim_resource().is_some() {
|
||||
self.rtsim_resource_blocks.push(pos);
|
||||
@ -166,7 +169,16 @@ impl<'a> Canvas<'a> {
|
||||
let _ = self.chunk.set(pos - self.wpos(), block);
|
||||
}
|
||||
|
||||
/// Map a block in the canvas chunk. Note that if the block is a resource
|
||||
/// (see [`Block::get_rtsim_resource`]) then [`Canvas::map_resource`] should
|
||||
/// be used instead.
|
||||
pub fn map(&mut self, pos: Vec3<i32>, f: impl FnOnce(Block) -> Block) {
|
||||
let _ = self.chunk.map(pos - self.wpos(), f);
|
||||
}
|
||||
|
||||
/// Like [`Canvas::map`], except allows marking resource-containing blocks
|
||||
/// appropriately.
|
||||
pub fn map_resource(&mut self, pos: Vec3<i32>, f: impl FnOnce(Block) -> Block) {
|
||||
let _ = self.chunk.map(pos - self.wpos(), |b| {
|
||||
let new_block = f(b);
|
||||
if new_block.get_rtsim_resource().is_some() {
|
||||
|
@ -553,7 +553,7 @@ fn write_column<R: Rng>(
|
||||
for z in bedrock..z_range.end {
|
||||
let wpos = wpos2d.with_z(z);
|
||||
let mut try_spawn_entity = false;
|
||||
canvas.map(wpos, |_block| {
|
||||
canvas.map_resource(wpos, |_block| {
|
||||
if z < z_range.start - 4 && !void_below {
|
||||
Block::new(BlockKind::Lava, Rgb::new(255, 65, 0))
|
||||
} else if basalt > 0.0
|
||||
|
@ -1098,7 +1098,7 @@ pub fn apply_scatter_to(canvas: &mut Canvas, _rng: &mut impl Rng, calendar: Opti
|
||||
.find(|z| !is_under(canvas.get(Vec3::new(wpos2d.x, wpos2d.y, alt + z))))
|
||||
})
|
||||
{
|
||||
canvas.map(Vec3::new(wpos2d.x, wpos2d.y, alt + solid_end), |block| {
|
||||
canvas.map_resource(Vec3::new(wpos2d.x, wpos2d.y, alt + solid_end), |block| {
|
||||
block.with_sprite(kind)
|
||||
});
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ pub fn apply_trees_to(
|
||||
if last_block.is_filled() {
|
||||
for (chance, sprite) in hanging_sprites {
|
||||
if dynamic_rng.gen_bool(*chance as f64) {
|
||||
canvas.map(wpos, |block| block.with_sprite(*sprite));
|
||||
canvas.map_resource(wpos, |block| block.with_sprite(*sprite));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user