diff options
Diffstat (limited to 'scene/animation')
| -rw-r--r-- | scene/animation/SCsub | 4 | ||||
| -rw-r--r-- | scene/animation/animation_cache.cpp | 14 | ||||
| -rw-r--r-- | scene/animation/animation_cache.h | 4 | ||||
| -rw-r--r-- | scene/animation/animation_player.cpp | 131 | ||||
| -rw-r--r-- | scene/animation/animation_player.h | 13 | ||||
| -rw-r--r-- | scene/animation/animation_tree_player.cpp | 337 | ||||
| -rw-r--r-- | scene/animation/animation_tree_player.h | 17 | ||||
| -rw-r--r-- | scene/animation/transitioner.cpp | 34 | ||||
| -rw-r--r-- | scene/animation/transitioner.h | 68 | ||||
| -rw-r--r-- | scene/animation/tween.cpp | 261 | ||||
| -rw-r--r-- | scene/animation/tween.h | 27 | ||||
| -rw-r--r-- | scene/animation/tween_interpolaters.cpp | 4 |
12 files changed, 446 insertions, 468 deletions
diff --git a/scene/animation/SCsub b/scene/animation/SCsub index bbe59b3054..bf9125be7f 100644 --- a/scene/animation/SCsub +++ b/scene/animation/SCsub @@ -1,5 +1,7 @@ +#!/usr/bin/env python + Import('env') -env.add_source_files(env.scene_sources,"*.cpp") +env.add_source_files(env.scene_sources, "*.cpp") Export('env') diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp index b1123897b2..25ca74de9f 100644 --- a/scene/animation/animation_cache.cpp +++ b/scene/animation/animation_cache.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 */ @@ -59,7 +59,7 @@ void AnimationCache::_clear_cache() { while(connected_nodes.size()) { - connected_nodes.front()->get()->disconnect("exit_tree",this,"_node_exit_tree"); + connected_nodes.front()->get()->disconnect("tree_exited",this,"_node_exit_tree"); connected_nodes.erase(connected_nodes.front()); } path_cache.clear();; @@ -206,7 +206,7 @@ void AnimationCache::_update_cache() { if (!connected_nodes.has(path.node)) { connected_nodes.insert(path.node); - path.node->connect("exit_tree",this,"_node_exit_tree",Node::make_binds(path.node),CONNECT_ONESHOT); + path.node->connect("tree_exited",this,"_node_exit_tree",Node::make_binds(path.node),CONNECT_ONESHOT); } @@ -292,7 +292,7 @@ void AnimationCache::set_all(float p_time, float p_delta) { Vector3 loc,scale; Quat rot; animation->transform_track_interpolate(i,p_time,&loc,&rot,&scale); - Transform tr( Matrix3(rot), loc ); + Transform tr( Basis(rot), loc ); tr.basis.scale(scale); set_track_transform(i,tr); @@ -301,7 +301,7 @@ void AnimationCache::set_all(float p_time, float p_delta) { } break; case Animation::TYPE_VALUE: { - if (animation->value_track_is_continuous(i)) { + if (animation->value_track_get_update_mode(i)==Animation::UPDATE_CONTINUOUS || (animation->value_track_get_update_mode(i)==Animation::UPDATE_DISCRETE && p_delta==0)) { Variant v = animation->value_track_interpolate(i,p_time); set_track_value(i,v); } else { @@ -368,8 +368,8 @@ void AnimationCache::set_animation(const Ref<Animation>& p_animation) { void AnimationCache::_bind_methods() { - ObjectTypeDB::bind_method(_MD("_node_exit_tree"),&AnimationCache::_node_exit_tree); - ObjectTypeDB::bind_method(_MD("_animation_changed"),&AnimationCache::_animation_changed); + ClassDB::bind_method(_MD("_node_exit_tree"),&AnimationCache::_node_exit_tree); + ClassDB::bind_method(_MD("_animation_changed"),&AnimationCache::_animation_changed); } void AnimationCache::set_root(Node* p_root) { diff --git a/scene/animation/animation_cache.h b/scene/animation/animation_cache.h index c9b4ff298c..75e004c811 100644 --- a/scene/animation/animation_cache.h +++ b/scene/animation/animation_cache.h @@ -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 */ @@ -34,7 +34,7 @@ class AnimationCache : public Object { - OBJ_TYPE(AnimationCache,Object); + GDCLASS(AnimationCache,Object); struct Path { diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 2399bee539..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); @@ -174,7 +174,7 @@ void AnimationPlayer::_get_property_list( List<PropertyInfo> *p_list) const { hint+=E->get(); } - p_list->push_back( PropertyInfo( Variant::STRING, "playback/play", PROPERTY_HINT_ENUM, hint,PROPERTY_USAGE_EDITOR) ); + p_list->push_back( PropertyInfo( Variant::STRING, "playback/play", PROPERTY_HINT_ENUM, hint,PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_ANIMATE_AS_TRIGGER) ); p_list->push_back( PropertyInfo( Variant::BOOL, "playback/active", PROPERTY_HINT_NONE,"" ) ); p_list->push_back( PropertyInfo( Variant::REAL, "playback/speed", PROPERTY_HINT_RANGE, "-64,64,0.01") ); @@ -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; @@ -421,12 +421,15 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p TrackNodeCache::PropertyAnim *pa = &E->get(); - if (a->value_track_is_continuous(i) || p_delta==0) { //delta == 0 means seek + if (a->value_track_get_update_mode(i)==Animation::UPDATE_CONTINUOUS || (p_delta==0 && a->value_track_get_update_mode(i)==Animation::UPDATE_DISCRETE)) { //delta == 0 means seek 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 (pa->accum_pass!=accum_pass) { ERR_CONTINUE( cache_update_prop_size >= NODE_CACHE_UPDATE_MAX ); cache_update_prop[cache_update_prop_size++]=pa; @@ -437,11 +440,12 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p } - } else if (p_allow_discrete) { + } else if (p_allow_discrete && p_delta!=0) { List<int> indices; a->value_track_get_key_indices(i,p_time,p_delta,&indices); + for(List<int>::Element *F=indices.front();F;F=F->next()) { Variant value=a->track_get_key_value(i,F->get()); @@ -463,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 @@ -472,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 @@ -677,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 @@ -686,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 @@ -711,7 +715,7 @@ void AnimationPlayer::_animation_process(float p_delta) { -// bool any_active=false; + //bool any_active=false; if (playback.current.from) { @@ -731,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); } } @@ -1080,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; } @@ -1229,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; @@ -1289,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")) ); diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index 2ae3a0756c..41bae6c928 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -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 */ @@ -33,14 +33,13 @@ #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> */ class AnimationPlayer : public Node { - OBJ_TYPE( AnimationPlayer, Node ); + GDCLASS( AnimationPlayer, Node ); OBJ_CATEGORY("Animation Nodes"); public: @@ -209,11 +208,11 @@ private: void _node_removed(Node *p_node); // bind helpers - DVector<String> _get_animation_list() const { + PoolVector<String> _get_animation_list() const { List<StringName> animations; get_animation_list(&animations); - DVector<String> ret; + PoolVector<String> ret; while(animations.size()) { ret.push_back( animations.front()->get()); @@ -272,8 +271,8 @@ public: bool is_active() const; bool is_valid() const; - void set_speed(float p_speed); - float get_speed() const; + void set_speed_scale(float p_speed); + float get_speed_scale() const; void set_autoplay(const String& pname); String get_autoplay() const; diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp index 211c5961b0..c3a05240bb 100644 --- a/scene/animation/animation_tree_player.cpp +++ b/scene/animation/animation_tree_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 */ @@ -58,8 +58,8 @@ void AnimationTreePlayer::_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; @@ -214,7 +214,7 @@ bool AnimationTreePlayer::_set(const StringName& p_name, const Variant& p_value) StringName src = connections[i*3+0]; StringName dst = connections[i*3+1]; int dst_in = connections[i*3+2]; - connect(src,dst,dst_in); + connect_nodes(src,dst,dst_in); } set_active(data.get_valid("active")); @@ -416,8 +416,8 @@ void AnimationTreePlayer::_notification(int p_what) { if (!processing) { //make sure that a previous process state was not saved //only process if "processing" is set - set_fixed_process(false); - set_process(false); + set_fixed_process_internal(false); + set_process_internal(false); } } break; case NOTIFICATION_READY: { @@ -426,14 +426,14 @@ void AnimationTreePlayer::_notification(int p_what) { _update_sources(); } } break; - case NOTIFICATION_PROCESS: { + case NOTIFICATION_INTERNAL_PROCESS: { if (animation_process_mode==ANIMATION_PROCESS_FIXED) break; if (processing) _process_animation( get_process_delta_time() ); } break; - case NOTIFICATION_FIXED_PROCESS: { + case NOTIFICATION_INTERNAL_FIXED_PROCESS: { if (animation_process_mode==ANIMATION_PROCESS_IDLE) break; @@ -445,8 +445,44 @@ void AnimationTreePlayer::_notification(int p_what) { } +void AnimationTreePlayer::_compute_weights(float *p_fallback_weight, HashMap<NodePath,float> *p_weights, float p_coeff, const HashMap<NodePath,bool> *p_filter, float p_filtered_coeff) { -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) { + if (p_filter != NULL) { + + List<NodePath> key_list; + p_filter->get_key_list(&key_list); + + for (List<NodePath>::Element *E = key_list.front();E; E=E->next()) { + + if ((*p_filter)[E->get()]) { + + if (p_weights->has(E->get())) { + (*p_weights)[E->get()] *= p_filtered_coeff; + } else { + p_weights->set(E->get(), *p_fallback_weight * p_filtered_coeff); + } + + } else if (p_weights->has(E->get())) { + (*p_weights)[E->get()] *= p_coeff; + } + } + } + + List<NodePath> key_list; + p_weights->get_key_list(&key_list); + + for (List<NodePath>::Element *E = key_list.front();E;E=E->next()) { + if (p_filter == NULL || !p_filter->has(E->get())) { + (*p_weights)[E->get()] *= p_coeff; + } + } + + *p_fallback_weight *= p_coeff; + +} + + +float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode **r_prev_anim, float p_time, bool p_seek, float p_fallback_weight, HashMap<NodePath,float>* p_weights) { ERR_FAIL_COND_V(!node_map.has(p_node), 0); NodeBase *nb=node_map[p_node]; @@ -458,7 +494,9 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode case NODE_OUTPUT: { NodeOut *on = static_cast<NodeOut*>(nb); - return _process_node(on->inputs[0].node,r_prev_anim,p_weight,p_time,p_seek); + HashMap<NodePath, float> weights; + + return _process_node(on->inputs[0].node,r_prev_anim,p_time,p_seek, p_fallback_weight, &weights); } break; case NODE_ANIMATION: { @@ -468,10 +506,10 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode float rem = 0; if (!an->animation.is_null()) { - // float pos = an->time; -// float delta = p_time; + //float pos = an->time; + //float delta = p_time; - // const Animation *a = an->animation.operator->(); + //const Animation *a = an->animation.operator->(); if (p_seek) { an->time=p_time; @@ -494,15 +532,18 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode } an->skip=true; + for (List<AnimationNode::TrackRef>::Element *E=an->tref.front();E;E=E->next()) { 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)) { + if (an->filter.has(track_path) && an->filter[track_path]) { E->get().weight = 0; - E->get().track->skip = true; } else { - E->get().weight=p_weight; + if (p_weights->has(track_path)) { + float weight = (*p_weights)[track_path]; + E->get().weight = weight; + } else { + E->get().weight = p_fallback_weight; + } } if (E->get().weight>CMP_EPSILON) an->skip=false; @@ -531,7 +572,7 @@ 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,p_seek,p_filter,p_reverse_weight); + return _process_node(osn->inputs[0].node,r_prev_anim,p_time,p_seek, p_fallback_weight, p_weights); } float os_seek = p_seek; @@ -563,16 +604,14 @@ 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()) { - p_filter = &osn->filter; - p_reverse_weight = p_weight; - os_reverse_weight = -1; - } + HashMap<NodePath, float> os_weights(*p_weights); + float os_fallback_weight = p_fallback_weight; + _compute_weights(&p_fallback_weight, p_weights, osn->mix?1.0 : 1.0 - blend, &osn->filter, 1.0); + _compute_weights(&os_fallback_weight, &os_weights, blend, &osn->filter, 0.0); - 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); + main_rem = _process_node(osn->inputs[0].node,r_prev_anim,p_time,p_seek, p_fallback_weight, p_weights); + os_rem = _process_node(osn->inputs[1].node,r_prev_anim,p_time,os_seek, os_fallback_weight, &os_weights); if (osn->start) { osn->remaining=os_rem; @@ -591,9 +630,11 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode case NODE_MIX: { MixNode *mn = static_cast<MixNode*>(nb); - - 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); + HashMap<NodePath, float> mn_weights(*p_weights); + float mn_fallback_weight = p_fallback_weight; + _compute_weights(&mn_fallback_weight, &mn_weights, mn->amount); + float rem = _process_node(mn->inputs[0].node,r_prev_anim, p_time,p_seek,p_fallback_weight,p_weights); + _process_node(mn->inputs[1].node,r_prev_anim,p_time,p_seek,mn_fallback_weight,&mn_weights); return rem; } break; @@ -601,16 +642,12 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode Blend2Node *bn = static_cast<Blend2Node*>(nb); - float rem; - if (!bn->filter.empty()) { - - 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,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); - } + HashMap<NodePath, float> bn_weights(*p_weights); + float bn_fallback_weight = p_fallback_weight; + _compute_weights(&p_fallback_weight,p_weights, 1.0 - bn->value, &bn->filter, 1.0); + _compute_weights(&bn_fallback_weight,&bn_weights, bn->value, &bn->filter, 0.0); + float rem = _process_node(bn->inputs[0].node,r_prev_anim,p_time,p_seek,p_fallback_weight,p_weights); + _process_node(bn->inputs[1].node,r_prev_anim,p_time,p_seek,bn_fallback_weight,&bn_weights); return rem; } break; @@ -629,19 +666,39 @@ 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,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); + HashMap<NodePath, float> upper_weights(*p_weights); + float upper_fallback_weight = p_fallback_weight; + HashMap<NodePath, float> lower_weights(*p_weights); + float lower_fallback_weight = p_fallback_weight; + _compute_weights(&upper_fallback_weight,&upper_weights, upper_blend); + _compute_weights(&p_fallback_weight,p_weights, blend); + _compute_weights(&lower_fallback_weight,&lower_weights, lower_blend); + + rem = _process_node(bn->inputs[1].node,r_prev_anim,p_time,p_seek,p_fallback_weight,p_weights); + _process_node(bn->inputs[0].node,r_prev_anim,p_time,p_seek,lower_fallback_weight,&lower_weights); + _process_node(bn->inputs[2].node,r_prev_anim,p_time,p_seek,upper_fallback_weight,&upper_weights); 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,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); + HashMap<NodePath, float> weights1(*p_weights); + float fallback_weight1 = p_fallback_weight; + HashMap<NodePath, float> weights2(*p_weights); + float fallback_weight2 = p_fallback_weight; + HashMap<NodePath, float> weights3(*p_weights); + float fallback_weight3 = p_fallback_weight; + + _compute_weights(&p_fallback_weight,p_weights, 1.0-bn->value.x); + _compute_weights(&fallback_weight1,&weights1, bn->value.x); + _compute_weights(&fallback_weight2,&weights2, 1.0-bn->value.y); + _compute_weights(&fallback_weight3,&weights3, bn->value.y); + + float rem = _process_node(bn->inputs[0].node,r_prev_anim,p_time,p_seek,p_fallback_weight,p_weights); + _process_node(bn->inputs[1].node,r_prev_anim,p_time,p_seek,fallback_weight1,&weights1); + float rem2 = _process_node(bn->inputs[2].node,r_prev_anim,p_time,p_seek,fallback_weight2,&weights2); + _process_node(bn->inputs[3].node,r_prev_anim,p_time,p_seek,fallback_weight3,&weights3); return MAX(rem,rem2); @@ -650,9 +707,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,true,p_filter,p_reverse_weight); + rem = _process_node(tsn->inputs[0].node,r_prev_anim,p_time,true,p_fallback_weight,p_weights); else - rem = _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time*tsn->scale,false,p_filter,p_reverse_weight); + rem = _process_node(tsn->inputs[0].node,r_prev_anim,p_time*tsn->scale,false,p_fallback_weight,p_weights); if (tsn->scale == 0) return INFINITY; else @@ -669,16 +726,18 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode } tsn->seek_pos=-1; - return _process_node(tsn->inputs[0].node,r_prev_anim,p_weight,p_time,p_seek); + return _process_node(tsn->inputs[0].node,r_prev_anim,p_time,p_seek,p_fallback_weight,p_weights); } break; case NODE_TRANSITION: { TransitionNode *tn = static_cast<TransitionNode*>(nb); + HashMap<NodePath, float> prev_weights(*p_weights); + float prev_fallback_weight = p_fallback_weight; 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,p_seek,p_filter,p_reverse_weight); + float rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,p_time,p_seek,p_fallback_weight,p_weights); if (p_seek) tn->time=p_time; else @@ -698,22 +757,25 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode float rem; + _compute_weights(&p_fallback_weight,p_weights, 1.0-blend); + _compute_weights(&prev_fallback_weight,&prev_weights, blend); + 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,p_filter,p_reverse_weight*(1.0-blend)); + rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,0,true,p_fallback_weight,p_weights); } else { - 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)); + rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,p_time,p_seek,p_fallback_weight,p_weights); } tn->switched=false; 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); + _process_node(tn->inputs[tn->prev].node,r_prev_anim,0,false,prev_fallback_weight,&prev_weights); tn->time=p_time; } else { - _process_node(tn->inputs[tn->prev].node,r_prev_anim,p_weight*blend,p_time,false,p_filter,p_reverse_weight*blend); + _process_node(tn->inputs[tn->prev].node,r_prev_anim,p_time,false,prev_fallback_weight,&prev_weights); tn->time+=p_time; tn->prev_xfading-=p_time; if (tn->prev_xfading<0) { @@ -750,10 +812,11 @@ void AnimationTreePlayer::_process_animation(float p_delta) { AnimationNode *prev=NULL; if (reset_request) { - _process_node(out_name,&prev, 1.0, 0, true); + + _process_node(out_name,&prev, 0, true); reset_request=false; } else - _process_node(out_name,&prev, 1.0, p_delta); + _process_node(out_name,&prev, p_delta); if (dirty_caches) { //some animation changed.. ignore this pass @@ -802,8 +865,6 @@ void AnimationTreePlayer::_process_animation(float p_delta) { if (tr.track==NULL || tr.local_track<0 || tr.weight < CMP_EPSILON) continue; - float blend=tr.weight; - switch(a->track_get_type(tr.local_track)) { case Animation::TYPE_TRANSFORM: { ///< Transform a node or a bone. @@ -812,22 +873,22 @@ void AnimationTreePlayer::_process_animation(float p_delta) { Vector3 scale; a->transform_track_interpolate(tr.local_track,anim_list->time,&loc,&rot,&scale); - tr.track->loc+=loc*blend; + tr.track->loc+=loc*tr.weight; scale.x-=1.0; scale.y-=1.0; scale.z-=1.0; - tr.track->scale+=scale*blend; + tr.track->scale+=scale*tr.weight; - tr.track->rot = tr.track->rot * empty_rot.slerp(rot,blend); + tr.track->rot = tr.track->rot * empty_rot.slerp(rot,tr.weight); } break; case Animation::TYPE_VALUE: { ///< Set a value in a property, can be interpolated. - if (a->value_track_is_continuous(tr.local_track)) { + if (a->value_track_get_update_mode(tr.local_track)==Animation::UPDATE_CONTINUOUS) { Variant value = a->value_track_interpolate(tr.local_track,anim_list->time); - Variant::blend(tr.track->value,value,blend,tr.track->value); + Variant::blend(tr.track->value,value,tr.weight,tr.track->value); } else { int index = a->track_find_key(tr.local_track,anim_list->time); tr.track->value = a->track_get_key_value(tr.local_track, index); @@ -1435,17 +1496,17 @@ AnimationTreePlayer::ConnectError AnimationTreePlayer::_cycle_test(const StringN } -Error AnimationTreePlayer::connect(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input) { +Error AnimationTreePlayer::connect_nodes(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input) { ERR_FAIL_COND_V( !node_map.has(p_src_node) , ERR_INVALID_PARAMETER); ERR_FAIL_COND_V( !node_map.has(p_dst_node) , ERR_INVALID_PARAMETER); ERR_FAIL_COND_V( p_src_node==p_dst_node , ERR_INVALID_PARAMETER); -// NodeBase *src = node_map[p_src_node]; + //NodeBase *src = node_map[p_src_node]; NodeBase *dst = node_map[p_dst_node]; ERR_FAIL_INDEX_V( p_dst_input, dst->inputs.size(), ERR_INVALID_PARAMETER); -// int oldval = dst->inputs[p_dst_input].node; + //int oldval = dst->inputs[p_dst_input].node; for(Map<StringName,NodeBase*>::Element *E=node_map.front();E;E=E->next()) { @@ -1477,7 +1538,7 @@ Error AnimationTreePlayer::connect(const StringName& p_src_node,const StringName return OK; } -bool AnimationTreePlayer::is_connected(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input) const { +bool AnimationTreePlayer::are_nodes_connected(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input) const { ERR_FAIL_COND_V( !node_map.has(p_src_node) , false); ERR_FAIL_COND_V( !node_map.has(p_dst_node) , false); @@ -1489,7 +1550,7 @@ bool AnimationTreePlayer::is_connected(const StringName& p_src_node,const String } -void AnimationTreePlayer::disconnect(const StringName& p_node, int p_input) { +void AnimationTreePlayer::disconnect_nodes(const StringName& p_node, int p_input) { ERR_FAIL_COND( !node_map.has(p_node)); @@ -1679,11 +1740,11 @@ NodePath AnimationTreePlayer::get_master_player() const{ return master; } -DVector<String> AnimationTreePlayer::_get_node_list() { +PoolVector<String> AnimationTreePlayer::_get_node_list() { List<StringName> nl; get_node_list(&nl); - DVector<String> ret; + PoolVector<String> ret; ret.resize(nl.size()); int idx=0; for(List<StringName>::Element *E=nl.front();E;E=E->next()) { @@ -1767,105 +1828,106 @@ Error AnimationTreePlayer::node_rename(const StringName& p_node,const StringName void AnimationTreePlayer::_bind_methods() { - ObjectTypeDB::bind_method(_MD("add_node","type","id"),&AnimationTreePlayer::add_node); + ClassDB::bind_method(_MD("add_node","type","id"),&AnimationTreePlayer::add_node); - ObjectTypeDB::bind_method(_MD("node_exists","node"),&AnimationTreePlayer::node_exists); - ObjectTypeDB::bind_method(_MD("node_rename","node","new_name"),&AnimationTreePlayer::node_rename); + ClassDB::bind_method(_MD("node_exists","node"),&AnimationTreePlayer::node_exists); + ClassDB::bind_method(_MD("node_rename","node","new_name"),&AnimationTreePlayer::node_rename); - ObjectTypeDB::bind_method(_MD("node_get_type","id"),&AnimationTreePlayer::node_get_type); - ObjectTypeDB::bind_method(_MD("node_get_input_count","id"),&AnimationTreePlayer::node_get_input_count); - ObjectTypeDB::bind_method(_MD("node_get_input_source","id","idx"),&AnimationTreePlayer::node_get_input_source); + ClassDB::bind_method(_MD("node_get_type","id"),&AnimationTreePlayer::node_get_type); + ClassDB::bind_method(_MD("node_get_input_count","id"),&AnimationTreePlayer::node_get_input_count); + ClassDB::bind_method(_MD("node_get_input_source","id","idx"),&AnimationTreePlayer::node_get_input_source); - ObjectTypeDB::bind_method(_MD("animation_node_set_animation","id","animation:Animation"),&AnimationTreePlayer::animation_node_set_animation); - ObjectTypeDB::bind_method(_MD("animation_node_get_animation:Animation","id"),&AnimationTreePlayer::animation_node_get_animation); + ClassDB::bind_method(_MD("animation_node_set_animation","id","animation:Animation"),&AnimationTreePlayer::animation_node_set_animation); + ClassDB::bind_method(_MD("animation_node_get_animation:Animation","id"),&AnimationTreePlayer::animation_node_get_animation); - 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); + ClassDB::bind_method(_MD("animation_node_set_master_animation","id","source"),&AnimationTreePlayer::animation_node_set_master_animation); + ClassDB::bind_method(_MD("animation_node_get_master_animation","id"),&AnimationTreePlayer::animation_node_get_master_animation); + ClassDB::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); + ClassDB::bind_method(_MD("oneshot_node_set_fadein_time","id","time_sec"),&AnimationTreePlayer::oneshot_node_set_fadein_time); + ClassDB::bind_method(_MD("oneshot_node_get_fadein_time","id"),&AnimationTreePlayer::oneshot_node_get_fadein_time); - ObjectTypeDB::bind_method(_MD("oneshot_node_set_fadeout_time","id","time_sec"),&AnimationTreePlayer::oneshot_node_set_fadeout_time); - ObjectTypeDB::bind_method(_MD("oneshot_node_get_fadeout_time","id"),&AnimationTreePlayer::oneshot_node_get_fadeout_time); + ClassDB::bind_method(_MD("oneshot_node_set_fadeout_time","id","time_sec"),&AnimationTreePlayer::oneshot_node_set_fadeout_time); + ClassDB::bind_method(_MD("oneshot_node_get_fadeout_time","id"),&AnimationTreePlayer::oneshot_node_get_fadeout_time); - ObjectTypeDB::bind_method(_MD("oneshot_node_set_autorestart","id","enable"),&AnimationTreePlayer::oneshot_node_set_autorestart); - ObjectTypeDB::bind_method(_MD("oneshot_node_set_autorestart_delay","id","delay_sec"),&AnimationTreePlayer::oneshot_node_set_autorestart_delay); - ObjectTypeDB::bind_method(_MD("oneshot_node_set_autorestart_random_delay","id","rand_sec"),&AnimationTreePlayer::oneshot_node_set_autorestart_random_delay); + ClassDB::bind_method(_MD("oneshot_node_set_autorestart","id","enable"),&AnimationTreePlayer::oneshot_node_set_autorestart); + ClassDB::bind_method(_MD("oneshot_node_set_autorestart_delay","id","delay_sec"),&AnimationTreePlayer::oneshot_node_set_autorestart_delay); + ClassDB::bind_method(_MD("oneshot_node_set_autorestart_random_delay","id","rand_sec"),&AnimationTreePlayer::oneshot_node_set_autorestart_random_delay); - ObjectTypeDB::bind_method(_MD("oneshot_node_has_autorestart","id"),&AnimationTreePlayer::oneshot_node_has_autorestart); - ObjectTypeDB::bind_method(_MD("oneshot_node_get_autorestart_delay","id"),&AnimationTreePlayer::oneshot_node_get_autorestart_delay); - ObjectTypeDB::bind_method(_MD("oneshot_node_get_autorestart_random_delay","id"),&AnimationTreePlayer::oneshot_node_get_autorestart_random_delay); + ClassDB::bind_method(_MD("oneshot_node_has_autorestart","id"),&AnimationTreePlayer::oneshot_node_has_autorestart); + ClassDB::bind_method(_MD("oneshot_node_get_autorestart_delay","id"),&AnimationTreePlayer::oneshot_node_get_autorestart_delay); + ClassDB::bind_method(_MD("oneshot_node_get_autorestart_random_delay","id"),&AnimationTreePlayer::oneshot_node_get_autorestart_random_delay); - ObjectTypeDB::bind_method(_MD("oneshot_node_start","id"),&AnimationTreePlayer::oneshot_node_start); - ObjectTypeDB::bind_method(_MD("oneshot_node_stop","id"),&AnimationTreePlayer::oneshot_node_stop); - ObjectTypeDB::bind_method(_MD("oneshot_node_is_active","id"),&AnimationTreePlayer::oneshot_node_is_active); - ObjectTypeDB::bind_method(_MD("oneshot_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::oneshot_node_set_filter_path); + ClassDB::bind_method(_MD("oneshot_node_start","id"),&AnimationTreePlayer::oneshot_node_start); + ClassDB::bind_method(_MD("oneshot_node_stop","id"),&AnimationTreePlayer::oneshot_node_stop); + ClassDB::bind_method(_MD("oneshot_node_is_active","id"),&AnimationTreePlayer::oneshot_node_is_active); + ClassDB::bind_method(_MD("oneshot_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::oneshot_node_set_filter_path); - ObjectTypeDB::bind_method(_MD("mix_node_set_amount","id","ratio"),&AnimationTreePlayer::mix_node_set_amount); - ObjectTypeDB::bind_method(_MD("mix_node_get_amount","id"),&AnimationTreePlayer::mix_node_get_amount); + ClassDB::bind_method(_MD("mix_node_set_amount","id","ratio"),&AnimationTreePlayer::mix_node_set_amount); + ClassDB::bind_method(_MD("mix_node_get_amount","id"),&AnimationTreePlayer::mix_node_get_amount); - ObjectTypeDB::bind_method(_MD("blend2_node_set_amount","id","blend"),&AnimationTreePlayer::blend2_node_set_amount); - ObjectTypeDB::bind_method(_MD("blend2_node_get_amount","id"),&AnimationTreePlayer::blend2_node_get_amount); - ObjectTypeDB::bind_method(_MD("blend2_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::blend2_node_set_filter_path); + ClassDB::bind_method(_MD("blend2_node_set_amount","id","blend"),&AnimationTreePlayer::blend2_node_set_amount); + ClassDB::bind_method(_MD("blend2_node_get_amount","id"),&AnimationTreePlayer::blend2_node_get_amount); + ClassDB::bind_method(_MD("blend2_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::blend2_node_set_filter_path); - ObjectTypeDB::bind_method(_MD("blend3_node_set_amount","id","blend"),&AnimationTreePlayer::blend3_node_set_amount); - ObjectTypeDB::bind_method(_MD("blend3_node_get_amount","id"),&AnimationTreePlayer::blend3_node_get_amount); + ClassDB::bind_method(_MD("blend3_node_set_amount","id","blend"),&AnimationTreePlayer::blend3_node_set_amount); + ClassDB::bind_method(_MD("blend3_node_get_amount","id"),&AnimationTreePlayer::blend3_node_get_amount); - ObjectTypeDB::bind_method(_MD("blend4_node_set_amount","id","blend"),&AnimationTreePlayer::blend4_node_set_amount); - ObjectTypeDB::bind_method(_MD("blend4_node_get_amount","id"),&AnimationTreePlayer::blend4_node_get_amount); + ClassDB::bind_method(_MD("blend4_node_set_amount","id","blend"),&AnimationTreePlayer::blend4_node_set_amount); + ClassDB::bind_method(_MD("blend4_node_get_amount","id"),&AnimationTreePlayer::blend4_node_get_amount); - ObjectTypeDB::bind_method(_MD("timescale_node_set_scale","id","scale"),&AnimationTreePlayer::timescale_node_set_scale); - ObjectTypeDB::bind_method(_MD("timescale_node_get_scale","id"),&AnimationTreePlayer::timescale_node_get_scale); + ClassDB::bind_method(_MD("timescale_node_set_scale","id","scale"),&AnimationTreePlayer::timescale_node_set_scale); + ClassDB::bind_method(_MD("timescale_node_get_scale","id"),&AnimationTreePlayer::timescale_node_get_scale); - ObjectTypeDB::bind_method(_MD("timeseek_node_seek","id","pos_sec"),&AnimationTreePlayer::timeseek_node_seek); + ClassDB::bind_method(_MD("timeseek_node_seek","id","pos_sec"),&AnimationTreePlayer::timeseek_node_seek); - ObjectTypeDB::bind_method(_MD("transition_node_set_input_count","id","count"),&AnimationTreePlayer::transition_node_set_input_count); - ObjectTypeDB::bind_method(_MD("transition_node_get_input_count","id"),&AnimationTreePlayer::transition_node_get_input_count); - ObjectTypeDB::bind_method(_MD("transition_node_delete_input","id","input_idx"),&AnimationTreePlayer::transition_node_delete_input); + ClassDB::bind_method(_MD("transition_node_set_input_count","id","count"),&AnimationTreePlayer::transition_node_set_input_count); + ClassDB::bind_method(_MD("transition_node_get_input_count","id"),&AnimationTreePlayer::transition_node_get_input_count); + ClassDB::bind_method(_MD("transition_node_delete_input","id","input_idx"),&AnimationTreePlayer::transition_node_delete_input); - ObjectTypeDB::bind_method(_MD("transition_node_set_input_auto_advance","id","input_idx","enable"),&AnimationTreePlayer::transition_node_set_input_auto_advance); - ObjectTypeDB::bind_method(_MD("transition_node_has_input_auto_advance","id","input_idx"),&AnimationTreePlayer::transition_node_has_input_auto_advance); + ClassDB::bind_method(_MD("transition_node_set_input_auto_advance","id","input_idx","enable"),&AnimationTreePlayer::transition_node_set_input_auto_advance); + ClassDB::bind_method(_MD("transition_node_has_input_auto_advance","id","input_idx"),&AnimationTreePlayer::transition_node_has_input_auto_advance); - ObjectTypeDB::bind_method(_MD("transition_node_set_xfade_time","id","time_sec"),&AnimationTreePlayer::transition_node_set_xfade_time); - ObjectTypeDB::bind_method(_MD("transition_node_get_xfade_time","id"),&AnimationTreePlayer::transition_node_get_xfade_time); + ClassDB::bind_method(_MD("transition_node_set_xfade_time","id","time_sec"),&AnimationTreePlayer::transition_node_set_xfade_time); + ClassDB::bind_method(_MD("transition_node_get_xfade_time","id"),&AnimationTreePlayer::transition_node_get_xfade_time); - ObjectTypeDB::bind_method(_MD("transition_node_set_current","id","input_idx"),&AnimationTreePlayer::transition_node_set_current); - ObjectTypeDB::bind_method(_MD("transition_node_get_current","id"),&AnimationTreePlayer::transition_node_get_current); + ClassDB::bind_method(_MD("transition_node_set_current","id","input_idx"),&AnimationTreePlayer::transition_node_set_current); + ClassDB::bind_method(_MD("transition_node_get_current","id"),&AnimationTreePlayer::transition_node_get_current); - ObjectTypeDB::bind_method(_MD("node_set_pos","id","screen_pos"),&AnimationTreePlayer::node_set_pos); - ObjectTypeDB::bind_method(_MD("node_get_pos","id"),&AnimationTreePlayer::node_get_pos); + ClassDB::bind_method(_MD("node_set_pos","id","screen_pos"),&AnimationTreePlayer::node_set_pos); + ClassDB::bind_method(_MD("node_get_pos","id"),&AnimationTreePlayer::node_get_pos); - ObjectTypeDB::bind_method(_MD("remove_node","id"),&AnimationTreePlayer::remove_node); - ObjectTypeDB::bind_method(_MD("connect","id","dst_id","dst_input_idx"),&AnimationTreePlayer::connect); - ObjectTypeDB::bind_method(_MD("is_connected","id","dst_id","dst_input_idx"),&AnimationTreePlayer::is_connected); - ObjectTypeDB::bind_method(_MD("disconnect","id","dst_input_idx"),&AnimationTreePlayer::disconnect); + ClassDB::bind_method(_MD("remove_node","id"),&AnimationTreePlayer::remove_node); + ClassDB::bind_method(_MD("connect_nodes","id","dst_id","dst_input_idx"),&AnimationTreePlayer::connect_nodes); + ClassDB::bind_method(_MD("are_nodes_connected","id","dst_id","dst_input_idx"),&AnimationTreePlayer::are_nodes_connected); + ClassDB::bind_method(_MD("disconnect_nodes","id","dst_input_idx"),&AnimationTreePlayer::disconnect_nodes); - ObjectTypeDB::bind_method(_MD("set_active","enabled"),&AnimationTreePlayer::set_active); - ObjectTypeDB::bind_method(_MD("is_active"),&AnimationTreePlayer::is_active); + ClassDB::bind_method(_MD("set_active","enabled"),&AnimationTreePlayer::set_active); + ClassDB::bind_method(_MD("is_active"),&AnimationTreePlayer::is_active); - ObjectTypeDB::bind_method(_MD("set_base_path","path"),&AnimationTreePlayer::set_base_path); - ObjectTypeDB::bind_method(_MD("get_base_path"),&AnimationTreePlayer::get_base_path); + ClassDB::bind_method(_MD("set_base_path","path"),&AnimationTreePlayer::set_base_path); + ClassDB::bind_method(_MD("get_base_path"),&AnimationTreePlayer::get_base_path); - ObjectTypeDB::bind_method(_MD("set_master_player","nodepath"),&AnimationTreePlayer::set_master_player); - ObjectTypeDB::bind_method(_MD("get_master_player"),&AnimationTreePlayer::get_master_player); + ClassDB::bind_method(_MD("set_master_player","nodepath"),&AnimationTreePlayer::set_master_player); + ClassDB::bind_method(_MD("get_master_player"),&AnimationTreePlayer::get_master_player); - ObjectTypeDB::bind_method(_MD("get_node_list"),&AnimationTreePlayer::_get_node_list); + ClassDB::bind_method(_MD("get_node_list"),&AnimationTreePlayer::_get_node_list); - ObjectTypeDB::bind_method(_MD("set_animation_process_mode","mode"),&AnimationTreePlayer::set_animation_process_mode); - ObjectTypeDB::bind_method(_MD("get_animation_process_mode"),&AnimationTreePlayer::get_animation_process_mode); + ClassDB::bind_method(_MD("set_animation_process_mode","mode"),&AnimationTreePlayer::set_animation_process_mode); + ClassDB::bind_method(_MD("get_animation_process_mode"),&AnimationTreePlayer::get_animation_process_mode); - ObjectTypeDB::bind_method(_MD("advance", "delta"), &AnimationTreePlayer::advance); + ClassDB::bind_method(_MD("advance", "delta"), &AnimationTreePlayer::advance); - ObjectTypeDB::bind_method(_MD("reset"),&AnimationTreePlayer::reset); + ClassDB::bind_method(_MD("reset"),&AnimationTreePlayer::reset); - ObjectTypeDB::bind_method(_MD("recompute_caches"),&AnimationTreePlayer::recompute_caches); + ClassDB::bind_method(_MD("recompute_caches"),&AnimationTreePlayer::recompute_caches); - ADD_PROPERTY(PropertyInfo(Variant::INT, "playback/process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_animation_process_mode"), _SCS("get_animation_process_mode")); + 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")); BIND_CONSTANT( NODE_OUTPUT ); BIND_CONSTANT( NODE_ANIMATION ); @@ -1904,6 +1966,3 @@ AnimationTreePlayer::~AnimationTreePlayer() { node_map.erase( node_map.front() ); } } - - - diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h index 0e78281e4c..5e118be034 100644 --- a/scene/animation/animation_tree_player.h +++ b/scene/animation/animation_tree_player.h @@ -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 */ @@ -33,13 +33,12 @@ #include "scene/resources/animation.h" #include "scene/3d/spatial.h" #include "scene/3d/skeleton.h" -#include "scene/main/misc.h" #include "animation_player.h" class AnimationTreePlayer : public Node { - OBJ_TYPE( AnimationTreePlayer, Node ); + GDCLASS( AnimationTreePlayer, Node ); OBJ_CATEGORY("Animation Nodes"); public: @@ -274,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 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_step, bool p_seek=false, float p_fallback_weight = 1.0, HashMap<NodePath,float>* p_weights = NULL); void _process_animation(float p_delta); bool reset_request; @@ -283,7 +282,9 @@ private: Track* _find_track(const NodePath& p_path); void _recompute_caches(); void _recompute_caches(const StringName& p_node); - DVector<String> _get_node_list(); + PoolVector<String> _get_node_list(); + + void _compute_weights(float *p_fallback_weight, HashMap<NodePath,float> *p_weights, float p_coeff, const HashMap<NodePath,bool> *p_filter = NULL, float p_filtered_coeff = 0); protected: @@ -396,9 +397,9 @@ public: void get_node_list(List<StringName> *p_node_list) const; void remove_node(const StringName& p_node); - Error connect(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input); - bool is_connected(const StringName& p_src_node,const StringName& p_dst_node, int p_input) const; - void disconnect(const StringName& p_src_node, int p_input); + Error connect_nodes(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input); + bool are_nodes_connected(const StringName& p_src_node,const StringName& p_dst_node, int p_input) const; + void disconnect_nodes(const StringName& p_src_node, int p_input); void set_base_path(const NodePath& p_path); NodePath get_base_path() const; 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 6f6f5d3aff..0916119db3 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.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 */ @@ -109,7 +109,7 @@ bool Tween::_set(const StringName& p_name, const Variant& p_value) { String name=p_name; if (name=="playback/speed" || name=="speed") { //bw compatibility - set_speed(p_value); + set_speed_scale(p_value); } else if (name=="playback/active") { set_active(p_value); @@ -155,21 +155,21 @@ void Tween::_notification(int p_what) { if (!processing) { //make sure that a previous process state was not saved //only process if "processing" is set - set_fixed_process(false); - set_process(false); + set_fixed_process_internal(false); + set_process_internal(false); } } break; case NOTIFICATION_READY: { } break; - case NOTIFICATION_PROCESS: { + case NOTIFICATION_INTERNAL_PROCESS: { if (tween_process_mode==TWEEN_PROCESS_FIXED) break; if (processing) _tween_process( get_process_delta_time() ); } break; - case NOTIFICATION_FIXED_PROCESS: { + case NOTIFICATION_INTERNAL_FIXED_PROCESS: { if (tween_process_mode==TWEEN_PROCESS_IDLE) break; @@ -186,45 +186,46 @@ void Tween::_notification(int p_what) { void Tween::_bind_methods() { - ObjectTypeDB::bind_method(_MD("is_active"),&Tween::is_active ); - ObjectTypeDB::bind_method(_MD("set_active","active"),&Tween::set_active ); - - ObjectTypeDB::bind_method(_MD("is_repeat"),&Tween::is_repeat ); - ObjectTypeDB::bind_method(_MD("set_repeat","repeat"),&Tween::set_repeat ); - - ObjectTypeDB::bind_method(_MD("set_speed","speed"),&Tween::set_speed); - ObjectTypeDB::bind_method(_MD("get_speed"),&Tween::get_speed); - - ObjectTypeDB::bind_method(_MD("set_tween_process_mode","mode"),&Tween::set_tween_process_mode); - ObjectTypeDB::bind_method(_MD("get_tween_process_mode"),&Tween::get_tween_process_mode); - - ObjectTypeDB::bind_method(_MD("start"),&Tween::start ); - ObjectTypeDB::bind_method(_MD("reset","object","key"),&Tween::reset ); - ObjectTypeDB::bind_method(_MD("reset_all"),&Tween::reset_all ); - ObjectTypeDB::bind_method(_MD("stop","object","key"),&Tween::stop ); - ObjectTypeDB::bind_method(_MD("stop_all"),&Tween::stop_all ); - ObjectTypeDB::bind_method(_MD("resume","object","key"),&Tween::resume ); - ObjectTypeDB::bind_method(_MD("resume_all"),&Tween::resume_all ); - ObjectTypeDB::bind_method(_MD("remove","object","key"),&Tween::remove ); - ObjectTypeDB::bind_method(_MD("remove_all"),&Tween::remove_all ); - ObjectTypeDB::bind_method(_MD("seek","time"),&Tween::seek ); - ObjectTypeDB::bind_method(_MD("tell"),&Tween::tell ); - ObjectTypeDB::bind_method(_MD("get_runtime"),&Tween::get_runtime ); - - ObjectTypeDB::bind_method(_MD("interpolate_property","object","property","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_property, DEFVAL(0) ); - ObjectTypeDB::bind_method(_MD("interpolate_method","object","method","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_method, DEFVAL(0) ); - ObjectTypeDB::bind_method(_MD("interpolate_callback","object","times_in_sec","callback","arg1", "arg2","arg3","arg4","arg5"),&Tween::interpolate_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()) ); - ObjectTypeDB::bind_method(_MD("interpolate_deferred_callback","object","times_in_sec","callback","arg1","arg2","arg3","arg4","arg5"),&Tween::interpolate_deferred_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()) ); - ObjectTypeDB::bind_method(_MD("follow_property","object","property","initial_val","target","target_property","times_in_sec","trans_type","ease_type","delay"),&Tween::follow_property, DEFVAL(0) ); - ObjectTypeDB::bind_method(_MD("follow_method","object","method","initial_val","target","target_method","times_in_sec","trans_type","ease_type","delay"),&Tween::follow_method, DEFVAL(0) ); - ObjectTypeDB::bind_method(_MD("targeting_property","object","property","initial","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::targeting_property, DEFVAL(0) ); - ObjectTypeDB::bind_method(_MD("targeting_method","object","method","initial","initial_method","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::targeting_method, DEFVAL(0) ); - - ADD_SIGNAL( MethodInfo("tween_start", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) ); + ClassDB::bind_method(_MD("is_active"),&Tween::is_active ); + ClassDB::bind_method(_MD("set_active","active"),&Tween::set_active ); + + ClassDB::bind_method(_MD("is_repeat"),&Tween::is_repeat ); + ClassDB::bind_method(_MD("set_repeat","repeat"),&Tween::set_repeat ); + + ClassDB::bind_method(_MD("set_speed_scale","speed"),&Tween::set_speed_scale); + ClassDB::bind_method(_MD("get_speed_scale"),&Tween::get_speed_scale); + + ClassDB::bind_method(_MD("set_tween_process_mode","mode"),&Tween::set_tween_process_mode); + ClassDB::bind_method(_MD("get_tween_process_mode"),&Tween::get_tween_process_mode); + + ClassDB::bind_method(_MD("start"),&Tween::start ); + ClassDB::bind_method(_MD("reset","object","key"),&Tween::reset, DEFVAL("") ); + ClassDB::bind_method(_MD("reset_all"),&Tween::reset_all ); + ClassDB::bind_method(_MD("stop","object","key"),&Tween::stop, DEFVAL("") ); + ClassDB::bind_method(_MD("stop_all"),&Tween::stop_all ); + ClassDB::bind_method(_MD("resume","object","key"),&Tween::resume, DEFVAL("") ); + ClassDB::bind_method(_MD("resume_all"),&Tween::resume_all ); + ClassDB::bind_method(_MD("remove","object","key"),&Tween::remove, DEFVAL("") ); + ClassDB::bind_method(_MD("_remove","object","key","first_only"),&Tween::_remove ); + ClassDB::bind_method(_MD("remove_all"),&Tween::remove_all ); + ClassDB::bind_method(_MD("seek","time"),&Tween::seek ); + ClassDB::bind_method(_MD("tell"),&Tween::tell ); + ClassDB::bind_method(_MD("get_runtime"),&Tween::get_runtime ); + + ClassDB::bind_method(_MD("interpolate_property","object","property","initial_val","final_val","duration","trans_type","ease_type","delay"),&Tween::interpolate_property, DEFVAL(0) ); + ClassDB::bind_method(_MD("interpolate_method","object","method","initial_val","final_val","duration","trans_type","ease_type","delay"),&Tween::interpolate_method, DEFVAL(0) ); + ClassDB::bind_method(_MD("interpolate_callback","object","duration","callback","arg1", "arg2","arg3","arg4","arg5"),&Tween::interpolate_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()) ); + ClassDB::bind_method(_MD("interpolate_deferred_callback","object","duration","callback","arg1","arg2","arg3","arg4","arg5"),&Tween::interpolate_deferred_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()) ); + ClassDB::bind_method(_MD("follow_property","object","property","initial_val","target","target_property","duration","trans_type","ease_type","delay"),&Tween::follow_property, DEFVAL(0) ); + ClassDB::bind_method(_MD("follow_method","object","method","initial_val","target","target_method","duration","trans_type","ease_type","delay"),&Tween::follow_method, DEFVAL(0) ); + ClassDB::bind_method(_MD("targeting_property","object","property","initial","initial_val","final_val","duration","trans_type","ease_type","delay"),&Tween::targeting_property, DEFVAL(0) ); + ClassDB::bind_method(_MD("targeting_method","object","method","initial","initial_method","final_val","duration","trans_type","ease_type","delay"),&Tween::targeting_method, DEFVAL(0) ); + + ADD_SIGNAL( MethodInfo("tween_started", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) ); ADD_SIGNAL( MethodInfo("tween_step", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key"), PropertyInfo( Variant::REAL,"elapsed"), PropertyInfo( Variant::OBJECT,"value")) ); - ADD_SIGNAL( MethodInfo("tween_complete", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) ); + ADD_SIGNAL( MethodInfo("tween_completed", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) ); - ADD_PROPERTY( PropertyInfo( Variant::INT, "playback/process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_tween_process_mode"), _SCS("get_tween_process_mode")); + ADD_PROPERTY( PropertyInfo( Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_tween_process_mode"), _SCS("get_tween_process_mode")); BIND_CONSTANT(TWEEN_PROCESS_FIXED); BIND_CONSTANT(TWEEN_PROCESS_IDLE); @@ -338,21 +339,21 @@ Variant Tween::_run_equation(InterpolateData& p_data) { Variant result; #define APPLY_EQUATION(element)\ - r.element = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, i.element, d.element, p_data.times_in_sec); + r.element = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, i.element, d.element, p_data.duration); switch(initial_val.get_type()) { case Variant::BOOL: - result = ( _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, initial_val, delta_val, p_data.times_in_sec)) >= 0.5; + result = ( _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, initial_val, delta_val, p_data.duration)) >= 0.5; break; case Variant::INT: - result = (int) _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (int) initial_val, (int) delta_val, p_data.times_in_sec); + result = (int) _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (int) initial_val, (int) delta_val, p_data.duration); break; case Variant::REAL: - result = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (real_t) initial_val, (real_t) delta_val, p_data.times_in_sec); + result = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (real_t) initial_val, (real_t) delta_val, p_data.duration); break; case Variant::VECTOR2: @@ -382,11 +383,11 @@ Variant Tween::_run_equation(InterpolateData& p_data) { } break; - case Variant::MATRIX3: + case Variant::BASIS: { - Matrix3 i = initial_val; - Matrix3 d = delta_val; - Matrix3 r; + Basis i = initial_val; + Basis d = delta_val; + Basis r; APPLY_EQUATION(elements[0][0]); APPLY_EQUATION(elements[0][1]); @@ -402,11 +403,11 @@ Variant Tween::_run_equation(InterpolateData& p_data) { } break; - case Variant::MATRIX32: + case Variant::TRANSFORM2D: { - Matrix3 i = initial_val; - Matrix3 d = delta_val; - Matrix3 r; + Basis i = initial_val; + Basis d = delta_val; + Basis r; APPLY_EQUATION(elements[0][0]); APPLY_EQUATION(elements[0][1]); @@ -432,11 +433,11 @@ Variant Tween::_run_equation(InterpolateData& p_data) { result = r; } break; - case Variant::_AABB: + case Variant::RECT3: { - AABB i = initial_val; - AABB d = delta_val; - AABB r; + Rect3 i = initial_val; + Rect3 d = delta_val; + Rect3 r; APPLY_EQUATION(pos.x); APPLY_EQUATION(pos.y); @@ -572,13 +573,13 @@ void Tween::_tween_process(float p_delta) { continue; else if(prev_delaying) { - emit_signal("tween_start",object,data.key); + emit_signal("tween_started",object,data.key); _apply_tween_value(data, data.initial_val); } - if(data.elapsed > (data.delay + data.times_in_sec)) { + if(data.elapsed > (data.delay + data.duration)) { - data.elapsed = data.delay + data.times_in_sec; + data.elapsed = data.delay + data.duration; data.finish = true; } @@ -619,6 +620,8 @@ void Tween::_tween_process(float p_delta) { }; object->call(data.key, (const Variant **) arg, data.args, error); } + if (!repeat) + call_deferred("_remove", object, data.key, true); } continue; } @@ -629,10 +632,10 @@ void Tween::_tween_process(float p_delta) { _apply_tween_value(data, result); if (data.finish) { - emit_signal("tween_complete",object,data.key); + emit_signal("tween_completed",object,data.key); // not repeat mode, remove completed action if (!repeat) - call_deferred("remove", object, data.key); + call_deferred("_remove", object, data.key, true); } } pending_update --; @@ -663,8 +666,8 @@ void Tween::_set_process(bool p_process,bool p_force) { switch(tween_process_mode) { - case TWEEN_PROCESS_FIXED: set_fixed_process(p_process && active); break; - case TWEEN_PROCESS_IDLE: set_process(p_process && active); break; + case TWEEN_PROCESS_FIXED: set_fixed_process_internal(p_process && active); break; + case TWEEN_PROCESS_IDLE: set_process_internal(p_process && active); break; } processing=p_process; @@ -694,12 +697,12 @@ void Tween::set_repeat(bool p_repeat) { repeat = p_repeat; } -void Tween::set_speed(float p_speed) { +void Tween::set_speed_scale(float p_speed) { speed_scale=p_speed; } -float Tween::get_speed() const { +float Tween::get_speed_scale() const { return speed_scale; } @@ -721,7 +724,7 @@ bool Tween::reset(Object *p_object, String p_key) { if(object == NULL) continue; - if(object == p_object && data.key == p_key) { + if(object == p_object && (data.key == p_key || p_key == "")) { data.elapsed = 0; data.finish = false; @@ -757,7 +760,7 @@ bool Tween::stop(Object *p_object, String p_key) { Object *object = ObjectDB::get_instance(data.id); if(object == NULL) continue; - if(object == p_object && data.key == p_key) + if(object == p_object && (data.key == p_key || p_key == "")) data.active = false; } pending_update --; @@ -791,7 +794,7 @@ bool Tween::resume(Object *p_object, String p_key) { Object *object = ObjectDB::get_instance(data.id); if(object == NULL) continue; - if(object == p_object && data.key == p_key) + if(object == p_object && (data.key == p_key || p_key == "")) data.active = true; } pending_update --; @@ -814,23 +817,33 @@ bool Tween::resume_all() { } bool Tween::remove(Object *p_object, String p_key) { + _remove(p_object, p_key, false); + return true; +} + +void Tween::_remove(Object *p_object, String p_key, bool first_only) { if(pending_update != 0) { - call_deferred("remove", p_object, p_key); - return true; + call_deferred("_remove", p_object, p_key, first_only); + return; } + List<List<InterpolateData>::Element *> for_removal; for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) { InterpolateData& data = E->get(); Object *object = ObjectDB::get_instance(data.id); if(object == NULL) continue; - if(object == p_object && data.key == p_key) { - interpolates.erase(E); - return true; + if(object == p_object && (data.key == p_key || p_key == "")) { + for_removal.push_back(E); + if (first_only) { + break; + } } } - return true; + for(List<List<InterpolateData>::Element *>::Element *E=for_removal.front();E;E=E->next()) { + interpolates.erase(E->get()); + } } bool Tween::remove_all() { @@ -858,10 +871,10 @@ bool Tween::seek(real_t p_time) { data.finish = false; continue; } - else if(data.elapsed >= (data.delay + data.times_in_sec)) { + else if(data.elapsed >= (data.delay + data.duration)) { data.finish = true; - data.elapsed = (data.delay + data.times_in_sec); + data.elapsed = (data.delay + data.duration); } else data.finish = false; @@ -903,7 +916,7 @@ real_t Tween::get_runtime() const { for(const List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) { const InterpolateData& data = E->get(); - real_t t = data.delay + data.times_in_sec; + real_t t = data.delay + data.duration; if(t > runtime) runtime = t; } @@ -940,11 +953,11 @@ bool Tween::_calc_delta_val(const Variant& p_initial_val, const Variant& p_final delta_val = final_val.operator Vector3() - initial_val.operator Vector3(); break; - case Variant::MATRIX3: + case Variant::BASIS: { - Matrix3 i = initial_val; - Matrix3 f = final_val; - delta_val = Matrix3(f.elements[0][0] - i.elements[0][0], + Basis i = initial_val; + Basis f = final_val; + delta_val = Basis(f.elements[0][0] - i.elements[0][0], f.elements[0][1] - i.elements[0][1], f.elements[0][2] - i.elements[0][2], f.elements[1][0] - i.elements[1][0], @@ -957,11 +970,11 @@ bool Tween::_calc_delta_val(const Variant& p_initial_val, const Variant& p_final } break; - case Variant::MATRIX32: + case Variant::TRANSFORM2D: { - Matrix32 i = initial_val; - Matrix32 f = final_val; - Matrix32 d = Matrix32(); + Transform2D i = initial_val; + Transform2D f = final_val; + Transform2D d = Transform2D(); d[0][0] = f.elements[0][0] - i.elements[0][0]; d[0][1] = f.elements[0][1] - i.elements[0][1]; d[1][0] = f.elements[1][0] - i.elements[1][0]; @@ -974,11 +987,11 @@ bool Tween::_calc_delta_val(const Variant& p_initial_val, const Variant& p_final case Variant::QUAT: delta_val = final_val.operator Quat() - initial_val.operator Quat(); break; - case Variant::_AABB: + case Variant::RECT3: { - AABB i = initial_val; - AABB f = final_val; - delta_val = AABB(f.pos - i.pos, f.size - i.size); + Rect3 i = initial_val; + Rect3 f = final_val; + delta_val = Rect3(f.pos - i.pos, f.size - i.size); } break; case Variant::TRANSFORM: @@ -1022,7 +1035,7 @@ bool Tween::interpolate_property(Object *p_object , String p_property , Variant p_initial_val , Variant p_final_val - , real_t p_times_in_sec + , real_t p_duration , TransitionType p_trans_type , EaseType p_ease_type , real_t p_delay @@ -1033,7 +1046,7 @@ bool Tween::interpolate_property(Object *p_object , p_property , p_initial_val , p_final_val - , p_times_in_sec + , p_duration , p_trans_type , p_ease_type , p_delay @@ -1047,7 +1060,7 @@ bool Tween::interpolate_property(Object *p_object 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_duration <= 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); ERR_FAIL_COND_V(p_delay < 0, false); @@ -1066,7 +1079,7 @@ bool Tween::interpolate_property(Object *p_object data.key = p_property; data.initial_val = p_initial_val; data.final_val = p_final_val; - data.times_in_sec = p_times_in_sec; + data.duration = p_duration; data.trans_type = p_trans_type; data.ease_type = p_ease_type; data.delay = p_delay; @@ -1082,7 +1095,7 @@ bool Tween::interpolate_method(Object *p_object , String p_method , Variant p_initial_val , Variant p_final_val - , real_t p_times_in_sec + , real_t p_duration , TransitionType p_trans_type , EaseType p_ease_type , real_t p_delay @@ -1093,7 +1106,7 @@ bool Tween::interpolate_method(Object *p_object , p_method , p_initial_val , p_final_val - , p_times_in_sec + , p_duration , p_trans_type , p_ease_type , p_delay @@ -1107,7 +1120,7 @@ bool Tween::interpolate_method(Object *p_object 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_duration <= 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); ERR_FAIL_COND_V(p_delay < 0, false); @@ -1125,7 +1138,7 @@ bool Tween::interpolate_method(Object *p_object data.key = p_method; data.initial_val = p_initial_val; data.final_val = p_final_val; - data.times_in_sec = p_times_in_sec; + data.duration = p_duration; data.trans_type = p_trans_type; data.ease_type = p_ease_type; data.delay = p_delay; @@ -1138,7 +1151,7 @@ bool Tween::interpolate_method(Object *p_object } bool Tween::interpolate_callback(Object *p_object - , real_t p_times_in_sec + , real_t p_duration , String p_callback , VARIANT_ARG_DECLARE ) { @@ -1146,7 +1159,7 @@ bool Tween::interpolate_callback(Object *p_object if(pending_update != 0) { _add_pending_command("interpolate_callback" , p_object - , p_times_in_sec + , p_duration , p_callback , p_arg1 , p_arg2 @@ -1159,7 +1172,7 @@ bool Tween::interpolate_callback(Object *p_object 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_FAIL_COND_V(p_duration < 0, false); ERR_EXPLAIN("Object has no callback named: %s" + p_callback); ERR_FAIL_COND_V(!p_object->has_method(p_callback), false); @@ -1173,7 +1186,7 @@ bool Tween::interpolate_callback(Object *p_object data.id = p_object->get_instance_ID(); data.key = p_callback; - data.times_in_sec = p_times_in_sec; + data.duration = p_duration; data.delay = 0; int args=0; @@ -1204,7 +1217,7 @@ bool Tween::interpolate_callback(Object *p_object } bool Tween::interpolate_deferred_callback(Object *p_object - , real_t p_times_in_sec + , real_t p_duration , String p_callback , VARIANT_ARG_DECLARE ) { @@ -1212,7 +1225,7 @@ bool Tween::interpolate_deferred_callback(Object *p_object if(pending_update != 0) { _add_pending_command("interpolate_deferred_callback" , p_object - , p_times_in_sec + , p_duration , p_callback , p_arg1 , p_arg2 @@ -1224,7 +1237,7 @@ bool Tween::interpolate_deferred_callback(Object *p_object } 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_FAIL_COND_V(p_duration < 0, false); ERR_EXPLAIN("Object has no callback named: %s" + p_callback); ERR_FAIL_COND_V(!p_object->has_method(p_callback), false); @@ -1238,7 +1251,7 @@ bool Tween::interpolate_deferred_callback(Object *p_object data.id = p_object->get_instance_ID(); data.key = p_callback; - data.times_in_sec = p_times_in_sec; + data.duration = p_duration; data.delay = 0; int args=0; @@ -1273,7 +1286,7 @@ bool Tween::follow_property(Object *p_object , Variant p_initial_val , Object *p_target , String p_target_property - , real_t p_times_in_sec + , real_t p_duration , TransitionType p_trans_type , EaseType p_ease_type , real_t p_delay @@ -1285,7 +1298,7 @@ bool Tween::follow_property(Object *p_object , p_initial_val , p_target , p_target_property - , p_times_in_sec + , p_duration , p_trans_type , p_ease_type , p_delay @@ -1299,7 +1312,7 @@ bool Tween::follow_property(Object *p_object 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_duration <= 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); ERR_FAIL_COND_V(p_delay < 0, false); @@ -1327,7 +1340,7 @@ bool Tween::follow_property(Object *p_object data.initial_val = p_initial_val; data.target_id = p_target->get_instance_ID(); data.target_key = p_target_property; - data.times_in_sec = p_times_in_sec; + data.duration = p_duration; data.trans_type = p_trans_type; data.ease_type = p_ease_type; data.delay = p_delay; @@ -1341,7 +1354,7 @@ bool Tween::follow_method(Object *p_object , Variant p_initial_val , Object *p_target , String p_target_method - , real_t p_times_in_sec + , real_t p_duration , TransitionType p_trans_type , EaseType p_ease_type , real_t p_delay @@ -1353,7 +1366,7 @@ bool Tween::follow_method(Object *p_object , p_initial_val , p_target , p_target_method - , p_times_in_sec + , p_duration , p_trans_type , p_ease_type , p_delay @@ -1367,7 +1380,7 @@ bool Tween::follow_method(Object *p_object 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_duration <= 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); ERR_FAIL_COND_V(p_delay < 0, false); @@ -1396,7 +1409,7 @@ bool Tween::follow_method(Object *p_object data.initial_val = p_initial_val; data.target_id = p_target->get_instance_ID(); data.target_key = p_target_method; - data.times_in_sec = p_times_in_sec; + data.duration = p_duration; data.trans_type = p_trans_type; data.ease_type = p_ease_type; data.delay = p_delay; @@ -1410,7 +1423,7 @@ bool Tween::targeting_property(Object *p_object , Object *p_initial , String p_initial_property , Variant p_final_val - , real_t p_times_in_sec + , real_t p_duration , TransitionType p_trans_type , EaseType p_ease_type , real_t p_delay @@ -1422,7 +1435,7 @@ bool Tween::targeting_property(Object *p_object , p_initial , p_initial_property , p_final_val - , p_times_in_sec + , p_duration , p_trans_type , p_ease_type , p_delay @@ -1436,7 +1449,7 @@ bool Tween::targeting_property(Object *p_object 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_duration <= 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); ERR_FAIL_COND_V(p_delay < 0, false); @@ -1465,7 +1478,7 @@ bool Tween::targeting_property(Object *p_object data.target_key = p_initial_property; data.initial_val = initial_val; data.final_val = p_final_val; - data.times_in_sec = p_times_in_sec; + data.duration = p_duration; data.trans_type = p_trans_type; data.ease_type = p_ease_type; data.delay = p_delay; @@ -1483,7 +1496,7 @@ bool Tween::targeting_method(Object *p_object , Object *p_initial , String p_initial_method , Variant p_final_val - , real_t p_times_in_sec + , real_t p_duration , TransitionType p_trans_type , EaseType p_ease_type , real_t p_delay @@ -1495,7 +1508,7 @@ bool Tween::targeting_method(Object *p_object , p_initial , p_initial_method , p_final_val - , p_times_in_sec + , p_duration , p_trans_type , p_ease_type , p_delay @@ -1509,7 +1522,7 @@ bool Tween::targeting_method(Object *p_object 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_duration <= 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); ERR_FAIL_COND_V(p_delay < 0, false); @@ -1539,7 +1552,7 @@ bool Tween::targeting_method(Object *p_object data.target_key = p_initial_method; data.initial_val = initial_val; data.final_val = p_final_val; - data.times_in_sec = p_times_in_sec; + data.duration = p_duration; data.trans_type = p_trans_type; data.ease_type = p_ease_type; data.delay = p_delay; diff --git a/scene/animation/tween.h b/scene/animation/tween.h index d0455cdc71..07c2e90da2 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -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 */ @@ -34,7 +34,7 @@ class Tween : public Node { - OBJ_TYPE( Tween, Node ); + GDCLASS( Tween, Node ); public: enum TweenProcessMode { @@ -92,7 +92,7 @@ private: Variant final_val; ObjectID target_id; StringName target_key; - real_t times_in_sec; + real_t duration; TransitionType trans_type; EaseType ease_type; real_t delay; @@ -143,6 +143,7 @@ private: void _tween_process(float p_delta); void _set_process(bool p_process,bool p_force=false); + void _remove(Object *p_node, String p_key, bool first_only); protected: @@ -164,8 +165,8 @@ public: void set_tween_process_mode(TweenProcessMode p_mode); TweenProcessMode get_tween_process_mode() const; - void set_speed(float p_speed); - float get_speed() const; + void set_speed_scale(float p_speed); + float get_speed_scale() const; bool start(); bool reset(Object *p_node, String p_key); @@ -185,7 +186,7 @@ public: , String p_property , Variant p_initial_val , Variant p_final_val - , real_t p_times_in_sec + , real_t p_duration , TransitionType p_trans_type , EaseType p_ease_type , real_t p_delay = 0 @@ -195,20 +196,20 @@ public: , String p_method , Variant p_initial_val , Variant p_final_val - , real_t p_times_in_sec + , real_t p_duration , TransitionType p_trans_type , EaseType p_ease_type , real_t p_delay = 0 ); bool interpolate_callback(Object *p_object - , real_t p_times_in_sec + , real_t p_duration , String p_callback , VARIANT_ARG_DECLARE ); bool interpolate_deferred_callback(Object *p_object - , real_t p_times_in_sec + , real_t p_duration , String p_callback , VARIANT_ARG_DECLARE ); @@ -218,7 +219,7 @@ public: , Variant p_initial_val , Object *p_target , String p_target_property - , real_t p_times_in_sec + , real_t p_duration , TransitionType p_trans_type , EaseType p_ease_type , real_t p_delay = 0 @@ -229,7 +230,7 @@ public: , Variant p_initial_val , Object *p_target , String p_target_method - , real_t p_times_in_sec + , real_t p_duration , TransitionType p_trans_type , EaseType p_ease_type , real_t p_delay = 0 @@ -240,7 +241,7 @@ public: , Object *p_initial , String p_initial_property , Variant p_final_val - , real_t p_times_in_sec + , real_t p_duration , TransitionType p_trans_type , EaseType p_ease_type , real_t p_delay = 0 @@ -251,7 +252,7 @@ public: , Object *p_initial , String p_initial_method , Variant p_final_val - , real_t p_times_in_sec + , real_t p_duration , TransitionType p_trans_type , EaseType p_ease_type , real_t p_delay = 0 diff --git a/scene/animation/tween_interpolaters.cpp b/scene/animation/tween_interpolaters.cpp index 80588d643e..5ba9673014 100644 --- a/scene/animation/tween_interpolaters.cpp +++ b/scene/animation/tween_interpolaters.cpp @@ -1,11 +1,11 @@ /*************************************************************************/ -/* tween.cpp */ +/* tween_interpolaters.cpp */ /*************************************************************************/ /* This file is part of: */ /* 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 */ |