summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorAnilforextra <anilforextra@gmail.com>2022-02-10 15:21:17 +0545
committerAnilforextra <anilforextra@gmail.com>2022-02-10 15:56:01 +0545
commitbb5d130509156e48bdd22d68c780bfa69b28a270 (patch)
treec1d6d6a757636008b51c5fcf0995cfc4cabbf8ae /scene
parentf21a62b62027a88ea90de539a48df8e280a820e8 (diff)
Code quality cleanup for some variable scopes.
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/line_2d.cpp6
-rw-r--r--scene/2d/node_2d.cpp3
-rw-r--r--scene/2d/polygon_2d.cpp4
3 files changed, 6 insertions, 7 deletions
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp
index 7f2290bdc7..c19a582286 100644
--- a/scene/2d/line_2d.cpp
+++ b/scene/2d/line_2d.cpp
@@ -268,15 +268,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 1f4dec6864..5f92e68e69 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;
}