diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-05-27 12:55:42 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-27 12:55:42 -0300 |
commit | c80ac06253e832284be7ae37515b0ca1ecf11a52 (patch) | |
tree | 78b6e2feb366dedc76eaa4535de275c5d54b4c8d /scene | |
parent | 97342e69856d0f5d15523cfdd13edaeefeb4c823 (diff) | |
parent | 4b545e3105bb804ac5f412fcd83a9832675475d0 (diff) |
Merge pull request #18691 from Web-eWorks/atlasfixes
Fix Sprite3d using AtlasTexture... Again.
Diffstat (limited to 'scene')
-rw-r--r-- | scene/3d/sprite_3d.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 232855c978..d833e6a8bb 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<AtlasTexture> 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<AtlasTexture> 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, |