diff options
author | Josh Grams <josh@qualdan.com> | 2016-04-06 15:09:00 -0400 |
---|---|---|
committer | Josh Grams <josh@qualdan.com> | 2016-04-06 15:09:00 -0400 |
commit | 4f6b2152e2e12a6c9157ea3190830b627cbae3b7 (patch) | |
tree | ac08c40efcdd4d1e788e1249fe78a0216e6342f9 /scene/animation/animation_tree_player.cpp | |
parent | 1b95dca6bd8113503f4da21c148f7eb98e7722e6 (diff) | |
download | redot-engine-4f6b2152e2e12a6c9157ea3190830b627cbae3b7.tar.gz |
AnimationTreePlayer (transition_node_set_current): fix by removing copy-paste duplication.
Diffstat (limited to 'scene/animation/animation_tree_player.cpp')
-rw-r--r-- | scene/animation/animation_tree_player.cpp | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp index 0f8599706e..ce341e2b09 100644 --- a/scene/animation/animation_tree_player.cpp +++ b/scene/animation/animation_tree_player.cpp @@ -676,14 +676,7 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode if (tn->input_data[tn->current].auto_advance && rem <= tn->xfade) { - tn->prev=tn->current; - tn->current++; - if (tn->current>=tn->inputs.size()) - tn->current=0; - tn->prev_xfading=tn->xfade; - tn->prev_time=tn->time; - tn->time=0; - tn->switched=true; + tn->set_current((tn->current+1) % tn->inputs.size()); } @@ -1156,21 +1149,24 @@ void AnimationTreePlayer::transition_node_set_xfade_time(const StringName& p_nod n->xfade=p_time; } +void AnimationTreePlayer::TransitionNode::set_current(int p_current) { + ERR_FAIL_INDEX(p_current,inputs.size()); -void AnimationTreePlayer::transition_node_set_current(const StringName& p_node, int p_current) { - - GET_NODE( NODE_TRANSITION, TransitionNode ); - ERR_FAIL_INDEX(p_current,n->inputs.size()); - - if (n->current==p_current) + if (current==p_current) return; - n->prev=n->current; - n->prev_xfading=n->xfade; - n->prev_time=n->time; - n->time=0; - n->current=p_current; + prev=current; + prev_xfading=xfade; + prev_time=time; + time=0; + current=p_current; + switched=true; +} + +void AnimationTreePlayer::transition_node_set_current(const StringName& p_node, int p_current) { + GET_NODE( NODE_TRANSITION, TransitionNode ); + n->set_current(p_current); } |