From d1c93a0af3f9c9e924ba5552177fca2fa30a7aac Mon Sep 17 00:00:00 2001 From: Webster Sheets Date: Mon, 7 May 2018 16:05:28 -0400 Subject: [PATCH] Fix AtlasTexture usage in Sprite3D. Changes as requested in b484d5c. (cherry picked from commit 4b545e3105bb804ac5f412fcd83a9832675475d0) --- scene/3d/sprite_3d.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index dd037ac2c02..fc7a6476aa3 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -366,6 +366,16 @@ void Sprite3D::_draw() { final_rect.position * pixel_size, }; + + Vector2 src_tsize = Vector2(texture->get_width(), texture->get_height()); + + // Properly setup UVs for impostor textures (AtlasTexture). + Ref atlas_tex = texture; + if (atlas_tex != NULL) { + src_tsize[0] = atlas_tex->get_atlas()->get_width(); + src_tsize[1] = atlas_tex->get_atlas()->get_height(); + } + Vector2 uvs[4] = { final_src_rect.position / tsize, (final_src_rect.position + Vector2(final_src_rect.size.x, 0)) / tsize, @@ -656,6 +666,16 @@ void AnimatedSprite3D::_draw() { final_rect.position * pixel_size, }; + + Vector2 src_tsize = Vector2(texture->get_width(), texture->get_height()); + + // Properly setup UVs for impostor textures (AtlasTexture). + Ref atlas_tex = texture; + if (atlas_tex != NULL) { + src_tsize[0] = atlas_tex->get_atlas()->get_width(); + src_tsize[1] = atlas_tex->get_atlas()->get_height(); + } + Vector2 uvs[4] = { final_src_rect.position / tsize, (final_src_rect.position + Vector2(final_src_rect.size.x, 0)) / tsize,