Fix stencil mask pattern (off by one errors)

This commit is contained in:
Maximilian Ammann 2022-01-21 15:46:15 +01:00
parent e2abd9facd
commit 0fab6b5114
3 changed files with 8 additions and 7 deletions

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 348 KiB

After

Width:  |  Height:  |  Size: 425 KiB

View File

@ -68,8 +68,8 @@ impl WorldTileCoords {
pub fn into_aligned(self) -> AlignedWorldTileCoords {
AlignedWorldTileCoords(WorldTileCoords {
x: self.x / 2 * 2,
y: self.y / 2 * 2,
x: div_floor(self.x, 2) * 2,
y: div_floor(self.y, 2) * 2,
z: self.z,
})
}

View File

@ -107,6 +107,7 @@ impl TileMaskPattern {
pub fn update_pattern(&mut self, z: u8, extent: f32) {
if !self.bounding_box.is_initialized() {
// Happens if `update_bounds` hasn't been called so far
return;
}
@ -115,13 +116,13 @@ impl TileMaskPattern {
let start: WorldTileCoords = (self.bounding_box.min_x, self.bounding_box.min_y, z).into(); // upper left corner
let end: WorldTileCoords = (self.bounding_box.max_x, self.bounding_box.max_y, z).into(); // lower right corner
let aligned_start = start.into_aligned();
let aligned_start = start.into_aligned().upper_left();
let aligned_end = end.into_aligned().lower_right();
let start_world = start.into_world(extent);
let start_world = aligned_start.into_world(extent);
let dy = aligned_end.y - aligned_start.0.y;
let dx = aligned_end.x - aligned_start.0.x;
let dy = aligned_end.y - aligned_start.y + 1;
let dx = aligned_end.x - aligned_start.x + 1;
let anchor_x = start_world.x;
let anchor_y = start_world.y;