From f3d3bf9d03711a0b60f30f2fb651e825b6e63a23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pa=CC=84vels=20Nadtoc=CC=8Cajevs?= <7645683+bruvzg@users.noreply.github.com> Date: Sat, 19 Apr 2025 12:51:59 +0300 Subject: [PATCH] Fix `is_pixel_opaque` bound checks. --- scene/resources/compressed_texture.cpp | 4 ++-- scene/resources/image_texture.cpp | 4 ++-- scene/resources/portable_compressed_texture.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scene/resources/compressed_texture.cpp b/scene/resources/compressed_texture.cpp index 0a5f1f16671..30b605f288c 100644 --- a/scene/resources/compressed_texture.cpp +++ b/scene/resources/compressed_texture.cpp @@ -269,8 +269,8 @@ bool CompressedTexture2D::is_pixel_opaque(int p_x, int p_y) const { int x = p_x * aw / w; int y = p_y * ah / h; - x = CLAMP(x, 0, aw); - y = CLAMP(y, 0, ah); + x = CLAMP(x, 0, aw - 1); + y = CLAMP(y, 0, ah - 1); return alpha_cache->get_bit(x, y); } diff --git a/scene/resources/image_texture.cpp b/scene/resources/image_texture.cpp index b92f381f757..3f5411c663a 100644 --- a/scene/resources/image_texture.cpp +++ b/scene/resources/image_texture.cpp @@ -197,8 +197,8 @@ bool ImageTexture::is_pixel_opaque(int p_x, int p_y) const { int x = p_x * aw / w; int y = p_y * ah / h; - x = CLAMP(x, 0, aw); - y = CLAMP(y, 0, ah); + x = CLAMP(x, 0, aw - 1); + y = CLAMP(y, 0, ah - 1); return alpha_cache->get_bit(x, y); } diff --git a/scene/resources/portable_compressed_texture.cpp b/scene/resources/portable_compressed_texture.cpp index 65fef3d6a41..2ee87ebd30c 100644 --- a/scene/resources/portable_compressed_texture.cpp +++ b/scene/resources/portable_compressed_texture.cpp @@ -313,8 +313,8 @@ bool PortableCompressedTexture2D::is_pixel_opaque(int p_x, int p_y) const { int x = p_x * aw / size.width; int y = p_y * ah / size.height; - x = CLAMP(x, 0, aw); - y = CLAMP(y, 0, ah); + x = CLAMP(x, 0, aw - 1); + y = CLAMP(y, 0, ah - 1); return alpha_cache->get_bit(x, y); }