diff options
Diffstat (limited to 'scene/animation')
-rw-r--r-- | scene/animation/animation_player.cpp | 6 | ||||
-rw-r--r-- | scene/animation/animation_player.h | 1 | ||||
-rw-r--r-- | scene/animation/animation_tree_player.cpp | 234 | ||||
-rw-r--r-- | scene/animation/animation_tree_player.h | 16 | ||||
-rw-r--r-- | scene/animation/transitioner.cpp | 34 | ||||
-rw-r--r-- | scene/animation/transitioner.h | 68 | ||||
-rw-r--r-- | scene/animation/tween.cpp | 13 | ||||
-rw-r--r-- | scene/animation/tween_interpolaters.cpp | 2 |
8 files changed, 163 insertions, 211 deletions
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 32958112e5..2399bee539 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -1013,6 +1013,8 @@ void AnimationPlayer::play(const StringName& p_name, float p_custom_blend, float _set_process(true); // always process when starting an animation playing = true; + emit_signal(SceneStringNames::get_singleton()->animation_started, c.assigned); + if (is_inside_tree() && get_tree()->is_editor_hint()) return; // no next in this case @@ -1297,6 +1299,9 @@ void AnimationPlayer::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_animation:Animation","name"),&AnimationPlayer::get_animation); ObjectTypeDB::bind_method(_MD("get_animation_list"),&AnimationPlayer::_get_animation_list); + ObjectTypeDB::bind_method(_MD("animation_set_next", "anim_from", "anim_to"), &AnimationPlayer::animation_set_next); + ObjectTypeDB::bind_method(_MD("animation_get_next", "anim_from"), &AnimationPlayer::animation_get_next); + ObjectTypeDB::bind_method(_MD("set_blend_time","anim_from","anim_to","sec"),&AnimationPlayer::set_blend_time); ObjectTypeDB::bind_method(_MD("get_blend_time","anim_from","anim_to"),&AnimationPlayer::get_blend_time); @@ -1347,6 +1352,7 @@ void AnimationPlayer::_bind_methods() { ADD_SIGNAL( MethodInfo("finished") ); ADD_SIGNAL( MethodInfo("animation_changed", PropertyInfo(Variant::STRING,"old_name"), PropertyInfo(Variant::STRING,"new_name")) ); + ADD_SIGNAL( MethodInfo("animation_started", PropertyInfo(Variant::STRING,"name")) ); BIND_CONSTANT( ANIMATION_PROCESS_FIXED ); BIND_CONSTANT( ANIMATION_PROCESS_IDLE ); diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index 2ae3a0756c..ac0265dbaa 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -33,7 +33,6 @@ #include "scene/resources/animation.h" #include "scene/3d/spatial.h" #include "scene/3d/skeleton.h" -#include "scene/main/misc.h" #include "scene/2d/node_2d.h" /** @author Juan Linietsky <reduzio@gmail.com> diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp index 9dcad8a533..0f7ed1cb29 100644 --- a/scene/animation/animation_tree_player.cpp +++ b/scene/animation/animation_tree_player.cpp @@ -139,6 +139,11 @@ bool AnimationTreePlayer::_set(const StringName& p_name, const Variant& p_value) animation_node_set_master_animation(id,node.get_valid("from")); else animation_node_set_animation(id,node.get_valid("animation")); + Array filters= node.get_valid("filter"); + for(int i=0;i<filters.size();i++) { + + animation_node_set_filter_path(id,filters[i],true); + } } break; case NODE_ONESHOT: { @@ -276,6 +281,15 @@ bool AnimationTreePlayer::_get(const StringName& p_name,Variant &r_ret) const { } else { node["animation"]=an->animation; } + Array k; + List<NodePath> keys; + an->filter.get_key_list(&keys); + k.resize(keys.size()); + int i=0; + for(List<NodePath>::Element *E=keys.front();E;E=E->next()) { + k[i++]=E->get(); + } + node["filter"]=k; } break; case NODE_ONESHOT: { OneShotNode *osn = static_cast<OneShotNode*>(n); @@ -432,20 +446,19 @@ void AnimationTreePlayer::_notification(int p_what) { } -float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode **r_prev_anim,float p_weight, float p_time, bool switched, bool p_seek,const HashMap<NodePath,bool> *p_filter, float p_reverse_weight) { +float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode **r_prev_anim,float p_weight, float p_time, bool p_seek,const HashMap<NodePath,bool> *p_filter, float p_reverse_weight) { ERR_FAIL_COND_V(!node_map.has(p_node), 0); NodeBase *nb=node_map[p_node]; //transform to seconds... - switch(nb->type) { case NODE_OUTPUT: { NodeOut *on = static_cast<NodeOut*>(nb); - return _process_node(on->inputs[0].node,r_prev_anim,p_weight,p_time,switched,p_seek); + return _process_node(on->inputs[0].node,r_prev_anim,p_weight,p_time,p_seek); } break; case NODE_ANIMATION: { @@ -464,7 +477,7 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode an->time=p_time; an->step=0; } else { - an->time+=p_time; + an->time=MAX(0,an->time+p_time); an->step=p_time; } @@ -479,20 +492,15 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode an->time=anim_size; } - if (switched && an->time >= anim_size) { - an->time = 0.0; - } an->skip=true; for (List<AnimationNode::TrackRef>::Element *E=an->tref.front();E;E=E->next()) { - - if (p_filter && p_filter->has(an->animation->track_get_path(E->get().local_track))) { - - if (p_reverse_weight<0) - E->get().weight=0; - else - E->get().weight=p_reverse_weight; - + NodePath track_path = an->animation->track_get_path(E->get().local_track); + if (p_filter && p_filter->has(track_path)) { + E->get().weight = MAX(0, p_reverse_weight); + } else if(an->filter.has(track_path)) { + E->get().weight = 0; + E->get().track->skip = true; } else { E->get().weight=p_weight; } @@ -523,13 +531,17 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode if (!osn->active) { //make it as if this node doesn't exist, pass input 0 by. - return _process_node(osn->inputs[0].node,r_prev_anim,p_weight,p_time,switched,p_seek,p_filter,p_reverse_weight); + return _process_node(osn->inputs[0].node,r_prev_anim,p_weight,p_time,p_seek,p_filter,p_reverse_weight); } + float os_seek = p_seek; + if (p_seek) osn->time=p_time; - if (osn->start) + if (osn->start) { osn->time=0; + os_seek = true; + } float blend; @@ -551,18 +563,17 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode float main_rem; float os_rem; + float os_reverse_weight = p_reverse_weight; if (!osn->filter.empty()) { - - main_rem = _process_node(osn->inputs[0].node,r_prev_anim,(osn->mix?p_weight:p_weight*(1.0-blend)),p_time,switched,p_seek,&osn->filter,p_weight); - os_rem = _process_node(osn->inputs[1].node,r_prev_anim,p_weight*blend,p_time,osn->start,p_seek,&osn->filter,-1); - - } else { - - main_rem = _process_node(osn->inputs[0].node,r_prev_anim,(osn->mix?p_weight:p_weight*(1.0-blend)),p_time,switched,p_seek); - os_rem = _process_node(osn->inputs[1].node,r_prev_anim,p_weight*blend,p_time,osn->start,p_seek); + p_filter = &osn->filter; + p_reverse_weight = p_weight; + os_reverse_weight = -1; } + main_rem = _process_node(osn->inputs[0].node,r_prev_anim,(osn->mix?p_weight:p_weight*(1.0-blend)),p_time,p_seek,p_filter,p_reverse_weight); + os_rem = _process_node(osn->inputs[1].node,r_prev_anim,p_weight*blend,p_time,os_seek,p_filter,os_reverse_weight); + if (osn->start) { osn->remaining=os_rem; osn->start=false; @@ -570,8 +581,8 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode if (!p_seek) { osn->time+=p_time; - osn->remaining-=p_time; - if (osn->remaining<0) + osn->remaining=os_rem; + if (osn->remaining<=0) osn->active=false; } @@ -581,8 +592,8 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode MixNode *mn = static_cast<MixNode*>(nb); - float rem = _process_node(mn->inputs[0].node,r_prev_anim,p_weight,p_time,switched,p_seek,p_filter,p_reverse_weight); - _process_node(mn->inputs[1].node,r_prev_anim,p_weight*mn->amount,p_time,switched,p_seek,p_filter,p_reverse_weight); + float rem = _process_node(mn->inputs[0].node,r_prev_anim,p_weight,p_time,p_seek,p_filter,p_reverse_weight); + _process_node(mn->inputs[1].node,r_prev_anim,p_weight*mn->amount,p_time,p_seek,p_filter,p_reverse_weight); return rem; } break; @@ -593,12 +604,12 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode float rem; if (!bn->filter.empty()) { - rem = _process_node(bn->inputs[0].node,r_prev_anim,p_weight*(1.0-bn->value),p_time,switched,p_seek,&bn->filter,p_weight); - _process_node(bn->inputs[1].node,r_prev_anim,p_weight*bn->value,p_time,switched,p_seek,&bn->filter,-1); + rem = _process_node(bn->inputs[0].node,r_prev_anim,p_weight*(1.0-bn->value),p_time,p_seek,&bn->filter,p_weight); + _process_node(bn->inputs[1].node,r_prev_anim,p_weight*bn->value,p_time,p_seek,&bn->filter,-1); } else { - rem = _process_node(bn->inputs[0].node,r_prev_anim,p_weight*(1.0-bn->value),p_time,switched,p_seek,p_filter,p_reverse_weight*(1.0-bn->value)); - _process_node(bn->inputs[1].node,r_prev_anim,p_weight*bn->value,p_time,switched,p_seek,p_filter,p_reverse_weight*bn->value); + rem = _process_node(bn->inputs[0].node,r_prev_anim,p_weight*(1.0-bn->value),p_time,p_seek,p_filter,p_reverse_weight*(1.0-bn->value)); + _process_node(bn->inputs[1].node,r_prev_anim,p_weight*bn->value,p_time,p_seek,p_filter,p_reverse_weight*bn->value); } return rem; @@ -618,19 +629,19 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode upper_blend = bn->value; } - rem = _process_node(bn->inputs[1].node,r_prev_anim,p_weight*blend,p_time,switched,p_seek,p_filter,p_reverse_weight*blend); - _process_node(bn->inputs[2].node,r_prev_anim,p_weight*upper_blend,p_time,switched,p_seek,p_filter,p_reverse_weight*upper_blend); - _process_node(bn->inputs[0].node,r_prev_anim,p_weight*lower_blend,p_time,switched,p_seek,p_filter,p_reverse_weight*lower_blend); + rem = _process_node(bn->inputs[1].node,r_prev_anim,p_weight*blend,p_time,p_seek,p_filter,p_reverse_weight*blend); + _process_node(bn->inputs[2].node,r_prev_anim,p_weight*upper_blend,p_time,p_seek,p_filter,p_reverse_weight*upper_blend); + _process_node(bn->inputs[0].node,r_prev_anim,p_weight*lower_blend,p_time,p_seek,p_filter,p_reverse_weight*lower_blend); return rem; } break; case NODE_BLEND4: { Blend4Node *bn = static_cast<Blend4Node*>(nb); - float rem = _process_node(bn->inputs[0].node,r_prev_anim,p_weight*(1.0-bn->value.x),p_time,switched,p_seek,p_filter,p_reverse_weight*(1.0-bn->value.x)); - _process_node(bn->inputs[1].node,r_prev_anim,p_weight*bn->value.x,p_time,switched,p_seek,p_filter,p_reverse_weight*bn->value.x); - float rem2 = _process_node(bn->inputs[2].node,r_prev_anim,p_weight*(1.0-bn->value.y),p_time,switched,p_seek,p_filter,p_reverse_weight*(1.0-bn->value.y)); - _process_node(bn->inputs[3].node,r_prev_anim,p_weight*bn->value.y,p_time,switched,p_seek,p_filter,p_reverse_weight*bn->value.y); + float rem = _process_node(bn->inputs[0].node,r_prev_anim,p_weight*(1.0-bn->value.x),p_time,p_seek,p_filter,p_reverse_weight*(1.0-bn->value.x)); + _process_node(bn->inputs[1].node,r_prev_anim,p_weight*bn->value.x,p_time,p_seek,p_filter,p_reverse_weight*bn->value.x); + float rem2 = _process_node(bn->inputs[2].node,r_prev_anim,p_weight*(1.0-bn->value.y),p_time,p_seek,p_filter,p_reverse_weight*(1.0-bn->value.y)); + _process_node(bn->inputs[3].node,r_prev_anim,p_weight*bn->value.y,p_time,p_seek,p_filter,p_reverse_weight*bn->value.y); return MAX(rem,rem2); @@ -639,9 +650,9 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode TimeScaleNode *tsn = static_cast<TimeScaleNode*>(nb); float rem; if (p_seek) - rem = _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time,switched,true,p_filter,p_reverse_weight); + rem = _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time,true,p_filter,p_reverse_weight); else - rem = _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time*tsn->scale,switched,false,p_filter,p_reverse_weight); + rem = _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time*tsn->scale,false,p_filter,p_reverse_weight); if (tsn->scale == 0) return INFINITY; else @@ -651,68 +662,58 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode case NODE_TIMESEEK: { TimeSeekNode *tsn = static_cast<TimeSeekNode*>(nb); - if (tsn->seek_pos>=0) { + if (tsn->seek_pos>=0 && !p_seek) { - float res = _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,tsn->seek_pos,switched,true,p_filter,p_reverse_weight); - tsn->seek_pos=-1; - return res; + p_time = tsn->seek_pos; + p_seek = true; + } + tsn->seek_pos=-1; - } else - return _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time,switched,p_seek); + return _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time,p_seek, p_filter, p_reverse_weight); } break; case NODE_TRANSITION: { TransitionNode *tn = static_cast<TransitionNode*>(nb); - if (tn->prev<0) { + if (tn->prev<0) { // process current animation, check for transition - float rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,p_weight,p_time,switched,p_seek,p_filter,p_reverse_weight); + float rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,p_weight,p_time,p_seek,p_filter,p_reverse_weight); if (p_seek) tn->time=p_time; else tn->time+=p_time; - if (tn->input_data[tn->current].auto_advance && rem < tn->xfade) { + 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()); } return rem; - } else { + } else { // cross-fading from tn->prev to tn->current float blend = tn->xfade? (tn->prev_xfading/tn->xfade) : 1; float rem; - if (!p_seek && tn->switched) { //just switched + if (!p_seek && tn->switched) { //just switched, seek to start of current - rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,p_weight*(1.0-blend),0,true,true,p_filter,p_reverse_weight*(1.0-blend)); + rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,p_weight*(1.0-blend),0,true,p_filter,p_reverse_weight*(1.0-blend)); } else { - rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,p_weight*(1.0-blend),p_time,switched,p_seek,p_filter,p_reverse_weight*(1.0-blend)); + rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,p_weight*(1.0-blend),p_time,p_seek,p_filter,p_reverse_weight*(1.0-blend)); } tn->switched=false; - //if (!p_seek) - - - if (p_seek) { - _process_node(tn->inputs[tn->prev].node,r_prev_anim,p_weight*blend,0,true,false,p_filter,p_reverse_weight*blend); + if (p_seek) { // don't seek prev animation + _process_node(tn->inputs[tn->prev].node,r_prev_anim,p_weight*blend,0,false,p_filter,p_reverse_weight*blend); tn->time=p_time; } else { - _process_node(tn->inputs[tn->prev].node,r_prev_anim,p_weight*blend,p_time,switched,false,p_filter,p_reverse_weight*blend); + _process_node(tn->inputs[tn->prev].node,r_prev_anim,p_weight*blend,p_time,false,p_filter,p_reverse_weight*blend); tn->time+=p_time; tn->prev_xfading-=p_time; if (tn->prev_xfading<0) { @@ -749,10 +750,10 @@ void AnimationTreePlayer::_process_animation(float p_delta) { AnimationNode *prev=NULL; if (reset_request) { - _process_node(out_name,&prev, 1.0, 0, true, true ); + _process_node(out_name,&prev, 1.0, 0, true); reset_request=false; } else - _process_node(out_name,&prev, 1.0, p_delta, false, false ); + _process_node(out_name,&prev, 1.0, p_delta); if (dirty_caches) { //some animation changed.. ignore this pass @@ -775,9 +776,10 @@ void AnimationTreePlayer::_process_animation(float p_delta) { t.scale.y=0; t.scale.z=0; - Variant value = t.node->get(t.property); - value.zero(); - t.node->set(t.property, value); + t.value = t.object->get(t.property); + t.value.zero(); + + t.skip = false; } @@ -824,18 +826,11 @@ void AnimationTreePlayer::_process_animation(float p_delta) { case Animation::TYPE_VALUE: { ///< Set a value in a property, can be interpolated. if (a->value_track_is_continuous(tr.local_track)) { - Variant blended, value = a->value_track_interpolate(tr.local_track,anim_list->time); - Variant::blend(tr.track->node->get(tr.track->property),value,blend,blended); - tr.track->node->set(tr.track->property,blended); + Variant value = a->value_track_interpolate(tr.local_track,anim_list->time); + Variant::blend(tr.track->value,value,blend,tr.track->value); } else { - - List<int> indices; - a->value_track_get_key_indices(tr.local_track,anim_list->time,anim_list->step,&indices); - for(List<int>::Element *E=indices.front();E;E=E->next()) { - - Variant value = a->track_get_key_value(tr.local_track,E->get()); - tr.track->node->set(tr.track->property,value); - } + int index = a->track_find_key(tr.local_track,anim_list->time); + tr.track->value = a->track_get_key_value(tr.local_track, index); } } break; case Animation::TYPE_METHOD: { ///< Call any method on a specific node. @@ -847,7 +842,7 @@ void AnimationTreePlayer::_process_animation(float p_delta) { StringName method = a->method_track_get_name(tr.local_track,E->get()); Vector<Variant> args=a->method_track_get_params(tr.local_track,E->get()); args.resize(VARIANT_ARG_MAX); - tr.track->node->call(method,args[0],args[1],args[2],args[3],args[4]); + tr.track->object->call(method,args[0],args[1],args[2],args[3],args[4]); } } break; } @@ -864,11 +859,13 @@ void AnimationTreePlayer::_process_animation(float p_delta) { Track &t = E->get(); - if (!t.node) + if (t.skip || !t.object) continue; - if(t.property) // value track; was applied in step 2 + if(t.property) { // value track + t.object->set(t.property,t.value); continue; + } Transform xform; xform.basis=t.rot; @@ -993,6 +990,24 @@ void AnimationTreePlayer::animation_node_set_master_animation(const StringName& } +void AnimationTreePlayer::animation_node_set_filter_path(const StringName& p_node,const NodePath& p_track_path,bool p_filter) { + + GET_NODE( NODE_ANIMATION, AnimationNode ); + + if (p_filter) + n->filter[p_track_path]=true; + else + n->filter.erase(p_track_path); + +} + +void AnimationTreePlayer::animation_node_set_get_filtered_paths(const StringName& p_node,List<NodePath> *r_paths) const{ + + GET_NODE( NODE_ANIMATION, AnimationNode ); + + n->filter.get_key_list(r_paths); +} + void AnimationTreePlayer::oneshot_node_set_fadein_time(const StringName& p_node,float p_time) { GET_NODE( NODE_ONESHOT, OneShotNode ); @@ -1158,21 +1173,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); } @@ -1217,6 +1235,12 @@ String AnimationTreePlayer::animation_node_get_master_animation(const StringName } +bool AnimationTreePlayer::animation_node_is_path_filtered(const StringName& p_node,const NodePath& p_path) const { + + GET_NODE_V(NODE_ANIMATION, AnimationNode, 0 ); + return n->filter.has(p_path); +} + float AnimationTreePlayer::oneshot_node_get_fadein_time(const StringName& p_node) const { @@ -1500,7 +1524,8 @@ AnimationTreePlayer::Track* AnimationTreePlayer::_find_track(const NodePath& p_p Node *parent=get_node(base_path); ERR_FAIL_COND_V(!parent,NULL); - Node *child=parent->get_node(p_path); + RES resource; + Node *child=parent->get_node_and_resource(p_path,resource); if (!child) { String err = "Animation track references unknown Node: '"+String(p_path)+"'."; WARN_PRINT(err.ascii().get_data()); @@ -1528,7 +1553,7 @@ AnimationTreePlayer::Track* AnimationTreePlayer::_find_track(const NodePath& p_p Track tr; tr.id=id; - tr.node=child; + tr.object=resource.is_valid()?(Object*)resource.ptr():(Object*)child; tr.skeleton=child->cast_to<Skeleton>(); tr.spatial=child->cast_to<Spatial>(); tr.bone_idx=bone_idx; @@ -1606,6 +1631,7 @@ void AnimationTreePlayer::set_active(bool p_active) { active = p_active; processing = active; + reset_request = p_active; _set_process(processing, true); } @@ -1623,7 +1649,7 @@ AnimationTreePlayer::ConnectError AnimationTreePlayer::get_last_error() const { void AnimationTreePlayer::reset() { - reset_request=false; + reset_request=true; } @@ -1755,6 +1781,7 @@ void AnimationTreePlayer::_bind_methods() { ObjectTypeDB::bind_method(_MD("animation_node_set_master_animation","id","source"),&AnimationTreePlayer::animation_node_set_master_animation); ObjectTypeDB::bind_method(_MD("animation_node_get_master_animation","id"),&AnimationTreePlayer::animation_node_get_master_animation); + ObjectTypeDB::bind_method(_MD("animation_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::animation_node_set_filter_path); ObjectTypeDB::bind_method(_MD("oneshot_node_set_fadein_time","id","time_sec"),&AnimationTreePlayer::oneshot_node_set_fadein_time); ObjectTypeDB::bind_method(_MD("oneshot_node_get_fadein_time","id"),&AnimationTreePlayer::oneshot_node_get_fadein_time); @@ -1860,12 +1887,11 @@ AnimationTreePlayer::AnimationTreePlayer() { out_name="out"; out->pos=Point2(40,40); node_map.insert( out_name , out); - AnimationProcessMode animation_process_mode; animation_process_mode = ANIMATION_PROCESS_IDLE; processing = false; active=false; dirty_caches=true; - reset_request=false; + reset_request=true; last_error=CONNECT_INCOMPLETE; base_path=String(".."); } diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h index 0fec9a9551..dae891b5ce 100644 --- a/scene/animation/animation_tree_player.h +++ b/scene/animation/animation_tree_player.h @@ -33,7 +33,6 @@ #include "scene/resources/animation.h" #include "scene/3d/spatial.h" #include "scene/3d/skeleton.h" -#include "scene/main/misc.h" #include "animation_player.h" @@ -99,7 +98,7 @@ private: struct Track { uint32_t id; - Node *node; + Object *object; Spatial* spatial; Skeleton *skeleton; int bone_idx; @@ -109,6 +108,9 @@ private: Quat rot; Vector3 scale; + Variant value; + + bool skip; }; @@ -160,6 +162,9 @@ private: float step; String from; bool skip; + + HashMap<NodePath,bool> filter; + AnimationNode() { type=NODE_ANIMATION; next=NULL; last_version=0; skip=false; } }; @@ -246,6 +251,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); }; @@ -267,7 +273,7 @@ private: Map<StringName,NodeBase*> node_map; // return time left to finish animation - float _process_node(const StringName& p_node,AnimationNode **r_prev_anim, float p_weight,float p_step, bool switched, bool p_seek=false,const HashMap<NodePath,bool> *p_filter=NULL, float p_reverse_weight=0); + float _process_node(const StringName& p_node,AnimationNode **r_prev_anim, float p_weight,float p_step, bool p_seek=false,const HashMap<NodePath,bool> *p_filter=NULL, float p_reverse_weight=0); void _process_animation(float p_delta); bool reset_request; @@ -307,6 +313,10 @@ public: void animation_node_set_master_animation(const StringName& p_node,const String& p_master_animation); String animation_node_get_master_animation(const StringName& p_node) const; + void animation_node_set_filter_path(const StringName& p_node,const NodePath& p_filter,bool p_enable); + void animation_node_set_get_filtered_paths(const StringName& p_node,List<NodePath> *r_paths) const; + bool animation_node_is_path_filtered(const StringName& p_node,const NodePath& p_path) const; + /* ONE SHOT NODE */ void oneshot_node_set_fadein_time(const StringName& p_node,float p_time); diff --git a/scene/animation/transitioner.cpp b/scene/animation/transitioner.cpp deleted file mode 100644 index adcf73d489..0000000000 --- a/scene/animation/transitioner.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/*************************************************************************/ -/* transitioner.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "transitioner.h" -/* -Transitioner::Transitioner() -{ -} -*/ diff --git a/scene/animation/transitioner.h b/scene/animation/transitioner.h deleted file mode 100644 index 8b7ec4f3fa..0000000000 --- a/scene/animation/transitioner.h +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************/ -/* transitioner.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef TRANSITIONER_H -#define TRANSITIONER_H - -/* -class Transitioner : public Node { - OBJ_TYPE(Transitioner, Node); -public: - enum Interpolation { - INTERPOLATION_NEAREST, - INTERPOLATION_LINEAR, - INTERPOLATION_CUBIC - }; - - enum TransitionType { - TYPE_PROPERTY, - TYPE_METHOD, - TYPE_TRANSITION - - }; - - - void create_transition(const String& p_transition, TransitionType p_type); - void transition_set_target(const NodePath& p_node,const String& p_target); - TransitionType transition_get_type() const; - void transition_add_key(const String& p_transition,float p_time, const Variant& p_key); - int transition_get_key_count(const String& p_transition) const; - Variant transition_get_key_time(const String& p_transition.int p_key_index) const - Variant transition_get_key(const String& p_transition,int p_key_index) const; - - void transition_remove_key(const String& p_transition, int p_key_index); - void transition_clear_keys(const String& p_transition); - void remove_transition(const String& p_transition); - - void transition_ - - - Transitioner(); -}; -*/ -#endif // TRANSITIONER_H diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 7edd57603b..6f6f5d3aff 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -1045,6 +1045,7 @@ bool Tween::interpolate_property(Object *p_object if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); ERR_FAIL_COND_V(p_object == NULL, false); + ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false); ERR_FAIL_COND_V(p_initial_val.get_type() != p_final_val.get_type(), false); ERR_FAIL_COND_V(p_times_in_sec <= 0, false); ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false); @@ -1104,6 +1105,7 @@ bool Tween::interpolate_method(Object *p_object if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); ERR_FAIL_COND_V(p_object == NULL, false); + ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false); ERR_FAIL_COND_V(p_initial_val.get_type() != p_final_val.get_type(), false); ERR_FAIL_COND_V(p_times_in_sec <= 0, false); ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false); @@ -1154,7 +1156,9 @@ bool Tween::interpolate_callback(Object *p_object ); return true; } + ERR_FAIL_COND_V(p_object == NULL, false); + ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false); ERR_FAIL_COND_V(p_times_in_sec < 0, false); ERR_EXPLAIN("Object has no callback named: %s" + p_callback); @@ -1219,6 +1223,7 @@ bool Tween::interpolate_deferred_callback(Object *p_object return true; } ERR_FAIL_COND_V(p_object == NULL, false); + ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false); ERR_FAIL_COND_V(p_times_in_sec < 0, false); ERR_EXPLAIN("Object has no callback named: %s" + p_callback); @@ -1291,7 +1296,9 @@ bool Tween::follow_property(Object *p_object if(p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t(); ERR_FAIL_COND_V(p_object == NULL, false); + ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false); ERR_FAIL_COND_V(p_target == NULL, false); + ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_target), false); ERR_FAIL_COND_V(p_times_in_sec <= 0, false); ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false); ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false); @@ -1357,7 +1364,9 @@ bool Tween::follow_method(Object *p_object if(p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t(); ERR_FAIL_COND_V(p_object == NULL, false); + ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false); ERR_FAIL_COND_V(p_target == NULL, false); + ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_target), false); ERR_FAIL_COND_V(p_times_in_sec <= 0, false); ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false); ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false); @@ -1424,7 +1433,9 @@ bool Tween::targeting_property(Object *p_object if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); ERR_FAIL_COND_V(p_object == NULL, false); + ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false); ERR_FAIL_COND_V(p_initial == NULL, false); + ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_initial), false); ERR_FAIL_COND_V(p_times_in_sec <= 0, false); ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false); ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false); @@ -1495,7 +1506,9 @@ bool Tween::targeting_method(Object *p_object if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); ERR_FAIL_COND_V(p_object == NULL, false); + ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false); ERR_FAIL_COND_V(p_initial == NULL, false); + ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_initial), false); ERR_FAIL_COND_V(p_times_in_sec <= 0, false); ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false); ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false); diff --git a/scene/animation/tween_interpolaters.cpp b/scene/animation/tween_interpolaters.cpp index 80588d643e..058a7f12bc 100644 --- a/scene/animation/tween_interpolaters.cpp +++ b/scene/animation/tween_interpolaters.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* tween.cpp */ +/* tween_interpolaters.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ |