diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-03-13 22:10:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-13 22:10:16 +0100 |
commit | 4f40a71e03bccf8c508748ebba3f81f535ef9b98 (patch) | |
tree | 4650b19236ef60989f3ea23b8adff16c6b3c0390 /scene/2d | |
parent | cc6d051af29696fe326771dade859986f0871418 (diff) | |
parent | bb5d130509156e48bdd22d68c780bfa69b28a270 (diff) |
Merge pull request #57436 from AnilBK/change-scopes
Scope Changes for some variables.
Diffstat (limited to 'scene/2d')
-rw-r--r-- | scene/2d/line_2d.cpp | 6 | ||||
-rw-r--r-- | scene/2d/node_2d.cpp | 3 | ||||
-rw-r--r-- | scene/2d/polygon_2d.cpp | 4 |
3 files changed, 6 insertions, 7 deletions
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp index 2716bb2e25..8cbcc9acf6 100644 --- a/scene/2d/line_2d.cpp +++ b/scene/2d/line_2d.cpp @@ -265,15 +265,15 @@ bool Line2D::get_antialiased() const { } void Line2D::_draw() { - if (_points.size() <= 1 || _width == 0.f) { + int len = _points.size(); + if (len <= 1 || _width == 0.f) { return; } // TODO Is this really needed? // Copy points for faster access Vector<Vector2> points; - points.resize(_points.size()); - int len = points.size(); + points.resize(len); { const Vector2 *points_read = _points.ptr(); for (int i = 0; i < len; ++i) { diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index 9d26543243..dd88bda304 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -244,10 +244,9 @@ Point2 Node2D::get_global_position() const { } void Node2D::set_global_position(const Point2 &p_pos) { - Transform2D inv; CanvasItem *pi = get_parent_item(); if (pi) { - inv = pi->get_global_transform().affine_inverse(); + Transform2D inv = pi->get_global_transform().affine_inverse(); set_position(inv.xform(p_pos)); } else { set_position(p_pos); diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 1fe4adb4db..f9986c2f30 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -295,14 +295,14 @@ void Polygon2D::_notification(int p_what) { } Vector<Color> colors; + colors.resize(len); + if (vertex_colors.size() == points.size()) { - colors.resize(len); const Color *color_r = vertex_colors.ptr(); for (int i = 0; i < len; i++) { colors.write[i] = color_r[i]; } } else { - colors.resize(len); for (int i = 0; i < len; i++) { colors.write[i] = color; } |