From 46e451d8369741d61c2529dbb8dc6269a4879c91 Mon Sep 17 00:00:00 2001 From: Lily Lyons Date: Tue, 12 Sep 2023 07:59:26 -0700 Subject: [PATCH] fix(tilemap): :bug: Fix tileset rendering with no autotiles --- src/graphics/primitives/tiles/atlas.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/graphics/primitives/tiles/atlas.rs b/src/graphics/primitives/tiles/atlas.rs index ddfb1ce0..03196002 100644 --- a/src/graphics/primitives/tiles/atlas.rs +++ b/src/graphics/primitives/tiles/atlas.rs @@ -82,7 +82,9 @@ impl Atlas { autotiles[i] .as_deref() .map(image_cache::WgpuTexture::width) - .unwrap_or(0) + // Why unwrap with a width of 96? Even though the autotile doesn't exist, it still has an effective width on the atlas of one frame. + // Further rendering code breaks down with an autotile width of 0, anyway. + .unwrap_or(96) / 96 }); @@ -90,7 +92,7 @@ impl Atlas { .iter() .map(|f| f * AUTOTILE_FRAME_WIDTH) .max() - .unwrap_or(0); + .unwrap_or(AUTOTILE_FRAME_WIDTH); let render_state = &state!().render_state; let mut encoder =