Skip to content

Commit

Permalink
AnimationTreePlayer (transition_node_set_current): fix by removing co…
Browse files Browse the repository at this point in the history
…py-paste duplication.
  • Loading branch information
JoshuaGrams committed Apr 6, 2016
1 parent 1b95dca commit 4f6b215
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
34 changes: 15 additions & 19 deletions scene/animation/animation_tree_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}


Expand Down Expand Up @@ -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);
}


Expand Down
1 change: 1 addition & 0 deletions scene/animation/animation_tree_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ class AnimationTreePlayer : public Node {
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);
};


Expand Down

0 comments on commit 4f6b215

Please sign in to comment.