Now the initial width and height of the main texture will be set properly even if the first added texture is an AtlasTexture.

This commit is contained in:
Relintai 2019-10-30 20:32:08 +01:00
parent e865e55db0
commit 0dd28a6525

View File

@ -67,11 +67,26 @@ void TextureLayerMerger::add_texture(Ref<Texture> p_texture, Color p_color, Vect
entry.rect = p_rect; entry.rect = p_rect;
if (_width == 0 || _height == 0) {
Ref<AtlasTexture> at = p_texture;
int w = 0;
int h = 0;
if (at.is_valid()) {
w = at->get_region().size.x;
h = at->get_region().size.y;
} else {
w = p_texture->get_width();
h = p_texture->get_height();
}
if (_width == 0) if (_width == 0)
_width = p_texture->get_width(); _width = w;
if (_height == 0) if (_height == 0)
_height = p_texture->get_height(); _height = h;
}
_entries.push_back(entry); _entries.push_back(entry);
} }