Flag surrounding sections as dirty when setting a block
This commit is contained in:
parent
b42e60d5eb
commit
2ad817c540
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue