From 0dd28a6525b52db8054300e3b6450dc6d7d7afd3 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 30 Oct 2019 20:32:08 +0100 Subject: [PATCH] Now the initial width and height of the main texture will be set properly even if the first added texture is an AtlasTexture. --- layers/texture_layer_merger.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/layers/texture_layer_merger.cpp b/layers/texture_layer_merger.cpp index cde711c..2976e4f 100644 --- a/layers/texture_layer_merger.cpp +++ b/layers/texture_layer_merger.cpp @@ -67,11 +67,26 @@ void TextureLayerMerger::add_texture(Ref p_texture, Color p_color, Vect entry.rect = p_rect; - if (_width == 0) - _width = p_texture->get_width(); + if (_width == 0 || _height == 0) { + Ref at = p_texture; - if (_height == 0) - _height = p_texture->get_height(); + 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) + _width = w; + + if (_height == 0) + _height = h; + } _entries.push_back(entry); }