summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2019-01-04 16:11:37 +0100
committerGitHub <noreply@github.com>2019-01-04 16:11:37 +0100
commitbc9899fb9f1559cae1108dff239ce1c9874beb15 (patch)
tree899589c684d643e83e92c5f987ddcbe2c6d816b2
parent1504c961125c76f007bc2ff061c3854effbe3e56 (diff)
parent9d6f16e8645387cbeb3b4c3a543e6b485a822573 (diff)
Merge pull request #24504 from harrisyu/AtlasCheckPixelOpaque
Fix #24470 Atlas Texture with margin setting cause error in editor.
-rw-r--r--scene/resources/texture.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 2e0f04ffcb..d719aa6126 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -1087,8 +1087,12 @@ bool AtlasTexture::is_pixel_opaque(int p_x, int p_y) const {
if (!atlas.is_valid())
return true;
- int x = p_x + region.position.x + margin.position.x;
- int y = p_y + region.position.y + margin.position.y;
+ int x = p_x + region.position.x - margin.position.x;
+ int y = p_y + region.position.y - margin.position.y;
+
+ // margin edge may outside of atlas
+ if (x < 0 || x >= atlas->get_width()) return false;
+ if (y < 0 || y >= atlas->get_height()) return false;
return atlas->is_pixel_opaque(x, y);
}