Flag surrounding sections as dirty when setting a block

This commit is contained in:
Thinkofname 2016-04-01 21:13:31 +01:00
parent b42e60d5eb
commit 2ad817c540
1 changed files with 9 additions and 0 deletions

View File

@ -65,6 +65,7 @@ impl World {
if current != new {
self.set_block_raw(bx, by, bz, new);
}
self.set_dirty(bx >> 4, by >> 4, bz >> 4);
}
}
}
@ -219,6 +220,14 @@ impl World {
out
}
fn set_dirty(&mut self, x: i32, y: i32, z: i32) {
if let Some(chunk) = self.chunks.get_mut(&CPos(x, z)) {
if let Some(sec) = chunk.sections.get_mut(y as usize).and_then(|v| v.as_mut()) {
sec.dirty = true;
}
}
}
pub fn is_section_dirty(&self, pos: (i32, i32, i32)) -> bool {
if let Some(chunk) = self.chunks.get(&CPos(pos.0, pos.2)) {
if let Some(sec) = chunk.sections[pos.1 as usize].as_ref() {