diff options
Diffstat (limited to 'scene/animation/animation_node_state_machine.cpp')
-rw-r--r-- | scene/animation/animation_node_state_machine.cpp | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index 9f5e06c43d..4a387772a8 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -33,12 +33,10 @@ ///////////////////////////////////////////////// void AnimationNodeStateMachineTransition::set_switch_mode(SwitchMode p_mode) { - switch_mode = p_mode; } AnimationNodeStateMachineTransition::SwitchMode AnimationNodeStateMachineTransition::get_switch_mode() const { - return switch_mode; } @@ -71,7 +69,6 @@ StringName AnimationNodeStateMachineTransition::get_advance_condition_name() con } void AnimationNodeStateMachineTransition::set_xfade_time(float p_xfade) { - ERR_FAIL_COND(p_xfade < 0); xfade = p_xfade; emit_changed(); @@ -133,7 +130,6 @@ void AnimationNodeStateMachineTransition::_bind_methods() { } AnimationNodeStateMachineTransition::AnimationNodeStateMachineTransition() { - switch_mode = SWITCH_MODE_IMMEDIATE; auto_advance = false; xfade = 0; @@ -144,7 +140,6 @@ AnimationNodeStateMachineTransition::AnimationNodeStateMachineTransition() { //////////////////////////////////////////////////////// void AnimationNodeStateMachinePlayback::travel(const StringName &p_state) { - start_request_travel = true; start_request = p_state; stop_request = false; @@ -156,7 +151,6 @@ void AnimationNodeStateMachinePlayback::start(const StringName &p_state) { stop_request = false; } void AnimationNodeStateMachinePlayback::stop() { - stop_request = true; } bool AnimationNodeStateMachinePlayback::is_playing() const { @@ -179,7 +173,6 @@ float AnimationNodeStateMachinePlayback::get_current_length() const { } bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_state_machine, const StringName &p_travel) { - ERR_FAIL_COND_V(!playing, false); ERR_FAIL_COND_V(!p_state_machine->states.has(p_travel), false); ERR_FAIL_COND_V(!p_state_machine->states.has(current), false); @@ -219,7 +212,6 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta //begin astar bool found_route = false; while (!found_route) { - if (open_list.size() == 0) { return false; //no path found } @@ -229,7 +221,6 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta float least_cost = 1e20; for (List<int>::Element *E = open_list.front(); E; E = E->next()) { - float cost = cost_map[p_state_machine->transitions[E->get()].to].distance; cost += p_state_machine->states[p_state_machine->transitions[E->get()].to].position.distance_to(target_pos); @@ -293,7 +284,6 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta } float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_state_machine, float p_time, bool p_seek) { - //if not playing and it can restart, then restart if (!playing && start_request == StringName()) { if (!stop_request && p_state_machine->start_node) { @@ -347,7 +337,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st bool do_start = (p_seek && p_time == 0) || play_start || current == StringName(); if (do_start) { - if (p_state_machine->start_node != StringName() && p_seek && p_time == 0) { current = p_state_machine->start_node; } @@ -365,7 +354,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st float fade_blend = 1.0; if (fading_from != StringName()) { - if (!p_state_machine->states.has(fading_from)) { fading_from = StringName(); } else { @@ -382,7 +370,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st float rem = p_state_machine->blend_node(current, p_state_machine->states[current].node, p_time, p_seek, fade_blend, AnimationNode::FILTER_IGNORE, false); if (fading_from != StringName()) { - p_state_machine->blend_node(fading_from, p_state_machine->states[fading_from].node, p_time, p_seek, 1.0 - fade_blend, AnimationNode::FILTER_IGNORE, false); } @@ -407,7 +394,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st AnimationNodeStateMachineTransition::SwitchMode switch_mode = AnimationNodeStateMachineTransition::SWITCH_MODE_IMMEDIATE; if (path.size()) { - for (int i = 0; i < p_state_machine->transitions.size(); i++) { if (p_state_machine->transitions[i].from == current && p_state_machine->transitions[i].to == path[0]) { next_xfade = p_state_machine->transitions[i].transition->get_xfade_time(); @@ -419,7 +405,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st float priority_best = 1e20; int auto_advance_to = -1; for (int i = 0; i < p_state_machine->transitions.size(); i++) { - bool auto_advance = false; if (p_state_machine->transitions[i].transition->has_auto_advance()) { auto_advance = true; @@ -430,7 +415,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st } if (p_state_machine->transitions[i].from == current && auto_advance) { - if (p_state_machine->transitions[i].transition->get_priority() <= priority_best) { priority_best = p_state_machine->transitions[i].transition->get_priority(); auto_advance_to = i; @@ -447,7 +431,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st //if next, see when to transition if (next != StringName()) { - bool goto_next = false; if (switch_mode == AnimationNodeStateMachineTransition::SWITCH_MODE_AT_END) { @@ -492,7 +475,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st //compute time left for transitions by using the end node if (p_state_machine->end_node != StringName() && p_state_machine->end_node != current) { - rem = p_state_machine->blend_node(p_state_machine->end_node, p_state_machine->states[p_state_machine->end_node].node, 0, true, 0, AnimationNode::FILTER_IGNORE, false); } @@ -500,7 +482,6 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st } void AnimationNodeStateMachinePlayback::_bind_methods() { - ClassDB::bind_method(D_METHOD("travel", "to_node"), &AnimationNodeStateMachinePlayback::travel); ClassDB::bind_method(D_METHOD("start", "node"), &AnimationNodeStateMachinePlayback::start); ClassDB::bind_method(D_METHOD("stop"), &AnimationNodeStateMachinePlayback::stop); @@ -542,7 +523,6 @@ void AnimationNodeStateMachine::get_parameter_list(List<PropertyInfo> *r_list) c } Variant AnimationNodeStateMachine::get_parameter_default_value(const StringName &p_parameter) const { - if (p_parameter == playback) { Ref<AnimationNodeStateMachinePlayback> p; p.instance(); @@ -553,7 +533,6 @@ Variant AnimationNodeStateMachine::get_parameter_default_value(const StringName } void AnimationNodeStateMachine::add_node(const StringName &p_name, Ref<AnimationNode> p_node, const Vector2 &p_position) { - ERR_FAIL_COND(states.has(p_name)); ERR_FAIL_COND(p_node.is_null()); ERR_FAIL_COND(String(p_name).find("/") != -1); @@ -571,7 +550,6 @@ void AnimationNodeStateMachine::add_node(const StringName &p_name, Ref<Animation } void AnimationNodeStateMachine::replace_node(const StringName &p_name, Ref<AnimationNode> p_node) { - ERR_FAIL_COND(states.has(p_name) == false); ERR_FAIL_COND(p_node.is_null()); ERR_FAIL_COND(String(p_name).find("/") != -1); @@ -592,7 +570,6 @@ void AnimationNodeStateMachine::replace_node(const StringName &p_name, Ref<Anima } Ref<AnimationNode> AnimationNodeStateMachine::get_node(const StringName &p_name) const { - ERR_FAIL_COND_V(!states.has(p_name), Ref<AnimationNode>()); return states[p_name].node; @@ -629,7 +606,6 @@ bool AnimationNodeStateMachine::has_node(const StringName &p_name) const { return states.has(p_name); } void AnimationNodeStateMachine::remove_node(const StringName &p_name) { - ERR_FAIL_COND(!states.has(p_name)); { @@ -668,7 +644,6 @@ void AnimationNodeStateMachine::remove_node(const StringName &p_name) { } void AnimationNodeStateMachine::rename_node(const StringName &p_name, const StringName &p_new_name) { - ERR_FAIL_COND(!states.has(p_name)); ERR_FAIL_COND(states.has(p_new_name)); @@ -702,7 +677,6 @@ void AnimationNodeStateMachine::rename_node(const StringName &p_name, const Stri } void AnimationNodeStateMachine::get_node_list(List<StringName> *r_nodes) const { - List<StringName> nodes; for (Map<StringName, State>::Element *E = states.front(); E; E = E->next()) { nodes.push_back(E->key()); @@ -715,7 +689,6 @@ void AnimationNodeStateMachine::get_node_list(List<StringName> *r_nodes) const { } bool AnimationNodeStateMachine::has_transition(const StringName &p_from, const StringName &p_to) const { - for (int i = 0; i < transitions.size(); i++) { if (transitions[i].from == p_from && transitions[i].to == p_to) return true; @@ -724,7 +697,6 @@ bool AnimationNodeStateMachine::has_transition(const StringName &p_from, const S } int AnimationNodeStateMachine::find_transition(const StringName &p_from, const StringName &p_to) const { - for (int i = 0; i < transitions.size(); i++) { if (transitions[i].from == p_from && transitions[i].to == p_to) return i; @@ -733,7 +705,6 @@ int AnimationNodeStateMachine::find_transition(const StringName &p_from, const S } void AnimationNodeStateMachine::add_transition(const StringName &p_from, const StringName &p_to, const Ref<AnimationNodeStateMachineTransition> &p_transition) { - ERR_FAIL_COND(p_from == p_to); ERR_FAIL_COND(!states.has(p_from)); ERR_FAIL_COND(!states.has(p_to)); @@ -758,22 +729,18 @@ Ref<AnimationNodeStateMachineTransition> AnimationNodeStateMachine::get_transiti return transitions[p_transition].transition; } StringName AnimationNodeStateMachine::get_transition_from(int p_transition) const { - ERR_FAIL_INDEX_V(p_transition, transitions.size(), StringName()); return transitions[p_transition].from; } StringName AnimationNodeStateMachine::get_transition_to(int p_transition) const { - ERR_FAIL_INDEX_V(p_transition, transitions.size(), StringName()); return transitions[p_transition].to; } int AnimationNodeStateMachine::get_transition_count() const { - return transitions.size(); } void AnimationNodeStateMachine::remove_transition(const StringName &p_from, const StringName &p_to) { - for (int i = 0; i < transitions.size(); i++) { if (transitions[i].from == p_from && transitions[i].to == p_to) { transitions.write[i].transition->disconnect("advance_condition_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed)); @@ -788,7 +755,6 @@ void AnimationNodeStateMachine::remove_transition(const StringName &p_from, cons } void AnimationNodeStateMachine::remove_transition_by_index(int p_transition) { - ERR_FAIL_INDEX(p_transition, transitions.size()); transitions.write[p_transition].transition->disconnect("advance_condition_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed)); transitions.remove(p_transition); @@ -798,24 +764,20 @@ void AnimationNodeStateMachine::remove_transition_by_index(int p_transition) { } void AnimationNodeStateMachine::set_start_node(const StringName &p_node) { - ERR_FAIL_COND(p_node != StringName() && !states.has(p_node)); start_node = p_node; } String AnimationNodeStateMachine::get_start_node() const { - return start_node; } void AnimationNodeStateMachine::set_end_node(const StringName &p_node) { - ERR_FAIL_COND(p_node != StringName() && !states.has(p_node)); end_node = p_node; } String AnimationNodeStateMachine::get_end_node() const { - return end_node; } @@ -828,7 +790,6 @@ Vector2 AnimationNodeStateMachine::get_graph_offset() const { } float AnimationNodeStateMachine::process(float p_time, bool p_seek) { - Ref<AnimationNodeStateMachinePlayback> playback = get_parameter(this->playback); ERR_FAIL_COND_V(playback.is_null(), 0.0); @@ -847,7 +808,6 @@ 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); @@ -862,14 +822,12 @@ bool AnimationNodeStateMachine::_set(const StringName &p_name, const Variant &p_ } if (what == "position") { - if (states.has(node_name)) { states[node_name].position = p_value; } return true; } } else if (name == "transitions") { - Array trans = p_value; ERR_FAIL_COND_V(trans.size() % 3 != 0, false); @@ -892,7 +850,6 @@ 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); @@ -906,7 +863,6 @@ bool AnimationNodeStateMachine::_get(const StringName &p_name, Variant &r_ret) c } if (what == "position") { - if (states.has(node_name)) { r_ret = states[node_name].position; return true; @@ -938,7 +894,6 @@ bool AnimationNodeStateMachine::_get(const StringName &p_name, Variant &r_ret) c return false; } void AnimationNodeStateMachine::_get_property_list(List<PropertyInfo> *p_list) const { - List<StringName> names; for (Map<StringName, State>::Element *E = states.front(); E; E = E->next()) { names.push_back(E->key()); @@ -963,7 +918,6 @@ void AnimationNodeStateMachine::set_node_position(const StringName &p_name, cons } Vector2 AnimationNodeStateMachine::get_node_position(const StringName &p_name) const { - ERR_FAIL_COND_V(!states.has(p_name), Vector2()); return states[p_name].position; } @@ -973,7 +927,6 @@ void AnimationNodeStateMachine::_tree_changed() { } void AnimationNodeStateMachine::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_node", "name", "node", "position"), &AnimationNodeStateMachine::add_node, DEFVAL(Vector2())); ClassDB::bind_method(D_METHOD("replace_node", "name", "node"), &AnimationNodeStateMachine::replace_node); ClassDB::bind_method(D_METHOD("get_node", "name"), &AnimationNodeStateMachine::get_node); @@ -1005,6 +958,5 @@ void AnimationNodeStateMachine::_bind_methods() { } AnimationNodeStateMachine::AnimationNodeStateMachine() { - playback = "playback"; } |