summaryrefslogtreecommitdiff
path: root/scene/animation/animation_player.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/animation/animation_player.cpp')
-rw-r--r--scene/animation/animation_player.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index f9d36138a2..f8b58b5cb5 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-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 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 */
@@ -35,10 +35,10 @@ bool AnimationPlayer::_set(const StringName& p_name, const Variant& p_value) {
String name=p_name;
- if (name=="playback/speed" || name=="speed") { //bw compatibility
+ if (p_name==SceneStringNames::get_singleton()->playback_speed || p_name==SceneStringNames::get_singleton()->speed) { //bw compatibility
set_speed(p_value);
- } else if (name=="playback/active") {
+ } else if (p_name==SceneStringNames::get_singleton()->playback_active) {
set_active(p_value);
} else if (name.begins_with("playback/play")) {
@@ -52,16 +52,16 @@ bool AnimationPlayer::_set(const StringName& p_name, const Variant& p_value) {
} else if (name.begins_with("anims/")) {
- String which=name.get_slice("/",1);
+ String which=name.get_slicec('/',1);
add_animation(which,p_value);
} else if (name.begins_with("next/")) {
- String which=name.get_slice("/",1);
+ String which=name.get_slicec('/',1);
animation_set_next(which,p_value);
- } else if (name=="blend_times") {
+ } else if (p_name==SceneStringNames::get_singleton()->blend_times) {
Array array=p_value;
int len = array.size();
@@ -77,7 +77,7 @@ bool AnimationPlayer::_set(const StringName& p_name, const Variant& p_value) {
set_blend_time(from,to,time);
}
- } else if (name=="autoplay") {
+ } else if (p_name==SceneStringNames::get_singleton()->autoplay) {
autoplay=p_value;
} else
@@ -106,12 +106,12 @@ bool AnimationPlayer::_get(const StringName& p_name,Variant &r_ret) const {
} else if (name.begins_with("anims/")) {
- String which=name.get_slice("/",1);
+ String which=name.get_slicec('/',1);
r_ret= get_animation(which).get_ref_ptr();
} else if (name.begins_with("next/")) {
- String which=name.get_slice("/",1);
+ String which=name.get_slicec('/',1);
r_ret= animation_get_next(which);
@@ -223,7 +223,7 @@ void AnimationPlayer::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
- stop_all();
+ //stop_all();
clear_caches();
} break;
}
@@ -295,7 +295,7 @@ void AnimationPlayer::_generate_node_caches(AnimationData* p_anim) {
p_anim->node_cache[i]->bone_idx=p_anim->node_cache[i]->skeleton->find_bone(bone_name);
if (p_anim->node_cache[i]->bone_idx<0) {
- // broken track (unexisting bone)
+ // broken track (nonexistent bone)
p_anim->node_cache[i]->skeleton=NULL;
p_anim->node_cache[i]->spatial=NULL;
printf("bone is %ls\n", String(bone_name).c_str());
@@ -661,8 +661,11 @@ void AnimationPlayer::_animation_process(float p_delta) {
Error AnimationPlayer::add_animation(const StringName& p_name, const Ref<Animation>& p_animation) {
+#ifdef DEBUG_ENABLED
ERR_EXPLAIN("Invalid animation name: "+String(p_name));
ERR_FAIL_COND_V( String(p_name).find("/")!=-1 || String(p_name).find(":")!=-1 || String(p_name).find(",")!=-1 || String(p_name).find("[")!=-1, ERR_INVALID_PARAMETER );
+#endif
+
ERR_FAIL_COND_V( p_animation.is_null() , ERR_INVALID_PARAMETER );
//print_line("Add anim: "+String(p_name)+" name: "+p_animation->get_name());
@@ -967,14 +970,16 @@ String AnimationPlayer::get_current_animation() const {
}
-void AnimationPlayer::stop() {
+void AnimationPlayer::stop(bool p_reset) {
Playback &c=playback;
c.blend.clear();
- c.current.from=NULL;
+ if (p_reset) {
+ c.current.from=NULL;
+ }
_set_process(false);
queued.clear();
- playing = false;
+ playing = false;
}
void AnimationPlayer::stop_all() {
@@ -1211,7 +1216,7 @@ void AnimationPlayer::_bind_methods() {
ObjectTypeDB::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("stop"),&AnimationPlayer::stop);
+ 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);
@@ -1269,7 +1274,7 @@ AnimationPlayer::AnimationPlayer() {
animation_process_mode=ANIMATION_PROCESS_IDLE;
processing=false;
default_blend_time=0;
- root=NodePath("..");
+ root=SceneStringNames::get_singleton()->path_pp;
playing = false;
active=true;
}