Merge pull request #18691 from Web-eWorks/atlasfixes

Fix Sprite3d using AtlasTexture... Again.
This commit is contained in:
Juan Linietsky 2018-05-27 12:55:42 -03:00 committed by GitHub
commit c80ac06253
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 0 deletions

View File

@ -366,6 +366,16 @@ void Sprite3D::_draw() {
final_rect.position * pixel_size, 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] = { Vector2 uvs[4] = {
final_src_rect.position / tsize, final_src_rect.position / tsize,
(final_src_rect.position + Vector2(final_src_rect.size.x, 0)) / 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, 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] = { Vector2 uvs[4] = {
final_src_rect.position / tsize, final_src_rect.position / tsize,
(final_src_rect.position + Vector2(final_src_rect.size.x, 0)) / tsize, (final_src_rect.position + Vector2(final_src_rect.size.x, 0)) / tsize,