From fdaa2920eb21fff3320a17e9239e04dfadecdb00 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 18 Apr 2015 14:38:54 -0300 Subject: Updated copyright year in all headers --- scene/resources/animation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scene/resources/animation.cpp') diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 80993c7eaf..0f11a66703 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.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 */ -- cgit v1.2.3 From 62129469278b284b91845a678b517c04cefbebfe Mon Sep 17 00:00:00 2001 From: Nathan Warden Date: Sat, 2 May 2015 12:17:59 -0500 Subject: Fixed some items caught in cppcheck --- scene/resources/animation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scene/resources/animation.cpp') diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 0f11a66703..095406dad9 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -1216,8 +1216,8 @@ T Animation::_interpolate( const Vector< TKey >& p_keys, float p_time, Inter if (p_ok) *p_ok=true; - - int next; + + int next=0; float c=0; // prepare for all cases of interpolation -- cgit v1.2.3 From 95047562d743b1c1fdc007432c8a0c145a455c5d Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 29 Jun 2015 00:29:49 -0300 Subject: 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. --- scene/resources/animation.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'scene/resources/animation.cpp') diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 095406dad9..9d668a5716 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -42,8 +42,8 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) { set_step(p_value); else if (name.begins_with("tracks/")) { - int track=name.get_slice("/",1).to_int(); - String what=name.get_slice("/",2); + int track=name.get_slicec('/',1).to_int(); + String what=name.get_slicec('/',2); if (tracks.size()==track && what=="type") { @@ -257,8 +257,8 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const { r_ret= step; else if (name.begins_with("tracks/")) { - int track=name.get_slice("/",1).to_int(); - String what=name.get_slice("/",2); + int track=name.get_slicec('/',1).to_int(); + String what=name.get_slicec('/',2); ERR_FAIL_INDEX_V( track, tracks.size(), false ); if (what=="type") { -- cgit v1.2.3 From 55b34e05b3d735a84e1af9833e19c0b816c18252 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 30 Jun 2015 11:28:43 -0300 Subject: -some changes by okam --- scene/resources/animation.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'scene/resources/animation.cpp') diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 9d668a5716..afd4dc5304 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -1718,7 +1718,7 @@ void Animation::clear() { -bool Animation::_transform_track_optimize_key(const TKey &t0,const TKey &t1, const TKey &t2, float p_alowed_linear_err,float p_alowed_angular_err,float p_max_optimizable_angle) { +bool Animation::_transform_track_optimize_key(const TKey &t0,const TKey &t1, const TKey &t2, float p_alowed_linear_err,float p_alowed_angular_err,float p_max_optimizable_angle,const Vector3& p_norm) { real_t c = (t1.time-t0.time)/(t2.time-t0.time); @@ -1754,6 +1754,9 @@ bool Animation::_transform_track_optimize_key(const TKey &t0,const return false; //beyond allowed error for colinearity } + if (p_norm!=Vector3() && Math::acos(pd.normalized().dot(p_norm))>p_alowed_angular_err) + return false; + t[0] = (d1-d0)/(d2-d0); } } @@ -1905,16 +1908,21 @@ void Animation::_transform_track_optimize(int p_idx,float p_alowed_linear_err,fl bool prev_erased=false; TKey first_erased; + Vector3 norm; + for(int i=1;itransforms.size()-1;i++) { TKey &t0 = tt->transforms[i-1]; TKey &t1 = tt->transforms[i]; TKey &t2 = tt->transforms[i+1]; - bool erase = _transform_track_optimize_key(t0,t1,t2,p_alowed_linear_err,p_alowed_angular_err,p_max_optimizable_angle); + bool erase = _transform_track_optimize_key(t0,t1,t2,p_alowed_linear_err,p_alowed_angular_err,p_max_optimizable_angle,norm); + if (erase && !prev_erased) { + norm=(t2.value.loc-t1.value.loc).normalized(); + } - if (prev_erased && !_transform_track_optimize_key(t0,first_erased,t2,p_alowed_linear_err,p_alowed_angular_err,p_max_optimizable_angle)) { + if (prev_erased && !_transform_track_optimize_key(t0,first_erased,t2,p_alowed_linear_err,p_alowed_angular_err,p_max_optimizable_angle,norm)) { //avoid error to go beyond first erased key erase=false; } @@ -1932,9 +1940,11 @@ void Animation::_transform_track_optimize(int p_idx,float p_alowed_linear_err,fl } else { prev_erased=false; + norm=Vector3(); } + // print_line(itos(i)+" could be eliminated: "+rtos(tr)); //} } -- cgit v1.2.3