diff options
Diffstat (limited to 'scene/animation/animation_player.cpp')
| -rw-r--r-- | scene/animation/animation_player.cpp | 127 |
1 files changed, 65 insertions, 62 deletions
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 30af9b0094..8b81c45597 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -36,7 +36,7 @@ bool AnimationPlayer::_set(const StringName& p_name, const Variant& p_value) { String name=p_name; if (p_name==SceneStringNames::get_singleton()->playback_speed || p_name==SceneStringNames::get_singleton()->speed) { //bw compatibility - set_speed(p_value); + set_speed_scale(p_value); } else if (p_name==SceneStringNames::get_singleton()->playback_active) { set_active(p_value); @@ -214,14 +214,14 @@ void AnimationPlayer::_notification(int p_what) { set_autoplay(""); //this line is the fix for autoplay issues with animatio } } break; - case NOTIFICATION_PROCESS: { + case NOTIFICATION_INTERNAL_PROCESS: { if (animation_process_mode==ANIMATION_PROCESS_FIXED) break; if (processing) _animation_process( get_process_delta_time() ); } break; - case NOTIFICATION_FIXED_PROCESS: { + case NOTIFICATION_INTERNAL_FIXED_PROCESS: { if (animation_process_mode==ANIMATION_PROCESS_IDLE) break; @@ -269,8 +269,8 @@ void AnimationPlayer::_generate_node_caches(AnimationData* p_anim) { } { - if (!child->is_connected("exit_tree",this,"_node_removed")) - child->connect("exit_tree",this,"_node_removed",make_binds(child),CONNECT_ONESHOT); + if (!child->is_connected("tree_exited",this,"_node_removed")) + child->connect("tree_exited",this,"_node_removed",make_binds(child),CONNECT_ONESHOT); } TrackNodeCacheKey key; @@ -426,8 +426,10 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p Variant value=a->value_track_interpolate(i,p_time); //thanks to trigger mode, this should be solved now.. - //if (p_delta==0 && value.get_type()==Variant::STRING) - // continue; // doing this with strings is messy, should find another way + /* + if (p_delta==0 && value.get_type()==Variant::STRING) + continue; // doing this with strings is messy, should find another way + */ if (pa->accum_pass!=accum_pass) { ERR_CONTINUE( cache_update_prop_size >= NODE_CACHE_UPDATE_MAX ); cache_update_prop[cache_update_prop_size++]=pa; @@ -465,7 +467,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p ERR_PRINTS("Position key at time "+rtos(p_time)+" in Animation Track '"+String(pa->owner->path)+"' not of type Vector2()"); } #endif - static_cast<Node2D*>(pa->object)->set_pos(value); + static_cast<Node2D*>(pa->object)->set_position(value); } break; case SP_NODE2D_ROT: { #ifdef DEBUG_ENABLED @@ -474,7 +476,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p } #endif - static_cast<Node2D*>(pa->object)->set_rot(Math::deg2rad(value)); + static_cast<Node2D*>(pa->object)->set_rotation(Math::deg2rad(value)); } break; case SP_NODE2D_SCALE: { #ifdef DEBUG_ENABLED @@ -679,7 +681,7 @@ void AnimationPlayer::_animation_update_transforms() { ERR_PRINTS("Position key at time "+rtos(playback.current.pos)+" in Animation '"+get_current_animation()+"', Track '"+String(pa->owner->path)+"' not of type Vector2()"); } #endif - static_cast<Node2D*>(pa->object)->set_pos(pa->value_accum); + static_cast<Node2D*>(pa->object)->set_position(pa->value_accum); } break; case SP_NODE2D_ROT: { #ifdef DEBUG_ENABLED @@ -688,7 +690,7 @@ void AnimationPlayer::_animation_update_transforms() { } #endif - static_cast<Node2D*>(pa->object)->set_rot(Math::deg2rad(pa->value_accum)); + static_cast<Node2D*>(pa->object)->set_rotation(Math::deg2rad(pa->value_accum)); } break; case SP_NODE2D_SCALE: { #ifdef DEBUG_ENABLED @@ -713,7 +715,7 @@ void AnimationPlayer::_animation_process(float p_delta) { -// bool any_active=false; + //bool any_active=false; if (playback.current.from) { @@ -733,7 +735,7 @@ void AnimationPlayer::_animation_process(float p_delta) { playing = false; _set_process(false); end_notify=false; - emit_signal(SceneStringNames::get_singleton()->finished); + emit_signal(SceneStringNames::get_singleton()->animation_finished,playback.assigned); } } @@ -1082,13 +1084,13 @@ void AnimationPlayer::stop_all() { } -void AnimationPlayer::set_speed(float p_speed) { +void AnimationPlayer::set_speed_scale(float p_speed) { speed_scale=p_speed; } -float AnimationPlayer::get_speed() const { +float AnimationPlayer::get_speed_scale() const { return speed_scale; } @@ -1231,8 +1233,8 @@ void AnimationPlayer::_set_process(bool p_process,bool p_force) { switch(animation_process_mode) { - case ANIMATION_PROCESS_FIXED: set_fixed_process(p_process && active); break; - case ANIMATION_PROCESS_IDLE: set_process(p_process && active); break; + case ANIMATION_PROCESS_FIXED: set_fixed_process_internal(p_process && active); break; + case ANIMATION_PROCESS_IDLE: set_process_internal(p_process && active); break; } processing=p_process; @@ -1291,68 +1293,69 @@ void AnimationPlayer::get_argument_options(const StringName& p_function,int p_id void AnimationPlayer::_bind_methods() { - ObjectTypeDB::bind_method(_MD("_node_removed"),&AnimationPlayer::_node_removed); - ObjectTypeDB::bind_method(_MD("_animation_changed"),&AnimationPlayer::_animation_changed); + ClassDB::bind_method(_MD("_node_removed"),&AnimationPlayer::_node_removed); + ClassDB::bind_method(_MD("_animation_changed"),&AnimationPlayer::_animation_changed); - ObjectTypeDB::bind_method(_MD("add_animation","name","animation:Animation"),&AnimationPlayer::add_animation); - ObjectTypeDB::bind_method(_MD("remove_animation","name"),&AnimationPlayer::remove_animation); - ObjectTypeDB::bind_method(_MD("rename_animation","name","newname"),&AnimationPlayer::rename_animation); - ObjectTypeDB::bind_method(_MD("has_animation","name"),&AnimationPlayer::has_animation); - ObjectTypeDB::bind_method(_MD("get_animation:Animation","name"),&AnimationPlayer::get_animation); - ObjectTypeDB::bind_method(_MD("get_animation_list"),&AnimationPlayer::_get_animation_list); + ClassDB::bind_method(_MD("add_animation","name","animation:Animation"),&AnimationPlayer::add_animation); + ClassDB::bind_method(_MD("remove_animation","name"),&AnimationPlayer::remove_animation); + ClassDB::bind_method(_MD("rename_animation","name","newname"),&AnimationPlayer::rename_animation); + ClassDB::bind_method(_MD("has_animation","name"),&AnimationPlayer::has_animation); + ClassDB::bind_method(_MD("get_animation:Animation","name"),&AnimationPlayer::get_animation); + ClassDB::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); + ClassDB::bind_method(_MD("animation_set_next", "anim_from", "anim_to"), &AnimationPlayer::animation_set_next); + ClassDB::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); + ClassDB::bind_method(_MD("set_blend_time","anim_from","anim_to","sec"),&AnimationPlayer::set_blend_time); + ClassDB::bind_method(_MD("get_blend_time","anim_from","anim_to"),&AnimationPlayer::get_blend_time); - ObjectTypeDB::bind_method(_MD("set_default_blend_time","sec"),&AnimationPlayer::set_default_blend_time); - ObjectTypeDB::bind_method(_MD("get_default_blend_time"),&AnimationPlayer::get_default_blend_time); + ClassDB::bind_method(_MD("set_default_blend_time","sec"),&AnimationPlayer::set_default_blend_time); + ClassDB::bind_method(_MD("get_default_blend_time"),&AnimationPlayer::get_default_blend_time); - ObjectTypeDB::bind_method(_MD("play","name","custom_blend","custom_speed","from_end"),&AnimationPlayer::play,DEFVAL(""),DEFVAL(-1),DEFVAL(1.0),DEFVAL(false)); - ObjectTypeDB::bind_method(_MD("play_backwards","name","custom_blend"),&AnimationPlayer::play_backwards,DEFVAL(""),DEFVAL(-1)); - ObjectTypeDB::bind_method(_MD("stop","reset"),&AnimationPlayer::stop,DEFVAL(true)); - ObjectTypeDB::bind_method(_MD("stop_all"),&AnimationPlayer::stop_all); - ObjectTypeDB::bind_method(_MD("is_playing"),&AnimationPlayer::is_playing); - ObjectTypeDB::bind_method(_MD("set_current_animation","anim"),&AnimationPlayer::set_current_animation); - ObjectTypeDB::bind_method(_MD("get_current_animation"),&AnimationPlayer::get_current_animation); - ObjectTypeDB::bind_method(_MD("queue","name"),&AnimationPlayer::queue); - ObjectTypeDB::bind_method(_MD("clear_queue"),&AnimationPlayer::clear_queue); + ClassDB::bind_method(_MD("play","name","custom_blend","custom_speed","from_end"),&AnimationPlayer::play,DEFVAL(""),DEFVAL(-1),DEFVAL(1.0),DEFVAL(false)); + ClassDB::bind_method(_MD("play_backwards","name","custom_blend"),&AnimationPlayer::play_backwards,DEFVAL(""),DEFVAL(-1)); + ClassDB::bind_method(_MD("stop","reset"),&AnimationPlayer::stop,DEFVAL(true)); + ClassDB::bind_method(_MD("stop_all"),&AnimationPlayer::stop_all); + ClassDB::bind_method(_MD("is_playing"),&AnimationPlayer::is_playing); + ClassDB::bind_method(_MD("set_current_animation","anim"),&AnimationPlayer::set_current_animation); + ClassDB::bind_method(_MD("get_current_animation"),&AnimationPlayer::get_current_animation); + ClassDB::bind_method(_MD("queue","name"),&AnimationPlayer::queue); + ClassDB::bind_method(_MD("clear_queue"),&AnimationPlayer::clear_queue); - ObjectTypeDB::bind_method(_MD("set_active","active"),&AnimationPlayer::set_active); - ObjectTypeDB::bind_method(_MD("is_active"),&AnimationPlayer::is_active); + ClassDB::bind_method(_MD("set_active","active"),&AnimationPlayer::set_active); + ClassDB::bind_method(_MD("is_active"),&AnimationPlayer::is_active); - ObjectTypeDB::bind_method(_MD("set_speed","speed"),&AnimationPlayer::set_speed); - ObjectTypeDB::bind_method(_MD("get_speed"),&AnimationPlayer::get_speed); + ClassDB::bind_method(_MD("set_speed_scale","speed"),&AnimationPlayer::set_speed_scale); + ClassDB::bind_method(_MD("get_speed_scale"),&AnimationPlayer::get_speed_scale); - ObjectTypeDB::bind_method(_MD("set_autoplay","name"),&AnimationPlayer::set_autoplay); - ObjectTypeDB::bind_method(_MD("get_autoplay"),&AnimationPlayer::get_autoplay); + ClassDB::bind_method(_MD("set_autoplay","name"),&AnimationPlayer::set_autoplay); + ClassDB::bind_method(_MD("get_autoplay"),&AnimationPlayer::get_autoplay); - ObjectTypeDB::bind_method(_MD("set_root","path"),&AnimationPlayer::set_root); - ObjectTypeDB::bind_method(_MD("get_root"),&AnimationPlayer::get_root); + ClassDB::bind_method(_MD("set_root","path"),&AnimationPlayer::set_root); + ClassDB::bind_method(_MD("get_root"),&AnimationPlayer::get_root); - ObjectTypeDB::bind_method(_MD("seek","pos_sec","update"),&AnimationPlayer::seek,DEFVAL(false)); - ObjectTypeDB::bind_method(_MD("get_pos"),&AnimationPlayer::get_current_animation_pos); + ClassDB::bind_method(_MD("seek","pos_sec","update"),&AnimationPlayer::seek,DEFVAL(false)); + ClassDB::bind_method(_MD("get_pos"),&AnimationPlayer::get_current_animation_pos); - ObjectTypeDB::bind_method(_MD("find_animation","animation:Animation"),&AnimationPlayer::find_animation); + ClassDB::bind_method(_MD("find_animation","animation:Animation"),&AnimationPlayer::find_animation); - ObjectTypeDB::bind_method(_MD("clear_caches"),&AnimationPlayer::clear_caches); + ClassDB::bind_method(_MD("clear_caches"),&AnimationPlayer::clear_caches); - ObjectTypeDB::bind_method(_MD("set_animation_process_mode","mode"),&AnimationPlayer::set_animation_process_mode); - ObjectTypeDB::bind_method(_MD("get_animation_process_mode"),&AnimationPlayer::get_animation_process_mode); + ClassDB::bind_method(_MD("set_animation_process_mode","mode"),&AnimationPlayer::set_animation_process_mode); + ClassDB::bind_method(_MD("get_animation_process_mode"),&AnimationPlayer::get_animation_process_mode); - ObjectTypeDB::bind_method(_MD("get_current_animation_pos"),&AnimationPlayer::get_current_animation_pos); - ObjectTypeDB::bind_method(_MD("get_current_animation_length"),&AnimationPlayer::get_current_animation_length); + ClassDB::bind_method(_MD("get_current_animation_pos"),&AnimationPlayer::get_current_animation_pos); + ClassDB::bind_method(_MD("get_current_animation_length"),&AnimationPlayer::get_current_animation_length); - ObjectTypeDB::bind_method(_MD("advance","delta"),&AnimationPlayer::advance); + ClassDB::bind_method(_MD("advance","delta"),&AnimationPlayer::advance); - ADD_PROPERTY( PropertyInfo( Variant::INT, "playback/process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_animation_process_mode"), _SCS("get_animation_process_mode")); - ADD_PROPERTY( PropertyInfo( Variant::REAL, "playback/default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01"), _SCS("set_default_blend_time"), _SCS("get_default_blend_time")); - ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "root/root"), _SCS("set_root"), _SCS("get_root")); + ADD_GROUP("Playback","playback_"); + ADD_PROPERTY( PropertyInfo( Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_animation_process_mode"), _SCS("get_animation_process_mode")); + ADD_PROPERTY( PropertyInfo( Variant::REAL, "playback_default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01"), _SCS("set_default_blend_time"), _SCS("get_default_blend_time")); + ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "root_node"), _SCS("set_root"), _SCS("get_root")); - ADD_SIGNAL( MethodInfo("finished") ); + ADD_SIGNAL( MethodInfo("animation_finished", PropertyInfo(Variant::STRING,"name")) ); ADD_SIGNAL( MethodInfo("animation_changed", PropertyInfo(Variant::STRING,"old_name"), PropertyInfo(Variant::STRING,"new_name")) ); ADD_SIGNAL( MethodInfo("animation_started", PropertyInfo(Variant::STRING,"name")) ); |