From 55b34e05b3d735a84e1af9833e19c0b816c18252 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 30 Jun 2015 11:28:43 -0300 Subject: [PATCH] -some changes by okam --- core/globals.cpp | 9 +++++++++ core/globals.h | 1 + core/io/file_access_encrypted.cpp | 4 +++- core/print_string.cpp | 1 + core/print_string.h | 1 + drivers/speex/audio_stream_speex.cpp | 2 +- drivers/unix/os_unix.cpp | 6 ++++++ main/main.cpp | 3 +++ modules/gdscript/gd_script.cpp | 8 ++++++++ modules/gdscript/gd_script.h | 2 ++ platform/iphone/app_delegate.mm | 23 +++++++++++++++++++++++ scene/resources/animation.cpp | 16 +++++++++++++--- scene/resources/animation.h | 2 +- 13 files changed, 72 insertions(+), 6 deletions(-) diff --git a/core/globals.cpp b/core/globals.cpp index 062adc21f99..731c5b7dff1 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -1149,6 +1149,12 @@ Error Globals::_save_settings_text(const String& p_file,const Map& p_ignore_masks) { ERR_FAIL_COND_V(p_path=="",ERR_INVALID_PARAMETER); @@ -1361,6 +1367,9 @@ void Globals::_bind_methods() { ObjectTypeDB::bind_method(_MD("has_singleton"),&Globals::has_singleton); ObjectTypeDB::bind_method(_MD("get_singleton"),&Globals::get_singleton_object); ObjectTypeDB::bind_method(_MD("load_resource_pack"),&Globals::_load_resource_pack); + + ObjectTypeDB::bind_method(_MD("save_custom"),&Globals::_save_custom_bnd); + } Globals::Globals() { diff --git a/core/globals.h b/core/globals.h index f739bcfb90b..2ec56966f63 100644 --- a/core/globals.h +++ b/core/globals.h @@ -86,6 +86,7 @@ protected: List singletons; + Error _save_custom_bnd(const String& p_file); bool _load_resource_pack(const String& p_pack); diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index 29f27dcbdab..65b1ca52076 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -5,10 +5,12 @@ #include "print_string.h" #define COMP_MAGIC 0x43454447 +#include "core/variant.h" +#include Error FileAccessEncrypted::open_and_parse(FileAccess *p_base,const Vector& p_key,Mode p_mode) { - print_line("open and parse!"); + //print_line("open and parse!"); ERR_FAIL_COND_V(file!=NULL,ERR_ALREADY_IN_USE); ERR_FAIL_COND_V(p_key.size()!=32,ERR_INVALID_PARAMETER); diff --git a/core/print_string.cpp b/core/print_string.cpp index a06d4de2373..42e018f3032 100644 --- a/core/print_string.cpp +++ b/core/print_string.cpp @@ -32,6 +32,7 @@ static PrintHandlerList *print_handler_list=NULL; bool _print_line_enabled=true; +bool _print_error_enabled = true; void add_print_handler(PrintHandlerList *p_handler) { diff --git a/core/print_string.h b/core/print_string.h index 854f8ec2e50..4ea389b3a1f 100644 --- a/core/print_string.h +++ b/core/print_string.h @@ -52,6 +52,7 @@ void add_print_handler(PrintHandlerList *p_handler); void remove_print_handler(PrintHandlerList *p_handler); extern bool _print_line_enabled; +extern bool _print_error_enabled; extern void print_line(String p_string); #endif diff --git a/drivers/speex/audio_stream_speex.cpp b/drivers/speex/audio_stream_speex.cpp index a6bac78b4d4..bcf4c515f80 100644 --- a/drivers/speex/audio_stream_speex.cpp +++ b/drivers/speex/audio_stream_speex.cpp @@ -21,7 +21,7 @@ void AudioStreamSpeex::update() { //printf("update, loops %i, read ofs %i\n", (int)loops, read_ofs); //printf("playing %i, paused %i\n", (int)playing, (int)paused); - if (!playing || paused || !data.size()) + if (!active || !playing || paused || !data.size()) return; /* diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 8ba56490d79..f6d9e0fb4e8 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -57,8 +57,14 @@ #include #include #include "globals.h" + +extern bool _print_error_enabled; + void OS_Unix::print_error(const char* p_function,const char* p_file,int p_line,const char *p_code,const char*p_rationale,ErrorType p_type) { + if (!_print_error_enabled) + return; + if (p_rationale && p_rationale[0]) { print("\E[1;31;40mERROR: %s: \E[1;37;40m%s\n",p_function,p_rationale); diff --git a/main/main.cpp b/main/main.cpp index f68bde003ee..4cf4f3c7cdb 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -605,6 +605,9 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas if (bool(Globals::get_singleton()->get("application/disable_stdout"))) { quiet_stdout=true; } + if (bool(Globals::get_singleton()->get("application/disable_stderr"))) { + _print_error_enabled = false; + }; if (quiet_stdout) _print_line_enabled=false; diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 63bb44784d0..53ae0c87021 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -1977,9 +1977,17 @@ void GDScript::_bind_methods() { ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"new",&GDScript::_new,MethodInfo("new")); + ObjectTypeDB::bind_method(_MD("get_as_byte_code"),&GDScript::get_as_byte_code); + } +Vector GDScript::get_as_byte_code() const { + + GDTokenizerBuffer tokenizer; + return tokenizer.parse_code_string(source); +}; + Error GDScript::load_byte_code(const String& p_path) { diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h index 4672f3b8be3..1e1279d5f54 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gd_script.h @@ -349,6 +349,8 @@ public: Error load_source_code(const String& p_path); Error load_byte_code(const String& p_path); + Vector get_as_byte_code() const; + virtual ScriptLanguage *get_language() const; GDScript(); diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index 2c7a0a0790c..dba37ab1b8c 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -138,6 +138,29 @@ static int frame_count = 0; Main::setup2(); ++frame_count; + // this might be necessary before here + for (NSString* key in [[NSBundle mainBundle] infoDictionary]) { + NSObject* value = [xyz objectForKey:key]; + String ukey = String::utf8([key UTF8String]); + + // we need a NSObject to Variant conversor + + if ([value isKindOfClass:[NSString class]]) { + NSString* str = (NSString*)value; + String uval = String::utf8([str UTF8String]); + + Globals::get_singleton()->set("Info.plist/"+ukey, uval); + + } else if ([value isKindOfClass:[NSNumber class]]) { + + NSNumber* n = (NSNumber*)value; + double dval = [n doubleValue]; + + Globals::get_singleton()->set("Info.plist/"+ukey, dval); + }; + // do stuff + } + } break; /* case 3: { diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 9d668a57162..afd4dc53040 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)); //} } diff --git a/scene/resources/animation.h b/scene/resources/animation.h index d4042646fb6..256826a4bb5 100644 --- a/scene/resources/animation.h +++ b/scene/resources/animation.h @@ -204,7 +204,7 @@ private: return idxr; } - bool _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 _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); void _transform_track_optimize(int p_idx, float p_allowed_err=0.05, float p_alowed_angular_err=0.01,float p_max_optimizable_angle=Math_PI*0.125); protected: