@@ -164,20 +164,13 @@ void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile
164164 return ;
165165 }
166166
167- Rect2 rc = region ;
167+ Rect2 src_rect = Rect2 ( 0 , 0 , get_width (), get_height ()) ;
168168
169- if (rc.size .width == 0 ) {
170- rc.size .width = atlas->get_width ();
171- }
172-
173- if (rc.size .height == 0 ) {
174- rc.size .height = atlas->get_height ();
169+ Rect2 dr;
170+ Rect2 src_c;
171+ if (get_rect_region (p_rect, src_rect, dr, src_c)) {
172+ atlas->draw_rect_region (p_canvas_item, dr, src_c, p_modulate, p_transpose, filter_clip);
175173 }
176-
177- Vector2 scale = p_rect.size / (region.size + margin.size );
178- Rect2 dr (p_rect.position + margin.position * scale, rc.size * scale);
179-
180- atlas->draw_rect_region (p_canvas_item, dr, rc, p_modulate, p_transpose, filter_clip);
181174}
182175
183176void AtlasTexture::draw_rect_region (RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, bool p_clip_uv) const {
@@ -188,9 +181,9 @@ void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, cons
188181
189182 Rect2 dr;
190183 Rect2 src_c;
191- get_rect_region (p_rect, p_src_rect, dr, src_c);
192-
193- atlas-> draw_rect_region (p_canvas_item, dr, src_c, p_modulate, p_transpose, filter_clip);
184+ if ( get_rect_region (p_rect, p_src_rect, dr, src_c)) {
185+ atlas-> draw_rect_region (p_canvas_item, dr, src_c, p_modulate, p_transpose, filter_clip);
186+ }
194187}
195188
196189bool AtlasTexture::get_rect_region (const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
0 commit comments