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 | |
parent | 1b95dca6bd8113503f4da21c148f7eb98e7722e6 (diff) |
AnimationTreePlayer (transition_node_set_current): fix by removing copy-paste duplication.
Diffstat (limited to 'scene')
-rw-r--r-- | scene/animation/animation_tree_player.cpp | 34 | ||||
-rw-r--r-- | scene/animation/animation_tree_player.h | 1 |
2 files changed, 16 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); } diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h index 2e8ddc34d8..7cc96fc1e3 100644 --- a/scene/animation/animation_tree_player.h +++ b/scene/animation/animation_tree_player.h @@ -246,6 +246,7 @@ private: float xfade; TransitionNode() { type=NODE_TRANSITION; xfade=0; inputs.resize(1); input_data.resize(1); current=0; prev=-1; prev_time=0; prev_xfading=0; switched=false; } + void set_current(int p_current); }; |