diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-09-29 12:53:28 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-10-07 11:32:33 +0300 |
commit | 0103af1ddda6a2aa31227965141dd7d3a513e081 (patch) | |
tree | b0965bb65919bc1495ee02204a91e5ed3a9b56a7 /editor/plugins | |
parent | 5b7f62af55b7f322192f95258d825b163cbf9dc1 (diff) |
Fix MSVC warnings, rename shadowed variables, fix uninitialized values, change warnings=all to use /W4.
Diffstat (limited to 'editor/plugins')
27 files changed, 757 insertions, 757 deletions
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index c928b95642..cb07d8cf01 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -561,8 +561,8 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl const Vector2 p = (vertex == edited_point) ? edited_point.pos : (points[i] + offset); const Vector2 point = xform.xform(p); - const Color modulate = vertex == active_point ? Color(0.5, 1, 2) : Color(1, 1, 1); - p_overlay->draw_texture(handle, point - handle->get_size() * 0.5, modulate); + const Color overlay_modulate = vertex == active_point ? Color(0.5, 1, 2) : Color(1, 1, 1); + p_overlay->draw_texture(handle, point - handle->get_size() * 0.5, overlay_modulate); if (vertex == hover_point) { Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index f75dcdf2d6..765d85c1ac 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -406,11 +406,11 @@ void AnimationNodeBlendSpace2DEditor::_tool_switch(int p_tool) { making_triangle.clear(); if (p_tool == 2) { - Vector<Vector2> points; + Vector<Vector2> bl_points; for (int i = 0; i < blend_space->get_blend_point_count(); i++) { - points.push_back(blend_space->get_blend_point_position(i)); + bl_points.push_back(blend_space->get_blend_point_position(i)); } - Vector<Delaunay2D::Triangle> tr = Delaunay2D::triangulate(points); + Vector<Delaunay2D::Triangle> tr = Delaunay2D::triangulate(bl_points); for (int i = 0; i < tr.size(); i++) { blend_space->add_triangle(tr[i].points[0], tr[i].points[1], tr[i].points[2]); } @@ -494,8 +494,8 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { //triangles first for (int i = 0; i < blend_space->get_triangle_count(); i++) { - Vector<Vector2> points; - points.resize(3); + Vector<Vector2> bl_points; + bl_points.resize(3); for (int j = 0; j < 3; j++) { int point_idx = blend_space->get_triangle_point(i, j); @@ -509,11 +509,11 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space()); point *= s; point.y = s.height - point.y; - points.write[j] = point; + bl_points.write[j] = point; } for (int j = 0; j < 3; j++) { - blend_space_draw->draw_line(points[j], points[(j + 1) % 3], linecolor, Math::round(EDSCALE), true); + blend_space_draw->draw_line(bl_points[j], bl_points[(j + 1) % 3], linecolor, Math::round(EDSCALE), true); } Color color; @@ -530,7 +530,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { color, color }; - blend_space_draw->draw_primitive(points, colors, Vector<Vector2>()); + blend_space_draw->draw_primitive(bl_points, colors, Vector<Vector2>()); } points.clear(); @@ -560,19 +560,19 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { } if (making_triangle.size()) { - Vector<Vector2> points; + Vector<Vector2> bl_points; for (int i = 0; i < making_triangle.size(); i++) { Vector2 point = blend_space->get_blend_point_position(making_triangle[i]); point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space()); point *= s; point.y = s.height - point.y; - points.push_back(point); + bl_points.push_back(point); } - for (int i = 0; i < points.size() - 1; i++) { - blend_space_draw->draw_line(points[i], points[i + 1], linecolor, Math::round(2 * EDSCALE), true); + for (int i = 0; i < bl_points.size() - 1; i++) { + blend_space_draw->draw_line(bl_points[i], bl_points[i + 1], linecolor, Math::round(2 * EDSCALE), true); } - blend_space_draw->draw_line(points[points.size() - 1], blend_space_draw->get_local_mouse_position(), linecolor, Math::round(2 * EDSCALE), true); + blend_space_draw->draw_line(bl_points[bl_points.size() - 1], blend_space_draw->get_local_mouse_position(), linecolor, Math::round(2 * EDSCALE), true); } ///draw cursor position diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index ca7b2d0015..067730a87a 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -262,10 +262,10 @@ void AnimationNodeBlendTreeEditor::update_graph() { node->add_theme_color_override("resizer_color", c); } - List<AnimationNodeBlendTree::NodeConnection> connections; - blend_tree->get_node_connections(&connections); + List<AnimationNodeBlendTree::NodeConnection> node_connections; + blend_tree->get_node_connections(&node_connections); - for (const AnimationNodeBlendTree::NodeConnection &E : connections) { + for (const AnimationNodeBlendTree::NodeConnection &E : node_connections) { StringName from = E.output_node; StringName to = E.input_node; int to_idx = E.input_index; @@ -293,9 +293,9 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) { if (p_idx == MENU_LOAD_FILE) { open_file->clear_filters(); - List<String> filters; - ResourceLoader::get_recognized_extensions_for_type("AnimationNode", &filters); - for (const String &E : filters) { + List<String> ext_filters; + ResourceLoader::get_recognized_extensions_for_type("AnimationNode", &ext_filters); + for (const String &E : ext_filters) { open_file->add_filter("*." + E); } open_file->popup_file_dialog(); @@ -611,10 +611,10 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano HashSet<String> paths; HashMap<String, RBSet<String>> types; { - List<StringName> animations; - player->get_animation_list(&animations); + List<StringName> animation_list; + player->get_animation_list(&animation_list); - for (const StringName &E : animations) { + for (const StringName &E : animation_list) { Ref<Animation> anim = player->get_animation(E); for (int i = 0; i < anim->get_track_count(); i++) { String track_path = anim->track_get_path(i); @@ -970,10 +970,10 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima //recreate connections graph->clear_connections(); - List<AnimationNodeBlendTree::NodeConnection> connections; - blend_tree->get_node_connections(&connections); + List<AnimationNodeBlendTree::NodeConnection> node_connections; + blend_tree->get_node_connections(&node_connections); - for (const AnimationNodeBlendTree::NodeConnection &E : connections) { + for (const AnimationNodeBlendTree::NodeConnection &E : node_connections) { StringName from = E.output_node; StringName to = E.input_node; int to_idx = E.input_index; diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index e8caac565c..dc84c08506 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -826,13 +826,13 @@ void AnimationPlayerEditor::_update_player() { } // Check if the global library is foreign since we want to disable options for adding/remove/renaming animations if it is. - Ref<AnimationLibrary> library = player->get_animation_library(K); + Ref<AnimationLibrary> anim_library = player->get_animation_library(K); if (K == "") { - foreign_global_anim_lib = EditorNode::get_singleton()->is_resource_read_only(library); + foreign_global_anim_lib = EditorNode::get_singleton()->is_resource_read_only(anim_library); } List<StringName> animlist; - library->get_animation_list(&animlist); + anim_library->get_animation_list(&animlist); for (const StringName &E : animlist) { String path = K; @@ -913,19 +913,19 @@ void AnimationPlayerEditor::_update_player() { void AnimationPlayerEditor::_update_animation_list_icons() { for (int i = 0; i < animation->get_item_count(); i++) { - String name = animation->get_item_text(i); + String anim_name = animation->get_item_text(i); if (animation->is_item_disabled(i) || animation->is_item_separator(i)) { continue; } Ref<Texture2D> icon; - if (name == player->get_autoplay()) { - if (name == SceneStringNames::get_singleton()->RESET) { + if (anim_name == player->get_autoplay()) { + if (anim_name == SceneStringNames::get_singleton()->RESET) { icon = autoplay_reset_icon; } else { icon = autoplay_icon; } - } else if (name == SceneStringNames::get_singleton()->RESET) { + } else if (anim_name == SceneStringNames::get_singleton()->RESET) { icon = reset_icon; } @@ -1356,8 +1356,8 @@ void AnimationPlayerEditor::_free_onion_layers() { void AnimationPlayerEditor::_prepare_onion_layers_1() { // This would be called per viewport and we want to act once only. - int64_t frame = get_tree()->get_frame(); - if (frame == onion.last_frame) { + int64_t cur_frame = get_tree()->get_frame(); + if (cur_frame == onion.last_frame) { return; } @@ -1366,7 +1366,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_1() { return; } - onion.last_frame = frame; + onion.last_frame = cur_frame; // Refresh viewports with no onion layers overlaid. onion.can_overlay = false; diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 3c9486cdaa..2d1f4088a0 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -243,19 +243,19 @@ void EditorAssetLibraryItemDescription::configure(const String &p_title, int p_a } void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, const String &p_url) { - Preview preview; - preview.id = p_id; - preview.video_link = p_url; - preview.is_video = p_video; - preview.button = memnew(Button); - preview.button->set_icon(previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons"))); - preview.button->set_toggle_mode(true); - preview.button->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDescription::_preview_click).bind(p_id)); - preview_hb->add_child(preview.button); + Preview new_preview; + new_preview.id = p_id; + new_preview.video_link = p_url; + new_preview.is_video = p_video; + new_preview.button = memnew(Button); + new_preview.button->set_icon(previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons"))); + new_preview.button->set_toggle_mode(true); + new_preview.button->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDescription::_preview_click).bind(p_id)); + preview_hb->add_child(new_preview.button); if (!p_video) { - preview.image = previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons")); + new_preview.image = previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons")); } - preview_images.push_back(preview); + preview_images.push_back(new_preview); if (preview_images.size() == 1 && !p_video) { _preview_click(p_id); } diff --git a/editor/plugins/audio_stream_randomizer_editor_plugin.cpp b/editor/plugins/audio_stream_randomizer_editor_plugin.cpp index d670197c53..e21a50a434 100644 --- a/editor/plugins/audio_stream_randomizer_editor_plugin.cpp +++ b/editor/plugins/audio_stream_randomizer_editor_plugin.cpp @@ -44,8 +44,8 @@ void AudioStreamRandomizerEditorPlugin::make_visible(bool p_visible) { } void AudioStreamRandomizerEditorPlugin::_move_stream_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) { - Ref<EditorUndoRedoManager> undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); - ERR_FAIL_COND(undo_redo.is_null()); + Ref<EditorUndoRedoManager> undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); + ERR_FAIL_COND(undo_redo_man.is_null()); AudioStreamRandomizer *randomizer = Object::cast_to<AudioStreamRandomizer>(p_edited); if (!randomizer) { @@ -76,12 +76,12 @@ void AudioStreamRandomizerEditorPlugin::_move_stream_array_element(Object *p_und end = MIN(MAX(p_from_index, p_to_pos) + 1, end); } -#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property)); +#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property)); // Save layers' properties. if (p_from_index < 0) { - undo_redo->add_undo_method(randomizer, "remove_stream", p_to_pos < 0 ? randomizer->get_streams_count() : p_to_pos); + undo_redo_man->add_undo_method(randomizer, "remove_stream", p_to_pos < 0 ? randomizer->get_streams_count() : p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_undo_method(randomizer, "add_stream", p_from_index); + undo_redo_man->add_undo_method(randomizer, "add_stream", p_from_index); } List<PropertyInfo> properties; @@ -107,11 +107,11 @@ void AudioStreamRandomizerEditorPlugin::_move_stream_array_element(Object *p_und #undef ADD_UNDO if (p_from_index < 0) { - undo_redo->add_do_method(randomizer, "add_stream", p_to_pos); + undo_redo_man->add_do_method(randomizer, "add_stream", p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_do_method(randomizer, "remove_stream", p_from_index); + undo_redo_man->add_do_method(randomizer, "remove_stream", p_from_index); } else { - undo_redo->add_do_method(randomizer, "move_stream", p_from_index, p_to_pos); + undo_redo_man->add_do_method(randomizer, "move_stream", p_from_index, p_to_pos); } } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 84b8b4aed8..6e108a9a72 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -304,7 +304,7 @@ void CanvasItemEditor::_snap_other_nodes( Point2 &r_current_snap, SnapTarget (&r_current_snap_target)[2], const SnapTarget p_snap_target, List<const CanvasItem *> p_exceptions, const Node *p_current) { - const CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_current); + const CanvasItem *ci = Object::cast_to<CanvasItem>(p_current); // Check if the element is in the exception bool exception = false; @@ -315,12 +315,12 @@ void CanvasItemEditor::_snap_other_nodes( } }; - if (canvas_item && !exception) { - Transform2D ci_transform = canvas_item->get_global_transform_with_canvas(); + if (ci && !exception) { + Transform2D ci_transform = ci->get_global_transform_with_canvas(); if (fmod(ci_transform.get_rotation() - p_transform_to_snap.get_rotation(), (real_t)360.0) == 0.0) { - if (canvas_item->_edit_use_rect()) { - Point2 begin = ci_transform.xform(canvas_item->_edit_get_rect().get_position()); - Point2 end = ci_transform.xform(canvas_item->_edit_get_rect().get_position() + canvas_item->_edit_get_rect().get_size()); + if (ci->_edit_use_rect()) { + Point2 begin = ci_transform.xform(ci->_edit_get_rect().get_position()); + Point2 end = ci_transform.xform(ci->_edit_get_rect().get_position() + ci->_edit_get_rect().get_size()); _snap_if_closer_point(p_value, r_current_snap, r_current_snap_target, begin, p_snap_target, ci_transform.get_rotation()); _snap_if_closer_point(p_value, r_current_snap, r_current_snap_target, end, p_snap_target, ci_transform.get_rotation()); @@ -528,14 +528,14 @@ Rect2 CanvasItemEditor::_get_encompassing_rect_from_list(List<CanvasItem *> p_li ERR_FAIL_COND_V(p_list.is_empty(), Rect2()); // Handles the first element - CanvasItem *canvas_item = p_list.front()->get(); - Rect2 rect = Rect2(canvas_item->get_global_transform_with_canvas().xform(canvas_item->_edit_get_rect().get_center()), Size2()); + CanvasItem *ci = p_list.front()->get(); + Rect2 rect = Rect2(ci->get_global_transform_with_canvas().xform(ci->_edit_get_rect().get_center()), Size2()); // Expand with the other ones - for (CanvasItem *canvas_item2 : p_list) { - Transform2D xform = canvas_item2->get_global_transform_with_canvas(); + for (CanvasItem *ci2 : p_list) { + Transform2D xform = ci2->get_global_transform_with_canvas(); - Rect2 current_rect = canvas_item2->_edit_get_rect(); + Rect2 current_rect = ci2->_edit_get_rect(); rect.expand_to(xform.xform(current_rect.position)); rect.expand_to(xform.xform(current_rect.position + Vector2(current_rect.size.x, 0))); rect.expand_to(xform.xform(current_rect.position + current_rect.size)); @@ -553,24 +553,24 @@ void CanvasItemEditor::_expand_encompassing_rect_using_children(Rect2 &r_rect, c return; } - const CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node); + const CanvasItem *ci = Object::cast_to<CanvasItem>(p_node); for (int i = p_node->get_child_count() - 1; i >= 0; i--) { - if (canvas_item && !canvas_item->is_set_as_top_level()) { - _expand_encompassing_rect_using_children(r_rect, p_node->get_child(i), r_first, p_parent_xform * canvas_item->get_transform(), p_canvas_xform); + if (ci && !ci->is_set_as_top_level()) { + _expand_encompassing_rect_using_children(r_rect, p_node->get_child(i), r_first, p_parent_xform * ci->get_transform(), p_canvas_xform); } else { - const CanvasLayer *canvas_layer = Object::cast_to<CanvasLayer>(p_node); - _expand_encompassing_rect_using_children(r_rect, p_node->get_child(i), r_first, Transform2D(), canvas_layer ? canvas_layer->get_transform() : p_canvas_xform); + const CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node); + _expand_encompassing_rect_using_children(r_rect, p_node->get_child(i), r_first, Transform2D(), cl ? cl->get_transform() : p_canvas_xform); } } - if (canvas_item && canvas_item->is_visible_in_tree() && (include_locked_nodes || !_is_node_locked(canvas_item))) { + if (ci && ci->is_visible_in_tree() && (include_locked_nodes || !_is_node_locked(ci))) { Transform2D xform = p_canvas_xform; - if (!canvas_item->is_set_as_top_level()) { + if (!ci->is_set_as_top_level()) { xform *= p_parent_xform; } - xform *= canvas_item->get_transform(); - Rect2 rect = canvas_item->_edit_get_rect(); + xform *= ci->get_transform(); + Rect2 rect = ci->_edit_get_rect(); if (r_first) { r_rect = Rect2(xform.xform(rect.get_center()), Size2()); r_first = false; @@ -599,14 +599,14 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no } const real_t grab_distance = EDITOR_GET("editors/polygon_editor/point_grab_radius"); - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node); + CanvasItem *ci = Object::cast_to<CanvasItem>(p_node); for (int i = p_node->get_child_count() - 1; i >= 0; i--) { - if (canvas_item) { - if (!canvas_item->is_set_as_top_level()) { - _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_parent_xform * canvas_item->get_transform(), p_canvas_xform); + if (ci) { + if (!ci->is_set_as_top_level()) { + _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, p_parent_xform * ci->get_transform(), p_canvas_xform); } else { - _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, canvas_item->get_transform(), p_canvas_xform); + _find_canvas_items_at_pos(p_pos, p_node->get_child(i), r_items, ci->get_transform(), p_canvas_xform); } } else { CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node); @@ -614,18 +614,18 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no } } - if (canvas_item && canvas_item->is_visible_in_tree()) { + if (ci && ci->is_visible_in_tree()) { Transform2D xform = p_canvas_xform; - if (!canvas_item->is_set_as_top_level()) { + if (!ci->is_set_as_top_level()) { xform *= p_parent_xform; } - xform = (xform * canvas_item->get_transform()).affine_inverse(); + xform = (xform * ci->get_transform()).affine_inverse(); const real_t local_grab_distance = xform.basis_xform(Vector2(grab_distance, 0)).length() / zoom; - if (canvas_item->_edit_is_selected_on_click(xform.xform(p_pos), local_grab_distance)) { - Node2D *node = Object::cast_to<Node2D>(canvas_item); + if (ci->_edit_is_selected_on_click(xform.xform(p_pos), local_grab_distance)) { + Node2D *node = Object::cast_to<Node2D>(ci); _SelectResult res; - res.item = canvas_item; + res.item = ci; res.z_index = node ? node->get_z_index() : 0; res.has_z = node; r_items.push_back(res); @@ -647,13 +647,13 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel node = scene->get_deepest_editable_node(node); } - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(node); + CanvasItem *ci = Object::cast_to<CanvasItem>(node); if (!p_allow_locked) { // Replace the node by the group if grouped while (node && node != scene->get_parent()) { - CanvasItem *canvas_item_tmp = Object::cast_to<CanvasItem>(node); - if (canvas_item_tmp && node->has_meta("_edit_group_")) { - canvas_item = canvas_item_tmp; + CanvasItem *ci_tmp = Object::cast_to<CanvasItem>(node); + if (ci_tmp && node->has_meta("_edit_group_")) { + ci = ci_tmp; } node = node->get_parent(); } @@ -662,18 +662,18 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel // Check if the canvas item is already in the list (for groups or scenes) bool duplicate = false; for (int j = 0; j < i; j++) { - if (r_items[j].item == canvas_item) { + if (r_items[j].item == ci) { duplicate = true; break; } } //Remove the item if invalid - if (!canvas_item || duplicate || (canvas_item != scene && canvas_item->get_owner() != scene && !scene->is_editable_instance(canvas_item->get_owner())) || (!p_allow_locked && _is_node_locked(canvas_item))) { + if (!ci || duplicate || (ci != scene && ci->get_owner() != scene && !scene->is_editable_instance(ci->get_owner())) || (!p_allow_locked && _is_node_locked(ci))) { r_items.remove_at(i); i--; } else { - r_items.write[i].item = canvas_item; + r_items.write[i].item = ci; } } } @@ -686,7 +686,7 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n return; } - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node); + CanvasItem *ci = Object::cast_to<CanvasItem>(p_node); Node *scene = EditorNode::get_singleton()->get_edited_scene(); bool editable = p_node == scene || p_node->get_owner() == scene || p_node == scene->get_deepest_editable_node(p_node); @@ -695,37 +695,37 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n if (!lock_children || !editable) { for (int i = p_node->get_child_count() - 1; i >= 0; i--) { - if (canvas_item) { - if (!canvas_item->is_set_as_top_level()) { - _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, p_parent_xform * canvas_item->get_transform(), p_canvas_xform); + if (ci) { + if (!ci->is_set_as_top_level()) { + _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, p_parent_xform * ci->get_transform(), p_canvas_xform); } else { - _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, canvas_item->get_transform(), p_canvas_xform); + _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, ci->get_transform(), p_canvas_xform); } } else { - CanvasLayer *canvas_layer = Object::cast_to<CanvasLayer>(p_node); - _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, Transform2D(), canvas_layer ? canvas_layer->get_transform() : p_canvas_xform); + CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node); + _find_canvas_items_in_rect(p_rect, p_node->get_child(i), r_items, Transform2D(), cl ? cl->get_transform() : p_canvas_xform); } } } - if (canvas_item && canvas_item->is_visible_in_tree() && !locked && editable) { + if (ci && ci->is_visible_in_tree() && !locked && editable) { Transform2D xform = p_canvas_xform; - if (!canvas_item->is_set_as_top_level()) { + if (!ci->is_set_as_top_level()) { xform *= p_parent_xform; } - xform *= canvas_item->get_transform(); + xform *= ci->get_transform(); - if (canvas_item->_edit_use_rect()) { - Rect2 rect = canvas_item->_edit_get_rect(); + if (ci->_edit_use_rect()) { + Rect2 rect = ci->_edit_get_rect(); if (p_rect.has_point(xform.xform(rect.position)) && p_rect.has_point(xform.xform(rect.position + Vector2(rect.size.x, 0))) && p_rect.has_point(xform.xform(rect.position + Vector2(rect.size.x, rect.size.y))) && p_rect.has_point(xform.xform(rect.position + Vector2(0, rect.size.y)))) { - r_items->push_back(canvas_item); + r_items->push_back(ci); } } else { if (p_rect.has_point(xform.xform(Point2()))) { - r_items->push_back(canvas_item); + r_items->push_back(ci); } } } @@ -765,11 +765,11 @@ bool CanvasItemEditor::_select_click_on_item(CanvasItem *item, Point2 p_click_po List<CanvasItem *> CanvasItemEditor::_get_edited_canvas_items(bool retrieve_locked, bool remove_canvas_item_if_parent_in_selection) { List<CanvasItem *> selection; for (const KeyValue<Node *, Object *> &E : editor_selection->get_selection()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key); - if (canvas_item && canvas_item->is_visible_in_tree() && canvas_item->get_viewport() == EditorNode::get_singleton()->get_scene_root() && (retrieve_locked || !_is_node_locked(canvas_item))) { - CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); + CanvasItem *ci = Object::cast_to<CanvasItem>(E.key); + if (ci && ci->is_visible_in_tree() && ci->get_viewport() == EditorNode::get_singleton()->get_scene_root() && (retrieve_locked || !_is_node_locked(ci))) { + CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci); if (se) { - selection.push_back(canvas_item); + selection.push_back(ci); } } } @@ -819,18 +819,18 @@ void CanvasItemEditor::_save_canvas_item_state(List<CanvasItem *> p_canvas_items original_transform = Transform2D(); bool transform_stored = false; - for (CanvasItem *canvas_item : p_canvas_items) { - CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); + for (CanvasItem *ci : p_canvas_items) { + CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci); if (se) { if (!transform_stored) { - original_transform = canvas_item->get_global_transform(); + original_transform = ci->get_global_transform(); transform_stored = true; } - se->undo_state = canvas_item->_edit_get_state(); - se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); - if (canvas_item->_edit_use_rect()) { - se->pre_drag_rect = canvas_item->_edit_get_rect(); + se->undo_state = ci->_edit_get_state(); + se->pre_drag_xform = ci->get_global_transform_with_canvas(); + if (ci->_edit_use_rect()) { + se->pre_drag_rect = ci->_edit_get_rect(); } else { se->pre_drag_rect = Rect2(); } @@ -839,20 +839,20 @@ void CanvasItemEditor::_save_canvas_item_state(List<CanvasItem *> p_canvas_items } void CanvasItemEditor::_restore_canvas_item_state(List<CanvasItem *> p_canvas_items, bool restore_bones) { - for (CanvasItem *canvas_item : drag_selection) { - CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); - canvas_item->_edit_set_state(se->undo_state); + for (CanvasItem *ci : drag_selection) { + CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci); + ci->_edit_set_state(se->undo_state); } } void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_items, String action_name, bool commit_bones) { List<CanvasItem *> modified_canvas_items; - for (CanvasItem *canvas_item : p_canvas_items) { - Dictionary old_state = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item)->undo_state; - Dictionary new_state = canvas_item->_edit_get_state(); + for (CanvasItem *ci : p_canvas_items) { + Dictionary old_state = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci)->undo_state; + Dictionary new_state = ci->_edit_get_state(); if (old_state.hash() != new_state.hash()) { - modified_canvas_items.push_back(canvas_item); + modified_canvas_items.push_back(ci); } } @@ -861,16 +861,16 @@ void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_ite } undo_redo->create_action(action_name); - for (CanvasItem *canvas_item : modified_canvas_items) { - CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); + for (CanvasItem *ci : modified_canvas_items) { + CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci); if (se) { - undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); - undo_redo->add_undo_method(canvas_item, "_edit_set_state", se->undo_state); + undo_redo->add_do_method(ci, "_edit_set_state", ci->_edit_get_state()); + undo_redo->add_undo_method(ci, "_edit_set_state", se->undo_state); if (commit_bones) { for (const Dictionary &F : se->pre_drag_bones_undo_state) { - canvas_item = Object::cast_to<CanvasItem>(canvas_item->get_parent()); - undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); - undo_redo->add_undo_method(canvas_item, "_edit_set_state", F); + ci = Object::cast_to<CanvasItem>(ci->get_parent()); + undo_redo->add_do_method(ci, "_edit_set_state", ci->_edit_get_state()); + undo_redo->add_undo_method(ci, "_edit_set_state", F); } } } @@ -1318,9 +1318,9 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { // Filters the selection with nodes that allow setting the pivot drag_selection = List<CanvasItem *>(); - for (CanvasItem *canvas_item : selection) { - if (canvas_item->_edit_use_pivot()) { - drag_selection.push_back(canvas_item); + for (CanvasItem *ci : selection) { + if (ci->_edit_use_pivot()) { + drag_selection.push_back(ci); } } @@ -1334,8 +1334,8 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { } else { new_pos = snap_point(drag_from, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, nullptr, drag_selection); } - for (CanvasItem *canvas_item : drag_selection) { - canvas_item->_edit_set_pivot(canvas_item->get_global_transform_with_canvas().affine_inverse().xform(new_pos)); + for (CanvasItem *ci : drag_selection) { + ci->_edit_set_pivot(ci->get_global_transform_with_canvas().affine_inverse().xform(new_pos)); } drag_type = DRAG_PIVOT; @@ -1355,8 +1355,8 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { } else { new_pos = snap_point(drag_to, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL); } - for (CanvasItem *canvas_item : drag_selection) { - canvas_item->_edit_set_pivot(canvas_item->get_global_transform_with_canvas().affine_inverse().xform(new_pos)); + for (CanvasItem *ci : drag_selection) { + ci->_edit_set_pivot(ci->get_global_transform_with_canvas().affine_inverse().xform(new_pos)); } return true; } @@ -1408,11 +1408,11 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) { if (drag_selection.size() > 0) { drag_type = DRAG_ROTATE; drag_from = transform.affine_inverse().xform(b->get_position()); - CanvasItem *canvas_item = drag_selection[0]; - if (canvas_item->_edit_use_pivot()) { - drag_rotation_center = canvas_item->get_global_transform_with_canvas().xform(canvas_item->_edit_get_pivot()); + CanvasItem *ci = drag_selection[0]; + if (ci->_edit_use_pivot()) { + drag_rotation_center = ci->get_global_transform_with_canvas().xform(ci->_edit_get_pivot()); } else { - drag_rotation_center = canvas_item->get_global_transform_with_canvas().get_origin(); + drag_rotation_center = ci->get_global_transform_with_canvas().get_origin(); } _save_canvas_item_state(drag_selection); return true; @@ -1425,11 +1425,11 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) { // Rotate the node if (m.is_valid()) { _restore_canvas_item_state(drag_selection); - for (CanvasItem *canvas_item : drag_selection) { + for (CanvasItem *ci : drag_selection) { drag_to = transform.affine_inverse().xform(m->get_position()); //Rotate the opposite way if the canvas item's compounded scale has an uneven number of negative elements - bool opposite = (canvas_item->get_global_transform().get_scale().sign().dot(canvas_item->get_transform().get_scale().sign()) == 0); - canvas_item->_edit_set_rotation(snap_angle(canvas_item->_edit_get_rotation() + (opposite ? -1 : 1) * (drag_from - drag_rotation_center).angle_to(drag_to - drag_rotation_center), canvas_item->_edit_get_rotation())); + bool opposite = (ci->get_global_transform().get_scale().sign().dot(ci->get_transform().get_scale().sign()) == 0); + ci->_edit_set_rotation(snap_angle(ci->_edit_get_rotation() + (opposite ? -1 : 1) * (drag_from - drag_rotation_center).angle_to(drag_to - drag_rotation_center), ci->_edit_get_rotation())); viewport->queue_redraw(); } return true; @@ -1477,9 +1477,9 @@ bool CanvasItemEditor::_gui_input_open_scene_on_double_click(const Ref<InputEven if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed() && b->is_double_click() && tool == TOOL_SELECT) { List<CanvasItem *> selection = _get_edited_canvas_items(); if (selection.size() == 1) { - CanvasItem *canvas_item = selection[0]; - if (!canvas_item->get_scene_file_path().is_empty() && canvas_item != EditorNode::get_singleton()->get_edited_scene()) { - EditorNode::get_singleton()->open_request(canvas_item->get_scene_file_path()); + CanvasItem *ci = selection[0]; + if (!ci->get_scene_file_path().is_empty() && ci != EditorNode::get_singleton()->get_edited_scene()) { + EditorNode::get_singleton()->open_request(ci->get_scene_file_path()); return true; } } @@ -1641,10 +1641,10 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) { if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed() && tool == TOOL_SELECT) { List<CanvasItem *> selection = _get_edited_canvas_items(); if (selection.size() == 1) { - CanvasItem *canvas_item = selection[0]; - if (canvas_item->_edit_use_rect() && _is_node_movable(canvas_item)) { - Rect2 rect = canvas_item->_edit_get_rect(); - Transform2D xform = transform * canvas_item->get_global_transform_with_canvas(); + CanvasItem *ci = selection[0]; + if (ci->_edit_use_rect() && _is_node_movable(ci)) { + Rect2 rect = ci->_edit_get_rect(); + Transform2D xform = transform * ci->get_global_transform_with_canvas(); const Vector2 endpoints[4] = { xform.xform(rect.position), @@ -1689,7 +1689,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) { drag_type = resize_drag; drag_from = transform.affine_inverse().xform(b->get_position()); drag_selection = List<CanvasItem *>(); - drag_selection.push_back(canvas_item); + drag_selection.push_back(ci); _save_canvas_item_state(drag_selection); return true; } @@ -1702,36 +1702,36 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) { drag_type == DRAG_TOP_LEFT || drag_type == DRAG_TOP_RIGHT || drag_type == DRAG_BOTTOM_LEFT || drag_type == DRAG_BOTTOM_RIGHT) { // Resize the node if (m.is_valid()) { - CanvasItem *canvas_item = drag_selection[0]; - CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); + CanvasItem *ci = drag_selection[0]; + CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci); //Reset state - canvas_item->_edit_set_state(se->undo_state); + ci->_edit_set_state(se->undo_state); bool uniform = m->is_shift_pressed(); bool symmetric = m->is_alt_pressed(); - Rect2 local_rect = canvas_item->_edit_get_rect(); + Rect2 local_rect = ci->_edit_get_rect(); real_t aspect = local_rect.get_size().y / local_rect.get_size().x; Point2 current_begin = local_rect.get_position(); Point2 current_end = local_rect.get_position() + local_rect.get_size(); - Point2 max_begin = (symmetric) ? (current_begin + current_end - canvas_item->_edit_get_minimum_size()) / 2.0 : current_end - canvas_item->_edit_get_minimum_size(); - Point2 min_end = (symmetric) ? (current_begin + current_end + canvas_item->_edit_get_minimum_size()) / 2.0 : current_begin + canvas_item->_edit_get_minimum_size(); + Point2 max_begin = (symmetric) ? (current_begin + current_end - ci->_edit_get_minimum_size()) / 2.0 : current_end - ci->_edit_get_minimum_size(); + Point2 min_end = (symmetric) ? (current_begin + current_end + ci->_edit_get_minimum_size()) / 2.0 : current_begin + ci->_edit_get_minimum_size(); Point2 center = (current_begin + current_end) / 2.0; drag_to = transform.affine_inverse().xform(m->get_position()); - Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse(); + Transform2D xform = ci->get_global_transform_with_canvas().affine_inverse(); Point2 drag_to_snapped_begin; Point2 drag_to_snapped_end; // last call decides which snapping lines are drawn if (drag_type == DRAG_LEFT || drag_type == DRAG_TOP || drag_type == DRAG_TOP_LEFT) { - drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item); - drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item); + drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci); + drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci); } else { - drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item); - drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, canvas_item); + drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci); + drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci); } Point2 drag_begin = xform.xform(drag_to_snapped_begin); @@ -1787,7 +1787,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) { current_begin.y = 2.0 * center.y - current_end.y; } } - canvas_item->_edit_set_rect(Rect2(current_begin, current_end - current_begin)); + ci->_edit_set_rect(Rect2(current_begin, current_end - current_begin)); return true; } @@ -1850,11 +1850,11 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { if (b.is_valid() && b->get_button_index() == MouseButton::LEFT && b->is_pressed() && ((b->is_alt_pressed() && b->is_ctrl_pressed()) || tool == TOOL_SCALE)) { List<CanvasItem *> selection = _get_edited_canvas_items(); if (selection.size() == 1) { - CanvasItem *canvas_item = selection[0]; + CanvasItem *ci = selection[0]; - if (_is_node_movable(canvas_item)) { - Transform2D xform = transform * canvas_item->get_global_transform_with_canvas(); - Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); + if (_is_node_movable(ci)) { + Transform2D xform = transform * ci->get_global_transform_with_canvas(); + Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; drag_type = DRAG_SCALE_BOTH; @@ -1873,7 +1873,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { drag_from = transform.affine_inverse().xform(b->get_position()); drag_selection = List<CanvasItem *>(); - drag_selection.push_back(canvas_item); + drag_selection.push_back(ci); _save_canvas_item_state(drag_selection); return true; } @@ -1885,12 +1885,12 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { // Resize the node if (m.is_valid()) { _restore_canvas_item_state(drag_selection); - CanvasItem *canvas_item = drag_selection[0]; + CanvasItem *ci = drag_selection[0]; drag_to = transform.affine_inverse().xform(m->get_position()); - Transform2D parent_xform = canvas_item->get_global_transform_with_canvas() * canvas_item->get_transform().affine_inverse(); - Transform2D unscaled_transform = (transform * parent_xform * canvas_item->_edit_get_transform()).orthonormalized(); + Transform2D parent_xform = ci->get_global_transform_with_canvas() * ci->get_transform().affine_inverse(); + Transform2D unscaled_transform = (transform * parent_xform * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = (viewport->get_transform() * unscaled_transform).affine_inverse() * transform; bool uniform = m->is_shift_pressed(); @@ -1900,7 +1900,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { Point2 drag_to_local = simple_xform.xform(drag_to); Point2 offset = drag_to_local - drag_from_local; - Size2 scale = canvas_item->_edit_get_scale(); + Size2 scale = ci->_edit_get_scale(); Size2 original_scale = scale; real_t ratio = scale.y / scale.x; if (drag_type == DRAG_SCALE_BOTH) { @@ -1938,7 +1938,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { } } - canvas_item->_edit_set_scale(scale); + ci->_edit_set_scale(scale); return true; } @@ -1999,9 +1999,9 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { if (selection.size() > 0) { drag_type = DRAG_MOVE; - CanvasItem *canvas_item = selection[0]; - Transform2D parent_xform = canvas_item->get_global_transform_with_canvas() * canvas_item->get_transform().affine_inverse(); - Transform2D unscaled_transform = (transform * parent_xform * canvas_item->_edit_get_transform()).orthonormalized(); + CanvasItem *ci = selection[0]; + Transform2D parent_xform = ci->get_global_transform_with_canvas() * ci->get_transform().affine_inverse(); + Transform2D unscaled_transform = (transform * parent_xform * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; if (show_transformation_gizmos) { @@ -2058,10 +2058,10 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } int index = 0; - for (CanvasItem *canvas_item : drag_selection) { - Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform(); + for (CanvasItem *ci : drag_selection) { + Transform2D xform = ci->get_global_transform_with_canvas().affine_inverse() * ci->get_transform(); - canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); + ci->_edit_set_position(ci->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); index++; } return true; @@ -2181,10 +2181,10 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } int index = 0; - for (CanvasItem *canvas_item : drag_selection) { - Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform(); + for (CanvasItem *ci : drag_selection) { + Transform2D xform = ci->get_global_transform_with_canvas().affine_inverse() * ci->get_transform(); - canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); + ci->_edit_set_position(ci->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); index++; } } @@ -2263,8 +2263,8 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { Node *node = item; while (node && node != scene->get_parent()) { - CanvasItem *canvas_item_tmp = Object::cast_to<CanvasItem>(node); - if (canvas_item_tmp && node->has_meta("_edit_group_")) { + CanvasItem *ci_tmp = Object::cast_to<CanvasItem>(node); + if (ci_tmp && node->has_meta("_edit_group_")) { locked = 2; } node = node->get_parent(); @@ -2325,16 +2325,16 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { } // Find the item to select - CanvasItem *canvas_item = nullptr; + CanvasItem *ci = nullptr; Vector<_SelectResult> selection = Vector<_SelectResult>(); // Retrieve the canvas items _get_canvas_items_at_pos(click, selection); if (!selection.is_empty()) { - canvas_item = selection[0].item; + ci = selection[0].item; } - if (!canvas_item) { + if (!ci) { // Start a box selection if (!b->is_shift_pressed()) { // Clear the selection if not additive @@ -2348,7 +2348,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { box_selecting_to = drag_from; return true; } else { - bool still_selected = _select_click_on_item(canvas_item, click, b->is_shift_pressed()); + bool still_selected = _select_click_on_item(ci, click, b->is_shift_pressed()); // Start dragging if (still_selected) { // Drag the node(s) if requested @@ -2488,16 +2488,16 @@ bool CanvasItemEditor::_gui_input_hover(const Ref<InputEvent> &p_event) { // Compute the nodes names and icon position Vector<_HoverResult> hovering_results_tmp; for (int i = 0; i < hovering_results_items.size(); i++) { - CanvasItem *canvas_item = hovering_results_items[i].item; + CanvasItem *ci = hovering_results_items[i].item; - if (canvas_item->_edit_use_rect()) { + if (ci->_edit_use_rect()) { continue; } _HoverResult hover_result; - hover_result.position = canvas_item->get_global_transform_with_canvas().get_origin(); - hover_result.icon = EditorNode::get_singleton()->get_object_icon(canvas_item); - hover_result.name = canvas_item->get_name(); + hover_result.position = ci->get_global_transform_with_canvas().get_origin(); + hover_result.icon = EditorNode::get_singleton()->get_object_icon(ci); + hover_result.name = ci->get_name(); hovering_results_tmp.push_back(hover_result); } @@ -3312,16 +3312,16 @@ void CanvasItemEditor::_draw_selection() { Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); Ref<Texture2D> previous_position_icon = get_theme_icon(SNAME("EditorPositionPrevious"), SNAME("EditorIcons")); - RID ci = viewport->get_canvas_item(); + RID vp_ci = viewport->get_canvas_item(); List<CanvasItem *> selection = _get_edited_canvas_items(true, false); bool single = selection.size() == 1; for (CanvasItem *E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); - CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); + CanvasItem *ci = Object::cast_to<CanvasItem>(E); + CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci); - bool item_locked = canvas_item->has_meta("_edit_lock_"); + bool item_locked = ci->has_meta("_edit_lock_"); // Draw the previous position if we are dragging the node if (show_helpers && @@ -3331,7 +3331,7 @@ void CanvasItemEditor::_draw_selection() { const Transform2D pre_drag_xform = transform * se->pre_drag_xform; const Color pre_drag_color = Color(0.4, 0.6, 1, 0.7); - if (canvas_item->_edit_use_rect()) { + if (ci->_edit_use_rect()) { Vector2 pre_drag_endpoints[4] = { pre_drag_xform.xform(se->pre_drag_rect.position), pre_drag_xform.xform(se->pre_drag_rect.position + Vector2(se->pre_drag_rect.size.x, 0)), @@ -3347,11 +3347,11 @@ void CanvasItemEditor::_draw_selection() { } } - Transform2D xform = transform * canvas_item->get_global_transform_with_canvas(); + Transform2D xform = transform * ci->get_global_transform_with_canvas(); // Draw the selected items position / surrounding boxes - if (canvas_item->_edit_use_rect()) { - Rect2 rect = canvas_item->_edit_get_rect(); + if (ci->_edit_use_rect()) { + Rect2 rect = ci->_edit_get_rect(); const Vector2 endpoints[4] = { xform.xform(rect.position), xform.xform(rect.position + Vector2(rect.size.x, 0)), @@ -3369,7 +3369,7 @@ void CanvasItemEditor::_draw_selection() { viewport->draw_line(endpoints[i], endpoints[(i + 1) % 4], c, Math::round(2 * EDSCALE)); } } else { - Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); + Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; viewport->draw_set_transform_matrix(simple_xform); viewport->draw_texture(position_icon, -(position_icon->get_size() / 2)); @@ -3378,9 +3378,9 @@ void CanvasItemEditor::_draw_selection() { if (single && !item_locked && (tool == TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_SCALE || tool == TOOL_ROTATE || tool == TOOL_EDIT_PIVOT)) { //kind of sucks // Draw the pivot - if (canvas_item->_edit_use_pivot()) { + if (ci->_edit_use_pivot()) { // Draw the node's pivot - Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); + Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; viewport->draw_set_transform_matrix(simple_xform); @@ -3389,15 +3389,15 @@ void CanvasItemEditor::_draw_selection() { } // Draw control-related helpers - Control *control = Object::cast_to<Control>(canvas_item); + Control *control = Object::cast_to<Control>(ci); if (control && _is_node_movable(control)) { _draw_control_anchors(control); _draw_control_helpers(control); } // Draw the resize handles - if (tool == TOOL_SELECT && canvas_item->_edit_use_rect() && _is_node_movable(canvas_item)) { - Rect2 rect = canvas_item->_edit_get_rect(); + if (tool == TOOL_SELECT && ci->_edit_use_rect() && _is_node_movable(ci)) { + Rect2 rect = ci->_edit_get_rect(); const Vector2 endpoints[4] = { xform.xform(rect.position), xform.xform(rect.position + Vector2(rect.size.x, 0)), @@ -3411,12 +3411,12 @@ void CanvasItemEditor::_draw_selection() { Vector2 ofs = ((endpoints[i] - endpoints[prev]).normalized() + ((endpoints[i] - endpoints[next]).normalized())).normalized(); ofs *= Math_SQRT2 * (select_handle->get_size().width / 2); - select_handle->draw(ci, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor()); + select_handle->draw(vp_ci, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor()); ofs = (endpoints[i] + endpoints[next]) / 2; ofs += (endpoints[next] - endpoints[i]).orthogonal().normalized() * (select_handle->get_size().width / 2); - select_handle->draw(ci, (ofs - (select_handle->get_size() / 2)).floor()); + select_handle->draw(vp_ci, (ofs - (select_handle->get_size() / 2)).floor()); } } @@ -3424,8 +3424,8 @@ void CanvasItemEditor::_draw_selection() { bool is_ctrl = Input::get_singleton()->is_key_pressed(Key::CTRL); bool is_alt = Input::get_singleton()->is_key_pressed(Key::ALT); if (tool == TOOL_MOVE && show_transformation_gizmos) { - if (_is_node_movable(canvas_item)) { - Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); + if (_is_node_movable(ci)) { + Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; Size2 move_factor = Size2(MOVE_HANDLE_DISTANCE, MOVE_HANDLE_DISTANCE); @@ -3454,8 +3454,8 @@ void CanvasItemEditor::_draw_selection() { // Draw the rescale handles if (show_transformation_gizmos && ((is_alt && is_ctrl) || tool == TOOL_SCALE || drag_type == DRAG_SCALE_X || drag_type == DRAG_SCALE_Y)) { - if (_is_node_movable(canvas_item)) { - Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); + if (_is_node_movable(ci)) { + Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE); @@ -3589,16 +3589,16 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans if (p_node != scene && p_node->get_owner() != scene && !scene->is_editable_instance(p_node->get_owner())) { return; } - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node); - if (canvas_item && !canvas_item->is_visible_in_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(p_node); + if (ci && !ci->is_visible_in_tree()) { return; } Transform2D parent_xform = p_parent_xform; Transform2D canvas_xform = p_canvas_xform; - if (canvas_item && !canvas_item->is_set_as_top_level()) { - parent_xform = parent_xform * canvas_item->get_transform(); + if (ci && !ci->is_set_as_top_level()) { + parent_xform = parent_xform * ci->get_transform(); } else { CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node); parent_xform = Transform2D(); @@ -3609,12 +3609,12 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans _draw_invisible_nodes_positions(p_node->get_child(i), parent_xform, canvas_xform); } - if (canvas_item && !canvas_item->_edit_use_rect() && (!editor_selection->is_selected(canvas_item) || _is_node_locked(canvas_item))) { + if (ci && !ci->_edit_use_rect() && (!editor_selection->is_selected(ci) || _is_node_locked(ci))) { Transform2D xform = transform * canvas_xform * parent_xform; // Draw the node's position Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPositionUnselected"), SNAME("EditorIcons")); - Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); + Transform2D unscaled_transform = (xform * ci->get_transform().affine_inverse() * ci->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; viewport->draw_set_transform_matrix(simple_xform); viewport->draw_texture(position_icon, -position_icon->get_size() / 2, Color(1.0, 1.0, 1.0, 0.5)); @@ -3720,16 +3720,16 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p if (p_node != scene && p_node->get_owner() != scene && !scene->is_editable_instance(p_node->get_owner())) { return; } - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(p_node); - if (canvas_item && !canvas_item->is_visible_in_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(p_node); + if (ci && !ci->is_visible_in_tree()) { return; } Transform2D parent_xform = p_parent_xform; Transform2D canvas_xform = p_canvas_xform; - if (canvas_item && !canvas_item->is_set_as_top_level()) { - parent_xform = parent_xform * canvas_item->get_transform(); + if (ci && !ci->is_set_as_top_level()) { + parent_xform = parent_xform * ci->get_transform(); } else { CanvasLayer *cl = Object::cast_to<CanvasLayer>(p_node); parent_xform = Transform2D(); @@ -3740,19 +3740,19 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p _draw_locks_and_groups(p_node->get_child(i), parent_xform, canvas_xform); } - RID viewport_canvas_item = viewport->get_canvas_item(); - if (canvas_item) { + RID viewport_ci = viewport->get_canvas_item(); + if (ci) { real_t offset = 0; Ref<Texture2D> lock = get_theme_icon(SNAME("LockViewport"), SNAME("EditorIcons")); if (p_node->has_meta("_edit_lock_") && show_edit_locks) { - lock->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); + lock->draw(viewport_ci, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); offset += lock->get_size().x; } Ref<Texture2D> group = get_theme_icon(SNAME("GroupViewport"), SNAME("EditorIcons")); - if (canvas_item->has_meta("_edit_group_") && show_edit_locks) { - group->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); + if (ci->has_meta("_edit_group_") && show_edit_locks) { + group->draw(viewport_ci, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); //offset += group->get_size().x; } } @@ -3885,16 +3885,16 @@ void CanvasItemEditor::_notification(int p_what) { // Update the viewport if the canvas_item changes List<CanvasItem *> selection = _get_edited_canvas_items(true); - for (CanvasItem *canvas_item : selection) { - CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); + for (CanvasItem *ci : selection) { + CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(ci); Rect2 rect; - if (canvas_item->_edit_use_rect()) { - rect = canvas_item->_edit_get_rect(); + if (ci->_edit_use_rect()) { + rect = ci->_edit_get_rect(); } else { rect = Rect2(); } - Transform2D xform = canvas_item->get_transform(); + Transform2D xform = ci->get_transform(); if (rect != se->prev_rect || xform != se->prev_xform) { viewport->queue_redraw(); @@ -3902,7 +3902,7 @@ void CanvasItemEditor::_notification(int p_what) { se->prev_xform = xform; } - Control *control = Object::cast_to<Control>(canvas_item); + Control *control = Object::cast_to<Control>(ci); if (control) { real_t anchors[4]; Vector2 pivot; @@ -3923,7 +3923,7 @@ void CanvasItemEditor::_notification(int p_what) { } } - if (canvas_item->_edit_use_pivot()) { + if (ci->_edit_use_pivot()) { nb_having_pivot++; } } @@ -4184,17 +4184,17 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, AnimationTrackEditor *te = AnimationPlayerEditor::get_singleton()->get_track_editor(); te->make_insert_queue(); for (const KeyValue<Node *, Object *> &E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key); - if (!canvas_item || !canvas_item->is_visible_in_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(E.key); + if (!ci || !ci->is_visible_in_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { + if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { continue; } - if (Object::cast_to<Node2D>(canvas_item)) { - Node2D *n2d = Object::cast_to<Node2D>(canvas_item); + if (Object::cast_to<Node2D>(ci)) { + Node2D *n2d = Object::cast_to<Node2D>(ci); if (key_pos && p_location) { te->insert_node_value_key(n2d, "position", n2d->get_position(), p_on_existing); @@ -4241,8 +4241,8 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, } } - } else if (Object::cast_to<Control>(canvas_item)) { - Control *ctrl = Object::cast_to<Control>(canvas_item); + } else if (Object::cast_to<Control>(ci)) { + Control *ctrl = Object::cast_to<Control>(ci); if (key_pos) { te->insert_node_value_key(ctrl, "position", ctrl->get_position(), p_on_existing); @@ -4390,16 +4390,16 @@ void CanvasItemEditor::_popup_callback(int p_op) { List<Node *> selection = editor_selection->get_selected_node_list(); for (Node *E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); - if (!canvas_item || !canvas_item->is_inside_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(E); + if (!ci || !ci->is_inside_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { + if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { continue; } - undo_redo->add_do_method(canvas_item, "set_meta", "_edit_lock_", true); - undo_redo->add_undo_method(canvas_item, "remove_meta", "_edit_lock_"); + undo_redo->add_do_method(ci, "set_meta", "_edit_lock_", true); + undo_redo->add_undo_method(ci, "remove_meta", "_edit_lock_"); undo_redo->add_do_method(this, "emit_signal", "item_lock_status_changed"); undo_redo->add_undo_method(this, "emit_signal", "item_lock_status_changed"); } @@ -4412,16 +4412,16 @@ void CanvasItemEditor::_popup_callback(int p_op) { List<Node *> selection = editor_selection->get_selected_node_list(); for (Node *E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); - if (!canvas_item || !canvas_item->is_inside_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(E); + if (!ci || !ci->is_inside_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { + if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { continue; } - undo_redo->add_do_method(canvas_item, "remove_meta", "_edit_lock_"); - undo_redo->add_undo_method(canvas_item, "set_meta", "_edit_lock_", true); + undo_redo->add_do_method(ci, "remove_meta", "_edit_lock_"); + undo_redo->add_undo_method(ci, "set_meta", "_edit_lock_", true); undo_redo->add_do_method(this, "emit_signal", "item_lock_status_changed"); undo_redo->add_undo_method(this, "emit_signal", "item_lock_status_changed"); } @@ -4434,16 +4434,16 @@ void CanvasItemEditor::_popup_callback(int p_op) { List<Node *> selection = editor_selection->get_selected_node_list(); for (Node *E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); - if (!canvas_item || !canvas_item->is_inside_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(E); + if (!ci || !ci->is_inside_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { + if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { continue; } - undo_redo->add_do_method(canvas_item, "set_meta", "_edit_group_", true); - undo_redo->add_undo_method(canvas_item, "remove_meta", "_edit_group_"); + undo_redo->add_do_method(ci, "set_meta", "_edit_group_", true); + undo_redo->add_undo_method(ci, "remove_meta", "_edit_group_"); undo_redo->add_do_method(this, "emit_signal", "item_group_status_changed"); undo_redo->add_undo_method(this, "emit_signal", "item_group_status_changed"); } @@ -4456,16 +4456,16 @@ void CanvasItemEditor::_popup_callback(int p_op) { List<Node *> selection = editor_selection->get_selected_node_list(); for (Node *E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); - if (!canvas_item || !canvas_item->is_inside_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(E); + if (!ci || !ci->is_inside_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { + if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { continue; } - undo_redo->add_do_method(canvas_item, "remove_meta", "_edit_group_"); - undo_redo->add_undo_method(canvas_item, "set_meta", "_edit_group_", true); + undo_redo->add_do_method(ci, "remove_meta", "_edit_group_"); + undo_redo->add_undo_method(ci, "set_meta", "_edit_group_", true); undo_redo->add_do_method(this, "emit_signal", "item_group_status_changed"); undo_redo->add_undo_method(this, "emit_signal", "item_group_status_changed"); } @@ -4496,17 +4496,17 @@ void CanvasItemEditor::_popup_callback(int p_op) { const HashMap<Node *, Object *> &selection = editor_selection->get_selection(); for (const KeyValue<Node *, Object *> &E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key); - if (!canvas_item || !canvas_item->is_visible_in_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(E.key); + if (!ci || !ci->is_visible_in_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { + if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { continue; } - if (Object::cast_to<Node2D>(canvas_item)) { - Node2D *n2d = Object::cast_to<Node2D>(canvas_item); + if (Object::cast_to<Node2D>(ci)) { + Node2D *n2d = Object::cast_to<Node2D>(ci); PoseClipboard pc; pc.pos = n2d->get_position(); pc.rot = n2d->get_rotation(); @@ -4542,17 +4542,17 @@ void CanvasItemEditor::_popup_callback(int p_op) { HashMap<Node *, Object *> &selection = editor_selection->get_selection(); for (const KeyValue<Node *, Object *> &E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key); - if (!canvas_item || !canvas_item->is_visible_in_tree()) { + CanvasItem *ci = Object::cast_to<CanvasItem>(E.key); + if (!ci || !ci->is_visible_in_tree()) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { + if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { continue; } - if (Object::cast_to<Node2D>(canvas_item)) { - Node2D *n2d = Object::cast_to<Node2D>(canvas_item); + if (Object::cast_to<Node2D>(ci)) { + Node2D *n2d = Object::cast_to<Node2D>(ci); if (key_pos) { n2d->set_position(Vector2()); @@ -4563,8 +4563,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { if (key_scale) { n2d->set_scale(Vector2(1, 1)); } - } else if (Object::cast_to<Control>(canvas_item)) { - Control *ctrl = Object::cast_to<Control>(canvas_item); + } else if (Object::cast_to<Control>(ci)) { + Control *ctrl = Object::cast_to<Control>(ci); if (key_pos) { ctrl->set_position(Point2()); @@ -4658,28 +4658,28 @@ void CanvasItemEditor::_focus_selection(int p_op) { const HashMap<Node *, Object *> &selection = editor_selection->get_selection(); for (const KeyValue<Node *, Object *> &E : selection) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key); - if (!canvas_item) { + CanvasItem *ci = Object::cast_to<CanvasItem>(E.key); + if (!ci) { continue; } - if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { + if (ci->get_viewport() != EditorNode::get_singleton()->get_scene_root()) { continue; } // counting invisible items, for now - //if (!canvas_item->is_visible_in_tree()) continue; + //if (!ci->is_visible_in_tree()) continue; ++count; Rect2 item_rect; - if (canvas_item->_edit_use_rect()) { - item_rect = canvas_item->_edit_get_rect(); + if (ci->_edit_use_rect()) { + item_rect = ci->_edit_get_rect(); } else { item_rect = Rect2(); } - Vector2 pos = canvas_item->get_global_transform().get_origin(); - Vector2 scale = canvas_item->get_global_transform().get_scale(); - real_t angle = canvas_item->get_global_transform().get_rotation(); + Vector2 pos = ci->get_global_transform().get_origin(); + Vector2 scale = ci->get_global_transform().get_scale(); + real_t angle = ci->get_global_transform().get_rotation(); Transform2D t(angle, Vector2(0.f, 0.f)); item_rect = t.xform(item_rect); diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp index e56fd5dfe3..a0e6771768 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp @@ -110,8 +110,8 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() { int vpc = 0; { - Vector<uint8_t> data = img->get_data(); - const uint8_t *r = data.ptr(); + Vector<uint8_t> img_data = img->get_data(); + const uint8_t *r = img_data.ptr(); for (int i = 0; i < s.width; i++) { for (int j = 0; j < s.height; j++) { diff --git a/editor/plugins/editor_resource_conversion_plugin.cpp b/editor/plugins/editor_resource_conversion_plugin.cpp index 91394dbac7..2db860fd07 100644 --- a/editor/plugins/editor_resource_conversion_plugin.cpp +++ b/editor/plugins/editor_resource_conversion_plugin.cpp @@ -46,7 +46,7 @@ String EditorResourceConversionPlugin::converts_to() const { } bool EditorResourceConversionPlugin::handles(const Ref<Resource> &p_resource) const { - bool ret; + bool ret = false; if (GDVIRTUAL_CALL(_handles, p_resource, ret)) { return ret; } diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index e2d19c34e6..1b2afe2151 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -207,8 +207,8 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() { int vpc = 0; { - Vector<uint8_t> data = img->get_data(); - const uint8_t *r = data.ptr(); + Vector<uint8_t> img_data = img->get_data(); + const uint8_t *r = img_data.ptr(); for (int i = 0; i < s.width; i++) { for (int j = 0; j < s.height; j++) { diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index d91cbb6571..db3a46d1f1 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -255,8 +255,8 @@ void GPUParticles3DEditor::_menu_option(int p_option) { } } break; case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE: { - Ref<ParticleProcessMaterial> material = node->get_process_material(); - if (material.is_null()) { + Ref<ParticleProcessMaterial> mat = node->get_process_material(); + if (mat.is_null()) { EditorNode::get_singleton()->show_warning(TTR("A processor material of type 'ParticleProcessMaterial' is required.")); return; } @@ -366,13 +366,13 @@ void GPUParticles3DEditor::_generate_emission_points() { Ref<Image> image = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img)); Ref<ImageTexture> tex = ImageTexture::create_from_image(image); - Ref<ParticleProcessMaterial> material = node->get_process_material(); - ERR_FAIL_COND(material.is_null()); + Ref<ParticleProcessMaterial> mat = node->get_process_material(); + ERR_FAIL_COND(mat.is_null()); if (normals.size() > 0) { - material->set_emission_shape(ParticleProcessMaterial::EMISSION_SHAPE_DIRECTED_POINTS); - material->set_emission_point_count(point_count); - material->set_emission_point_texture(tex); + mat->set_emission_shape(ParticleProcessMaterial::EMISSION_SHAPE_DIRECTED_POINTS); + mat->set_emission_point_count(point_count); + mat->set_emission_point_texture(tex); Vector<uint8_t> point_img2; point_img2.resize(w * h * 3 * sizeof(float)); @@ -390,11 +390,11 @@ void GPUParticles3DEditor::_generate_emission_points() { } Ref<Image> image2 = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img2)); - material->set_emission_normal_texture(ImageTexture::create_from_image(image2)); + mat->set_emission_normal_texture(ImageTexture::create_from_image(image2)); } else { - material->set_emission_shape(ParticleProcessMaterial::EMISSION_SHAPE_POINTS); - material->set_emission_point_count(point_count); - material->set_emission_point_texture(tex); + mat->set_emission_shape(ParticleProcessMaterial::EMISSION_SHAPE_POINTS); + mat->set_emission_point_count(point_count); + mat->set_emission_point_texture(tex); } } diff --git a/editor/plugins/gradient_editor.cpp b/editor/plugins/gradient_editor.cpp index c13b162db6..822f303d93 100644 --- a/editor/plugins/gradient_editor.cpp +++ b/editor/plugins/gradient_editor.cpp @@ -90,8 +90,8 @@ void GradientEditor::_gradient_changed() { } editing = true; - Vector<Gradient::Point> points = gradient->get_points(); - set_points(points); + Vector<Gradient::Point> grad_points = gradient->get_points(); + set_points(grad_points); set_interpolation_mode(gradient->get_interpolation_mode()); queue_redraw(); editing = false; diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp index 31053f90b8..d73761d770 100644 --- a/editor/plugins/line_2d_editor_plugin.cpp +++ b/editor/plugins/line_2d_editor_plugin.cpp @@ -51,9 +51,9 @@ void Line2DEditor::_set_polygon(int p_idx, const Variant &p_polygon) const { } void Line2DEditor::_action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) { - Node2D *node = _get_node(); - undo_redo->add_do_method(node, "set_points", p_polygon); - undo_redo->add_undo_method(node, "set_points", p_previous); + Node2D *_node = _get_node(); + undo_redo->add_do_method(_node, "set_points", p_polygon); + undo_redo->add_undo_method(_node, "set_points", p_previous); } Line2DEditor::Line2DEditor() {} diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 4a262d2940..7194cd9d27 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -1119,7 +1119,7 @@ void EditorNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } bool EditorNode3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const { - bool ret; + bool ret = false; if (GDVIRTUAL_CALL(_is_handle_highlighted, Ref<EditorNode3DGizmo>(p_gizmo), p_id, p_secondary, ret)) { return ret; } @@ -1151,7 +1151,7 @@ void EditorNode3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, in } int EditorNode3DGizmoPlugin::subgizmos_intersect_ray(const EditorNode3DGizmo *p_gizmo, Camera3D *p_camera, const Vector2 &p_point) const { - int ret; + int ret = -1; if (GDVIRTUAL_CALL(_subgizmos_intersect_ray, Ref<EditorNode3DGizmo>(p_gizmo), p_camera, p_point, ret)) { return ret; } @@ -4167,9 +4167,9 @@ void CollisionObject3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->clear(); - List<uint32_t> owners; - co->get_shape_owners(&owners); - for (uint32_t &owner_id : owners) { + List<uint32_t> owner_ids; + co->get_shape_owners(&owner_ids); + for (uint32_t &owner_id : owner_ids) { Transform3D xform = co->shape_owner_get_transform(owner_id); Object *owner = co->shape_owner_get_owner(owner_id); // Exclude CollisionShape3D and CollisionPolygon3D as they have their gizmo. diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 2f49b3a62d..4430877b8a 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -2429,11 +2429,11 @@ void Node3DEditorViewport::_notification(int p_what) { } break; case NOTIFICATION_VISIBILITY_CHANGED: { - bool visible = is_visible_in_tree(); + bool vp_visible = is_visible_in_tree(); - set_process(visible); + set_process(vp_visible); - if (visible) { + if (vp_visible) { orthogonal = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL)); _update_name(); _update_camera(0); @@ -3880,8 +3880,8 @@ bool Node3DEditorViewport::_apply_preview_material(ObjectID p_target, const Poin Vector3 xform_ray = ai.basis.xform(world_ray).normalized(); Vector3 xform_pos = ai.xform(world_pos); - for (int surface = 0; surface < surface_count; surface++) { - Ref<TriangleMesh> surface_mesh = mesh->generate_surface_triangle_mesh(surface); + for (int surface_idx = 0; surface_idx < surface_count; surface_idx++) { + Ref<TriangleMesh> surface_mesh = mesh->generate_surface_triangle_mesh(surface_idx); Vector3 rpos, rnorm; if (surface_mesh->intersect_ray(xform_pos, xform_ray, rpos, rnorm)) { @@ -3894,7 +3894,7 @@ bool Node3DEditorViewport::_apply_preview_material(ObjectID p_target, const Poin } if (dist < closest_dist) { - closest_surface = surface; + closest_surface = surface_idx; closest_dist = dist; } } @@ -4020,16 +4020,16 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po Node3D *node3d = Object::cast_to<Node3D>(instantiated_scene); if (node3d) { - Transform3D global_transform; + Transform3D gl_transform; Node3D *parent_node3d = Object::cast_to<Node3D>(parent); if (parent_node3d) { - global_transform = parent_node3d->get_global_gizmo_transform(); + gl_transform = parent_node3d->get_global_gizmo_transform(); } - global_transform.origin = spatial_editor->snap_point(_get_instance_position(p_point)); - global_transform.basis *= node3d->get_transform().basis; + gl_transform.origin = spatial_editor->snap_point(_get_instance_position(p_point)); + gl_transform.basis *= node3d->get_transform().basis; - editor_data->get_undo_redo()->add_do_method(instantiated_scene, "set_global_transform", global_transform); + editor_data->get_undo_redo()->add_do_method(instantiated_scene, "set_global_transform", gl_transform); } return true; @@ -4163,8 +4163,8 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant } if (can_instantiate) { - Transform3D global_transform = Transform3D(Basis(), _get_instance_position(p_point)); - preview_node->set_global_transform(global_transform); + Transform3D gl_transform = Transform3D(Basis(), _get_instance_position(p_point)); + preview_node->set_global_transform(gl_transform); return true; } diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp index 0203f2933f..d7953bf4e0 100644 --- a/editor/plugins/path_3d_editor_plugin.cpp +++ b/editor/plugins/path_3d_editor_plugin.cpp @@ -264,33 +264,33 @@ void Path3DGizmo::redraw() { if (Path3DEditorPlugin::singleton->get_edited_path() == path) { v3p.clear(); - Vector<Vector3> handles; - Vector<Vector3> sec_handles; + Vector<Vector3> handle_points; + Vector<Vector3> sec_handle_points; for (int i = 0; i < c->get_point_count(); i++) { Vector3 p = c->get_point_position(i); - handles.push_back(p); + handle_points.push_back(p); // push Out points first so they get selected if the In and Out points are on top of each other. if (i < c->get_point_count() - 1) { v3p.push_back(p); v3p.push_back(p + c->get_point_out(i)); - sec_handles.push_back(p + c->get_point_out(i)); + sec_handle_points.push_back(p + c->get_point_out(i)); } if (i > 0) { v3p.push_back(p); v3p.push_back(p + c->get_point_in(i)); - sec_handles.push_back(p + c->get_point_in(i)); + sec_handle_points.push_back(p + c->get_point_in(i)); } } if (v3p.size() > 1) { add_lines(v3p, path_thin_material); } - if (handles.size()) { - add_handles(handles, handles_material); + if (handle_points.size()) { + add_handles(handle_points, handles_material); } - if (sec_handles.size()) { - add_handles(sec_handles, sec_handles_material, Vector<int>(), false, true); + if (sec_handle_points.size()) { + add_handles(sec_handle_points, sec_handles_material, Vector<int>(), false, true); } } } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 67813a3635..876ef3bae9 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -128,12 +128,12 @@ void EditorStandardSyntaxHighlighter::_update_cache() { } } - const Ref<Script> script = _get_edited_resource(); - if (script.is_valid()) { + const Ref<Script> scr = _get_edited_resource(); + if (scr.is_valid()) { /* Core types. */ const Color basetype_color = EDITOR_GET("text_editor/theme/highlighting/base_type_color"); List<String> core_types; - script->get_language()->get_core_type_words(&core_types); + scr->get_language()->get_core_type_words(&core_types); for (const String &E : core_types) { highlighter->add_keyword_color(E, basetype_color); } @@ -142,9 +142,9 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color"); const Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color"); List<String> keywords; - script->get_language()->get_reserved_words(&keywords); + scr->get_language()->get_reserved_words(&keywords); for (const String &E : keywords) { - if (script->get_language()->is_control_flow_keyword(E)) { + if (scr->get_language()->is_control_flow_keyword(E)) { highlighter->add_keyword_color(E, control_flow_keyword_color); } else { highlighter->add_keyword_color(E, keyword_color); @@ -153,19 +153,19 @@ void EditorStandardSyntaxHighlighter::_update_cache() { /* Member types. */ const Color member_variable_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color"); - StringName instance_base = script->get_instance_base_type(); + StringName instance_base = scr->get_instance_base_type(); if (instance_base != StringName()) { List<PropertyInfo> plist; ClassDB::get_property_list(instance_base, &plist); for (const PropertyInfo &E : plist) { - String name = E.name; + String prop_name = E.name; if (E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP) { continue; } - if (name.contains("/")) { + if (prop_name.contains("/")) { continue; } - highlighter->add_member_keyword_color(name, member_variable_color); + highlighter->add_member_keyword_color(prop_name, member_variable_color); } List<String> clist; @@ -178,7 +178,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { /* Comments */ const Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color"); List<String> comments; - script->get_language()->get_comment_delimiters(&comments); + scr->get_language()->get_comment_delimiters(&comments); for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); @@ -188,7 +188,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { /* Strings */ const Color string_color = EDITOR_GET("text_editor/theme/highlighting/string_color"); List<String> strings; - script->get_language()->get_string_delimiters(&strings); + scr->get_language()->get_string_delimiters(&strings); for (const String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); @@ -431,8 +431,8 @@ void ScriptEditor::_goto_script_line2(int p_line) { } void ScriptEditor::_goto_script_line(Ref<RefCounted> p_script, int p_line) { - Ref<Script> script = Object::cast_to<Script>(*p_script); - if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) { + Ref<Script> scr = Object::cast_to<Script>(*p_script); + if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) { if (edit(p_script, p_line, 0)) { EditorNode::get_singleton()->push_item(p_script.ptr()); @@ -447,15 +447,15 @@ void ScriptEditor::_goto_script_line(Ref<RefCounted> p_script, int p_line) { } void ScriptEditor::_set_execution(Ref<RefCounted> p_script, int p_line) { - Ref<Script> script = Object::cast_to<Script>(*p_script); - if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) { + Ref<Script> scr = Object::cast_to<Script>(*p_script); + if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) { for (int i = 0; i < tab_container->get_tab_count(); i++) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); if (!se) { continue; } - if ((script != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) { + if ((scr != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == scr->get_path()) { se->set_executing_line(p_line); } } @@ -463,15 +463,15 @@ void ScriptEditor::_set_execution(Ref<RefCounted> p_script, int p_line) { } void ScriptEditor::_clear_execution(Ref<RefCounted> p_script) { - Ref<Script> script = Object::cast_to<Script>(*p_script); - if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) { + Ref<Script> scr = Object::cast_to<Script>(*p_script); + if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) { for (int i = 0; i < tab_container->get_tab_count(); i++) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); if (!se) { continue; } - if ((script != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) { + if ((scr != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == scr->get_path()) { se->clear_executing_line(); } } @@ -479,19 +479,19 @@ void ScriptEditor::_clear_execution(Ref<RefCounted> p_script) { } void ScriptEditor::_set_breakpoint(Ref<RefCounted> p_script, int p_line, bool p_enabled) { - Ref<Script> script = Object::cast_to<Script>(*p_script); - if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) { + Ref<Script> scr = Object::cast_to<Script>(*p_script); + if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) { // Update if open. for (int i = 0; i < tab_container->get_tab_count(); i++) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); - if (se && se->get_edited_resource()->get_path() == script->get_path()) { + if (se && se->get_edited_resource()->get_path() == scr->get_path()) { se->set_breakpoint(p_line, p_enabled); return; } } // Handle closed. - Dictionary state = script_editor_cache->get_value(script->get_path(), "state"); + Dictionary state = script_editor_cache->get_value(scr->get_path(), "state"); Array breakpoints; if (state.has("breakpoints")) { breakpoints = state["breakpoints"]; @@ -505,8 +505,8 @@ void ScriptEditor::_set_breakpoint(Ref<RefCounted> p_script, int p_line, bool p_ breakpoints.push_back(p_line); } state["breakpoints"] = breakpoints; - script_editor_cache->set_value(script->get_path(), "state", state); - EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), p_line + 1, false); + script_editor_cache->set_value(scr->get_path(), "state", state); + EditorDebuggerNode::get_singleton()->set_breakpoint(scr->get_path(), p_line + 1, false); } } @@ -627,9 +627,9 @@ void ScriptEditor::_go_to_tab(int p_idx) { Object::cast_to<ScriptEditorBase>(c)->ensure_focus(); } - Ref<Script> script = Object::cast_to<ScriptEditorBase>(c)->get_edited_resource(); - if (script != nullptr) { - notify_script_changed(script); + Ref<Script> scr = Object::cast_to<ScriptEditorBase>(c)->get_edited_resource(); + if (scr != nullptr) { + notify_script_changed(scr); } Object::cast_to<ScriptEditorBase>(c)->validate(); @@ -705,9 +705,9 @@ void ScriptEditor::_open_recent_script(int p_idx) { ResourceLoader::get_recognized_extensions_for_type("Script", &extensions); if (extensions.find(path.get_extension())) { - Ref<Script> script = ResourceLoader::load(path); - if (script.is_valid()) { - edit(script, true); + Ref<Script> scr = ResourceLoader::load(path); + if (scr.is_valid()) { + edit(scr, true); return; } } @@ -729,9 +729,9 @@ void ScriptEditor::_open_recent_script(int p_idx) { } else { EditorNode::get_singleton()->load_resource(res_path); } - Ref<Script> script = ResourceLoader::load(path); - if (script.is_valid()) { - edit(script, true); + Ref<Script> scr = ResourceLoader::load(path); + if (scr.is_valid()) { + edit(scr, true); return; } } else if (!path.is_resource_file()) { @@ -774,9 +774,9 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) { previous_scripts.push_back(file->get_path()); } - Ref<Script> script = file; - if (script.is_valid()) { - notify_script_close(script); + Ref<Script> scr = file; + if (scr.is_valid()) { + notify_script_close(scr); } } } @@ -851,8 +851,8 @@ void ScriptEditor::_close_docs_tab() { void ScriptEditor::_copy_script_path() { ScriptEditorBase *se = _get_current_editor(); if (se) { - Ref<Resource> script = se->get_edited_resource(); - DisplayServer::get_singleton()->clipboard_set(script->get_path()); + Ref<Resource> scr = se->get_edited_resource(); + DisplayServer::get_singleton()->clipboard_set(scr->get_path()); } } @@ -908,9 +908,9 @@ void ScriptEditor::_resave_scripts(const String &p_str) { continue; } - Ref<Resource> script = se->get_edited_resource(); + Ref<Resource> scr = se->get_edited_resource(); - if (script->is_built_in()) { + if (scr->is_built_in()) { continue; //internal script, who cares } @@ -928,13 +928,13 @@ void ScriptEditor::_resave_scripts(const String &p_str) { } } - Ref<TextFile> text_file = script; + Ref<TextFile> text_file = scr; if (text_file != nullptr) { se->apply_code(); _save_text_file(text_file, text_file->get_path()); break; } else { - EditorNode::get_singleton()->save_resource(script); + EditorNode::get_singleton()->save_resource(scr); } se->tag_saved_version(); } @@ -949,9 +949,9 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) { continue; } - Ref<Resource> script = se->get_edited_resource(); + Ref<Resource> scr = se->get_edited_resource(); - if (script == p_res) { + if (scr == p_res) { se->tag_saved_version(); } } @@ -1106,8 +1106,8 @@ Ref<Script> ScriptEditor::_get_current_script() { ScriptEditorBase *current = _get_current_editor(); if (current) { - Ref<Script> script = current->get_edited_resource(); - return script != nullptr ? script : nullptr; + Ref<Script> scr = current->get_edited_resource(); + return scr != nullptr ? scr : nullptr; } else { return nullptr; } @@ -1284,7 +1284,7 @@ void ScriptEditor::_menu_option(int p_option) { Ref<Resource> resource = current->get_edited_resource(); Ref<TextFile> text_file = resource; - Ref<Script> script = resource; + Ref<Script> scr = resource; if (text_file != nullptr) { file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); @@ -1301,15 +1301,15 @@ void ScriptEditor::_menu_option(int p_option) { break; } - if (script.is_valid()) { - clear_docs_from_script(script); + if (scr.is_valid()) { + clear_docs_from_script(scr); } EditorNode::get_singleton()->push_item(resource.ptr()); EditorNode::get_singleton()->save_resource_as(resource); - if (script.is_valid()) { - update_docs_from_script(script); + if (scr.is_valid()) { + update_docs_from_script(scr); } } break; @@ -1367,18 +1367,18 @@ void ScriptEditor::_menu_option(int p_option) { _copy_script_path(); } break; case SHOW_IN_FILE_SYSTEM: { - const Ref<Resource> script = current->get_edited_resource(); - String path = script->get_path(); + const Ref<Resource> scr = current->get_edited_resource(); + String path = scr->get_path(); if (!path.is_empty()) { - if (script->is_built_in()) { + if (scr->is_built_in()) { path = path.get_slice("::", 0); // Show the scene instead. } FileSystemDock *file_system_dock = FileSystemDock::get_singleton(); file_system_dock->navigate_to_path(path); // Ensure that the FileSystem dock is visible. - TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control(); - tab_container->set_current_tab(tab_container->get_tab_idx_from_control(file_system_dock)); + TabContainer *dock_tab_container = (TabContainer *)file_system_dock->get_parent_control(); + dock_tab_container->set_current_tab(dock_tab_container->get_tab_idx_from_control(file_system_dock)); } } break; case CLOSE_DOCS: { @@ -1635,12 +1635,12 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); if (se) { - Ref<Script> script = se->get_edited_resource(); - if (script == nullptr || !script.is_valid()) { + Ref<Script> scr = se->get_edited_resource(); + if (scr == nullptr || !scr.is_valid()) { continue; } - if (script->is_built_in() && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed + if (scr->is_built_in() && scr->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed _close_tab(i, false); i--; } @@ -1668,12 +1668,12 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) { continue; } - Ref<Script> script = se->get_edited_resource(); - if (script == nullptr) { + Ref<Script> scr = se->get_edited_resource(); + if (scr == nullptr) { continue; } - String base = script->get_path(); + String base = scr->get_path(); loaded_scripts.insert(base); if (base.begins_with("local://") || base.is_empty()) { continue; @@ -2184,20 +2184,20 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col, return false; } - Ref<Script> script = p_resource; + Ref<Script> scr = p_resource; // Don't open dominant script if using an external editor. bool use_external_editor = EditorSettings::get_singleton()->get("text_editor/external/use_external_editor") || - (script.is_valid() && script->get_language()->overrides_external_editor()); - use_external_editor = use_external_editor && !(script.is_valid() && script->is_built_in()); // Ignore external editor for built-in scripts. + (scr.is_valid() && scr->get_language()->overrides_external_editor()); + use_external_editor = use_external_editor && !(scr.is_valid() && scr->is_built_in()); // Ignore external editor for built-in scripts. const bool open_dominant = EditorSettings::get_singleton()->get("text_editor/behavior/files/open_dominant_script_on_scene_change"); const bool should_open = (open_dominant && !use_external_editor) || !EditorNode::get_singleton()->is_changing_scene(); - if (script.is_valid() && script->get_language()->overrides_external_editor()) { + if (scr.is_valid() && scr->get_language()->overrides_external_editor()) { if (should_open) { - Error err = script->get_language()->open_in_external_editor(script, p_line >= 0 ? p_line : 0, p_col); + Error err = scr->get_language()->open_in_external_editor(scr, p_line >= 0 ? p_line : 0, p_col); if (err != OK) { ERR_PRINT("Couldn't open script in the overridden external text editor"); } @@ -2271,7 +2271,7 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col, continue; } - if ((script != nullptr && se->get_edited_resource() == p_resource) || se->get_edited_resource()->get_path() == p_resource->get_path()) { + if ((scr != nullptr && se->get_edited_resource() == p_resource) || se->get_edited_resource()->get_path() == p_resource->get_path()) { if (should_open) { se->enable_editor(); @@ -2316,9 +2316,9 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col, } se->add_syntax_highlighter(highlighter); - if (script != nullptr && !highlighter_set) { + if (scr != nullptr && !highlighter_set) { PackedStringArray languages = highlighter->_get_supported_languages(); - if (languages.has(script->get_language()->get_name())) { + if (languages.has(scr->get_language()->get_name())) { se->set_syntax_highlighter(highlighter); highlighter_set = true; } @@ -2399,7 +2399,7 @@ void ScriptEditor::save_current_script() { Ref<Resource> resource = current->get_edited_resource(); Ref<TextFile> text_file = resource; - Ref<Script> script = resource; + Ref<Script> scr = resource; if (text_file != nullptr) { current->apply_code(); @@ -2407,8 +2407,8 @@ void ScriptEditor::save_current_script() { return; } - if (script.is_valid()) { - clear_docs_from_script(script); + if (scr.is_valid()) { + clear_docs_from_script(scr); } if (resource->is_built_in()) { @@ -2423,8 +2423,8 @@ void ScriptEditor::save_current_script() { EditorNode::get_singleton()->save_resource(resource); } - if (script.is_valid()) { - update_docs_from_script(script); + if (scr.is_valid()) { + update_docs_from_script(scr); } } @@ -2462,21 +2462,21 @@ void ScriptEditor::save_all_scripts() { if (!edited_res->is_built_in()) { Ref<TextFile> text_file = edited_res; - Ref<Script> script = edited_res; + Ref<Script> scr = edited_res; if (text_file != nullptr) { _save_text_file(text_file, text_file->get_path()); continue; } - if (script.is_valid()) { - clear_docs_from_script(script); + if (scr.is_valid()) { + clear_docs_from_script(scr); } EditorNode::get_singleton()->save_resource(edited_res); //external script, save it - if (script.is_valid()) { - update_docs_from_script(script); + if (scr.is_valid()) { + update_docs_from_script(scr); } } else { // For built-in scripts, save their scenes instead. @@ -2526,13 +2526,13 @@ void ScriptEditor::reload_scripts(bool p_refresh_only) { continue; } - Ref<Script> script = edited_res; - if (script != nullptr) { - Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE); - ERR_CONTINUE(!rel_script.is_valid()); - script->set_source_code(rel_script->get_source_code()); - script->set_last_modified_time(rel_script->get_last_modified_time()); - script->reload(true); + Ref<Script> scr = edited_res; + if (scr != nullptr) { + Ref<Script> rel_scr = ResourceLoader::load(scr->get_path(), scr->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE); + ERR_CONTINUE(!rel_scr.is_valid()); + scr->set_source_code(rel_scr->get_source_code()); + scr->set_last_modified_time(rel_scr->get_last_modified_time()); + scr->reload(true); } Ref<TextFile> text_file = edited_res; @@ -2605,17 +2605,17 @@ void ScriptEditor::_editor_stop() { void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const PackedStringArray &p_args) { ERR_FAIL_COND(!p_obj); - Ref<Script> script = p_obj->get_script(); - ERR_FAIL_COND(!script.is_valid()); + Ref<Script> scr = p_obj->get_script(); + ERR_FAIL_COND(!scr.is_valid()); - EditorNode::get_singleton()->push_item(script.ptr()); + EditorNode::get_singleton()->push_item(scr.ptr()); for (int i = 0; i < tab_container->get_tab_count(); i++) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); if (!se) { continue; } - if (se->get_edited_resource() != script) { + if (se->get_edited_resource() != scr) { continue; } @@ -2626,7 +2626,7 @@ void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const script_list->select(script_list->find_metadata(i)); // Save the current script so the changes can be picked up by an external editor. - if (!script.ptr()->is_built_in()) { // But only if it's not built-in script. + if (!scr.ptr()->is_built_in()) { // But only if it's not built-in script. save_current_script(); } @@ -3376,9 +3376,9 @@ void ScriptEditor::_update_history_pos(int p_new_pos) { seb->set_edit_state(history[history_pos].state); seb->ensure_focus(); - Ref<Script> script = seb->get_edited_resource(); - if (script != nullptr) { - notify_script_changed(script); + Ref<Script> scr = seb->get_edited_resource(); + if (scr != nullptr) { + notify_script_changed(scr); } } @@ -3414,9 +3414,9 @@ Vector<Ref<Script>> ScriptEditor::get_open_scripts() const { continue; } - Ref<Script> script = se->get_edited_resource(); - if (script != nullptr) { - out_scripts.push_back(script); + Ref<Script> scr = se->get_edited_resource(); + if (scr != nullptr) { + out_scripts.push_back(scr); } } @@ -3467,9 +3467,9 @@ void ScriptEditor::_help_search(String p_text) { } void ScriptEditor::_open_script_request(const String &p_path) { - Ref<Script> script = ResourceLoader::load(p_path); - if (script.is_valid()) { - script_editor->edit(script, false); + Ref<Script> scr = ResourceLoader::load(p_path); + if (scr.is_valid()) { + script_editor->edit(scr, false); return; } @@ -3534,9 +3534,9 @@ void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_numb EditorNode::get_singleton()->load_scene(fpath); return; } else { - Ref<Script> script = res; - if (script.is_valid()) { - edit(script); + Ref<Script> scr = res; + if (scr.is_valid()) { + edit(scr); ScriptTextEditor *ste = Object::cast_to<ScriptTextEditor>(_get_current_editor()); if (ste) { @@ -3806,12 +3806,12 @@ ScriptEditor::ScriptEditor() { script_search_menu->get_popup()->connect("id_pressed", callable_mp(this, &ScriptEditor::_menu_option)); menu_hb->add_child(script_search_menu); - MenuButton *debug_menu = memnew(MenuButton); - menu_hb->add_child(debug_menu); - debug_menu->hide(); // Handled by EditorDebuggerNode below. + MenuButton *debug_menu_btn = memnew(MenuButton); + menu_hb->add_child(debug_menu_btn); + debug_menu_btn->hide(); // Handled by EditorDebuggerNode below. EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton(); - debugger->set_script_debug_button(debug_menu); + debugger->set_script_debug_button(debug_menu_btn); debugger->connect("goto_script_line", callable_mp(this, &ScriptEditor::_goto_script_line)); debugger->connect("set_execution", callable_mp(this, &ScriptEditor::_set_execution)); debugger->connect("clear_execution", callable_mp(this, &ScriptEditor::_clear_execution)); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 9910a97f88..58a0160010 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -703,25 +703,25 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo } for (const Ref<Script> &E : scripts) { - Ref<Script> script = E; + Ref<Script> scr = E; - if (p_for_script.is_valid() && p_for_script != script) { + if (p_for_script.is_valid() && p_for_script != scr) { continue; } - if (script->is_built_in()) { + if (scr->is_built_in()) { continue; //internal script, who cares, though weird } - uint64_t last_date = script->get_last_modified_time(); - uint64_t date = FileAccess::get_modified_time(script->get_path()); + uint64_t last_date = scr->get_last_modified_time(); + uint64_t date = FileAccess::get_modified_time(scr->get_path()); if (last_date != date) { - Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE); - ERR_CONTINUE(!rel_script.is_valid()); - script->set_source_code(rel_script->get_source_code()); - script->set_last_modified_time(rel_script->get_last_modified_time()); - script->update_exports(); + Ref<Script> rel_scr = ResourceLoader::load(scr->get_path(), scr->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE); + ERR_CONTINUE(!rel_scr.is_valid()); + scr->set_source_code(rel_scr->get_source_code()); + scr->set_last_modified_time(rel_scr->get_last_modified_time()); + scr->update_exports(); _trigger_live_script_reload(); } @@ -982,10 +982,10 @@ void ScriptTextEditor::_update_connected_methods() { Vector<Node *> nodes = _find_all_node_for_script(base, base, script); HashSet<StringName> methods_found; for (int i = 0; i < nodes.size(); i++) { - List<Connection> connections; - nodes[i]->get_signals_connected_to_this(&connections); + List<Connection> signal_connections; + nodes[i]->get_signals_connected_to_this(&signal_connections); - for (const Connection &connection : connections) { + for (const Connection &connection : signal_connections) { if (!(connection.flags & CONNECT_PERSIST)) { continue; } diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index 99f0ff638e..83245366f9 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -587,25 +587,25 @@ void Skeleton3DEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data void Skeleton3DEditor::move_skeleton_bone(NodePath p_skeleton_path, int32_t p_selected_boneidx, int32_t p_target_boneidx) { Node *node = get_node_or_null(p_skeleton_path); - Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node); - ERR_FAIL_NULL(skeleton); + Skeleton3D *skeleton_node = Object::cast_to<Skeleton3D>(node); + ERR_FAIL_NULL(skeleton_node); Ref<EditorUndoRedoManager> &ur = EditorNode::get_undo_redo(); ur->create_action(TTR("Set Bone Parentage")); // If the target is a child of ourselves, we move only *us* and not our children. - if (skeleton->is_bone_parent_of(p_target_boneidx, p_selected_boneidx)) { - const BoneId parent_idx = skeleton->get_bone_parent(p_selected_boneidx); - const int bone_count = skeleton->get_bone_count(); + if (skeleton_node->is_bone_parent_of(p_target_boneidx, p_selected_boneidx)) { + const BoneId parent_idx = skeleton_node->get_bone_parent(p_selected_boneidx); + const int bone_count = skeleton_node->get_bone_count(); for (BoneId i = 0; i < bone_count; ++i) { - if (skeleton->get_bone_parent(i) == p_selected_boneidx) { - ur->add_undo_method(skeleton, "set_bone_parent", i, skeleton->get_bone_parent(i)); - ur->add_do_method(skeleton, "set_bone_parent", i, parent_idx); - skeleton->set_bone_parent(i, parent_idx); + if (skeleton_node->get_bone_parent(i) == p_selected_boneidx) { + ur->add_undo_method(skeleton_node, "set_bone_parent", i, skeleton_node->get_bone_parent(i)); + ur->add_do_method(skeleton_node, "set_bone_parent", i, parent_idx); + skeleton_node->set_bone_parent(i, parent_idx); } } } - ur->add_undo_method(skeleton, "set_bone_parent", p_selected_boneidx, skeleton->get_bone_parent(p_selected_boneidx)); - ur->add_do_method(skeleton, "set_bone_parent", p_selected_boneidx, p_target_boneidx); - skeleton->set_bone_parent(p_selected_boneidx, p_target_boneidx); + ur->add_undo_method(skeleton_node, "set_bone_parent", p_selected_boneidx, skeleton_node->get_bone_parent(p_selected_boneidx)); + ur->add_do_method(skeleton_node, "set_bone_parent", p_selected_boneidx, p_target_boneidx); + skeleton_node->set_bone_parent(p_selected_boneidx, p_target_boneidx); update_joint_tree(); ur->commit_action(); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index d0a1ddafa1..cfece173d6 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -1095,8 +1095,8 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant & } for (int i = 0; i < files.size(); i++) { - String file = files[i]; - String ftype = EditorFileSystem::get_singleton()->get_file_type(file); + String f = files[i]; + String ftype = EditorFileSystem::get_singleton()->get_file_type(f); if (!ClassDB::is_parent_class(ftype, "Texture2D")) { return false; diff --git a/editor/plugins/text_shader_editor.cpp b/editor/plugins/text_shader_editor.cpp index 9dea990bd8..48086bf235 100644 --- a/editor/plugins/text_shader_editor.cpp +++ b/editor/plugins/text_shader_editor.cpp @@ -202,12 +202,12 @@ void ShaderTextEditor::set_warnings_panel(RichTextLabel *p_warnings_panel) { } void ShaderTextEditor::_load_theme_settings() { - CodeEdit *text_editor = get_text_editor(); + CodeEdit *te = get_text_editor(); Color updated_marked_line_color = EDITOR_GET("text_editor/theme/highlighting/mark_color"); if (updated_marked_line_color != marked_line_color) { - for (int i = 0; i < text_editor->get_line_count(); i++) { - if (text_editor->get_line_background_color(i) == marked_line_color) { - text_editor->set_line_background_color(i, updated_marked_line_color); + for (int i = 0; i < te->get_line_count(); i++) { + if (te->get_line_background_color(i) == marked_line_color) { + te->set_line_background_color(i, updated_marked_line_color); } } marked_line_color = updated_marked_line_color; @@ -257,14 +257,14 @@ void ShaderTextEditor::_load_theme_settings() { const Vector<ShaderLanguage::ModeInfo> &modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(i)); for (int j = 0; j < modes.size(); j++) { - const ShaderLanguage::ModeInfo &info = modes[j]; + const ShaderLanguage::ModeInfo &mode_info = modes[j]; - if (!info.options.is_empty()) { - for (int k = 0; k < info.options.size(); k++) { - built_ins.push_back(String(info.name) + "_" + String(info.options[k])); + if (!mode_info.options.is_empty()) { + for (int k = 0; k < mode_info.options.size(); k++) { + built_ins.push_back(String(mode_info.name) + "_" + String(mode_info.options[k])); } } else { - built_ins.push_back(String(info.name)); + built_ins.push_back(String(mode_info.name)); } } } @@ -278,14 +278,14 @@ void ShaderTextEditor::_load_theme_settings() { const Vector<ShaderLanguage::ModeInfo> &modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())); for (int i = 0; i < modes.size(); i++) { - const ShaderLanguage::ModeInfo &info = modes[i]; + const ShaderLanguage::ModeInfo &mode_info = modes[i]; - if (!info.options.is_empty()) { - for (int j = 0; j < info.options.size(); j++) { - built_ins.push_back(String(info.name) + "_" + String(info.options[j])); + if (!mode_info.options.is_empty()) { + for (int j = 0; j < mode_info.options.size(); j++) { + built_ins.push_back(String(mode_info.name) + "_" + String(mode_info.options[j])); } } else { - built_ins.push_back(String(info.name)); + built_ins.push_back(String(mode_info.name)); } } } @@ -303,12 +303,12 @@ void ShaderTextEditor::_load_theme_settings() { syntax_highlighter->add_color_region("//", "", comment_color, true); syntax_highlighter->set_disabled_branch_color(comment_color); - text_editor->clear_comment_delimiters(); - text_editor->add_comment_delimiter("/*", "*/", false); - text_editor->add_comment_delimiter("//", "", true); + te->clear_comment_delimiters(); + te->add_comment_delimiter("/*", "*/", false); + te->add_comment_delimiter("//", "", true); - if (!text_editor->has_auto_brace_completion_open_key("/*")) { - text_editor->add_auto_brace_completion_pair("/*", "*/"); + if (!te->has_auto_brace_completion_open_key("/*")) { + te->add_auto_brace_completion_pair("/*", "*/"); } // Colorize preprocessor include strings. @@ -399,22 +399,22 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptLa ShaderLanguage sl; String calltip; - ShaderLanguage::ShaderCompileInfo info; - info.global_shader_uniform_type_func = _get_global_shader_uniform_type; + ShaderLanguage::ShaderCompileInfo comp_info; + comp_info.global_shader_uniform_type_func = _get_global_shader_uniform_type; if (shader.is_null()) { - info.is_include = true; + comp_info.is_include = true; - sl.complete(code, info, r_options, calltip); + sl.complete(code, comp_info, r_options, calltip); get_text_editor()->set_code_hint(calltip); return; } _check_shader_mode(); - info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())); - info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())); - info.shader_types = ShaderTypes::get_singleton()->get_types(); + comp_info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())); + comp_info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())); + comp_info.shader_types = ShaderTypes::get_singleton()->get_types(); - sl.complete(code, info, r_options, calltip); + sl.complete(code, comp_info, r_options, calltip); get_text_editor()->set_code_hint(calltip); } @@ -464,22 +464,22 @@ void ShaderTextEditor::_validate_script() { //preprocessor error ERR_FAIL_COND(err_positions.size() == 0); - String error_text = error_pp; - int error_line = err_positions.front()->get().line; + String err_text = error_pp; + int err_line = err_positions.front()->get().line; if (err_positions.size() == 1) { // Error in main file - error_text = "error(" + itos(error_line) + "): " + error_text; + err_text = "error(" + itos(err_line) + "): " + err_text; } else { - error_text = "error(" + itos(error_line) + ") in include " + err_positions.back()->get().file.get_file() + ":" + itos(err_positions.back()->get().line) + ": " + error_text; + err_text = "error(" + itos(err_line) + ") in include " + err_positions.back()->get().file.get_file() + ":" + itos(err_positions.back()->get().line) + ": " + err_text; set_error_count(err_positions.size() - 1); } - set_error(error_text); - set_error_pos(error_line - 1, 0); + set_error(err_text); + set_error_pos(err_line - 1, 0); for (int i = 0; i < get_text_editor()->get_line_count(); i++) { get_text_editor()->set_line_background_color(i, Color(0, 0, 0, 0)); } - get_text_editor()->set_line_background_color(error_line - 1, marked_line_color); + get_text_editor()->set_line_background_color(err_line - 1, marked_line_color); set_warning_count(0); @@ -507,39 +507,39 @@ void ShaderTextEditor::_validate_script() { } sl.set_warning_flags(flags); - ShaderLanguage::ShaderCompileInfo info; - info.global_shader_uniform_type_func = _get_global_shader_uniform_type; + ShaderLanguage::ShaderCompileInfo comp_info; + comp_info.global_shader_uniform_type_func = _get_global_shader_uniform_type; if (shader.is_null()) { - info.is_include = true; + comp_info.is_include = true; } else { Shader::Mode mode = shader->get_mode(); - info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(mode)); - info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(mode)); - info.shader_types = ShaderTypes::get_singleton()->get_types(); + comp_info.functions = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(mode)); + comp_info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(mode)); + comp_info.shader_types = ShaderTypes::get_singleton()->get_types(); } code = code_pp; //compiler error - last_compile_result = sl.compile(code, info); + last_compile_result = sl.compile(code, comp_info); if (last_compile_result != OK) { - String error_text; - int error_line; + String err_text; + int err_line; Vector<ShaderLanguage::FilePosition> include_positions = sl.get_include_positions(); if (include_positions.size() > 1) { //error is in an include - error_line = include_positions[0].line; - error_text = "error(" + itos(error_line) + ") in include " + include_positions[include_positions.size() - 1].file + ":" + itos(include_positions[include_positions.size() - 1].line) + ": " + sl.get_error_text(); + err_line = include_positions[0].line; + err_text = "error(" + itos(err_line) + ") in include " + include_positions[include_positions.size() - 1].file + ":" + itos(include_positions[include_positions.size() - 1].line) + ": " + sl.get_error_text(); set_error_count(include_positions.size() - 1); } else { - error_line = sl.get_error_line(); - error_text = "error(" + itos(error_line) + "): " + sl.get_error_text(); + err_line = sl.get_error_line(); + err_text = "error(" + itos(err_line) + "): " + sl.get_error_text(); set_error_count(0); } - set_error(error_text); - set_error_pos(error_line - 1, 0); - get_text_editor()->set_line_background_color(error_line - 1, marked_line_color); + set_error(err_text); + set_error_pos(err_line - 1, 0); + get_text_editor()->set_line_background_color(err_line - 1, marked_line_color); } else { set_error(""); } diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index d0f8e1f32d..73ca8b6176 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -212,8 +212,8 @@ void GenericTilePolygonEditor::_base_control_draw() { for (int i = 0; i < (int)polygons.size(); i++) { const Vector<Vector2> &polygon = polygons[i]; for (int j = 0; j < polygon.size(); j++) { - const Color modulate = (tinted_polygon_index == i && tinted_point_index == j) ? Color(0.5, 1, 2) : Color(1, 1, 1); - base_control->draw_texture(handle, xform.xform(polygon[j]) - handle->get_size() / 2, modulate); + const Color poly_modulate = (tinted_polygon_index == i && tinted_point_index == j) ? Color(0.5, 1, 2) : Color(1, 1, 1); + base_control->draw_texture(handle, xform.xform(polygon[j]) - handle->get_size() / 2, poly_modulate); } } } @@ -2662,27 +2662,27 @@ TileDataTerrainsEditor::~TileDataTerrainsEditor() { } Variant TileDataNavigationEditor::_get_painted_value() { - Ref<NavigationPolygon> navigation_polygon; - navigation_polygon.instantiate(); + Ref<NavigationPolygon> nav_polygon; + nav_polygon.instantiate(); for (int i = 0; i < polygon_editor->get_polygon_count(); i++) { Vector<Vector2> polygon = polygon_editor->get_polygon(i); - navigation_polygon->add_outline(polygon); + nav_polygon->add_outline(polygon); } - navigation_polygon->make_polygons_from_outlines(); - return navigation_polygon; + nav_polygon->make_polygons_from_outlines(); + return nav_polygon; } void TileDataNavigationEditor::_set_painted_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile) { TileData *tile_data = p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile); ERR_FAIL_COND(!tile_data); - Ref<NavigationPolygon> navigation_polygon = tile_data->get_navigation_polygon(navigation_layer); + Ref<NavigationPolygon> nav_polygon = tile_data->get_navigation_polygon(navigation_layer); polygon_editor->clear_polygons(); - if (navigation_polygon.is_valid()) { - for (int i = 0; i < navigation_polygon->get_outline_count(); i++) { - polygon_editor->add_polygon(navigation_polygon->get_outline(i)); + if (nav_polygon.is_valid()) { + for (int i = 0; i < nav_polygon->get_outline_count(); i++) { + polygon_editor->add_polygon(nav_polygon->get_outline(i)); } } polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate()); @@ -2691,8 +2691,8 @@ void TileDataNavigationEditor::_set_painted_value(TileSetAtlasSource *p_tile_set void TileDataNavigationEditor::_set_value(TileSetAtlasSource *p_tile_set_atlas_source, Vector2 p_coords, int p_alternative_tile, Variant p_value) { TileData *tile_data = p_tile_set_atlas_source->get_tile_data(p_coords, p_alternative_tile); ERR_FAIL_COND(!tile_data); - Ref<NavigationPolygon> navigation_polygon = p_value; - tile_data->set_navigation_polygon(navigation_layer, navigation_polygon); + Ref<NavigationPolygon> nav_polygon = p_value; + tile_data->set_navigation_polygon(navigation_layer, nav_polygon); polygon_editor->set_background(p_tile_set_atlas_source->get_texture(), p_tile_set_atlas_source->get_tile_texture_region(p_coords), p_tile_set_atlas_source->get_tile_effective_texture_offset(p_coords, p_alternative_tile), tile_data->get_flip_h(), tile_data->get_flip_v(), tile_data->get_transpose(), tile_data->get_modulate()); } @@ -2740,9 +2740,9 @@ void TileDataNavigationEditor::draw_over_tile(CanvasItem *p_canvas_item, Transfo // Draw all shapes. RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), p_transform); - Ref<NavigationPolygon> navigation_polygon = tile_data->get_navigation_polygon(navigation_layer); - if (navigation_polygon.is_valid()) { - Vector<Vector2> verts = navigation_polygon->get_vertices(); + Ref<NavigationPolygon> nav_polygon = tile_data->get_navigation_polygon(navigation_layer); + if (nav_polygon.is_valid()) { + Vector<Vector2> verts = nav_polygon->get_vertices(); if (verts.size() < 3) { return; } @@ -2759,9 +2759,9 @@ void TileDataNavigationEditor::draw_over_tile(CanvasItem *p_canvas_item, Transfo } RandomPCG rand; - for (int i = 0; i < navigation_polygon->get_polygon_count(); i++) { + for (int i = 0; i < nav_polygon->get_polygon_count(); i++) { // An array of vertices for this polygon. - Vector<int> polygon = navigation_polygon->get_polygon(i); + Vector<int> polygon = nav_polygon->get_polygon(i); Vector<Vector2> vertices; vertices.resize(polygon.size()); for (int j = 0; j < polygon.size(); j++) { diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index acfa8b3d00..7cc29dbfad 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -3190,10 +3190,10 @@ void TileMapEditorTerrainsPlugin::_update_tiles_list() { TreeItem *selected_tree_item = terrains_tree->get_selected(); if (selected_tree_item && selected_tree_item->get_metadata(0)) { Dictionary metadata_dict = selected_tree_item->get_metadata(0); - int selected_terrain_set = metadata_dict["terrain_set"]; - int selected_terrain_id = metadata_dict["terrain_id"]; - ERR_FAIL_INDEX(selected_terrain_set, tile_set->get_terrain_sets_count()); - ERR_FAIL_INDEX(selected_terrain_id, tile_set->get_terrains_count(selected_terrain_set)); + int sel_terrain_set = metadata_dict["terrain_set"]; + int sel_terrain_id = metadata_dict["terrain_id"]; + ERR_FAIL_INDEX(sel_terrain_set, tile_set->get_terrain_sets_count()); + ERR_FAIL_INDEX(sel_terrain_id, tile_set->get_terrains_count(sel_terrain_set)); // Add the two first generic modes int item_index = terrains_tile_list->add_icon_item(main_vbox_container->get_theme_icon(SNAME("TerrainConnect"), SNAME("EditorIcons"))); @@ -3211,13 +3211,13 @@ void TileMapEditorTerrainsPlugin::_update_tiles_list() { // Sort the items in a map by the number of corresponding terrains. RBMap<int, RBSet<TileSet::TerrainsPattern>> sorted; - for (const TileSet::TerrainsPattern &E : per_terrain_terrains_patterns[selected_terrain_set][selected_terrain_id]) { + for (const TileSet::TerrainsPattern &E : per_terrain_terrains_patterns[sel_terrain_set][sel_terrain_id]) { // Count the number of matching sides/terrains. int count = 0; for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) { TileSet::CellNeighbor bit = TileSet::CellNeighbor(i); - if (tile_set->is_valid_terrain_peering_bit(selected_terrain_set, bit) && E.get_terrain_peering_bit(bit) == selected_terrain_id) { + if (tile_set->is_valid_terrain_peering_bit(sel_terrain_set, bit) && E.get_terrain_peering_bit(bit) == sel_terrain_id) { count++; } } @@ -3234,7 +3234,7 @@ void TileMapEditorTerrainsPlugin::_update_tiles_list() { bool transpose = false; double max_probability = -1.0; - for (const TileMapCell &cell : tile_set->get_tiles_for_terrains_pattern(selected_terrain_set, terrains_pattern)) { + for (const TileMapCell &cell : tile_set->get_tiles_for_terrains_pattern(sel_terrain_set, terrains_pattern)) { Ref<TileSetSource> source = tile_set->get_source(cell.source_id); Ref<TileSetAtlasSource> atlas_source = source; @@ -3689,8 +3689,8 @@ void TileMapEditor::_update_layers_selection() { } void TileMapEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) { - Ref<EditorUndoRedoManager> undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); - ERR_FAIL_COND(undo_redo.is_null()); + Ref<EditorUndoRedoManager> undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); + ERR_FAIL_COND(undo_redo_man.is_null()); TileMap *tile_map = Object::cast_to<TileMap>(p_edited); if (!tile_map) { @@ -3721,12 +3721,12 @@ void TileMapEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p_ end = MIN(MAX(p_from_index, p_to_pos) + 1, end); } -#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property)); +#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property)); // Save layers' properties. if (p_from_index < 0) { - undo_redo->add_undo_method(tile_map, "remove_layer", p_to_pos < 0 ? tile_map->get_layers_count() : p_to_pos); + undo_redo_man->add_undo_method(tile_map, "remove_layer", p_to_pos < 0 ? tile_map->get_layers_count() : p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_undo_method(tile_map, "add_layer", p_from_index); + undo_redo_man->add_undo_method(tile_map, "add_layer", p_from_index); } List<PropertyInfo> properties; @@ -3752,11 +3752,11 @@ void TileMapEditor::_move_tile_map_array_element(Object *p_undo_redo, Object *p_ #undef ADD_UNDO if (p_from_index < 0) { - undo_redo->add_do_method(tile_map, "add_layer", p_to_pos); + undo_redo_man->add_do_method(tile_map, "add_layer", p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_do_method(tile_map, "remove_layer", p_from_index); + undo_redo_man->add_do_method(tile_map, "remove_layer", p_from_index); } else { - undo_redo->add_do_method(tile_map, "move_layer", p_from_index, p_to_pos); + undo_redo_man->add_do_method(tile_map, "move_layer", p_from_index, p_to_pos); } } diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 4299ae8d3e..1857606f00 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -561,9 +561,9 @@ void TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles() { void TileSetAtlasSourceEditor::_update_atlas_source_inspector() { // Update visibility. - bool visible = tools_button_group->get_pressed_button() == tool_setup_atlas_source_button; - atlas_source_inspector_label->set_visible(visible); - atlas_source_inspector->set_visible(visible); + bool inspector_visible = tools_button_group->get_pressed_button() == tool_setup_atlas_source_button; + atlas_source_inspector_label->set_visible(inspector_visible); + atlas_source_inspector->set_visible(inspector_visible); } void TileSetAtlasSourceEditor::_update_tile_inspector() { @@ -2067,14 +2067,14 @@ void TileSetAtlasSourceEditor::_atlas_source_proxy_object_changed(String p_what) } void TileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value) { - Ref<EditorUndoRedoManager> undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); - ERR_FAIL_COND(!undo_redo.is_valid()); + Ref<EditorUndoRedoManager> undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); + ERR_FAIL_COND(!undo_redo_man.is_valid()); -#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property)); +#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property)); AtlasTileProxyObject *tile_data_proxy = Object::cast_to<AtlasTileProxyObject>(p_edited); if (tile_data_proxy) { - UndoRedo *internal_undo_redo = undo_redo->get_history_for_object(tile_data_proxy).undo_redo; + UndoRedo *internal_undo_redo = undo_redo_man->get_history_for_object(tile_data_proxy).undo_redo; internal_undo_redo->start_force_keep_in_merge_ends(); Vector<String> components = String(p_property).split("/", true, 2); @@ -2107,7 +2107,7 @@ void TileSetAtlasSourceEditor::_undo_redo_inspector_callback(Object *p_undo_redo TileSetAtlasSource *atlas_source = atlas_source_proxy->get_edited(); ERR_FAIL_COND(!atlas_source); - UndoRedo *internal_undo_redo = undo_redo->get_history_for_object(atlas_source).undo_redo; + UndoRedo *internal_undo_redo = undo_redo_man->get_history_for_object(atlas_source).undo_redo; internal_undo_redo->start_force_keep_in_merge_ends(); PackedVector2Array arr; diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index 7394288fcd..3b057b7631 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -407,11 +407,11 @@ void TileSetEditor::_tab_changed(int p_tab_changed) { } void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_edited, String p_array_prefix, int p_from_index, int p_to_pos) { - Ref<EditorUndoRedoManager> undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); - ERR_FAIL_COND(undo_redo.is_null()); + Ref<EditorUndoRedoManager> undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); + ERR_FAIL_COND(undo_redo_man.is_null()); - TileSet *tile_set = Object::cast_to<TileSet>(p_edited); - if (!tile_set) { + TileSet *ed_tile_set = Object::cast_to<TileSet>(p_edited); + if (!ed_tile_set) { return; } @@ -421,18 +421,18 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_ int begin = 0; int end; if (p_array_prefix == "occlusion_layer_") { - end = tile_set->get_occlusion_layers_count(); + end = ed_tile_set->get_occlusion_layers_count(); } else if (p_array_prefix == "physics_layer_") { - end = tile_set->get_physics_layers_count(); + end = ed_tile_set->get_physics_layers_count(); } else if (p_array_prefix == "terrain_set_") { - end = tile_set->get_terrain_sets_count(); + end = ed_tile_set->get_terrain_sets_count(); } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") { int terrain_set = components[0].trim_prefix("terrain_set_").to_int(); - end = tile_set->get_terrains_count(terrain_set); + end = ed_tile_set->get_terrains_count(terrain_set); } else if (p_array_prefix == "navigation_layer_") { - end = tile_set->get_navigation_layers_count(); + end = ed_tile_set->get_navigation_layers_count(); } else if (p_array_prefix == "custom_data_layer_") { - end = tile_set->get_custom_data_layers_count(); + end = ed_tile_set->get_custom_data_layers_count(); } else { ERR_FAIL_MSG("Invalid array prefix for TileSet."); } @@ -452,10 +452,10 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_ end = MIN(MAX(p_from_index, p_to_pos) + 1, end); } -#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property)); +#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property)); // Save layers' properties. List<PropertyInfo> properties; - tile_set->get_property_list(&properties); + ed_tile_set->get_property_list(&properties); for (PropertyInfo pi : properties) { if (pi.name.begins_with(p_array_prefix)) { String str = pi.name.trim_prefix(p_array_prefix); @@ -469,17 +469,17 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_ if (to_char_index > 0) { int array_index = str.left(to_char_index).to_int(); if (array_index >= begin && array_index < end) { - ADD_UNDO(tile_set, pi.name); + ADD_UNDO(ed_tile_set, pi.name); } } } } // Save properties for TileSetAtlasSources tile data - for (int i = 0; i < tile_set->get_source_count(); i++) { - int source_id = tile_set->get_source_id(i); + for (int i = 0; i < ed_tile_set->get_source_count(); i++) { + int source_id = ed_tile_set->get_source_id(i); - Ref<TileSetAtlasSource> tas = tile_set->get_source(source_id); + Ref<TileSetAtlasSource> tas = ed_tile_set->get_source(source_id); if (tas.is_valid()) { for (int j = 0; j < tas->get_tiles_count(); j++) { Vector2i tile_id = tas->get_tile_id(j); @@ -537,68 +537,68 @@ void TileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Object *p_ // Add do method. if (p_array_prefix == "occlusion_layer_") { if (p_from_index < 0) { - undo_redo->add_do_method(tile_set, "add_occlusion_layer", p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "add_occlusion_layer", p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_do_method(tile_set, "remove_occlusion_layer", p_from_index); + undo_redo_man->add_do_method(ed_tile_set, "remove_occlusion_layer", p_from_index); } else { - undo_redo->add_do_method(tile_set, "move_occlusion_layer", p_from_index, p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "move_occlusion_layer", p_from_index, p_to_pos); } } else if (p_array_prefix == "physics_layer_") { if (p_from_index < 0) { - undo_redo->add_do_method(tile_set, "add_physics_layer", p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "add_physics_layer", p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_do_method(tile_set, "remove_physics_layer", p_from_index); + undo_redo_man->add_do_method(ed_tile_set, "remove_physics_layer", p_from_index); } else { - undo_redo->add_do_method(tile_set, "move_physics_layer", p_from_index, p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "move_physics_layer", p_from_index, p_to_pos); } } else if (p_array_prefix == "terrain_set_") { if (p_from_index < 0) { - undo_redo->add_do_method(tile_set, "add_terrain_set", p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "add_terrain_set", p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_do_method(tile_set, "remove_terrain_set", p_from_index); + undo_redo_man->add_do_method(ed_tile_set, "remove_terrain_set", p_from_index); } else { - undo_redo->add_do_method(tile_set, "move_terrain_set", p_from_index, p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "move_terrain_set", p_from_index, p_to_pos); } } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") { int terrain_set = components[0].trim_prefix("terrain_set_").to_int(); if (p_from_index < 0) { - undo_redo->add_do_method(tile_set, "add_terrain", terrain_set, p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "add_terrain", terrain_set, p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_do_method(tile_set, "remove_terrain", terrain_set, p_from_index); + undo_redo_man->add_do_method(ed_tile_set, "remove_terrain", terrain_set, p_from_index); } else { - undo_redo->add_do_method(tile_set, "move_terrain", terrain_set, p_from_index, p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "move_terrain", terrain_set, p_from_index, p_to_pos); } } else if (p_array_prefix == "navigation_layer_") { if (p_from_index < 0) { - undo_redo->add_do_method(tile_set, "add_navigation_layer", p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "add_navigation_layer", p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_do_method(tile_set, "remove_navigation_layer", p_from_index); + undo_redo_man->add_do_method(ed_tile_set, "remove_navigation_layer", p_from_index); } else { - undo_redo->add_do_method(tile_set, "move_navigation_layer", p_from_index, p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "move_navigation_layer", p_from_index, p_to_pos); } } else if (p_array_prefix == "custom_data_layer_") { if (p_from_index < 0) { - undo_redo->add_do_method(tile_set, "add_custom_data_layer", p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "add_custom_data_layer", p_to_pos); } else if (p_to_pos < 0) { - undo_redo->add_do_method(tile_set, "remove_custom_data_layer", p_from_index); + undo_redo_man->add_do_method(ed_tile_set, "remove_custom_data_layer", p_from_index); } else { - undo_redo->add_do_method(tile_set, "move_custom_data_layer", p_from_index, p_to_pos); + undo_redo_man->add_do_method(ed_tile_set, "move_custom_data_layer", p_from_index, p_to_pos); } } } void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value) { - Ref<EditorUndoRedoManager> undo_redo = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); - ERR_FAIL_COND(undo_redo.is_null()); + Ref<EditorUndoRedoManager> undo_redo_man = Object::cast_to<EditorUndoRedoManager>(p_undo_redo); + ERR_FAIL_COND(undo_redo_man.is_null()); -#define ADD_UNDO(obj, property) undo_redo->add_undo_property(obj, property, obj->get(property)); - TileSet *tile_set = Object::cast_to<TileSet>(p_edited); - if (tile_set) { +#define ADD_UNDO(obj, property) undo_redo_man->add_undo_property(obj, property, obj->get(property)); + TileSet *ed_tile_set = Object::cast_to<TileSet>(p_edited); + if (ed_tile_set) { Vector<String> components = p_property.split("/", true, 3); - for (int i = 0; i < tile_set->get_source_count(); i++) { - int source_id = tile_set->get_source_id(i); + for (int i = 0; i < ed_tile_set->get_source_count(); i++) { + int source_id = ed_tile_set->get_source_id(i); - Ref<TileSetAtlasSource> tas = tile_set->get_source(source_id); + Ref<TileSetAtlasSource> tas = ed_tile_set->get_source(source_id); if (tas.is_valid()) { for (int j = 0; j < tas->get_tiles_count(); j++) { Vector2i tile_id = tas->get_tile_id(j); diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp index 17115519e2..68bc4389a2 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.cpp +++ b/editor/plugins/tiles/tiles_editor_plugin.cpp @@ -264,8 +264,8 @@ void TilesEditorPlugin::set_sorting_option(int p_option) { source_sort = p_option; } -List<int> TilesEditorPlugin::get_sorted_sources(const Ref<TileSet> tile_set) const { - SourceNameComparator::tile_set = tile_set; +List<int> TilesEditorPlugin::get_sorted_sources(const Ref<TileSet> p_tile_set) const { + SourceNameComparator::tile_set = p_tile_set; List<int> source_ids; for (int i = 0; i < tile_set->get_source_count(); i++) { diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 40993ea168..d87513bfe1 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -86,7 +86,7 @@ void VisualShaderNodePlugin::set_editor(VisualShaderEditor *p_editor) { } Control *VisualShaderNodePlugin::create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) { - Object *ret; + Object *ret = nullptr; if (GDVIRTUAL_CALL(_create_editor, p_parent_resource, p_node, ret)) { return Object::cast_to<Control>(ret); } @@ -1235,11 +1235,11 @@ void VisualShaderEditor::_update_nodes() { Ref<Resource> res = ResourceLoader::load(script_path); ERR_FAIL_COND(res.is_null()); ERR_FAIL_COND(!res->is_class("Script")); - Ref<Script> script = Ref<Script>(res); + Ref<Script> scr = Ref<Script>(res); Ref<VisualShaderNodeCustom> ref; ref.instantiate(); - ref->set_script(script); + ref->set_script(scr); if (!ref->is_available(visual_shader->get_mode(), visual_shader->get_shader_type())) { continue; } @@ -1278,7 +1278,7 @@ void VisualShaderEditor::_update_nodes() { Dictionary dict; dict["name"] = name; - dict["script"] = script; + dict["script"] = scr; dict["description"] = description; dict["return_icon_type"] = return_icon_type; @@ -1705,9 +1705,9 @@ void VisualShaderEditor::_update_graph() { } } - List<VisualShader::Connection> connections; - visual_shader->get_node_connections(type, &connections); - graph_plugin->set_connections(connections); + List<VisualShader::Connection> node_connections; + visual_shader->get_node_connections(type, &node_connections); + graph_plugin->set_connections(node_connections); Vector<int> nodes = visual_shader->get_node_list(type); @@ -1724,7 +1724,7 @@ void VisualShaderEditor::_update_graph() { graph_plugin->make_dirty(false); - for (const VisualShader::Connection &E : connections) { + for (const VisualShader::Connection &E : node_connections) { int from = E.from_node; int from_idx = E.from_port; int to = E.to_node; @@ -1899,45 +1899,45 @@ void VisualShaderEditor::_expand_output_port(int p_node, int p_port, bool p_expa visual_shader->get_node_connections(type, &conns); for (const VisualShader::Connection &E : conns) { - int from_node = E.from_node; - int from_port = E.from_port; - int to_node = E.to_node; - int to_port = E.to_port; + int cn_from_node = E.from_node; + int cn_from_port = E.from_port; + int cn_to_node = E.to_node; + int cn_to_port = E.to_port; - if (from_node == p_node) { + if (cn_from_node == p_node) { if (p_expand) { - if (from_port > p_port) { // reconnect ports after expanded ports - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port); + if (cn_from_port > p_port) { // reconnect ports after expanded ports + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); - undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port + type_size, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port + type_size, to_node, to_port); + undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port + type_size, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port + type_size, cn_to_node, cn_to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port + type_size, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port + type_size, to_node, to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port + type_size, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port + type_size, cn_to_node, cn_to_port); } } else { - if (from_port > p_port + type_size) { // reconnect ports after expanded ports - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port); + if (cn_from_port > p_port + type_size) { // reconnect ports after expanded ports + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); - undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, from_node, from_port - type_size, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port - type_size, to_node, to_port); + undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, cn_from_node, cn_from_port - type_size, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port - type_size, cn_to_node, cn_to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port - type_size, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port - type_size, to_node, to_port); - } else if (from_port > p_port) { // disconnect component ports - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port - type_size, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port - type_size, cn_to_node, cn_to_port); + } else if (cn_from_port > p_port) { // disconnect component ports + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); } } } @@ -1973,30 +1973,30 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); for (const VisualShader::Connection &E : conns) { - int from_node = E.from_node; - int from_port = E.from_port; - int to_node = E.to_node; - int to_port = E.to_port; - - if (to_node == p_node) { - if (to_port == p_port) { - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port); - - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); - } else if (to_port > p_port) { - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port); - - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); - - undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port - 1); - undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port - 1); - - undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port - 1); - undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port - 1); + int cn_from_node = E.from_node; + int cn_from_port = E.from_port; + int cn_to_node = E.to_node; + int cn_to_port = E.to_port; + + if (cn_to_node == p_node) { + if (cn_to_port == p_port) { + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + } else if (cn_to_port > p_port) { + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + + undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port - 1); + undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port - 1); + + undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port - 1); + undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port - 1); } } } @@ -2022,30 +2022,30 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); for (const VisualShader::Connection &E : conns) { - int from_node = E.from_node; - int from_port = E.from_port; - int to_node = E.to_node; - int to_port = E.to_port; - - if (from_node == p_node) { - if (from_port == p_port) { - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port); - - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); - } else if (from_port > p_port) { - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port, to_node, to_port); - - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); - - undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, from_node, from_port - 1, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port - 1, to_node, to_port); - - undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port - 1, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port - 1, to_node, to_port); + int cn_from_node = E.from_node; + int cn_from_port = E.from_port; + int cn_to_node = E.to_node; + int cn_to_port = E.to_port; + + if (cn_from_node == p_node) { + if (cn_from_port == p_port) { + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + } else if (cn_from_port > p_port) { + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + + undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes_forced", type, cn_from_node, cn_from_port - 1, cn_to_node, cn_to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port - 1, cn_to_node, cn_to_port); + + undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port - 1, cn_to_node, cn_to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port - 1, cn_to_node, cn_to_port); } } } @@ -2932,16 +2932,16 @@ void VisualShaderEditor::_add_varying(const String &p_name, VisualShader::Varyin void VisualShaderEditor::_remove_varying(const String &p_name) { undo_redo->create_action(vformat(TTR("Remove Varying from Visual Shader: %s"), p_name)); - VisualShader::VaryingMode mode = visual_shader->get_varying_mode(p_name); + VisualShader::VaryingMode var_mode = visual_shader->get_varying_mode(p_name); undo_redo->add_do_method(visual_shader.ptr(), "remove_varying", p_name); - undo_redo->add_undo_method(visual_shader.ptr(), "add_varying", p_name, mode, visual_shader->get_varying_type(p_name)); + undo_redo->add_undo_method(visual_shader.ptr(), "add_varying", p_name, var_mode, visual_shader->get_varying_type(p_name)); undo_redo->add_do_method(this, "_update_varyings"); undo_redo->add_undo_method(this, "_update_varyings"); for (int i = 0; i <= VisualShader::TYPE_LIGHT; i++) { - if (mode == VisualShader::VARYING_MODE_FRAG_TO_LIGHT && i == 0) { + if (var_mode == VisualShader::VARYING_MODE_FRAG_TO_LIGHT && i == 0) { continue; } @@ -2967,10 +2967,10 @@ void VisualShaderEditor::_remove_varying(const String &p_name) { } } - List<VisualShader::Connection> connections; - visual_shader->get_node_connections(type, &connections); + List<VisualShader::Connection> node_connections; + visual_shader->get_node_connections(type, &node_connections); - for (VisualShader::Connection &E : connections) { + for (VisualShader::Connection &E : node_connections) { Ref<VisualShaderNodeVaryingGetter> var_getter = Object::cast_to<VisualShaderNodeVaryingGetter>(visual_shader->get_node(type, E.from_node).ptr()); if (var_getter.is_valid() && E.from_port > 0) { undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); @@ -3847,10 +3847,10 @@ void VisualShaderEditor::_dup_copy_nodes(int p_type, List<CopyItem> &r_items, Li } } - List<VisualShader::Connection> connections; - visual_shader->get_node_connections(type, &connections); + List<VisualShader::Connection> node_connections; + visual_shader->get_node_connections(type, &node_connections); - for (const VisualShader::Connection &E : connections) { + for (const VisualShader::Connection &E : node_connections) { if (nodes.has(E.from_node) && nodes.has(E.to_node)) { r_connections.push_back(E); } @@ -3961,15 +3961,15 @@ void VisualShaderEditor::_duplicate_nodes() { int type = get_current_shader_type(); List<CopyItem> items; - List<VisualShader::Connection> connections; + List<VisualShader::Connection> node_connections; - _dup_copy_nodes(type, items, connections); + _dup_copy_nodes(type, items, node_connections); if (items.is_empty()) { return; } - _dup_paste_nodes(type, items, connections, Vector2(10, 10) * EDSCALE, true); + _dup_paste_nodes(type, items, node_connections, Vector2(10, 10) * EDSCALE, true); } void VisualShaderEditor::_copy_nodes(bool p_cut) { @@ -4064,11 +4064,11 @@ void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input, bool type_changed = next_input_type != prev_input_type; - Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("Visual Shader Input Type Changed")); + Ref<EditorUndoRedoManager> undo_redo_man = EditorNode::get_undo_redo(); + undo_redo_man->create_action(TTR("Visual Shader Input Type Changed")); - undo_redo->add_do_method(p_input.ptr(), "set_input_name", p_name); - undo_redo->add_undo_method(p_input.ptr(), "set_input_name", prev_name); + undo_redo_man->add_do_method(p_input.ptr(), "set_input_name", p_name); + undo_redo_man->add_undo_method(p_input.ptr(), "set_input_name", prev_name); if (type_changed) { for (int type_id = 0; type_id < VisualShader::TYPE_MAX; type_id++) { @@ -4098,30 +4098,30 @@ void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input, List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); for (const VisualShader::Connection &E : conns) { - int from_node = E.from_node; - int from_port = E.from_port; - int to_node = E.to_node; - int to_port = E.to_port; - - if (from_node == id) { - bool is_incompatible_types = !visual_shader->is_port_types_compatible(p_input->get_input_type_by_name(p_name), visual_shader->get_node(type, to_node)->get_input_port_type(to_port)); - - if (is_incompatible_types || from_port > type_size) { - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_port, to_node, to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_port, to_node, to_port); + int cn_from_node = E.from_node; + int cn_from_port = E.from_port; + int cn_to_node = E.to_node; + int cn_to_port = E.to_port; + + if (cn_from_node == id) { + bool is_incompatible_types = !visual_shader->is_port_types_compatible(p_input->get_input_type_by_name(p_name), visual_shader->get_node(type, cn_to_node)->get_input_port_type(cn_to_port)); + + if (is_incompatible_types || cn_from_port > type_size) { + undo_redo_man->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo_man->add_undo_method(visual_shader.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo_man->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); + undo_redo_man->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, cn_from_node, cn_from_port, cn_to_node, cn_to_port); } } } - undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type_id, id); - undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id); + undo_redo_man->add_do_method(graph_plugin.ptr(), "update_node", type_id, id); + undo_redo_man->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id); } } } - undo_redo->commit_action(); + undo_redo_man->commit_action(); } void VisualShaderEditor::_parameter_ref_select_item(Ref<VisualShaderNodeParameterRef> p_parameter_ref, String p_name) { @@ -4133,11 +4133,11 @@ void VisualShaderEditor::_parameter_ref_select_item(Ref<VisualShaderNodeParamete bool type_changed = p_parameter_ref->get_parameter_type_by_name(p_name) != p_parameter_ref->get_parameter_type_by_name(prev_name); - Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("ParameterRef Name Changed")); + Ref<EditorUndoRedoManager> undo_redo_man = EditorNode::get_undo_redo(); + undo_redo_man->create_action(TTR("ParameterRef Name Changed")); - undo_redo->add_do_method(p_parameter_ref.ptr(), "set_parameter_name", p_name); - undo_redo->add_undo_method(p_parameter_ref.ptr(), "set_parameter_name", prev_name); + undo_redo_man->add_do_method(p_parameter_ref.ptr(), "set_parameter_name", p_name); + undo_redo_man->add_undo_method(p_parameter_ref.ptr(), "set_parameter_name", prev_name); // update output port for (int type_id = 0; type_id < VisualShader::TYPE_MAX; type_id++) { @@ -4152,20 +4152,20 @@ void VisualShaderEditor::_parameter_ref_select_item(Ref<VisualShaderNodeParamete if (visual_shader->is_port_types_compatible(p_parameter_ref->get_parameter_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { continue; } - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } } - undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type_id, id); - undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id); + undo_redo_man->add_do_method(graph_plugin.ptr(), "update_node", type_id, id); + undo_redo_man->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id); break; } } - undo_redo->commit_action(); + undo_redo_man->commit_action(); } void VisualShaderEditor::_varying_select_item(Ref<VisualShaderNodeVarying> p_varying, String p_name) { @@ -4177,11 +4177,11 @@ void VisualShaderEditor::_varying_select_item(Ref<VisualShaderNodeVarying> p_var bool is_getter = Ref<VisualShaderNodeVaryingGetter>(p_varying.ptr()).is_valid(); - Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("Varying Name Changed")); + Ref<EditorUndoRedoManager> undo_redo_man = EditorNode::get_undo_redo(); + undo_redo_man->create_action(TTR("Varying Name Changed")); - undo_redo->add_do_method(p_varying.ptr(), "set_varying_name", p_name); - undo_redo->add_undo_method(p_varying.ptr(), "set_varying_name", prev_name); + undo_redo_man->add_do_method(p_varying.ptr(), "set_varying_name", p_name); + undo_redo_man->add_undo_method(p_varying.ptr(), "set_varying_name", prev_name); VisualShader::VaryingType vtype = p_varying->get_varying_type_by_name(p_name); VisualShader::VaryingType prev_vtype = p_varying->get_varying_type_by_name(prev_name); @@ -4189,8 +4189,8 @@ void VisualShaderEditor::_varying_select_item(Ref<VisualShaderNodeVarying> p_var bool type_changed = vtype != prev_vtype; if (type_changed) { - undo_redo->add_do_method(p_varying.ptr(), "set_varying_type", vtype); - undo_redo->add_undo_method(p_varying.ptr(), "set_varying_type", prev_vtype); + undo_redo_man->add_do_method(p_varying.ptr(), "set_varying_type", vtype); + undo_redo_man->add_undo_method(p_varying.ptr(), "set_varying_type", prev_vtype); } // update ports @@ -4209,32 +4209,32 @@ void VisualShaderEditor::_varying_select_item(Ref<VisualShaderNodeVarying> p_var if (visual_shader->is_port_types_compatible(p_varying->get_varying_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { continue; } - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } else { if (E.to_node == id) { if (visual_shader->is_port_types_compatible(p_varying->get_varying_type_by_name(p_name), visual_shader->get_node(type, E.from_node)->get_output_port_type(E.from_port))) { continue; } - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo_man->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } } } - undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type_id, id); - undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id); + undo_redo_man->add_do_method(graph_plugin.ptr(), "update_node", type_id, id); + undo_redo_man->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id); break; } } - undo_redo->commit_action(); + undo_redo_man->commit_action(); } void VisualShaderEditor::_float_constant_selected(int p_which) { @@ -4515,8 +4515,8 @@ void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da for (int i = 0; i < arr.size(); i++) { String type = ResourceLoader::get_resource_type(arr[i]); if (type == "GDScript") { - Ref<Script> script = ResourceLoader::load(arr[i]); - if (script->get_instance_base_type() == "VisualShaderNodeCustom") { + Ref<Script> scr = ResourceLoader::load(arr[i]); + if (scr->get_instance_base_type() == "VisualShaderNodeCustom") { saved_node_pos = p_point + Vector2(0, i * 250 * EDSCALE); saved_node_pos_dirty = true; @@ -6229,9 +6229,9 @@ void VisualShaderNodePortPreview::_shader_changed() { } } - Ref<ShaderMaterial> material; - material.instantiate(); - material->set_shader(preview_shader); + Ref<ShaderMaterial> mat; + mat.instantiate(); + mat->set_shader(preview_shader); //find if a material is also being edited and copy parameters to this one @@ -6252,12 +6252,12 @@ void VisualShaderNodePortPreview::_shader_changed() { List<PropertyInfo> params; src_mat->get_shader()->get_shader_uniform_list(¶ms); for (const PropertyInfo &E : params) { - material->set(E.name, src_mat->get(E.name)); + mat->set(E.name, src_mat->get(E.name)); } } } - set_material(material); + set_material(mat); } void VisualShaderNodePortPreview::setup(const Ref<VisualShader> &p_shader, VisualShader::Type p_type, int p_node, int p_port) { |