diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-09-19 20:04:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-19 20:04:46 +0200 |
commit | 1e73a44e241774d1ea84a8976f0963ae7df71cf9 (patch) | |
tree | 440be3ff6488c6f29048126723d1f25ae63248dc /scene/resources | |
parent | 28265fb52639067d11e392c808f5f28d120674e4 (diff) | |
parent | b7ed4829ba6035f7711bc59ac1b48c40468306a4 (diff) |
Merge pull request #31904 from byfron/styleboxflag_uvcoords
Computes UV coordinates of the canvas_item vertices of StyleBoxFlat
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/style_box.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index 5dd429fa75..4453032f67 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -713,6 +713,7 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const { Vector<Point2> verts; Vector<int> indices; Vector<Color> colors; + Vector<Point2> uvs; //DRAW SHADOW if (draw_shadow) { @@ -799,9 +800,17 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const { } } + //COMPUTE UV COORDINATES + Rect2 uv_rect = style_rect.grow(aa_on ? aa_size : 0); + uvs.resize(verts.size()); + for (int i = 0; i < verts.size(); i++) { + uvs.write[i].x = (verts[i].x - uv_rect.position.x) / uv_rect.size.width; + uvs.write[i].y = (verts[i].y - uv_rect.position.y) / uv_rect.size.height; + } + //DRAWING VisualServer *vs = VisualServer::get_singleton(); - vs->canvas_item_add_triangle_array(p_canvas_item, indices, verts, colors); + vs->canvas_item_add_triangle_array(p_canvas_item, indices, verts, colors, uvs); } float StyleBoxFlat::get_style_margin(Margin p_margin) const { |