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 /scene/animation | |
parent | 5b7f62af55b7f322192f95258d825b163cbf9dc1 (diff) |
Fix MSVC warnings, rename shadowed variables, fix uninitialized values, change warnings=all to use /W4.
Diffstat (limited to 'scene/animation')
-rw-r--r-- | scene/animation/animation_blend_space_2d.cpp | 36 | ||||
-rw-r--r-- | scene/animation/animation_blend_tree.cpp | 216 | ||||
-rw-r--r-- | scene/animation/animation_node_state_machine.cpp | 52 | ||||
-rw-r--r-- | scene/animation/animation_player.cpp | 7 | ||||
-rw-r--r-- | scene/animation/animation_tree.cpp | 8 | ||||
-rw-r--r-- | scene/animation/tween.cpp | 12 |
6 files changed, 165 insertions, 166 deletions
diff --git a/scene/animation/animation_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp index 2dc61efb94..0d8b7ba8f7 100644 --- a/scene/animation/animation_blend_space_2d.cpp +++ b/scene/animation/animation_blend_space_2d.cpp @@ -343,10 +343,10 @@ void AnimationNodeBlendSpace2D::_update_triangles() { points.write[i] = blend_points[i].position; } - Vector<Delaunay2D::Triangle> triangles = Delaunay2D::triangulate(points); + Vector<Delaunay2D::Triangle> tr = Delaunay2D::triangulate(points); - for (int i = 0; i < triangles.size(); i++) { - add_triangle(triangles[i].points[0], triangles[i].points[1], triangles[i].points[2]); + for (int i = 0; i < tr.size(); i++) { + add_triangle(tr[i].points[0], tr[i].points[1], tr[i].points[2]); } emit_signal(SNAME("triangles_updated")); } @@ -376,9 +376,9 @@ Vector2 AnimationNodeBlendSpace2D::get_closest_point(const Vector2 &p_point) { points[j], points[(j + 1) % 3] }; - Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, s); - if (first || closest.distance_to(p_point) < best_point.distance_to(p_point)) { - best_point = closest; + Vector2 closest_point = Geometry2D::get_closest_point_to_segment(p_point, s); + if (first || closest_point.distance_to(p_point) < best_point.distance_to(p_point)) { + best_point = closest_point; first = false; } } @@ -436,8 +436,8 @@ double AnimationNodeBlendSpace2D::process(double p_time, bool p_seek, bool p_see _update_triangles(); Vector2 blend_pos = get_parameter(blend_position); - int closest = get_parameter(this->closest); - double length_internal = get_parameter(this->length_internal); + int cur_closest = get_parameter(closest); + double cur_length_internal = get_parameter(length_internal); double mind = 0.0; //time of min distance point if (blend_mode == BLEND_MODE_INTERPOLATED) { @@ -528,37 +528,37 @@ double AnimationNodeBlendSpace2D::process(double p_time, bool p_seek, bool p_see } } - if (new_closest != closest && new_closest != -1) { + if (new_closest != cur_closest && new_closest != -1) { double from = 0.0; - if (blend_mode == BLEND_MODE_DISCRETE_CARRY && closest != -1) { + if (blend_mode == BLEND_MODE_DISCRETE_CARRY && cur_closest != -1) { //for ping-pong loop - Ref<AnimationNodeAnimation> na_c = static_cast<Ref<AnimationNodeAnimation>>(blend_points[closest].node); + Ref<AnimationNodeAnimation> na_c = static_cast<Ref<AnimationNodeAnimation>>(blend_points[cur_closest].node); Ref<AnimationNodeAnimation> na_n = static_cast<Ref<AnimationNodeAnimation>>(blend_points[new_closest].node); if (!na_c.is_null() && !na_n.is_null()) { na_n->set_backward(na_c->is_backward()); } //see how much animation remains - from = length_internal - blend_node(blend_points[closest].name, blend_points[closest].node, p_time, false, p_seek_root, 0.0, FILTER_IGNORE, true); + from = cur_length_internal - blend_node(blend_points[cur_closest].name, blend_points[cur_closest].node, p_time, false, p_seek_root, 0.0, FILTER_IGNORE, true); } mind = blend_node(blend_points[new_closest].name, blend_points[new_closest].node, from, true, p_seek_root, 1.0, FILTER_IGNORE, true); - length_internal = from + mind; + cur_length_internal = from + mind; - closest = new_closest; + cur_closest = new_closest; } else { - mind = blend_node(blend_points[closest].name, blend_points[closest].node, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, true); + mind = blend_node(blend_points[cur_closest].name, blend_points[cur_closest].node, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, true); } for (int i = 0; i < blend_points_used; i++) { - if (i != closest) { + if (i != cur_closest) { blend_node(blend_points[i].name, blend_points[i].node, p_time, p_seek, p_seek_root, 0, FILTER_IGNORE, sync); } } } - set_parameter(this->closest, closest); - set_parameter(this->length_internal, length_internal); + set_parameter(this->closest, cur_closest); + set_parameter(this->length_internal, cur_length_internal); return mind; } diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index c063d8f1bf..0c91729a6f 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -68,13 +68,13 @@ double AnimationNodeAnimation::process(double p_time, bool p_seek, bool p_seek_r AnimationPlayer *ap = state->player; ERR_FAIL_COND_V(!ap, 0); - double time = get_parameter(this->time); + double cur_time = get_parameter(time); if (!ap->has_animation(animation)) { AnimationNodeBlendTree *tree = Object::cast_to<AnimationNodeBlendTree>(parent); if (tree) { - String name = tree->get_node_name(Ref<AnimationNodeAnimation>(this)); - make_invalid(vformat(RTR("On BlendTree node '%s', animation not found: '%s'"), name, animation)); + String node_name = tree->get_node_name(Ref<AnimationNodeAnimation>(this)); + make_invalid(vformat(RTR("On BlendTree node '%s', animation not found: '%s'"), node_name, animation)); } else { make_invalid(vformat(RTR("Animation not found: '%s'"), animation)); @@ -86,58 +86,58 @@ double AnimationNodeAnimation::process(double p_time, bool p_seek, bool p_seek_r Ref<Animation> anim = ap->get_animation(animation); double anim_size = (double)anim->get_length(); double step = 0.0; - double prev_time = time; + double prev_time = cur_time; int pingponged = 0; bool current_backward = signbit(p_time); if (p_seek) { - step = p_time - time; - time = p_time; + step = p_time - cur_time; + cur_time = p_time; } else { p_time *= backward ? -1.0 : 1.0; - if (!(time == anim_size && !current_backward) && !(time == 0 && current_backward)) { - time = time + p_time; + if (!(cur_time == anim_size && !current_backward) && !(cur_time == 0 && current_backward)) { + cur_time = cur_time + p_time; step = p_time; } } if (anim->get_loop_mode() == Animation::LOOP_PINGPONG) { if (!Math::is_zero_approx(anim_size)) { - if ((int)Math::floor(abs(time - prev_time) / anim_size) % 2 == 0) { - if (prev_time >= 0 && time < 0) { + if ((int)Math::floor(abs(cur_time - prev_time) / anim_size) % 2 == 0) { + if (prev_time >= 0 && cur_time < 0) { backward = !backward; pingponged = -1; } - if (prev_time <= anim_size && time > anim_size) { + if (prev_time <= anim_size && cur_time > anim_size) { backward = !backward; pingponged = 1; } } - time = Math::pingpong(time, anim_size); + cur_time = Math::pingpong(cur_time, anim_size); } } else { if (anim->get_loop_mode() == Animation::LOOP_LINEAR) { if (!Math::is_zero_approx(anim_size)) { - time = Math::fposmod(time, anim_size); + cur_time = Math::fposmod(cur_time, anim_size); } - } else if (time < 0) { - step += time; - time = 0; - } else if (time > anim_size) { - step += anim_size - time; - time = anim_size; + } else if (cur_time < 0) { + step += cur_time; + cur_time = 0; + } else if (cur_time > anim_size) { + step += anim_size - cur_time; + cur_time = anim_size; } backward = false; } if (play_mode == PLAY_MODE_FORWARD) { - blend_animation(animation, time, step, p_seek, p_seek_root, 1.0, pingponged); + blend_animation(animation, cur_time, step, p_seek, p_seek_root, 1.0, pingponged); } else { - blend_animation(animation, anim_size - time, -step, p_seek, p_seek_root, 1.0, pingponged); + blend_animation(animation, anim_size - cur_time, -step, p_seek, p_seek_root, 1.0, pingponged); } - set_parameter(this->time, time); + set_parameter(time, cur_time); - return anim_size - time; + return anim_size - cur_time; } String AnimationNodeAnimation::get_caption() const { @@ -274,28 +274,28 @@ bool AnimationNodeOneShot::has_filter() const { } double AnimationNodeOneShot::process(double p_time, bool p_seek, bool p_seek_root) { - bool active = get_parameter(this->active); - bool prev_active = get_parameter(this->prev_active); - double time = get_parameter(this->time); - double remaining = get_parameter(this->remaining); - double time_to_restart = get_parameter(this->time_to_restart); + bool cur_active = get_parameter(active); + bool cur_prev_active = get_parameter(prev_active); + double cur_time = get_parameter(time); + double cur_remaining = get_parameter(remaining); + double cur_time_to_restart = get_parameter(time_to_restart); - if (!active) { + if (!cur_active) { //make it as if this node doesn't exist, pass input 0 by. - if (prev_active) { - set_parameter(this->prev_active, false); + if (cur_prev_active) { + set_parameter(prev_active, false); } - if (time_to_restart >= 0.0 && !p_seek) { - time_to_restart -= p_time; - if (time_to_restart < 0) { + if (cur_time_to_restart >= 0.0 && !p_seek) { + cur_time_to_restart -= p_time; + if (cur_time_to_restart < 0) { //restart - set_parameter(this->active, true); - active = true; + set_parameter(active, true); + cur_active = true; } - set_parameter(this->time_to_restart, time_to_restart); + set_parameter(time_to_restart, cur_time_to_restart); } - if (!active) { + if (!cur_active) { return blend_input(0, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, sync); } } @@ -303,27 +303,27 @@ double AnimationNodeOneShot::process(double p_time, bool p_seek, bool p_seek_roo bool os_seek = p_seek; if (p_seek) { - time = p_time; + cur_time = p_time; } - bool do_start = !prev_active; + bool do_start = !cur_prev_active; if (do_start) { - time = 0; + cur_time = 0; os_seek = true; - set_parameter(this->prev_active, true); + set_parameter(prev_active, true); } real_t blend; - if (time < fade_in) { + if (cur_time < fade_in) { if (fade_in > 0) { - blend = time / fade_in; + blend = cur_time / fade_in; } else { blend = 0; } - } else if (!do_start && remaining <= fade_out) { + } else if (!do_start && cur_remaining <= fade_out) { if (fade_out > 0) { - blend = (remaining / fade_out); + blend = (cur_remaining / fade_out); } else { blend = 0; } @@ -338,29 +338,29 @@ double AnimationNodeOneShot::process(double p_time, bool p_seek, bool p_seek_roo main_rem = blend_input(0, p_time, p_seek, p_seek_root, 1.0 - blend, FILTER_BLEND, sync); } - double os_rem = blend_input(1, os_seek ? time : p_time, os_seek, p_seek_root, blend, FILTER_PASS, true); + double os_rem = blend_input(1, os_seek ? cur_time : p_time, os_seek, p_seek_root, blend, FILTER_PASS, true); if (do_start) { - remaining = os_rem; + cur_remaining = os_rem; } if (!p_seek) { - time += p_time; - remaining = os_rem; - if (remaining <= 0) { - set_parameter(this->active, false); - set_parameter(this->prev_active, false); + cur_time += p_time; + cur_remaining = os_rem; + if (cur_remaining <= 0) { + set_parameter(active, false); + set_parameter(prev_active, false); if (autorestart) { double restart_sec = autorestart_delay + Math::randd() * autorestart_random_delay; - set_parameter(this->time_to_restart, restart_sec); + set_parameter(time_to_restart, restart_sec); } } } - set_parameter(this->time, time); - set_parameter(this->remaining, remaining); + set_parameter(time, cur_time); + set_parameter(remaining, cur_remaining); - return MAX(main_rem, remaining); + return MAX(main_rem, cur_remaining); } void AnimationNodeOneShot::_bind_methods() { @@ -554,11 +554,11 @@ String AnimationNodeTimeScale::get_caption() const { } double AnimationNodeTimeScale::process(double p_time, bool p_seek, bool p_seek_root) { - double scale = get_parameter(this->scale); + double cur_scale = get_parameter(scale); if (p_seek) { return blend_input(0, p_time, true, p_seek_root, 1.0, FILTER_IGNORE, true); } else { - return blend_input(0, p_time * scale, false, p_seek_root, 1.0, FILTER_IGNORE, true); + return blend_input(0, p_time * cur_scale, false, p_seek_root, 1.0, FILTER_IGNORE, true); } } @@ -584,12 +584,12 @@ String AnimationNodeTimeSeek::get_caption() const { } double AnimationNodeTimeSeek::process(double p_time, bool p_seek, bool p_seek_root) { - double seek_pos = get_parameter(this->seek_pos); + double cur_seek_pos = get_parameter(seek_pos); if (p_seek) { return blend_input(0, p_time, true, p_seek_root, 1.0, FILTER_IGNORE, true); - } else if (seek_pos >= 0) { - double ret = blend_input(0, seek_pos, true, true, 1.0, FILTER_IGNORE, true); - set_parameter(this->seek_pos, -1.0); //reset + } else if (cur_seek_pos >= 0) { + double ret = blend_input(0, cur_seek_pos, true, true, 1.0, FILTER_IGNORE, true); + set_parameter(seek_pos, -1.0); //reset return ret; } else { return blend_input(0, p_time, false, p_seek_root, 1.0, FILTER_IGNORE, true); @@ -701,80 +701,80 @@ bool AnimationNodeTransition::is_from_start() const { } double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_seek_root) { - int current = get_parameter(this->current); - int prev = get_parameter(this->prev); - int prev_current = get_parameter(this->prev_current); + int cur_current = get_parameter(current); + int cur_prev = get_parameter(prev); + int cur_prev_current = get_parameter(prev_current); - double time = get_parameter(this->time); - double prev_xfading = get_parameter(this->prev_xfading); + double cur_time = get_parameter(time); + double cur_prev_xfading = get_parameter(prev_xfading); - bool switched = current != prev_current; + bool switched = cur_current != cur_prev_current; if (switched) { - set_parameter(this->prev_current, current); - set_parameter(this->prev, prev_current); + set_parameter(prev_current, cur_current); + set_parameter(prev, cur_prev_current); - prev = prev_current; - prev_xfading = xfade_time; - time = 0; + cur_prev = cur_prev_current; + cur_prev_xfading = xfade_time; + cur_time = 0; switched = true; } - if (current < 0 || current >= enabled_inputs || prev >= enabled_inputs) { + if (cur_current < 0 || cur_current >= enabled_inputs || cur_prev >= enabled_inputs) { return 0; } double rem = 0.0; for (int i = 0; i < enabled_inputs; i++) { - if (i != current && i != prev) { + if (i != cur_current && i != cur_prev) { blend_input(i, p_time, p_seek, p_seek_root, 0, FILTER_IGNORE, sync); } } - if (prev < 0) { // process current animation, check for transition + if (cur_prev < 0) { // process current animation, check for transition - rem = blend_input(current, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, true); + rem = blend_input(cur_current, p_time, p_seek, p_seek_root, 1.0, FILTER_IGNORE, true); if (p_seek) { - time = p_time; + cur_time = p_time; } else { - time += p_time; + cur_time += p_time; } - if (inputs[current].auto_advance && rem <= xfade_time) { - set_parameter(this->current, (current + 1) % enabled_inputs); + if (inputs[cur_current].auto_advance && rem <= xfade_time) { + set_parameter(current, (cur_current + 1) % enabled_inputs); } } else { // cross-fading from prev to current - real_t blend = xfade_time == 0 ? 0 : (prev_xfading / xfade_time); + real_t blend = xfade_time == 0 ? 0 : (cur_prev_xfading / xfade_time); if (xfade_curve.is_valid()) { blend = xfade_curve->sample(blend); } if (from_start && !p_seek && switched) { //just switched, seek to start of current - rem = blend_input(current, 0, true, p_seek_root, 1.0 - blend, FILTER_IGNORE, true); + rem = blend_input(cur_current, 0, true, p_seek_root, 1.0 - blend, FILTER_IGNORE, true); } else { - rem = blend_input(current, p_time, p_seek, p_seek_root, 1.0 - blend, FILTER_IGNORE, true); + rem = blend_input(cur_current, p_time, p_seek, p_seek_root, 1.0 - blend, FILTER_IGNORE, true); } if (p_seek) { - blend_input(prev, p_time, true, p_seek_root, blend, FILTER_IGNORE, true); - time = p_time; + blend_input(cur_prev, p_time, true, p_seek_root, blend, FILTER_IGNORE, true); + cur_time = p_time; } else { - blend_input(prev, p_time, false, p_seek_root, blend, FILTER_IGNORE, true); - time += p_time; - prev_xfading -= p_time; - if (prev_xfading < 0) { - set_parameter(this->prev, -1); + blend_input(cur_prev, p_time, false, p_seek_root, blend, FILTER_IGNORE, true); + cur_time += p_time; + cur_prev_xfading -= p_time; + if (cur_prev_xfading < 0) { + set_parameter(prev, -1); } } } - set_parameter(this->time, time); - set_parameter(this->prev_xfading, prev_xfading); + set_parameter(time, cur_time); + set_parameter(prev_xfading, cur_prev_xfading); return rem; } @@ -1070,10 +1070,10 @@ Ref<AnimationNode> AnimationNodeBlendTree::get_child_by_name(const StringName &p } bool AnimationNodeBlendTree::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name; - if (name.begins_with("nodes/")) { - String node_name = name.get_slicec('/', 1); - String what = name.get_slicec('/', 2); + String prop_name = p_name; + if (prop_name.begins_with("nodes/")) { + String node_name = prop_name.get_slicec('/', 1); + String what = prop_name.get_slicec('/', 2); if (what == "node") { Ref<AnimationNode> anode = p_value; @@ -1089,7 +1089,7 @@ bool AnimationNodeBlendTree::_set(const StringName &p_name, const Variant &p_val } return true; } - } else if (name == "node_connections") { + } else if (prop_name == "node_connections") { Array conns = p_value; ERR_FAIL_COND_V(conns.size() % 3 != 0, false); @@ -1103,10 +1103,10 @@ bool AnimationNodeBlendTree::_set(const StringName &p_name, const Variant &p_val } bool AnimationNodeBlendTree::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name; - if (name.begins_with("nodes/")) { - String node_name = name.get_slicec('/', 1); - String what = name.get_slicec('/', 2); + String prop_name = p_name; + if (prop_name.begins_with("nodes/")) { + String node_name = prop_name.get_slicec('/', 1); + String what = prop_name.get_slicec('/', 2); if (what == "node") { if (nodes.has(node_name)) { @@ -1121,7 +1121,7 @@ bool AnimationNodeBlendTree::_get(const StringName &p_name, Variant &r_ret) cons return true; } } - } else if (name == "node_connections") { + } else if (prop_name == "node_connections") { List<NodeConnection> nc; get_node_connections(&nc); Array conns; @@ -1150,11 +1150,11 @@ void AnimationNodeBlendTree::_get_property_list(List<PropertyInfo> *p_list) cons names.sort_custom<StringName::AlphCompare>(); for (const StringName &E : names) { - String name = E; - if (name != "output") { - p_list->push_back(PropertyInfo(Variant::OBJECT, "nodes/" + name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NO_EDITOR)); + String prop_name = E; + if (prop_name != "output") { + p_list->push_back(PropertyInfo(Variant::OBJECT, "nodes/" + prop_name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NO_EDITOR)); } - p_list->push_back(PropertyInfo(Variant::VECTOR2, "nodes/" + name + "/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR)); + p_list->push_back(PropertyInfo(Variant::VECTOR2, "nodes/" + prop_name + "/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR)); } p_list->push_back(PropertyInfo(Variant::ARRAY, "node_connections", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR)); diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index facffb99ee..fa33591e8b 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -728,11 +728,11 @@ void AnimationNodeStateMachine::add_node(const StringName &p_name, Ref<Animation ERR_FAIL_COND(p_node.is_null()); ERR_FAIL_COND(String(p_name).contains("/")); - State state; - state.node = p_node; - state.position = p_position; + State state_new; + state_new.node = p_node; + state_new.position = p_position; - states[p_name] = state; + states[p_name] = state_new; Ref<AnimationNodeStateMachine> anodesm = p_node; @@ -960,8 +960,8 @@ bool AnimationNodeStateMachine::_can_connect(const StringName &p_name, Vector<An return true; } - String name = p_name; - Vector<String> path = name.split("/"); + String node_name = p_name; + Vector<String> path = node_name.split("/"); if (path.size() < 2) { return false; @@ -969,12 +969,12 @@ bool AnimationNodeStateMachine::_can_connect(const StringName &p_name, Vector<An if (path[0] == "..") { if (prev_state_machine != nullptr) { - return prev_state_machine->_can_connect(name.replace_first("../", ""), p_parents); + return prev_state_machine->_can_connect(node_name.replace_first("../", ""), p_parents); } } else if (states.has(path[0])) { Ref<AnimationNodeStateMachine> anodesm = states[path[0]].node; if (anodesm.is_valid()) { - return anodesm->_can_connect(name.replace_first(path[0] + "/", ""), p_parents); + return anodesm->_can_connect(node_name.replace_first(path[0] + "/", ""), p_parents); } } @@ -1151,10 +1151,10 @@ Vector2 AnimationNodeStateMachine::get_graph_offset() const { } double AnimationNodeStateMachine::process(double p_time, bool p_seek, bool p_seek_root) { - Ref<AnimationNodeStateMachinePlayback> playback = get_parameter(this->playback); - ERR_FAIL_COND_V(playback.is_null(), 0.0); + Ref<AnimationNodeStateMachinePlayback> playback_new = get_parameter(playback); + ERR_FAIL_COND_V(playback_new.is_null(), 0.0); - return playback->process(this, p_time, p_seek, p_seek_root); + return playback_new->process(this, p_time, p_seek, p_seek_root); } String AnimationNodeStateMachine::get_caption() const { @@ -1178,10 +1178,10 @@ Ref<AnimationNode> AnimationNodeStateMachine::get_child_by_name(const StringName } bool AnimationNodeStateMachine::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name; - if (name.begins_with("states/")) { - String node_name = name.get_slicec('/', 1); - String what = name.get_slicec('/', 2); + String prop_name = p_name; + if (prop_name.begins_with("states/")) { + String node_name = prop_name.get_slicec('/', 1); + String what = prop_name.get_slicec('/', 2); if (what == "node") { Ref<AnimationNode> anode = p_value; @@ -1197,7 +1197,7 @@ bool AnimationNodeStateMachine::_set(const StringName &p_name, const Variant &p_ } return true; } - } else if (name == "transitions") { + } else if (prop_name == "transitions") { Array trans = p_value; ERR_FAIL_COND_V(trans.size() % 3 != 0, false); @@ -1205,7 +1205,7 @@ bool AnimationNodeStateMachine::_set(const StringName &p_name, const Variant &p_ add_transition(trans[i], trans[i + 1], trans[i + 2]); } return true; - } else if (name == "graph_offset") { + } else if (prop_name == "graph_offset") { set_graph_offset(p_value); return true; } @@ -1214,10 +1214,10 @@ bool AnimationNodeStateMachine::_set(const StringName &p_name, const Variant &p_ } bool AnimationNodeStateMachine::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name; - if (name.begins_with("states/")) { - String node_name = name.get_slicec('/', 1); - String what = name.get_slicec('/', 2); + String prop_name = p_name; + if (prop_name.begins_with("states/")) { + String node_name = prop_name.get_slicec('/', 1); + String what = prop_name.get_slicec('/', 2); if (what == "node") { if (states.has(node_name) && can_edit_node(node_name)) { @@ -1232,7 +1232,7 @@ bool AnimationNodeStateMachine::_get(const StringName &p_name, Variant &r_ret) c return true; } } - } else if (name == "transitions") { + } else if (prop_name == "transitions") { Array trans; for (int i = 0; i < transitions.size(); i++) { String from = transitions[i].from; @@ -1249,7 +1249,7 @@ bool AnimationNodeStateMachine::_get(const StringName &p_name, Variant &r_ret) c r_ret = trans; return true; - } else if (name == "graph_offset") { + } else if (prop_name == "graph_offset") { r_ret = get_graph_offset(); return true; } @@ -1264,9 +1264,9 @@ void AnimationNodeStateMachine::_get_property_list(List<PropertyInfo> *p_list) c } names.sort_custom<StringName::AlphCompare>(); - for (const StringName &name : names) { - p_list->push_back(PropertyInfo(Variant::OBJECT, "states/" + name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NO_EDITOR)); - p_list->push_back(PropertyInfo(Variant::VECTOR2, "states/" + name + "/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR)); + for (const StringName &prop_name : names) { + p_list->push_back(PropertyInfo(Variant::OBJECT, "states/" + prop_name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NO_EDITOR)); + p_list->push_back(PropertyInfo(Variant::VECTOR2, "states/" + prop_name + "/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR)); } p_list->push_back(PropertyInfo(Variant::ARRAY, "transitions", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR)); diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 54b10d9d57..fe67c0886f 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -1504,9 +1504,9 @@ bool AnimationPlayer::has_animation(const StringName &p_name) const { Ref<Animation> AnimationPlayer::get_animation(const StringName &p_name) const { ERR_FAIL_COND_V_MSG(!animation_set.has(p_name), Ref<Animation>(), vformat("Animation not found: \"%s\".", p_name)); - const AnimationData &data = animation_set[p_name]; + const AnimationData &anim_data = animation_set[p_name]; - return data.animation; + return anim_data.animation; } void AnimationPlayer::get_animation_list(List<StringName> *p_animations) const { @@ -2037,8 +2037,7 @@ Ref<AnimatedValuesBackup> AnimationPlayer::apply_reset(bool p_user_initiated) { aux_player->add_animation_library("", al); aux_player->set_assigned_animation(SceneStringNames::get_singleton()->RESET); // Forcing the use of the original root because the scene where original player belongs may be not the active one - Node *root = get_node(get_root()); - Ref<AnimatedValuesBackup> old_values = aux_player->backup_animated_values(root); + Ref<AnimatedValuesBackup> old_values = aux_player->backup_animated_values(get_node(get_root())); aux_player->seek(0.0f, true); aux_player->queue_delete(); diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 05a4a2d024..4d09fa619c 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -97,8 +97,8 @@ void AnimationNode::blend_animation(const StringName &p_animation, double p_time if (animation.is_null()) { AnimationNodeBlendTree *btree = Object::cast_to<AnimationNodeBlendTree>(parent); if (btree) { - String name = btree->get_node_name(Ref<AnimationNodeAnimation>(this)); - make_invalid(vformat(RTR("In node '%s', invalid animation: '%s'."), name, p_animation)); + String node_name = btree->get_node_name(Ref<AnimationNodeAnimation>(this)); + make_invalid(vformat(RTR("In node '%s', invalid animation: '%s'."), node_name, p_animation)); } else { make_invalid(vformat(RTR("Invalid animation: '%s'."), p_animation)); } @@ -160,8 +160,8 @@ double AnimationNode::blend_input(int p_input, double p_time, bool p_seek, bool StringName node_name = connections[p_input]; if (!blend_tree->has_node(node_name)) { - String name = blend_tree->get_node_name(Ref<AnimationNode>(this)); - make_invalid(vformat(RTR("Nothing connected to input '%s' of node '%s'."), get_input_name(p_input), name)); + String node_name2 = blend_tree->get_node_name(Ref<AnimationNode>(this)); + make_invalid(vformat(RTR("Nothing connected to input '%s' of node '%s'."), get_input_name(p_input), node_name2)); return 0; } diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 4a0f870406..aa58e1044a 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -263,9 +263,9 @@ bool Tween::step(double p_delta) { } if (is_bound) { - Node *bound_node = get_bound_node(); - if (bound_node) { - if (!bound_node->is_inside_tree()) { + Node *node = get_bound_node(); + if (node) { + if (!node->is_inside_tree()) { return true; } } else { @@ -342,9 +342,9 @@ bool Tween::step(double p_delta) { bool Tween::can_process(bool p_tree_paused) const { if (is_bound && pause_mode == TWEEN_PAUSE_BOUND) { - Node *bound_node = get_bound_node(); - if (bound_node) { - return bound_node->is_inside_tree() && bound_node->can_process(); + Node *node = get_bound_node(); + if (node) { + return node->is_inside_tree() && node->can_process(); } } |