summaryrefslogtreecommitdiff
path: root/scene/animation/animation_player.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-06-29 00:29:49 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-06-29 00:29:49 -0300
commit95047562d743b1c1fdc007432c8a0c145a455c5d (patch)
treef563e5c900c4330fcc602b6e5a721bc63022b253 /scene/animation/animation_player.cpp
parent2b64f73b0459190d20b2f6de39275ee7979317c4 (diff)
Several performance improvements, mainly in loading and instancing scenes and resources.
A general speedup should be apparent, with even more peformance increase when compiling optimized. WARNING: Tested and it seems to work, but if something breaks, please report.
Diffstat (limited to 'scene/animation/animation_player.cpp')
-rw-r--r--scene/animation/animation_player.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 74ae2c0d55..f8b58b5cb5 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -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);
@@ -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());
@@ -1271,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;
}