diff options
Diffstat (limited to 'scene/animation')
| -rw-r--r-- | scene/animation/SCsub | 4 | ||||
| -rw-r--r-- | scene/animation/animation_cache.cpp | 12 | ||||
| -rw-r--r-- | scene/animation/animation_cache.h | 4 | ||||
| -rw-r--r-- | scene/animation/animation_player.cpp | 127 | ||||
| -rw-r--r-- | scene/animation/animation_player.h | 12 | ||||
| -rw-r--r-- | scene/animation/animation_tree_player.cpp | 187 | ||||
| -rw-r--r-- | scene/animation/animation_tree_player.h | 13 | ||||
| -rw-r--r-- | scene/animation/tween.cpp | 261 | ||||
| -rw-r--r-- | scene/animation/tween.h | 27 | ||||
| -rw-r--r-- | scene/animation/tween_interpolaters.cpp | 2 |
10 files changed, 327 insertions, 322 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 113e2c2278..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); @@ -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 30af9b0094..8b81c45597 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -36,7 +36,7 @@ bool AnimationPlayer::_set(const StringName& p_name, const Variant& p_value) { String name=p_name; if (p_name==SceneStringNames::get_singleton()->playback_speed || p_name==SceneStringNames::get_singleton()->speed) { //bw compatibility - set_speed(p_value); + set_speed_scale(p_value); } else if (p_name==SceneStringNames::get_singleton()->playback_active) { set_active(p_value); @@ -214,14 +214,14 @@ void AnimationPlayer::_notification(int p_what) { set_autoplay(""); //this line is the fix for autoplay issues with animatio } } break; - case NOTIFICATION_PROCESS: { + case NOTIFICATION_INTERNAL_PROCESS: { if (animation_process_mode==ANIMATION_PROCESS_FIXED) break; if (processing) _animation_process( get_process_delta_time() ); } break; - case NOTIFICATION_FIXED_PROCESS: { + case NOTIFICATION_INTERNAL_FIXED_PROCESS: { if (animation_process_mode==ANIMATION_PROCESS_IDLE) break; @@ -269,8 +269,8 @@ void AnimationPlayer::_generate_node_caches(AnimationData* p_anim) { } { - if (!child->is_connected("exit_tree",this,"_node_removed")) - child->connect("exit_tree",this,"_node_removed",make_binds(child),CONNECT_ONESHOT); + if (!child->is_connected("tree_exited",this,"_node_removed")) + child->connect("tree_exited",this,"_node_removed",make_binds(child),CONNECT_ONESHOT); } TrackNodeCacheKey key; @@ -426,8 +426,10 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p Variant value=a->value_track_interpolate(i,p_time); //thanks to trigger mode, this should be solved now.. - //if (p_delta==0 && value.get_type()==Variant::STRING) - // continue; // doing this with strings is messy, should find another way + /* + if (p_delta==0 && value.get_type()==Variant::STRING) + continue; // doing this with strings is messy, should find another way + */ if (pa->accum_pass!=accum_pass) { ERR_CONTINUE( cache_update_prop_size >= NODE_CACHE_UPDATE_MAX ); cache_update_prop[cache_update_prop_size++]=pa; @@ -465,7 +467,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p ERR_PRINTS("Position key at time "+rtos(p_time)+" in Animation Track '"+String(pa->owner->path)+"' not of type Vector2()"); } #endif - static_cast<Node2D*>(pa->object)->set_pos(value); + static_cast<Node2D*>(pa->object)->set_position(value); } break; case SP_NODE2D_ROT: { #ifdef DEBUG_ENABLED @@ -474,7 +476,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p } #endif - static_cast<Node2D*>(pa->object)->set_rot(Math::deg2rad(value)); + static_cast<Node2D*>(pa->object)->set_rotation(Math::deg2rad(value)); } break; case SP_NODE2D_SCALE: { #ifdef DEBUG_ENABLED @@ -679,7 +681,7 @@ void AnimationPlayer::_animation_update_transforms() { ERR_PRINTS("Position key at time "+rtos(playback.current.pos)+" in Animation '"+get_current_animation()+"', Track '"+String(pa->owner->path)+"' not of type Vector2()"); } #endif - static_cast<Node2D*>(pa->object)->set_pos(pa->value_accum); + static_cast<Node2D*>(pa->object)->set_position(pa->value_accum); } break; case SP_NODE2D_ROT: { #ifdef DEBUG_ENABLED @@ -688,7 +690,7 @@ void AnimationPlayer::_animation_update_transforms() { } #endif - static_cast<Node2D*>(pa->object)->set_rot(Math::deg2rad(pa->value_accum)); + static_cast<Node2D*>(pa->object)->set_rotation(Math::deg2rad(pa->value_accum)); } break; case SP_NODE2D_SCALE: { #ifdef DEBUG_ENABLED @@ -713,7 +715,7 @@ void AnimationPlayer::_animation_process(float p_delta) { -// bool any_active=false; + //bool any_active=false; if (playback.current.from) { @@ -733,7 +735,7 @@ void AnimationPlayer::_animation_process(float p_delta) { playing = false; _set_process(false); end_notify=false; - emit_signal(SceneStringNames::get_singleton()->finished); + emit_signal(SceneStringNames::get_singleton()->animation_finished,playback.assigned); } } @@ -1082,13 +1084,13 @@ void AnimationPlayer::stop_all() { } -void AnimationPlayer::set_speed(float p_speed) { +void AnimationPlayer::set_speed_scale(float p_speed) { speed_scale=p_speed; } -float AnimationPlayer::get_speed() const { +float AnimationPlayer::get_speed_scale() const { return speed_scale; } @@ -1231,8 +1233,8 @@ void AnimationPlayer::_set_process(bool p_process,bool p_force) { switch(animation_process_mode) { - case ANIMATION_PROCESS_FIXED: set_fixed_process(p_process && active); break; - case ANIMATION_PROCESS_IDLE: set_process(p_process && active); break; + case ANIMATION_PROCESS_FIXED: set_fixed_process_internal(p_process && active); break; + case ANIMATION_PROCESS_IDLE: set_process_internal(p_process && active); break; } processing=p_process; @@ -1291,68 +1293,69 @@ void AnimationPlayer::get_argument_options(const StringName& p_function,int p_id void AnimationPlayer::_bind_methods() { - ObjectTypeDB::bind_method(_MD("_node_removed"),&AnimationPlayer::_node_removed); - ObjectTypeDB::bind_method(_MD("_animation_changed"),&AnimationPlayer::_animation_changed); + ClassDB::bind_method(_MD("_node_removed"),&AnimationPlayer::_node_removed); + ClassDB::bind_method(_MD("_animation_changed"),&AnimationPlayer::_animation_changed); - ObjectTypeDB::bind_method(_MD("add_animation","name","animation:Animation"),&AnimationPlayer::add_animation); - ObjectTypeDB::bind_method(_MD("remove_animation","name"),&AnimationPlayer::remove_animation); - ObjectTypeDB::bind_method(_MD("rename_animation","name","newname"),&AnimationPlayer::rename_animation); - ObjectTypeDB::bind_method(_MD("has_animation","name"),&AnimationPlayer::has_animation); - ObjectTypeDB::bind_method(_MD("get_animation:Animation","name"),&AnimationPlayer::get_animation); - ObjectTypeDB::bind_method(_MD("get_animation_list"),&AnimationPlayer::_get_animation_list); + ClassDB::bind_method(_MD("add_animation","name","animation:Animation"),&AnimationPlayer::add_animation); + ClassDB::bind_method(_MD("remove_animation","name"),&AnimationPlayer::remove_animation); + ClassDB::bind_method(_MD("rename_animation","name","newname"),&AnimationPlayer::rename_animation); + ClassDB::bind_method(_MD("has_animation","name"),&AnimationPlayer::has_animation); + ClassDB::bind_method(_MD("get_animation:Animation","name"),&AnimationPlayer::get_animation); + ClassDB::bind_method(_MD("get_animation_list"),&AnimationPlayer::_get_animation_list); - ObjectTypeDB::bind_method(_MD("animation_set_next", "anim_from", "anim_to"), &AnimationPlayer::animation_set_next); - ObjectTypeDB::bind_method(_MD("animation_get_next", "anim_from"), &AnimationPlayer::animation_get_next); + ClassDB::bind_method(_MD("animation_set_next", "anim_from", "anim_to"), &AnimationPlayer::animation_set_next); + ClassDB::bind_method(_MD("animation_get_next", "anim_from"), &AnimationPlayer::animation_get_next); - ObjectTypeDB::bind_method(_MD("set_blend_time","anim_from","anim_to","sec"),&AnimationPlayer::set_blend_time); - ObjectTypeDB::bind_method(_MD("get_blend_time","anim_from","anim_to"),&AnimationPlayer::get_blend_time); + ClassDB::bind_method(_MD("set_blend_time","anim_from","anim_to","sec"),&AnimationPlayer::set_blend_time); + ClassDB::bind_method(_MD("get_blend_time","anim_from","anim_to"),&AnimationPlayer::get_blend_time); - ObjectTypeDB::bind_method(_MD("set_default_blend_time","sec"),&AnimationPlayer::set_default_blend_time); - ObjectTypeDB::bind_method(_MD("get_default_blend_time"),&AnimationPlayer::get_default_blend_time); + ClassDB::bind_method(_MD("set_default_blend_time","sec"),&AnimationPlayer::set_default_blend_time); + ClassDB::bind_method(_MD("get_default_blend_time"),&AnimationPlayer::get_default_blend_time); - ObjectTypeDB::bind_method(_MD("play","name","custom_blend","custom_speed","from_end"),&AnimationPlayer::play,DEFVAL(""),DEFVAL(-1),DEFVAL(1.0),DEFVAL(false)); - ObjectTypeDB::bind_method(_MD("play_backwards","name","custom_blend"),&AnimationPlayer::play_backwards,DEFVAL(""),DEFVAL(-1)); - ObjectTypeDB::bind_method(_MD("stop","reset"),&AnimationPlayer::stop,DEFVAL(true)); - ObjectTypeDB::bind_method(_MD("stop_all"),&AnimationPlayer::stop_all); - ObjectTypeDB::bind_method(_MD("is_playing"),&AnimationPlayer::is_playing); - ObjectTypeDB::bind_method(_MD("set_current_animation","anim"),&AnimationPlayer::set_current_animation); - ObjectTypeDB::bind_method(_MD("get_current_animation"),&AnimationPlayer::get_current_animation); - ObjectTypeDB::bind_method(_MD("queue","name"),&AnimationPlayer::queue); - ObjectTypeDB::bind_method(_MD("clear_queue"),&AnimationPlayer::clear_queue); + ClassDB::bind_method(_MD("play","name","custom_blend","custom_speed","from_end"),&AnimationPlayer::play,DEFVAL(""),DEFVAL(-1),DEFVAL(1.0),DEFVAL(false)); + ClassDB::bind_method(_MD("play_backwards","name","custom_blend"),&AnimationPlayer::play_backwards,DEFVAL(""),DEFVAL(-1)); + ClassDB::bind_method(_MD("stop","reset"),&AnimationPlayer::stop,DEFVAL(true)); + ClassDB::bind_method(_MD("stop_all"),&AnimationPlayer::stop_all); + ClassDB::bind_method(_MD("is_playing"),&AnimationPlayer::is_playing); + ClassDB::bind_method(_MD("set_current_animation","anim"),&AnimationPlayer::set_current_animation); + ClassDB::bind_method(_MD("get_current_animation"),&AnimationPlayer::get_current_animation); + ClassDB::bind_method(_MD("queue","name"),&AnimationPlayer::queue); + ClassDB::bind_method(_MD("clear_queue"),&AnimationPlayer::clear_queue); - ObjectTypeDB::bind_method(_MD("set_active","active"),&AnimationPlayer::set_active); - ObjectTypeDB::bind_method(_MD("is_active"),&AnimationPlayer::is_active); + ClassDB::bind_method(_MD("set_active","active"),&AnimationPlayer::set_active); + ClassDB::bind_method(_MD("is_active"),&AnimationPlayer::is_active); - ObjectTypeDB::bind_method(_MD("set_speed","speed"),&AnimationPlayer::set_speed); - ObjectTypeDB::bind_method(_MD("get_speed"),&AnimationPlayer::get_speed); + ClassDB::bind_method(_MD("set_speed_scale","speed"),&AnimationPlayer::set_speed_scale); + ClassDB::bind_method(_MD("get_speed_scale"),&AnimationPlayer::get_speed_scale); - ObjectTypeDB::bind_method(_MD("set_autoplay","name"),&AnimationPlayer::set_autoplay); - ObjectTypeDB::bind_method(_MD("get_autoplay"),&AnimationPlayer::get_autoplay); + ClassDB::bind_method(_MD("set_autoplay","name"),&AnimationPlayer::set_autoplay); + ClassDB::bind_method(_MD("get_autoplay"),&AnimationPlayer::get_autoplay); - ObjectTypeDB::bind_method(_MD("set_root","path"),&AnimationPlayer::set_root); - ObjectTypeDB::bind_method(_MD("get_root"),&AnimationPlayer::get_root); + ClassDB::bind_method(_MD("set_root","path"),&AnimationPlayer::set_root); + ClassDB::bind_method(_MD("get_root"),&AnimationPlayer::get_root); - ObjectTypeDB::bind_method(_MD("seek","pos_sec","update"),&AnimationPlayer::seek,DEFVAL(false)); - ObjectTypeDB::bind_method(_MD("get_pos"),&AnimationPlayer::get_current_animation_pos); + ClassDB::bind_method(_MD("seek","pos_sec","update"),&AnimationPlayer::seek,DEFVAL(false)); + ClassDB::bind_method(_MD("get_pos"),&AnimationPlayer::get_current_animation_pos); - ObjectTypeDB::bind_method(_MD("find_animation","animation:Animation"),&AnimationPlayer::find_animation); + ClassDB::bind_method(_MD("find_animation","animation:Animation"),&AnimationPlayer::find_animation); - ObjectTypeDB::bind_method(_MD("clear_caches"),&AnimationPlayer::clear_caches); + ClassDB::bind_method(_MD("clear_caches"),&AnimationPlayer::clear_caches); - ObjectTypeDB::bind_method(_MD("set_animation_process_mode","mode"),&AnimationPlayer::set_animation_process_mode); - ObjectTypeDB::bind_method(_MD("get_animation_process_mode"),&AnimationPlayer::get_animation_process_mode); + ClassDB::bind_method(_MD("set_animation_process_mode","mode"),&AnimationPlayer::set_animation_process_mode); + ClassDB::bind_method(_MD("get_animation_process_mode"),&AnimationPlayer::get_animation_process_mode); - ObjectTypeDB::bind_method(_MD("get_current_animation_pos"),&AnimationPlayer::get_current_animation_pos); - ObjectTypeDB::bind_method(_MD("get_current_animation_length"),&AnimationPlayer::get_current_animation_length); + ClassDB::bind_method(_MD("get_current_animation_pos"),&AnimationPlayer::get_current_animation_pos); + ClassDB::bind_method(_MD("get_current_animation_length"),&AnimationPlayer::get_current_animation_length); - ObjectTypeDB::bind_method(_MD("advance","delta"),&AnimationPlayer::advance); + ClassDB::bind_method(_MD("advance","delta"),&AnimationPlayer::advance); - ADD_PROPERTY( PropertyInfo( Variant::INT, "playback/process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_animation_process_mode"), _SCS("get_animation_process_mode")); - ADD_PROPERTY( PropertyInfo( Variant::REAL, "playback/default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01"), _SCS("set_default_blend_time"), _SCS("get_default_blend_time")); - ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "root/root"), _SCS("set_root"), _SCS("get_root")); + ADD_GROUP("Playback","playback_"); + ADD_PROPERTY( PropertyInfo( Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_animation_process_mode"), _SCS("get_animation_process_mode")); + ADD_PROPERTY( PropertyInfo( Variant::REAL, "playback_default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01"), _SCS("set_default_blend_time"), _SCS("get_default_blend_time")); + ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "root_node"), _SCS("set_root"), _SCS("get_root")); - ADD_SIGNAL( MethodInfo("finished") ); + ADD_SIGNAL( MethodInfo("animation_finished", PropertyInfo(Variant::STRING,"name")) ); ADD_SIGNAL( MethodInfo("animation_changed", PropertyInfo(Variant::STRING,"old_name"), PropertyInfo(Variant::STRING,"new_name")) ); ADD_SIGNAL( MethodInfo("animation_started", PropertyInfo(Variant::STRING,"name")) ); diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index ac0265dbaa..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 */ @@ -39,7 +39,7 @@ */ class AnimationPlayer : public Node { - OBJ_TYPE( AnimationPlayer, Node ); + GDCLASS( AnimationPlayer, Node ); OBJ_CATEGORY("Animation Nodes"); public: @@ -208,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()); @@ -271,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 9488ae37a8..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; @@ -494,15 +494,8 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode case NODE_OUTPUT: { NodeOut *on = static_cast<NodeOut*>(nb); - - for(TrackMap::Element *E=track_map.front();E;E=E->next()) { - E->get().total_weight = 0; - } - HashMap<NodePath, float> weights; - - return _process_node(on->inputs[0].node,r_prev_anim,p_time,p_seek, p_fallback_weight, &weights); } break; @@ -513,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; @@ -544,15 +537,12 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode NodePath track_path = an->animation->track_get_path(E->get().local_track); if (an->filter.has(track_path) && an->filter[track_path]) { E->get().weight = 0; - E->get().track->total_weight += p_fallback_weight; } else { if (p_weights->has(track_path)) { float weight = (*p_weights)[track_path]; E->get().weight = weight; - E->get().track->total_weight += weight; } else { E->get().weight = p_fallback_weight; - E->get().track->total_weight += p_fallback_weight; } } if (E->get().weight>CMP_EPSILON) @@ -875,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 / tr.track->total_weight; - switch(a->track_get_type(tr.local_track)) { case Animation::TYPE_TRANSFORM: { ///< Transform a node or a bone. @@ -885,14 +873,14 @@ 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; @@ -900,7 +888,7 @@ void AnimationTreePlayer::_process_animation(float p_delta) { 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); @@ -1508,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()) { @@ -1550,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); @@ -1562,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)); @@ -1752,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()) { @@ -1840,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 ); diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h index 6b5350e9ee..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 */ @@ -38,7 +38,7 @@ class AnimationTreePlayer : public Node { - OBJ_TYPE( AnimationTreePlayer, Node ); + GDCLASS( AnimationTreePlayer, Node ); OBJ_CATEGORY("Animation Nodes"); public: @@ -111,7 +111,6 @@ private: Variant value; bool skip; - float total_weight; }; @@ -283,7 +282,7 @@ 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); @@ -398,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/tween.cpp b/scene/animation/tween.cpp index adc8f9c8cf..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; } @@ -620,7 +621,7 @@ 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); + call_deferred("_remove", object, data.key, true); } continue; } @@ -631,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 --; @@ -665,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; @@ -696,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; } @@ -723,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; @@ -759,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 --; @@ -793,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 --; @@ -816,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() { @@ -860,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; @@ -905,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; } @@ -942,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], @@ -959,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]; @@ -976,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: @@ -1024,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 @@ -1035,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 @@ -1049,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); @@ -1068,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; @@ -1084,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 @@ -1095,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 @@ -1109,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); @@ -1127,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; @@ -1140,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 ) { @@ -1148,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 @@ -1161,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); @@ -1175,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; @@ -1206,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 ) { @@ -1214,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 @@ -1226,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); @@ -1240,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; @@ -1275,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 @@ -1287,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 @@ -1301,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); @@ -1329,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; @@ -1343,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 @@ -1355,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 @@ -1369,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); @@ -1398,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; @@ -1412,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 @@ -1424,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 @@ -1438,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); @@ -1467,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; @@ -1485,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 @@ -1497,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 @@ -1511,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); @@ -1541,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 058a7f12bc..5ba9673014 100644 --- a/scene/animation/tween_interpolaters.cpp +++ b/scene/animation/tween_interpolaters.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 */ |