Merge pull request #57436 from AnilBK/change-scopes

Scope Changes for some variables.
This commit is contained in:
Rémi Verschelde 2022-03-13 22:10:16 +01:00 committed by GitHub
commit 4f40a71e03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 11 deletions

View File

@ -292,15 +292,14 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
_commit_action(); _commit_action();
return true; return true;
} else { } else {
Vector<Vector2> vertices2 = _get_polygon(insert.polygon); pre_move_edit = vertices;
pre_move_edit = vertices2;
edited_point = PosVertex(insert.polygon, insert.vertex + 1, xform.affine_inverse().xform(insert.pos)); edited_point = PosVertex(insert.polygon, insert.vertex + 1, xform.affine_inverse().xform(insert.pos));
vertices2.insert(edited_point.vertex, edited_point.pos); vertices.insert(edited_point.vertex, edited_point.pos);
selected_point = Vertex(edited_point.polygon, edited_point.vertex); selected_point = Vertex(edited_point.polygon, edited_point.vertex);
edge_point = PosVertex(); edge_point = PosVertex();
undo_redo->create_action(TTR("Insert Point")); undo_redo->create_action(TTR("Insert Point"));
_action_set_polygon(insert.polygon, vertices2); _action_set_polygon(insert.polygon, vertices);
_commit_action(); _commit_action();
return true; return true;
} }

View File

@ -265,15 +265,15 @@ bool Line2D::get_antialiased() const {
} }
void Line2D::_draw() { void Line2D::_draw() {
if (_points.size() <= 1 || _width == 0.f) { int len = _points.size();
if (len <= 1 || _width == 0.f) {
return; return;
} }
// TODO Is this really needed? // TODO Is this really needed?
// Copy points for faster access // Copy points for faster access
Vector<Vector2> points; Vector<Vector2> points;
points.resize(_points.size()); points.resize(len);
int len = points.size();
{ {
const Vector2 *points_read = _points.ptr(); const Vector2 *points_read = _points.ptr();
for (int i = 0; i < len; ++i) { for (int i = 0; i < len; ++i) {

View File

@ -244,10 +244,9 @@ Point2 Node2D::get_global_position() const {
} }
void Node2D::set_global_position(const Point2 &p_pos) { void Node2D::set_global_position(const Point2 &p_pos) {
Transform2D inv;
CanvasItem *pi = get_parent_item(); CanvasItem *pi = get_parent_item();
if (pi) { if (pi) {
inv = pi->get_global_transform().affine_inverse(); Transform2D inv = pi->get_global_transform().affine_inverse();
set_position(inv.xform(p_pos)); set_position(inv.xform(p_pos));
} else { } else {
set_position(p_pos); set_position(p_pos);

View File

@ -295,14 +295,14 @@ void Polygon2D::_notification(int p_what) {
} }
Vector<Color> colors; Vector<Color> colors;
colors.resize(len);
if (vertex_colors.size() == points.size()) { if (vertex_colors.size() == points.size()) {
colors.resize(len);
const Color *color_r = vertex_colors.ptr(); const Color *color_r = vertex_colors.ptr();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
colors.write[i] = color_r[i]; colors.write[i] = color_r[i];
} }
} else { } else {
colors.resize(len);
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
colors.write[i] = color; colors.write[i] = color;
} }