diff options
author | reduz <reduzio@gmail.com> | 2014-04-05 09:42:55 -0300 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2014-04-05 09:42:55 -0300 |
commit | 6a737c79fcf3cee934c4f6331715747571649098 (patch) | |
tree | 32bcccdf01acabf468fb53789a8d020f0ac03299 | |
parent | f9820d4c404fa8790361dae3c45ea8f0e49d6cbf (diff) | |
parent | 61179e82c7078adab3a6d78ed47184f111db7d62 (diff) |
Merge pull request #211 from sanikoyes/hotfix-render-altas-texture-sprite
fix render sprite used atlas texture position error
-rw-r--r-- | scene/resources/texture.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index e5ac674784..be3b921bad 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -580,7 +580,18 @@ void AtlasTexture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Vector2 ofs = (src_c.pos-src.pos); Vector2 scale = p_rect.size / p_src_rect.size; - + if(scale.x < 0) + { + float mx = (margin.size.width - margin.pos.x); + mx -= margin.pos.x; + ofs.x = -(ofs.x + mx); + } + if(scale.y < 0) + { + float my = margin.size.height - margin.pos.y; + my -= margin.pos.y; + ofs.y = -(ofs.y + my); + } Rect2 dr( p_rect.pos+ofs*scale,src_c.size*scale ); VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,dr,atlas->get_rid(),src_c,p_modulate); |