From 891db1e1125fc73c53ef815e2847b6841050da77 Mon Sep 17 00:00:00 2001 From: jack Date: Sat, 25 Apr 2015 22:18:57 -0400 Subject: Set name on isometric-light demo's engine.cfg --- demos/2d/isometric_light/engine.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/2d/isometric_light/engine.cfg b/demos/2d/isometric_light/engine.cfg index 0d9e432d5d..08393f1724 100644 --- a/demos/2d/isometric_light/engine.cfg +++ b/demos/2d/isometric_light/engine.cfg @@ -1,5 +1,6 @@ [application] +name="Isometric 2D + Lighting" main_scene="res://map.scn" [input] -- cgit v1.2.3 From f62e09150e473d9416d4e12547925a3b321d8764 Mon Sep 17 00:00:00 2001 From: jack Date: Sat, 25 Apr 2015 22:20:06 -0400 Subject: Set name on truck-town demo's engine.cfg --- demos/3d/truck_town/engine.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/3d/truck_town/engine.cfg b/demos/3d/truck_town/engine.cfg index f47c0de4fa..3c340e6dcd 100644 --- a/demos/3d/truck_town/engine.cfg +++ b/demos/3d/truck_town/engine.cfg @@ -1,5 +1,6 @@ [application] +name="Truck Town" main_scene="res://car_select.scn" [display] -- cgit v1.2.3 From d066c06e36bdf81b67a142732c519b6a464e51cd Mon Sep 17 00:00:00 2001 From: jack Date: Sat, 25 Apr 2015 22:21:09 -0400 Subject: Set name on rich text bbcode demo's engine.cfg --- demos/gui/rich_text_bbcode/engine.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/gui/rich_text_bbcode/engine.cfg b/demos/gui/rich_text_bbcode/engine.cfg index 5fb2587d91..e0ea296f6d 100644 --- a/demos/gui/rich_text_bbcode/engine.cfg +++ b/demos/gui/rich_text_bbcode/engine.cfg @@ -1,3 +1,4 @@ [application] +name="Rich Text Label (BBCode)" main_scene="res://rich_text_bbcode.scn" -- cgit v1.2.3 From ffbe3eeff9782e19a33fea7eec60846f10729a9f Mon Sep 17 00:00:00 2001 From: jack Date: Sat, 25 Apr 2015 22:22:04 -0400 Subject: Set name on window management demo's engine.cfg --- demos/misc/window_management/engine.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/misc/window_management/engine.cfg b/demos/misc/window_management/engine.cfg index c53bd45fb7..0a34231673 100644 --- a/demos/misc/window_management/engine.cfg +++ b/demos/misc/window_management/engine.cfg @@ -1,6 +1,6 @@ [application] -name="window_management" +name="Window Management" main_scene="res://window_management.scn" icon="icon.png" -- cgit v1.2.3 From d22a13e2e8979769fa8d50c98c8eecc8644fe9e4 Mon Sep 17 00:00:00 2001 From: jack Date: Sat, 25 Apr 2015 22:45:49 -0400 Subject: issue #1715 - menu separator There was a request for a separator between Open Scene and Save Scene to avoid accidental mis-clicks. So here's that! --- tools/editor/editor_node.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index f50db40525..6d992960f3 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -3504,6 +3504,7 @@ EditorNode::EditorNode() { p=file_menu->get_popup(); p->add_item("New Scene",FILE_NEW_SCENE); p->add_item("Open Scene..",FILE_OPEN_SCENE,KEY_MASK_CMD+KEY_O); + p->add_separator(); p->add_item("Save Scene",FILE_SAVE_SCENE,KEY_MASK_CMD+KEY_S); p->add_item("Save Scene As..",FILE_SAVE_AS_SCENE,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_S); p->add_separator(); -- cgit v1.2.3 From 1a6012aff57498a476982f8dd918b5898da6e1f1 Mon Sep 17 00:00:00 2001 From: Gen Date: Tue, 28 Apr 2015 23:06:34 +0800 Subject: Update label.cpp --- scene/gui/label.cpp | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 6afff81fde..951df155d5 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -170,7 +170,7 @@ void Label::_notification(int p_what) { while(to && to->char_pos>=0) { taken+=to->pixel_width; - if (to!=from) { + if (to!=from && to->space_insert) { spaces++; } to=to->next; @@ -212,15 +212,15 @@ void Label::_notification(int p_what) { ERR_PRINT("BUG"); return; } - if (from!=wc) { + if (from!=wc && from->space_insert) { /* spacing */ x_ofs+=space_w; if (can_fill && align==ALIGN_FILL && spaces) { - + x_ofs+=int((size.width-(taken+space_w*spaces))/spaces); } - - + + } @@ -411,6 +411,38 @@ void Label::regenerate_word_cache() { } + }else if ((current < 65||current >90) && (current<97||current>122)) { + if (current_word_size>0) { + + WordCache *wc = memnew( WordCache ); + if (word_cache) { + last->next=wc; + } else { + word_cache=wc; + } + last=wc; + + wc->pixel_width=current_word_size; + wc->char_pos=word_pos; + wc->word_len=i-word_pos; + current_word_size=0; + } + WordCache *wc = memnew( WordCache ); + if (word_cache) { + last->next=wc; + } else { + word_cache=wc; + } + last=wc; + + wc->pixel_width=font->get_char_size(current).width; + wc->char_pos=i; + wc->word_len=1; + wc->space_insert = false; + current_word_size=0; + word_pos = i+1; + line_width+=wc->pixel_width; + total_char_cache++; } else { if (current_word_size==0) { -- cgit v1.2.3 From dfc59d1e006a0c7c90d48d2781b48000cbd7c88c Mon Sep 17 00:00:00 2001 From: Gen Date: Tue, 28 Apr 2015 23:07:41 +0800 Subject: Update label.h --- scene/gui/label.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scene/gui/label.h b/scene/gui/label.h index 3b0dddc1a3..6c1a5d8c86 100644 --- a/scene/gui/label.h +++ b/scene/gui/label.h @@ -75,8 +75,9 @@ private: int char_pos; // if -1, then newline int word_len; int pixel_width; + bool space_insert; WordCache *next; - WordCache() { char_pos=0; word_len=0; pixel_width=0; next=0; } + WordCache() { char_pos=0; word_len=0; pixel_width=0; next=0; space_insert=true;} }; bool word_cache_dirty; -- cgit v1.2.3 From ad358562e5ab2c0fdb916acba7cf3118802de21f Mon Sep 17 00:00:00 2001 From: Gen Date: Wed, 29 Apr 2015 16:34:25 +0800 Subject: record the number of space before a words. --- scene/gui/label.cpp | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 951df155d5..e5226ca9b3 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -170,8 +170,8 @@ void Label::_notification(int p_what) { while(to && to->char_pos>=0) { taken+=to->pixel_width; - if (to!=from && to->space_insert) { - spaces++; + if (to!=from && to->space_count) { + spaces+=to->space_count; } to=to->next; } @@ -212,9 +212,9 @@ void Label::_notification(int p_what) { ERR_PRINT("BUG"); return; } - if (from!=wc && from->space_insert) { + if (from!=wc && from->space_count) { /* spacing */ - x_ofs+=space_w; + x_ofs+=space_w*from->space_count; if (can_fill && align==ALIGN_FILL && spaces) { x_ofs+=int((size.width-(taken+space_w*spaces))/spaces); @@ -366,6 +366,8 @@ void Label::regenerate_word_cache() { int word_pos=0; int line_width=0; int last_width=0; + int space_count=0; + int space_width=font->get_char_size(' ').width; line_count=1; total_char_cache=0; @@ -383,7 +385,6 @@ void Label::regenerate_word_cache() { if (current<33) { if (current_word_size>0) { - WordCache *wc = memnew( WordCache ); if (word_cache) { last->next=wc; @@ -395,7 +396,9 @@ void Label::regenerate_word_cache() { wc->pixel_width=current_word_size; wc->char_pos=word_pos; wc->word_len=i-word_pos; + wc->space_count = space_count; current_word_size=0; + space_count=0; } @@ -408,10 +411,16 @@ void Label::regenerate_word_cache() { if (i 0) { + space_count++; + line_width+=space_width; + }else { + space_count=0; + } } - }else if ((current < 65||current >90) && (current<97||current>122)) { + }else if ((current < 65||current >90) && (current<97||current>122) && (current<48||current>57)) { if (current_word_size>0) { WordCache *wc = memnew( WordCache ); @@ -425,7 +434,9 @@ void Label::regenerate_word_cache() { wc->pixel_width=current_word_size; wc->char_pos=word_pos; wc->word_len=i-word_pos; + wc->space_count = space_count; current_word_size=0; + space_count=0; } WordCache *wc = memnew( WordCache ); if (word_cache) { @@ -438,16 +449,14 @@ void Label::regenerate_word_cache() { wc->pixel_width=font->get_char_size(current).width; wc->char_pos=i; wc->word_len=1; - wc->space_insert = false; + wc->space_count=space_count; current_word_size=0; - word_pos = i+1; - line_width+=wc->pixel_width; + space_count=0; total_char_cache++; + line_width+=wc->pixel_width; } else { - + // latin characters if (current_word_size==0) { - if (line_width>0) // add a space before the new word if a word existed before - line_width+=font->get_char_size(' ').width; word_pos=i; } @@ -457,9 +466,10 @@ void Label::regenerate_word_cache() { total_char_cache++; } - + + print_line(itos(line_width)); if ((autowrap && line_width>=width && last_widthnext=wc; @@ -467,14 +477,14 @@ void Label::regenerate_word_cache() { word_cache=wc; } last=wc; - + wc->pixel_width=0; wc->char_pos=insert_newline?WordCache::CHAR_NEWLINE:WordCache::CHAR_WRAPLINE; line_width=current_word_size; line_count++; - + } last_width=line_width; -- cgit v1.2.3 From 6fa342a1b05ad4f4f079ba38925e4980439137c4 Mon Sep 17 00:00:00 2001 From: Gen Date: Wed, 29 Apr 2015 16:34:56 +0800 Subject: record the number of space before a word. --- scene/gui/label.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scene/gui/label.h b/scene/gui/label.h index 6c1a5d8c86..81e3ab5676 100644 --- a/scene/gui/label.h +++ b/scene/gui/label.h @@ -75,9 +75,9 @@ private: int char_pos; // if -1, then newline int word_len; int pixel_width; - bool space_insert; + int space_count; WordCache *next; - WordCache() { char_pos=0; word_len=0; pixel_width=0; next=0; space_insert=true;} + WordCache() { char_pos=0; word_len=0; pixel_width=0; next=0; space_count=0;} }; bool word_cache_dirty; -- cgit v1.2.3 From 02d672753f18eb3dbae1f5479861b84a1912a5db Mon Sep 17 00:00:00 2001 From: Gen Date: Wed, 29 Apr 2015 23:43:39 +0800 Subject: space is only skipped when autowrap. --- scene/gui/label.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index e5226ca9b3..83b36daff4 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -212,7 +212,7 @@ void Label::_notification(int p_what) { ERR_PRINT("BUG"); return; } - if (from!=wc && from->space_count) { + if (from->space_count) { /* spacing */ x_ofs+=space_w*from->space_count; if (can_fill && align==ALIGN_FILL && spaces) { @@ -411,7 +411,7 @@ void Label::regenerate_word_cache() { if (i 0) { + if (line_width > 0 || last==NULL || last->char_pos!=WordCache::CHAR_WRAPLINE) { space_count++; line_width+=space_width; }else { @@ -467,7 +467,6 @@ void Label::regenerate_word_cache() { } - print_line(itos(line_width)); if ((autowrap && line_width>=width && last_width Date: Thu, 30 Apr 2015 00:03:19 +0800 Subject: Update label.cpp --- scene/gui/label.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 83b36daff4..4069fbb553 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -437,6 +437,25 @@ void Label::regenerate_word_cache() { wc->space_count = space_count; current_word_size=0; space_count=0; + } + float current_width = font->get_char_size(current).width; + if ((autowrap && line_width+current_width>=width && last_widthnext=wc; + } else { + word_cache=wc; + } + last=wc; + + wc->pixel_width=0; + wc->char_pos=WordCache::CHAR_WRAPLINE; + + line_width=0; + line_count++; + + } WordCache *wc = memnew( WordCache ); if (word_cache) { @@ -446,7 +465,7 @@ void Label::regenerate_word_cache() { } last=wc; - wc->pixel_width=font->get_char_size(current).width; + wc->pixel_width=current_width; wc->char_pos=i; wc->word_len=1; wc->space_count=space_count; -- cgit v1.2.3 From c322eddffb6ac9abc709cfdc7bdc4466bdb7b80a Mon Sep 17 00:00:00 2001 From: Gen Date: Thu, 30 Apr 2015 12:47:05 +0800 Subject: fixed a autowrap bug when word is too length. --- scene/gui/label.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 4069fbb553..38e7435aeb 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -99,7 +99,7 @@ void Label::_notification(int p_what) { int chars_total=0; int vbegin=0,vsep=0; - + if (lines_total && lines_total < lines_visible) { @@ -136,10 +136,9 @@ void Label::_notification(int p_what) { if (!wc) return; - + int c = 0; int line=0; while(wc) { - /* handle lines not meant to be drawn quickly */ if (line>line_to) break; @@ -253,7 +252,7 @@ void Label::_notification(int p_what) { } for (int i=0;iword_len;i++) { - + if (visible_chars < 0 || chars_total=width && last_width=width && last && last->char_pos >= 0) || insert_newline) { WordCache *wc = memnew( WordCache ); if (word_cache) { @@ -525,7 +524,7 @@ void Label::regenerate_word_cache() { set_max(line_count); word_cache_dirty=false; - + } -- cgit v1.2.3 From 0bc5b7a1464b442a9e54cd05c9720d1d53693ee1 Mon Sep 17 00:00:00 2001 From: Gen Date: Fri, 1 May 2015 18:47:34 +0800 Subject: Optimize the code. --- scene/gui/label.cpp | 97 +++++++++++++++++------------------------------------ 1 file changed, 31 insertions(+), 66 deletions(-) diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 38e7435aeb..1751d335ee 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -360,11 +360,10 @@ void Label::regenerate_word_cache() { int width=autowrap?get_size().width:get_longest_line_width(); Ref font = get_font("font"); - + int current_word_size=0; int word_pos=0; int line_width=0; - int last_width=0; int space_count=0; int space_width=font->get_char_size(' ').width; line_count=1; @@ -375,14 +374,16 @@ void Label::regenerate_word_cache() { for (int i=0;i=33 && (current < 65||current >90) && (current<97||current>122) && (current<48||current>57); bool insert_newline=false; - + int char_width; + if (current<33) { - + if (current_word_size>0) { WordCache *wc = memnew( WordCache ); if (word_cache) { @@ -391,16 +392,16 @@ void Label::regenerate_word_cache() { word_cache=wc; } last=wc; - + wc->pixel_width=current_word_size; wc->char_pos=word_pos; wc->word_len=i-word_pos; wc->space_count = space_count; current_word_size=0; space_count=0; - + } - + if (current=='\n') { insert_newline=true; @@ -419,73 +420,39 @@ void Label::regenerate_word_cache() { } - }else if ((current < 65||current >90) && (current<97||current>122) && (current<48||current>57)) { - if (current_word_size>0) { - - WordCache *wc = memnew( WordCache ); - if (word_cache) { - last->next=wc; - } else { - word_cache=wc; - } - last=wc; - - wc->pixel_width=current_word_size; - wc->char_pos=word_pos; - wc->word_len=i-word_pos; - wc->space_count = space_count; - current_word_size=0; - space_count=0; - } - float current_width = font->get_char_size(current).width; - if ((autowrap && line_width+current_width>=width && last_widthnext=wc; - } else { - word_cache=wc; - } - last=wc; - - wc->pixel_width=0; - wc->char_pos=WordCache::CHAR_WRAPLINE; - - line_width=0; - line_count++; - - - } - WordCache *wc = memnew( WordCache ); - if (word_cache) { - last->next=wc; - } else { - word_cache=wc; - } - last=wc; - - wc->pixel_width=current_width; - wc->char_pos=i; - wc->word_len=1; - wc->space_count=space_count; - current_word_size=0; - space_count=0; - total_char_cache++; - line_width+=wc->pixel_width; } else { // latin characters if (current_word_size==0) { word_pos=i; } - int char_width=font->get_char_size(current).width; + char_width=font->get_char_size(current).width; current_word_size+=char_width; line_width+=char_width; total_char_cache++; } - if ((autowrap && line_width>=width && last && last->char_pos >= 0) || insert_newline) { + if ((autowrap && line_width>=width && (last && last->char_pos >= 0 || not_latin)) || insert_newline) { + if (not_latin) { + if (current_word_size>0) { + WordCache *wc = memnew( WordCache ); + if (word_cache) { + last->next=wc; + } else { + word_cache=wc; + } + last=wc; + + wc->pixel_width=current_word_size-char_width; + wc->char_pos=word_pos; + wc->word_len=i-word_pos; + wc->space_count = space_count; + current_word_size=char_width; + space_count=0; + word_pos=i; + } + } WordCache *wc = memnew( WordCache ); if (word_cache) { @@ -500,12 +467,10 @@ void Label::regenerate_word_cache() { line_width=current_word_size; line_count++; - + space_count=0; } - last_width=line_width; - } //total_char_cache -= line_count + 1; // do not count new lines (including the first one) -- cgit v1.2.3 From 8e7973d660b1f7bc25323b8ef843310f1deb2107 Mon Sep 17 00:00:00 2001 From: Biliogadafr Date: Sat, 2 May 2015 00:03:49 +0300 Subject: Triple click doesn't select line if click was done on different lines. Fix #1727 --- scene/gui/text_edit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 1e82432165..6cdff20aaf 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1249,7 +1249,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { } - if (!mb.doubleclick && (OS::get_singleton()->get_ticks_msec()-last_dblclk)<600) { + if (!mb.doubleclick && (OS::get_singleton()->get_ticks_msec()-last_dblclk)<600 && cursor.line==prev_line) { //tripleclick select line select(cursor.line,0,cursor.line,text[cursor.line].length()); last_dblclk=0; -- cgit v1.2.3 From 524d9fad59cd596bb291648c8c2e1b4a46fb2d02 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 1 May 2015 23:21:27 -0300 Subject: -fixed godot icon for android -added a genname option to generate the name of android app --- platform/android/export/export.cpp | 37 ++++++++++++++++++++++++---- platform/android/java/res/drawable/icon.png | Bin 91728 -> 17135 bytes 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index d0e2dfbce1..d169ec51d5 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -225,6 +225,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { static void _device_poll_thread(void *ud); + String get_package_name(); + String get_project_name() const; void _fix_manifest(Vector& p_manifest); void _fix_resources(Vector& p_manifest); @@ -756,7 +758,7 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector& p_manifest) { if (tname=="manifest" && attrname=="package") { print_line("FOUND PACKAGE"); - string_table[attr_value]=package; + string_table[attr_value]=get_package_name(); } //print_line("tname: "+tname); @@ -1169,7 +1171,7 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d if (apk_expansion) { - String apkfname="main."+itos(version_code)+"."+package+".obb"; + String apkfname="main."+itos(version_code)+"."+get_package_name()+".obb"; String fullpath=p_path.get_base_dir().plus_file(apkfname); FileAccess *pf = FileAccess::open(fullpath,FileAccess::WRITE); if (!pf) { @@ -1514,7 +1516,7 @@ Error EditorExportPlatformAndroid::run(int p_device, bool p_dumb) { args.push_back("-s"); args.push_back(devices[p_device].id); args.push_back("uninstall"); - args.push_back(package); + args.push_back(get_package_name()); err = OS::get_singleton()->execute(adb,args,true,NULL,NULL,&rv); #if 0 @@ -1552,7 +1554,7 @@ Error EditorExportPlatformAndroid::run(int p_device, bool p_dumb) { args.push_back("-a"); args.push_back("android.intent.action.MAIN"); args.push_back("-n"); - args.push_back(package+"/com.android.godot.Godot"); + args.push_back(get_package_name()+"/com.android.godot.Godot"); err = OS::get_singleton()->execute(adb,args,true,NULL,NULL,&rv); if (err || rv!=0) { @@ -1564,12 +1566,37 @@ Error EditorExportPlatformAndroid::run(int p_device, bool p_dumb) { return OK; } +String EditorExportPlatformAndroid::get_package_name() { + + String pname = package; + String basename = Globals::get_singleton()->get("application/name"); + basename=basename.to_lower(); + + String name; + bool first=true; + for(int i=0;i='0' && c<='9' && first) { + continue; + } + if ((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9')) { + name+=String::chr(c); + first=false; + } + } + if (name=="") + name="noname"; + + pname=pname.replace("$genname",name); + return pname; + +} EditorExportPlatformAndroid::EditorExportPlatformAndroid() { version_code=1; version_name="1.0"; - package="com.android.noname"; + package="org.godotengine.$genname"; name=""; _signed=true; apk_expansion=false; diff --git a/platform/android/java/res/drawable/icon.png b/platform/android/java/res/drawable/icon.png index 050a1cf930..78757e9035 100644 Binary files a/platform/android/java/res/drawable/icon.png and b/platform/android/java/res/drawable/icon.png differ -- 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/3d/sprite_3d.cpp | 2 +- scene/resources/animation.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 35f6523c6a..4952f742df 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -292,7 +292,7 @@ SpriteBase3D::SpriteBase3D() { parent_sprite=NULL; pI=NULL; - for(int i=0;i<4;i++) + for(int i=0;i >& 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 2296b0508e0e2d2ed51bc6cb892fa8a8abb55ff7 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 2 May 2015 16:35:43 -0300 Subject: 2D pathfinder fixes, should now always find the best path. --- scene/2d/navigation2d.cpp | 38 +++++++++++++++++++++++++++++++++++--- scene/2d/navigation2d.h | 2 ++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp index d427bf4bc3..5a02501816 100644 --- a/scene/2d/navigation2d.cpp +++ b/scene/2d/navigation2d.cpp @@ -32,6 +32,7 @@ void Navigation2D::_navpoly_link(int p_id) { p.edges.resize(plen); Vector2 center; + float sum=0; for(int j=0;j=len) { + valid=false; + break; + } + + Vector2 epn = nm.xform.xform(r[idxn]); + + sum+=(epn.x-ep.x)*(epn.y+ep.y); + + } + p.clockwise=sum>0; + if (!valid) { nm.polygons.pop_back(); ERR_CONTINUE(!valid); @@ -493,17 +509,30 @@ Vector Navigation2D::get_simple_path(const Vector2& p_start, const Vect left = _get_vertex(p->edges[prev].point); right = _get_vertex(p->edges[prev_n].point); - if (CLOCK_TANGENT(apex_point,left,(left+right)*0.5) < 0){ + if (p->clockwise) { SWAP(left,right); } + /*if (CLOCK_TANGENT(apex_point,left,(left+right)*0.5) < 0){ + SWAP(left,right); + }*/ } bool skip=false; + /* print_line("-----\nAPEX: "+(apex_point-end_point)); + print_line("LEFT:"); + print_line("\tPortal: "+(portal_left-end_point)); + print_line("\tPoint: "+(left-end_point)); + print_line("\tFree: "+itos(CLOCK_TANGENT(apex_point,portal_left,left) >= 0)); + print_line("RIGHT:"); + print_line("\tPortal: "+(portal_right-end_point)); + print_line("\tPoint: "+(right-end_point)); + print_line("\tFree: "+itos(CLOCK_TANGENT(apex_point,portal_right,right) <= 0)); +*/ if (CLOCK_TANGENT(apex_point,portal_left,left) >= 0){ //process - if (portal_left==apex_point || CLOCK_TANGENT(apex_point,left,portal_right) > 0) { + if (portal_left.distance_squared_to(apex_point) 0) { left_poly=p; portal_left=left; } else { @@ -519,12 +548,13 @@ Vector Navigation2D::get_simple_path(const Vector2& p_start, const Vect if (path[path.size()-1].distance_to(apex_point)>CMP_EPSILON) path.push_back(apex_point); skip=true; + //print_line("addpoint left"); } } if (!skip && CLOCK_TANGENT(apex_point,portal_right,right) <= 0){ //process - if (portal_right==apex_point || CLOCK_TANGENT(apex_point,right,portal_left) < 0) { + if (portal_right.distance_squared_to(apex_point) Navigation2D::get_simple_path(const Vector2& p_start, const Vect portal_left=apex_point; if (path[path.size()-1].distance_to(apex_point)>CMP_EPSILON) path.push_back(apex_point); + //print_line("addpoint right"); + } } diff --git a/scene/2d/navigation2d.h b/scene/2d/navigation2d.h index 7a33105b77..829b0f544b 100644 --- a/scene/2d/navigation2d.h +++ b/scene/2d/navigation2d.h @@ -60,6 +60,8 @@ class Navigation2D : public Node2D { float distance; int prev_edge; + bool clockwise; + NavMesh *owner; }; -- cgit v1.2.3 From 5f2aac4bbe14d1256feebd4bb12d8b61e5b55f3d Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 2 May 2015 17:39:29 -0300 Subject: same fixes to 3D navmesh.. --- scene/3d/navigation.cpp | 15 ++++++++++++++- scene/3d/navigation.h | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/scene/3d/navigation.cpp b/scene/3d/navigation.cpp index 8866a65801..48820706dd 100644 --- a/scene/3d/navigation.cpp +++ b/scene/3d/navigation.cpp @@ -30,6 +30,7 @@ void Navigation::_navmesh_link(int p_id) { p.edges.resize(plen); Vector3 center; + float sum=0; for(int j=0;j=2) { + Vector3 epa = nm.xform.xform(r[indices[j-2]]); + Vector3 epb = nm.xform.xform(r[indices[j-1]]); + + sum+=up.dot((epb-epa).cross(ep-epa)); + + } + } + p.clockwise=sum>0; + if (!valid) { nm.polygons.pop_back(); ERR_CONTINUE(!valid); @@ -399,7 +411,8 @@ Vector Navigation::get_simple_path(const Vector3& p_start, const Vector left = _get_vertex(p->edges[prev].point); right = _get_vertex(p->edges[prev_n].point); - if (CLOCK_TANGENT(apex_point,left,(left+right)*0.5).dot(up) < 0){ + //if (CLOCK_TANGENT(apex_point,left,(left+right)*0.5).dot(up) < 0){ + if (p->clockwise) { SWAP(left,right); } } diff --git a/scene/3d/navigation.h b/scene/3d/navigation.h index 54cec8f1f7..0f7f67571f 100644 --- a/scene/3d/navigation.h +++ b/scene/3d/navigation.h @@ -59,6 +59,8 @@ class Navigation : public Spatial { float distance; int prev_edge; + bool clockwise; + NavMesh *owner; }; -- cgit v1.2.3 From 2830f85b056672f4cbcc61ca55437d625d0a58da Mon Sep 17 00:00:00 2001 From: Simon Wenner Date: Sun, 3 May 2015 01:45:55 +0200 Subject: fixed uninitialized variable (cppcheck) --- core/io/file_access_memory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 749f7d1641..c22d637d01 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -132,7 +132,7 @@ bool FileAccessMemory::eof_reached() const { uint8_t FileAccessMemory::get_8() const { - uint8_t ret; + uint8_t ret = 0; if (pos < length) { ret = data[pos]; }; -- cgit v1.2.3 From a0e985c6c19a438ebf7afcd86cc922076f13e177 Mon Sep 17 00:00:00 2001 From: Simon Wenner Date: Sun, 3 May 2015 01:48:20 +0200 Subject: removed unnecessary semicolons --- core/io/file_access_memory.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index c22d637d01..2880c4ebda 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -39,7 +39,7 @@ void FileAccessMemory::register_file(String p_name, Vector p_data) { if (!files) { files = memnew((Map >)); - }; + } String name; if (Globals::get_singleton()) @@ -49,7 +49,7 @@ void FileAccessMemory::register_file(String p_name, Vector p_data) { name = DirAccess::normalize_path(name); (*files)[name] = p_data; -}; +} void FileAccessMemory::cleanup() { @@ -57,13 +57,13 @@ void FileAccessMemory::cleanup() { return; memdelete(files); -}; +} FileAccess* FileAccessMemory::create() { return memnew(FileAccessMemory); -}; +} bool FileAccessMemory::file_exists(const String& p_name) { @@ -71,7 +71,7 @@ bool FileAccessMemory::file_exists(const String& p_name) { name = DirAccess::normalize_path(name); return files && (files->find(name) != NULL); -}; +} Error FileAccessMemory::_open(const String& p_path, int p_mode_flags) { @@ -89,57 +89,57 @@ Error FileAccessMemory::_open(const String& p_path, int p_mode_flags) { pos = 0; return OK; -}; +} void FileAccessMemory::close() { data = NULL; -}; +} bool FileAccessMemory::is_open() const { return data != NULL; -}; +} void FileAccessMemory::seek(size_t p_position) { ERR_FAIL_COND(!data); pos = p_position; -}; +} void FileAccessMemory::seek_end(int64_t p_position) { ERR_FAIL_COND(!data); pos = length + p_position; -}; +} size_t FileAccessMemory::get_pos() const { ERR_FAIL_COND_V(!data, 0); return pos; -}; +} size_t FileAccessMemory::get_len() const { ERR_FAIL_COND_V(!data, 0); return length; -}; +} bool FileAccessMemory::eof_reached() const { return pos >= length; -}; +} uint8_t FileAccessMemory::get_8() const { uint8_t ret = 0; if (pos < length) { ret = data[pos]; - }; + } ++pos; return ret; -}; +} int FileAccessMemory::get_buffer(uint8_t *p_dst,int p_length) const { @@ -156,19 +156,19 @@ int FileAccessMemory::get_buffer(uint8_t *p_dst,int p_length) const { pos += p_length; return read; -}; +} Error FileAccessMemory::get_error() const { return pos >= length ? ERR_FILE_EOF : OK; -}; +} void FileAccessMemory::store_8(uint8_t p_byte) { ERR_FAIL_COND(!data); ERR_FAIL_COND(pos >= length); data[pos++] = p_byte; -}; +} void FileAccessMemory::store_buffer(const uint8_t *p_src,int p_length) { @@ -176,11 +176,11 @@ void FileAccessMemory::store_buffer(const uint8_t *p_src,int p_length) { int write = MIN(p_length, left); if (write < p_length) { WARN_PRINT("Writing less data than requested"); - }; + } copymem(&data[pos], p_src, write); pos += p_length; -}; +} FileAccessMemory::FileAccessMemory() { -- cgit v1.2.3 From bd08cd7fd2b309d0aa0af310f485ea056424fdd5 Mon Sep 17 00:00:00 2001 From: Simon Wenner Date: Sun, 3 May 2015 02:04:30 +0200 Subject: fixed broken comment block --- platform/android/android_native_app_glue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/android/android_native_app_glue.h b/platform/android/android_native_app_glue.h index a902a3b4da..f5ba27ae66 100644 --- a/platform/android/android_native_app_glue.h +++ b/platform/android/android_native_app_glue.h @@ -26,7 +26,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - * Copyright (C) 2010 The Android Open Source Project +/* Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. -- cgit v1.2.3 From 332d9af81ba9b74bf71b1201c65651db1f90756c Mon Sep 17 00:00:00 2001 From: Simon Wenner Date: Sun, 3 May 2015 02:11:43 +0200 Subject: fixed memory leak: triangulated (cppcheck) --- drivers/convex_decomp/b2Polygon.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/convex_decomp/b2Polygon.cpp b/drivers/convex_decomp/b2Polygon.cpp index 49a3e74c2a..668313967e 100644 --- a/drivers/convex_decomp/b2Polygon.cpp +++ b/drivers/convex_decomp/b2Polygon.cpp @@ -970,6 +970,7 @@ int32 DecomposeConvex(b2Polygon* p, b2Polygon* results, int32 maxPolys) { } if (nTri < 1) { //Still no luck? Oh well... + delete[] triangulated; return -1; } int32 nPolys = PolygonizeTriangles(triangulated, nTri, results, maxPolys); -- cgit v1.2.3 From 3f1826866bbd2b92cf5a9de780ef948323fe7b09 Mon Sep 17 00:00:00 2001 From: Simon Wenner Date: Sun, 3 May 2015 02:16:26 +0200 Subject: fixed uninitialized name pointers (cppcheck) --- drivers/chibi/cp_player_data_control.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/chibi/cp_player_data_control.cpp b/drivers/chibi/cp_player_data_control.cpp index 4d30c1a703..d5ca648fff 100644 --- a/drivers/chibi/cp_player_data_control.cpp +++ b/drivers/chibi/cp_player_data_control.cpp @@ -233,7 +233,7 @@ int CPPlayer::get_channel_voice(int p_channel) { const char* CPPlayer::get_voice_sample_name(int p_voice) { - const char *name; + const char *name = NULL; @@ -302,7 +302,7 @@ const char * CPPlayer::get_voice_instrument_name(int p_voice) { - const char *name; + const char *name = NULL; -- cgit v1.2.3 From af068439829a3fec3a76c4c5d4dd2dba71ab6c5f Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 3 May 2015 16:47:21 -0300 Subject: -new collision layer & mask system for 2D, for more flexible collision masking --- doc/base/classes.xml | 4 ++-- scene/2d/area_2d.cpp | 34 ++++++++++++++++++++++++++- scene/2d/area_2d.h | 8 +++++++ scene/2d/physics_body_2d.cpp | 18 +++++++++++++- scene/2d/physics_body_2d.h | 4 ++++ scene/2d/tile_map.cpp | 32 +++++++++++++++++++++---- scene/2d/tile_map.h | 9 +++++-- servers/physics_2d/area_pair_2d_sw.cpp | 4 ++-- servers/physics_2d/body_pair_2d_sw.cpp | 2 +- servers/physics_2d/collision_object_2d_sw.cpp | 2 +- servers/physics_2d/collision_object_2d_sw.h | 11 ++++++--- servers/physics_2d/physics_2d_server_sw.cpp | 24 +++++++++++++++---- servers/physics_2d/physics_2d_server_sw.h | 6 +++-- servers/physics_2d/space_2d_sw.cpp | 2 +- servers/physics_2d_server.cpp | 6 +++-- servers/physics_2d_server.h | 7 ++++-- servers/physics_server.cpp | 2 +- servers/physics_server.h | 4 ++-- 18 files changed, 147 insertions(+), 32 deletions(-) diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 905e999125..901bfa1253 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -19442,7 +19442,7 @@ - + @@ -19450,7 +19450,7 @@ - + diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index a40b1fb397..827256c2fa 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -512,6 +512,29 @@ bool Area2D::overlaps_body(Node* p_body) const{ } +void Area2D::set_collision_mask(uint32_t p_mask) { + + collision_mask=p_mask; + Physics2DServer::get_singleton()->area_set_collision_mask(get_rid(),p_mask); +} + +uint32_t Area2D::get_collision_mask() const { + + return collision_mask; +} + + +void Area2D::set_layer_mask(uint32_t p_mask) { + + layer_mask=p_mask; + Physics2DServer::get_singleton()->area_set_layer_mask(get_rid(),p_mask); +} + +uint32_t Area2D::get_layer_mask() const { + + return layer_mask; +} + void Area2D::_bind_methods() { @@ -542,6 +565,12 @@ void Area2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_priority","priority"),&Area2D::set_priority); ObjectTypeDB::bind_method(_MD("get_priority"),&Area2D::get_priority); + ObjectTypeDB::bind_method(_MD("set_collision_mask","collision_mask"),&Area2D::set_collision_mask); + ObjectTypeDB::bind_method(_MD("get_collision_mask"),&Area2D::get_collision_mask); + + ObjectTypeDB::bind_method(_MD("set_layer_mask","layer_mask"),&Area2D::set_layer_mask); + ObjectTypeDB::bind_method(_MD("get_layer_mask"),&Area2D::get_layer_mask); + ObjectTypeDB::bind_method(_MD("set_enable_monitoring","enable"),&Area2D::set_enable_monitoring); ObjectTypeDB::bind_method(_MD("is_monitoring_enabled"),&Area2D::is_monitoring_enabled); @@ -578,6 +607,8 @@ void Area2D::_bind_methods() { ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"priority",PROPERTY_HINT_RANGE,"0,128,1"),_SCS("set_priority"),_SCS("get_priority")); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_enable_monitoring"),_SCS("is_monitoring_enabled")); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"monitorable"),_SCS("set_monitorable"),_SCS("is_monitorable")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); } @@ -593,9 +624,10 @@ Area2D::Area2D() : CollisionObject2D(Physics2DServer::get_singleton()->area_crea priority=0; monitoring=false; monitorable=false; + collision_mask=1; + layer_mask=1; set_enable_monitoring(true); set_monitorable(true); - } Area2D::~Area2D() { diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h index 5964230a52..0c064f54cd 100644 --- a/scene/2d/area_2d.h +++ b/scene/2d/area_2d.h @@ -51,6 +51,8 @@ private: bool gravity_is_point; real_t linear_damp; real_t angular_damp; + uint32_t collision_mask; + uint32_t layer_mask; int priority; bool monitoring; bool monitorable; @@ -151,6 +153,12 @@ public: void set_monitorable(bool p_enable); bool is_monitorable() const; + void set_collision_mask(uint32_t p_mask); + uint32_t get_collision_mask() const; + + void set_layer_mask(uint32_t p_mask); + uint32_t get_layer_mask() const; + Array get_overlapping_bodies() const; //function for script Array get_overlapping_areas() const; //function for script diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index e7bc199608..6fb798714f 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -72,13 +72,16 @@ void PhysicsBody2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody2D::set_layer_mask); ObjectTypeDB::bind_method(_MD("get_layer_mask"),&PhysicsBody2D::get_layer_mask); + ObjectTypeDB::bind_method(_MD("set_collision_mask","mask"),&PhysicsBody2D::set_collision_mask); + ObjectTypeDB::bind_method(_MD("get_collision_mask"),&PhysicsBody2D::get_collision_mask); ObjectTypeDB::bind_method(_MD("set_one_way_collision_direction","dir"),&PhysicsBody2D::set_one_way_collision_direction); ObjectTypeDB::bind_method(_MD("get_one_way_collision_direction"),&PhysicsBody2D::get_one_way_collision_direction); ObjectTypeDB::bind_method(_MD("set_one_way_collision_max_depth","depth"),&PhysicsBody2D::set_one_way_collision_max_depth); ObjectTypeDB::bind_method(_MD("get_one_way_collision_max_depth"),&PhysicsBody2D::get_one_way_collision_max_depth); ObjectTypeDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::add_collision_exception_with); ObjectTypeDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::remove_collision_exception_with); - ADD_PROPERTY(PropertyInfo(Variant::INT,"layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask")); + ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask")); + ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"one_way_collision/direction"),_SCS("set_one_way_collision_direction"),_SCS("get_one_way_collision_direction")); ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"one_way_collision/max_depth"),_SCS("set_one_way_collision_max_depth"),_SCS("get_one_way_collision_max_depth")); } @@ -94,9 +97,22 @@ uint32_t PhysicsBody2D::get_layer_mask() const { return mask; } +void PhysicsBody2D::set_collision_mask(uint32_t p_mask) { + + collision_mask=p_mask; + Physics2DServer::get_singleton()->body_set_collision_mask(get_rid(),p_mask); +} + +uint32_t PhysicsBody2D::get_collision_mask() const { + + return collision_mask; +} + + PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) : CollisionObject2D( Physics2DServer::get_singleton()->body_create(p_mode), false) { mask=1; + collision_mask=1; set_one_way_collision_max_depth(0); set_pickable(false); diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index b8cba6e5ba..3cb94b95da 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -39,6 +39,7 @@ class PhysicsBody2D : public CollisionObject2D { OBJ_TYPE(PhysicsBody2D,CollisionObject2D); uint32_t mask; + uint32_t collision_mask; Vector2 one_way_collision_direction; float one_way_collision_max_depth; protected: @@ -52,6 +53,9 @@ public: void set_layer_mask(uint32_t p_mask); uint32_t get_layer_mask() const; + void set_collision_mask(uint32_t p_mask); + uint32_t get_collision_mask() const; + void add_collision_exception_with(Node* p_node); //must be physicsbody void remove_collision_exception_with(Node* p_node); diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index bf1677ae63..2fca1e67e8 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -519,6 +519,7 @@ Map::Element *TileMap::_create_quadrant(const q.body=Physics2DServer::get_singleton()->body_create(use_kinematic?Physics2DServer::BODY_MODE_KINEMATIC:Physics2DServer::BODY_MODE_STATIC); Physics2DServer::get_singleton()->body_attach_object_instance_ID(q.body,get_instance_ID()); Physics2DServer::get_singleton()->body_set_layer_mask(q.body,collision_layer); + Physics2DServer::get_singleton()->body_set_collision_mask(q.body,collision_mask); Physics2DServer::get_singleton()->body_set_param(q.body,Physics2DServer::BODY_PARAM_FRICTION,friction); Physics2DServer::get_singleton()->body_set_param(q.body,Physics2DServer::BODY_PARAM_BOUNCE,bounce); @@ -790,7 +791,7 @@ Rect2 TileMap::get_item_rect() const { return rect_cache; } -void TileMap::set_collision_layer_mask(uint32_t p_layer) { +void TileMap::set_collision_layer(uint32_t p_layer) { collision_layer=p_layer; for (Map::Element *E=quadrant_map.front();E;E=E->next()) { @@ -800,6 +801,16 @@ void TileMap::set_collision_layer_mask(uint32_t p_layer) { } } +void TileMap::set_collision_mask(uint32_t p_mask) { + + collision_mask=p_mask; + for (Map::Element *E=quadrant_map.front();E;E=E->next()) { + + Quadrant &q=E->get(); + Physics2DServer::get_singleton()->body_set_collision_mask(q.body,collision_mask); + } +} + bool TileMap::get_collision_use_kinematic() const{ return use_kinematic; @@ -844,11 +855,16 @@ float TileMap::get_collision_bounce() const{ } -uint32_t TileMap::get_collision_layer_mask() const { +uint32_t TileMap::get_collision_layer() const { return collision_layer; } +uint32_t TileMap::get_collision_mask() const { + + return collision_mask; +} + void TileMap::set_mode(Mode p_mode) { _clear_quadrants(); @@ -1077,8 +1093,11 @@ void TileMap::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_collision_use_kinematic","use_kinematic"),&TileMap::set_collision_use_kinematic); ObjectTypeDB::bind_method(_MD("get_collision_use_kinematic"),&TileMap::get_collision_use_kinematic); - ObjectTypeDB::bind_method(_MD("set_collision_layer_mask","mask"),&TileMap::set_collision_layer_mask); - ObjectTypeDB::bind_method(_MD("get_collision_layer_mask"),&TileMap::get_collision_layer_mask); + ObjectTypeDB::bind_method(_MD("set_collision_layer","mask"),&TileMap::set_collision_layer); + ObjectTypeDB::bind_method(_MD("get_collision_layer"),&TileMap::get_collision_layer); + + ObjectTypeDB::bind_method(_MD("set_collision_mask","mask"),&TileMap::set_collision_mask); + ObjectTypeDB::bind_method(_MD("get_collision_mask"),&TileMap::get_collision_mask); ObjectTypeDB::bind_method(_MD("set_collision_friction","value"),&TileMap::set_collision_friction); ObjectTypeDB::bind_method(_MD("get_collision_friction"),&TileMap::get_collision_friction); @@ -1117,7 +1136,9 @@ void TileMap::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collision/use_kinematic",PROPERTY_HINT_NONE,""),_SCS("set_collision_use_kinematic"),_SCS("get_collision_use_kinematic")); ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_friction"),_SCS("get_collision_friction")); ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_bounce"),_SCS("get_collision_bounce")); - ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_layer_mask"),_SCS("get_collision_layer_mask")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_layer"),_SCS("get_collision_layer")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); + ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"tile_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_tile_data"),_SCS("_get_tile_data")); ADD_SIGNAL(MethodInfo("settings_changed")); @@ -1146,6 +1167,7 @@ TileMap::TileMap() { center_x=false; center_y=false; collision_layer=1; + collision_mask=1; friction=1; bounce=0; mode=MODE_SQUARE; diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 233529f018..84ca65da4f 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -146,6 +146,8 @@ private: float friction; float bounce; uint32_t collision_layer; + uint32_t collision_mask; + TileOrigin tile_origin; void _fix_cell_transform(Matrix32& xform, const Cell& p_cell, const Vector2 &p_offset, const Size2 &p_sc); @@ -207,8 +209,11 @@ public: Rect2 get_item_rect() const; - void set_collision_layer_mask(uint32_t p_layer); - uint32_t get_collision_layer_mask() const; + void set_collision_layer(uint32_t p_layer); + uint32_t get_collision_layer() const; + + void set_collision_mask(uint32_t p_mask); + uint32_t get_collision_mask() const; void set_collision_use_kinematic(bool p_use_kinematic); bool get_collision_use_kinematic() const; diff --git a/servers/physics_2d/area_pair_2d_sw.cpp b/servers/physics_2d/area_pair_2d_sw.cpp index f73fbb628b..3b1705bd56 100644 --- a/servers/physics_2d/area_pair_2d_sw.cpp +++ b/servers/physics_2d/area_pair_2d_sw.cpp @@ -32,7 +32,7 @@ bool AreaPair2DSW::setup(float p_step) { - bool result = CollisionSolver2DSW::solve(body->get_shape(body_shape),body->get_transform() * body->get_shape_transform(body_shape),Vector2(),area->get_shape(area_shape),area->get_transform() * area->get_shape_transform(area_shape),Vector2(),NULL,this); + bool result = area->test_collision_mask(body) && CollisionSolver2DSW::solve(body->get_shape(body_shape),body->get_transform() * body->get_shape_transform(body_shape),Vector2(),area->get_shape(area_shape),area->get_transform() * area->get_shape_transform(area_shape),Vector2(),NULL,this); if (result!=colliding) { @@ -102,7 +102,7 @@ AreaPair2DSW::~AreaPair2DSW() { bool Area2Pair2DSW::setup(float p_step) { - bool result = CollisionSolver2DSW::solve(area_a->get_shape(shape_a),area_a->get_transform() * area_a->get_shape_transform(shape_a),Vector2(),area_b->get_shape(shape_b),area_b->get_transform() * area_b->get_shape_transform(shape_b),Vector2(),NULL,this); + bool result = area_a->test_collision_mask(area_b) && CollisionSolver2DSW::solve(area_a->get_shape(shape_a),area_a->get_transform() * area_a->get_shape_transform(shape_a),Vector2(),area_b->get_shape(shape_b),area_b->get_transform() * area_b->get_shape_transform(shape_b),Vector2(),NULL,this); if (result!=colliding) { diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp index a2402d1473..8913e396d2 100644 --- a/servers/physics_2d/body_pair_2d_sw.cpp +++ b/servers/physics_2d/body_pair_2d_sw.cpp @@ -234,7 +234,7 @@ bool BodyPair2DSW::setup(float p_step) { //cannot collide - if ((A->get_layer_mask()&B->get_layer_mask())==0 || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode()<=Physics2DServer::BODY_MODE_KINEMATIC && B->get_mode()<=Physics2DServer::BODY_MODE_KINEMATIC && A->get_max_contacts_reported()==0 && B->get_max_contacts_reported()==0)) { + if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode()<=Physics2DServer::BODY_MODE_KINEMATIC && B->get_mode()<=Physics2DServer::BODY_MODE_KINEMATIC && A->get_max_contacts_reported()==0 && B->get_max_contacts_reported()==0)) { collided=false; return false; } diff --git a/servers/physics_2d/collision_object_2d_sw.cpp b/servers/physics_2d/collision_object_2d_sw.cpp index 8160f22a31..7c8e223c57 100644 --- a/servers/physics_2d/collision_object_2d_sw.cpp +++ b/servers/physics_2d/collision_object_2d_sw.cpp @@ -226,7 +226,7 @@ CollisionObject2DSW::CollisionObject2DSW(Type p_type) { type=p_type; space=NULL; instance_id=0; - user_mask=0; + collision_mask=1; layer_mask=1; pickable=true; } diff --git a/servers/physics_2d/collision_object_2d_sw.h b/servers/physics_2d/collision_object_2d_sw.h index 58dc3e9cd9..f3432060b9 100644 --- a/servers/physics_2d/collision_object_2d_sw.h +++ b/servers/physics_2d/collision_object_2d_sw.h @@ -65,7 +65,7 @@ private: Space2DSW *space; Matrix32 transform; Matrix32 inv_transform; - uint32_t user_mask; + uint32_t collision_mask; uint32_t layer_mask; bool _static; @@ -117,8 +117,8 @@ public: _FORCE_INLINE_ bool is_shape_set_as_trigger(int p_idx) const { return shapes[p_idx].trigger; } - void set_user_mask(uint32_t p_mask) {user_mask=p_mask;} - _FORCE_INLINE_ uint32_t get_user_mask() const { return user_mask; } + void set_collision_mask(uint32_t p_mask) {collision_mask=p_mask;} + _FORCE_INLINE_ uint32_t get_collision_mask() const { return collision_mask; } void set_layer_mask(uint32_t p_mask) {layer_mask=p_mask;} _FORCE_INLINE_ uint32_t get_layer_mask() const { return layer_mask; } @@ -133,6 +133,11 @@ public: void set_pickable(bool p_pickable) { pickable=p_pickable; } _FORCE_INLINE_ bool is_pickable() const { return pickable; } + _FORCE_INLINE_ bool test_collision_mask(CollisionObject2DSW* p_other) const { + + return layer_mask&p_other->collision_mask || p_other->layer_mask&collision_mask; + } + virtual ~CollisionObject2DSW() {} }; diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index d31606acfb..08d871be69 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -480,6 +480,22 @@ void Physics2DServerSW::area_set_monitorable(RID p_area,bool p_monitorable) { } +void Physics2DServerSW::area_set_collision_mask(RID p_area,uint32_t p_mask) { + + Area2DSW *area = area_owner.get(p_area); + ERR_FAIL_COND(!area); + + area->set_collision_mask(p_mask); +} + +void Physics2DServerSW::area_set_layer_mask(RID p_area,uint32_t p_mask) { + + Area2DSW *area = area_owner.get(p_area); + ERR_FAIL_COND(!area); + + area->set_layer_mask(p_mask); +} + void Physics2DServerSW::area_set_monitor_callback(RID p_area,Object *p_receiver,const StringName& p_method) { @@ -726,20 +742,20 @@ uint32_t Physics2DServerSW::body_get_layer_mask(RID p_body, uint32_t p_flags) co }; -void Physics2DServerSW::body_set_user_mask(RID p_body, uint32_t p_flags) { +void Physics2DServerSW::body_set_collision_mask(RID p_body, uint32_t p_flags) { Body2DSW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); - body->set_user_mask(p_flags); + body->set_collision_mask(p_flags); }; -uint32_t Physics2DServerSW::body_get_user_mask(RID p_body, uint32_t p_flags) const { +uint32_t Physics2DServerSW::body_get_collision_mask(RID p_body, uint32_t p_flags) const { Body2DSW *body = body_owner.get(p_body); ERR_FAIL_COND_V(!body,0); - return body->get_user_mask(); + return body->get_collision_mask(); }; void Physics2DServerSW::body_set_param(RID p_body, BodyParameter p_param, float p_value) { diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h index 50675cbd09..341df2fdc9 100644 --- a/servers/physics_2d/physics_2d_server_sw.h +++ b/servers/physics_2d/physics_2d_server_sw.h @@ -134,6 +134,8 @@ public: virtual Variant area_get_param(RID p_parea,AreaParameter p_param) const; virtual Matrix32 area_get_transform(RID p_area) const; virtual void area_set_monitorable(RID p_area,bool p_monitorable); + virtual void area_set_collision_mask(RID p_area,uint32_t p_mask); + virtual void area_set_layer_mask(RID p_area,uint32_t p_mask); virtual void area_set_monitor_callback(RID p_area,Object *p_receiver,const StringName& p_method); virtual void area_set_area_monitor_callback(RID p_area,Object *p_receiver,const StringName& p_method); @@ -179,8 +181,8 @@ public: virtual void body_set_layer_mask(RID p_body, uint32_t p_mask); virtual uint32_t body_get_layer_mask(RID p_body, uint32_t p_mask) const; - virtual void body_set_user_mask(RID p_body, uint32_t p_mask); - virtual uint32_t body_get_user_mask(RID p_body, uint32_t p_mask) const; + virtual void body_set_collision_mask(RID p_body, uint32_t p_mask); + virtual uint32_t body_get_collision_mask(RID p_body, uint32_t p_mask) const; virtual void body_set_param(RID p_body, BodyParameter p_param, float p_value); virtual float body_get_param(RID p_body, BodyParameter p_param) const; diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 9a1b977bda..40e7b19f6f 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -596,7 +596,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body,const Vector2&p_motion,float p keep=false; else if (intersection_query_results[i]->get_type()==CollisionObject2DSW::TYPE_AREA) keep=false; - else if ((static_cast(intersection_query_results[i])->get_layer_mask()&p_body->get_layer_mask())==0) + else if ((static_cast(intersection_query_results[i])->test_collision_mask(p_body))==0) keep=false; else if (static_cast(intersection_query_results[i])->has_exception(p_body->get_self()) || p_body->has_exception(intersection_query_results[i]->get_self())) keep=false; diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp index 088c092e75..279ad0d742 100644 --- a/servers/physics_2d_server.cpp +++ b/servers/physics_2d_server.cpp @@ -536,6 +536,8 @@ void Physics2DServer::_bind_methods() { ObjectTypeDB::bind_method(_MD("area_remove_shape","area","shape_idx"),&Physics2DServer::area_remove_shape); ObjectTypeDB::bind_method(_MD("area_clear_shapes","area"),&Physics2DServer::area_clear_shapes); + ObjectTypeDB::bind_method(_MD("area_set_layer_mask","area","mask"),&Physics2DServer::area_set_layer_mask); + ObjectTypeDB::bind_method(_MD("area_set_collision_mask","area","mask"),&Physics2DServer::area_set_collision_mask); ObjectTypeDB::bind_method(_MD("area_set_param","area","param","value"),&Physics2DServer::area_set_param); ObjectTypeDB::bind_method(_MD("area_set_transform","area","transform"),&Physics2DServer::area_set_transform); @@ -584,8 +586,8 @@ void Physics2DServer::_bind_methods() { ObjectTypeDB::bind_method(_MD("body_set_layer_mask","body","mask"),&Physics2DServer::body_set_layer_mask); ObjectTypeDB::bind_method(_MD("body_get_layer_mask","body"),&Physics2DServer::body_get_layer_mask); - ObjectTypeDB::bind_method(_MD("body_set_user_mask","body","mask"),&Physics2DServer::body_set_user_mask); - ObjectTypeDB::bind_method(_MD("body_get_user_mask","body"),&Physics2DServer::body_get_user_mask); + ObjectTypeDB::bind_method(_MD("body_set_collision_mask","body","mask"),&Physics2DServer::body_set_collision_mask); + ObjectTypeDB::bind_method(_MD("body_get_collision_mask","body"),&Physics2DServer::body_get_collision_mask); ObjectTypeDB::bind_method(_MD("body_set_param","body","param","value"),&Physics2DServer::body_set_param); diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h index 306144c2ba..5411228c0f 100644 --- a/servers/physics_2d_server.h +++ b/servers/physics_2d_server.h @@ -347,6 +347,9 @@ public: virtual Variant area_get_param(RID p_parea,AreaParameter p_param) const=0; virtual Matrix32 area_get_transform(RID p_area) const=0; + virtual void area_set_collision_mask(RID p_area,uint32_t p_mask)=0; + virtual void area_set_layer_mask(RID p_area,uint32_t p_mask)=0; + virtual void area_set_monitorable(RID p_area,bool p_monitorable)=0; virtual void area_set_pickable(RID p_area,bool p_pickable)=0; @@ -404,8 +407,8 @@ public: virtual void body_set_layer_mask(RID p_body, uint32_t p_mask)=0; virtual uint32_t body_get_layer_mask(RID p_body, uint32_t p_mask) const=0; - virtual void body_set_user_mask(RID p_body, uint32_t p_mask)=0; - virtual uint32_t body_get_user_mask(RID p_body, uint32_t p_mask) const=0; + virtual void body_set_collision_mask(RID p_body, uint32_t p_mask)=0; + virtual uint32_t body_get_collision_mask(RID p_body, uint32_t p_mask) const=0; // common body variables enum BodyParameter { diff --git a/servers/physics_server.cpp b/servers/physics_server.cpp index 010e02d884..4feb1b5269 100644 --- a/servers/physics_server.cpp +++ b/servers/physics_server.cpp @@ -221,7 +221,7 @@ PhysicsShapeQueryParameters::PhysicsShapeQueryParameters() { ///////////////////////////////////// /* -Variant PhysicsDirectSpaceState::_intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max,const Vector& p_exclude,uint32_t p_user_mask) { +Variant PhysicsDirectSpaceState::_intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max,const Vector& p_exclude,uint32_t p_collision_mask) { diff --git a/servers/physics_server.h b/servers/physics_server.h index 97a1d34e7b..ffb462af22 100644 --- a/servers/physics_server.h +++ b/servers/physics_server.h @@ -131,8 +131,8 @@ class PhysicsDirectSpaceState : public Object { OBJ_TYPE( PhysicsDirectSpaceState, Object ); -// Variant _intersect_ray(const Vector3& p_from, const Vector3& p_to,const Vector& p_exclude=Vector(),uint32_t p_user_mask=0); -// Variant _intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max=64,const Vector& p_exclude=Vector(),uint32_t p_user_mask=0); +// Variant _intersect_ray(const Vector3& p_from, const Vector3& p_to,const Vector& p_exclude=Vector(),uint32_t p_collision_mask=0); +// Variant _intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max=64,const Vector& p_exclude=Vector(),uint32_t p_collision_mask=0); public: enum ObjectTypeMask { -- cgit v1.2.3 From 256a9fd1df44dfa222ef3303dacd176008e7a9cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20P=C3=A9rez?= Date: Sun, 3 May 2015 22:09:42 +0200 Subject: Missing return statement --- core/variant.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/variant.cpp b/core/variant.cpp index fe6a6b3e4f..5e2ab962a6 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -532,7 +532,7 @@ bool Variant::is_zero() const { } break; case QUAT: { - *reinterpret_cast(_data._mem)==Quat(); + return *reinterpret_cast(_data._mem)==Quat(); } break; case MATRIX3: { -- cgit v1.2.3 From 767f71a35e76a0848f6c3e7ba2b53a1be921c8f4 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 3 May 2015 18:18:21 -0300 Subject: -Made one way collision work with 2D physics (rigidbody) --- demos/2d/platformer/one_way_platform.png | Bin 0 -> 2287 bytes demos/2d/platformer/one_way_platform.xml | 220 ++++++++ demos/2d/platformer/stage.xml | 877 ++++++++++++++++++------------- servers/physics_2d/body_2d_sw.cpp | 1 + servers/physics_2d/body_2d_sw.h | 8 +- servers/physics_2d/body_pair_2d_sw.cpp | 53 ++ 6 files changed, 794 insertions(+), 365 deletions(-) create mode 100644 demos/2d/platformer/one_way_platform.png create mode 100644 demos/2d/platformer/one_way_platform.xml diff --git a/demos/2d/platformer/one_way_platform.png b/demos/2d/platformer/one_way_platform.png new file mode 100644 index 0000000000..b5eca877a6 Binary files /dev/null and b/demos/2d/platformer/one_way_platform.png differ diff --git a/demos/2d/platformer/one_way_platform.xml b/demos/2d/platformer/one_way_platform.xml new file mode 100644 index 0000000000..491dd32b17 --- /dev/null +++ b/demos/2d/platformer/one_way_platform.xml @@ -0,0 +1,220 @@ + + + + + 0 + 100, 10 + + + + + "conn_count" + 0 + "conns" + + "names" + + "one_way_platform" + "StaticBody2D" + "_import_path" + "visibility/visible" + "visibility/opacity" + "visibility/self_opacity" + "visibility/light_mask" + "transform/pos" + "transform/rot" + "transform/scale" + "z/z" + "z/relative" + "input/pickable" + "shape_count" + "shapes/0/shape" + "shapes/0/transform" + "shapes/0/trigger" + "collision/layers" + "collision/mask" + "one_way_collision/direction" + "one_way_collision/max_depth" + "constant_linear_velocity" + "constant_angular_velocity" + "friction" + "bounce" + "__meta__" + "sprite" + "Sprite" + "texture" + "centered" + "offset" + "flip_h" + "flip_v" + "vframes" + "hframes" + "frame" + "modulate" + "region" + "region_rect" + "CollisionShape2D" + "shape" + "trigger" + + "node_count" + 3 + "nodes" + -1, -1, 1, 0, -1, 24, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 1, 12, 8, 13, 3, 14, 9, 15, 10, 16, 8, 17, 3, 18, 3, 19, 11, 20, 12, 21, 4, 22, 5, 23, 2, 24, 5, 25, 13, 0, 0, 0, 27, 26, -1, 21, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 1, 28, 14, 29, 1, 30, 4, 31, 8, 32, 8, 33, 3, 34, 3, 35, 7, 36, 15, 37, 8, 38, 16, 0, 0, 0, 39, 39, -1, 12, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 17, 8, 5, 9, 6, 10, 7, 11, 1, 40, 9, 41, 8, 0 + "variants" + + "" + True + 1 + 1 + 0, 0 + 0 + 1, 1 + 0 + False + + 1, -0, 0, 1, 1.46304, -13.1672 + 0, 1 + 20 + + "__editor_plugin_screen__" + "2D" + "__editor_plugin_states__" + + "2D" + + "ofs" + -133.699, -110.553 + "snap_grid" + False + "snap_offset" + 0, 0 + "snap_pixel" + False + "snap_relative" + False + "snap_rotation" + False + "snap_rotation_offset" + 0 + "snap_rotation_step" + 0.261799 + "snap_show_grid" + False + "snap_step" + 10, 10 + "zoom" + 2.050546 + + "3D" + + "ambient_light_color" + 0.15, 0.15, 0.15, 1 + "default_light" + True + "default_srgb" + False + "deflight_rot_x" + 0.942478 + "deflight_rot_y" + 0.628319 + "fov" + 45 + "show_grid" + True + "show_origin" + True + "viewport_mode" + 1 + "viewports" + + + "distance" + 4 + "listener" + True + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False + "x_rot" + 0 + "y_rot" + 0 + + + "distance" + 4 + "listener" + False + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False + "x_rot" + 0 + "y_rot" + 0 + + + "distance" + 4 + "listener" + False + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False + "x_rot" + 0 + "y_rot" + 0 + + + "distance" + 4 + "listener" + False + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False + "x_rot" + 0 + "y_rot" + 0 + + + "zfar" + 500 + "znear" + 0.1 + + + "__editor_run_settings__" + + "custom_args" + "-l $scene" + "run_mode" + 0 + + + + 1, 1, 1, 1 + 0, 0, 0, 0 + 1.46304, -13.1672 + + "version" + 1 + + + + \ No newline at end of file diff --git a/demos/2d/platformer/stage.xml b/demos/2d/platformer/stage.xml index 610057183b..76df853326 100644 --- a/demos/2d/platformer/stage.xml +++ b/demos/2d/platformer/stage.xml @@ -1,17 +1,22 @@ - - + - - + - + + + + + "conn_count" + 0 + "conns" + "names" - + "stage" "Node" "_import_path" @@ -39,6 +44,7 @@ "collision/friction" "collision/bounce" "collision/layers" + "collision/mask" "tile_data" "coins" "coin" @@ -84,8 +90,6 @@ "coin 31 7 3" "coin 31 7 4" "coin 31 7 5" - "player" - "RigidBody2D" "props" "moving_platform" "Node2D" @@ -94,6 +98,10 @@ "moving_platform 2" "moving_platform 3" "seesaw" + "one_way_platform" + "StaticBody2D" + "player" + "RigidBody2D" "music" "StreamPlayer" "stream/stream" @@ -143,134 +151,146 @@ "uppercase" "percent_visible" - "version" - 1 - "conn_count" - 0 "node_count" - 66 + 67 + "nodes" + -1, -1, 1, 0, -1, 2, 2, 0, 3, 1, 0, 0, 0, 5, 4, -1, 25, 2, 0, 6, 2, 7, 3, 8, 3, 9, 4, 10, 5, 11, 6, 12, 7, 13, 8, 14, 2, 15, 8, 16, 9, 17, 10, 18, 11, 19, 12, 20, 13, 21, 8, 22, 14, 23, 14, 24, 3, 25, 6, 26, 4, 27, 4, 28, 15, 3, 16, 0, 0, 0, 1, 29, -1, 2, 2, 0, 3, 17, 0, 2, 0, 31, 30, 18, 3, 2, 0, 10, 19, 3, 20, 0, 2, 0, 31, 32, 18, 3, 2, 0, 10, 21, 3, 20, 0, 2, 0, 31, 33, 18, 3, 2, 0, 10, 22, 3, 20, 0, 2, 0, 31, 34, 18, 3, 2, 0, 10, 23, 3, 20, 0, 2, 0, 31, 35, 18, 3, 2, 0, 10, 24, 3, 20, 0, 2, 0, 31, 36, 18, 3, 2, 0, 10, 25, 3, 20, 0, 2, 0, 31, 37, 18, 3, 2, 0, 10, 26, 3, 20, 0, 2, 0, 31, 38, 18, 3, 2, 0, 10, 27, 3, 20, 0, 2, 0, 31, 39, 18, 3, 2, 0, 10, 28, 3, 20, 0, 2, 0, 31, 40, 18, 3, 2, 0, 10, 29, 3, 20, 0, 2, 0, 31, 41, 18, 3, 2, 0, 10, 30, 3, 20, 0, 2, 0, 31, 42, 18, 3, 2, 0, 10, 31, 3, 20, 0, 2, 0, 31, 43, 18, 3, 2, 0, 10, 32, 3, 20, 0, 2, 0, 31, 44, 18, 3, 2, 0, 10, 33, 3, 20, 0, 2, 0, 31, 45, 18, 3, 2, 0, 10, 34, 3, 20, 0, 2, 0, 31, 46, 18, 3, 2, 0, 10, 35, 3, 20, 0, 2, 0, 31, 47, 18, 3, 2, 0, 10, 36, 3, 20, 0, 2, 0, 31, 48, 18, 3, 2, 0, 10, 37, 3, 20, 0, 2, 0, 31, 49, 18, 3, 2, 0, 10, 38, 3, 20, 0, 2, 0, 31, 50, 18, 3, 2, 0, 10, 39, 3, 20, 0, 2, 0, 31, 51, 18, 3, 2, 0, 10, 40, 3, 20, 0, 2, 0, 31, 52, 18, 3, 2, 0, 10, 41, 3, 20, 0, 2, 0, 31, 53, 18, 3, 2, 0, 10, 42, 3, 20, 0, 2, 0, 31, 54, 18, 3, 2, 0, 10, 43, 3, 20, 0, 2, 0, 31, 55, 18, 3, 2, 0, 10, 44, 3, 20, 0, 2, 0, 31, 56, 18, 3, 2, 0, 10, 45, 3, 20, 0, 2, 0, 31, 57, 18, 3, 2, 0, 10, 46, 3, 20, 0, 2, 0, 31, 58, 18, 3, 2, 0, 10, 47, 3, 20, 0, 2, 0, 31, 59, 18, 3, 2, 0, 10, 48, 3, 20, 0, 2, 0, 31, 60, 18, 3, 2, 0, 10, 49, 3, 20, 0, 2, 0, 31, 61, 18, 3, 2, 0, 10, 50, 3, 20, 0, 2, 0, 31, 62, 18, 3, 2, 0, 10, 51, 3, 20, 0, 2, 0, 31, 63, 18, 3, 2, 0, 10, 52, 3, 20, 0, 2, 0, 31, 64, 18, 3, 2, 0, 10, 53, 3, 20, 0, 2, 0, 31, 65, 18, 3, 2, 0, 10, 54, 3, 20, 0, 2, 0, 31, 66, 18, 3, 2, 0, 10, 55, 3, 20, 0, 2, 0, 31, 67, 18, 3, 2, 0, 10, 56, 3, 20, 0, 2, 0, 31, 68, 18, 3, 2, 0, 10, 57, 3, 20, 0, 2, 0, 31, 69, 18, 3, 2, 0, 10, 58, 3, 20, 0, 2, 0, 31, 70, 18, 3, 2, 0, 10, 59, 3, 20, 0, 2, 0, 31, 71, 18, 3, 2, 0, 10, 60, 3, 20, 0, 2, 0, 31, 72, 18, 3, 2, 0, 10, 61, 3, 20, 0, 0, 0, 1, 73, -1, 1, 2, 0, 0, 45, 0, 75, 74, 62, 5, 2, 0, 10, 63, 3, 64, 76, 65, 77, 66, 0, 45, 0, 75, 78, 62, 5, 2, 0, 10, 67, 3, 64, 76, 68, 77, 69, 0, 45, 0, 75, 79, 62, 5, 2, 0, 10, 70, 3, 64, 76, 71, 77, 69, 0, 45, 0, 75, 80, 72, 3, 2, 0, 10, 73, 3, 74, 0, 45, 0, 82, 81, 75, 3, 2, 0, 10, 76, 3, 77, 0, 0, 0, 84, 83, 78, 3, 2, 0, 10, 79, 3, 80, 0, 0, 0, 86, 85, -1, 7, 2, 0, 87, 81, 88, 14, 89, 2, 90, 82, 91, 2, 92, 14, 0, 0, 0, 1, 93, -1, 1, 2, 0, 0, 53, 0, 84, 94, 83, 3, 2, 0, 10, 84, 3, 85, 0, 53, 0, 84, 95, 83, 3, 2, 0, 10, 86, 3, 85, 0, 53, 0, 84, 96, 83, 3, 2, 0, 10, 87, 3, 85, 0, 53, 0, 84, 97, 83, 3, 2, 0, 10, 88, 3, 85, 0, 53, 0, 84, 98, 83, 3, 2, 0, 10, 89, 3, 85, 0, 53, 0, 84, 99, 83, 3, 2, 0, 10, 90, 3, 85, 0, 53, 0, 84, 100, 83, 3, 2, 0, 10, 91, 3, 85, 0, 53, 0, 84, 101, 83, 3, 2, 0, 10, 92, 3, 85, 0, 53, 0, 84, 102, 83, 3, 2, 0, 10, 93, 3, 85, 0, 53, 0, 84, 103, 83, 3, 2, 0, 10, 94, 3, 85, 0, 53, 0, 84, 104, 83, 3, 2, 0, 10, 95, 3, 85, 0, 0, 0, 106, 105, 96, 2, 2, 0, 3, 97, 0, 0, 0, 107, 107, -1, 30, 2, 0, 6, 2, 7, 3, 8, 3, 9, 4, 108, 98, 109, 99, 110, 100, 111, 101, 112, 0, 113, 0, 114, 0, 115, 0, 116, 2, 117, 2, 118, 13, 119, 3, 120, 6, 121, 102, 122, 3, 123, 103, 124, 6, 125, 14, 126, 14, 127, 104, 128, 8, 129, 8, 130, 2, 131, 14, 132, 105, 0 "variants" - + "" + "__editor_plugin_screen__" + "2D" "__editor_plugin_states__" - "Script" - - "current" - 2 - "sources" - - "res://moving_platform.gd" - "res://enemy.gd" - "res://player.gd" - "res://coin.gd" - - "2D" - "pixel_snap" + "ofs" + 328.379, 822.226 + "snap_grid" False - "zoom" - 0.814506 - "use_snap" + "snap_offset" + 0, 0 + "snap_pixel" + False + "snap_relative" False - "snap_vec" + "snap_rotation" + False + "snap_rotation_offset" + 0 + "snap_rotation_step" + 0.261799 + "snap_show_grid" + False + "snap_step" 10, 10 - "ofs" - 177.488, 709.633 + "zoom" + 1.108032 "3D" + "ambient_light_color" + 0.15, 0.15, 0.15, 1 + "default_light" + True + "default_srgb" + False + "deflight_rot_x" + 0.942478 "deflight_rot_y" 0.628319 - "zfar" - 500 "fov" 45 + "show_grid" + True + "show_origin" + True + "viewport_mode" + 1 "viewports" "distance" - 4 - "x_rot" - 0 - "y_rot" - 0 + 18.643827 "listener" True + "pos" + 0, 0, 0 "use_environment" False "use_orthogonal" False - "pos" - 0, 0, 0 - - - "distance" - 4 "x_rot" 0 "y_rot" 0 + + + "distance" + 4 "listener" False + "pos" + 0, 0, 0 "use_environment" False "use_orthogonal" False - "pos" - 0, 0, 0 - - - "distance" - 4 "x_rot" 0 "y_rot" 0 + + + "distance" + 4 "listener" False + "pos" + 0, 0, 0 "use_environment" False "use_orthogonal" False - "pos" - 0, 0, 0 - - - "distance" - 4 "x_rot" 0 "y_rot" 0 + + + "distance" + 4 "listener" False + "pos" + 0, 0, 0 "use_environment" False "use_orthogonal" False - "pos" - 0, 0, 0 + "x_rot" + 0 + "y_rot" + 0 - "viewport_mode" - 1 - "default_light" - True - "ambient_light_color" - 0.15, 0.15, 0.15, 1 - "show_grid" - True - "show_origin" - True + "zfar" + 500 "znear" 0.1 - "default_srgb" - False - "deflight_rot_x" - 0.942478 + + "Script" + + "current" + 2 + "sources" + + "res://moving_platform.gd" + "res://enemy.gd" + "res://player.gd" + "res://coin.gd" + "__editor_run_settings__" @@ -280,8 +300,6 @@ "run_mode" 0 - "__editor_plugin_screen__" - "3D" True 1 @@ -296,7 +314,7 @@ 1, 0, 0, 1, 0, 0 2 False - 0, 2, 70, 536870914, 71, 10, 72, 10, 73, 10, 74, 10, 75, 10, 76, 10, 77, 10, 78, 10, 65536, 2, 65606, 536870914, 65607, 10, 65608, 10, 65609, 10, 65610, 10, 65611, 10, 65612, 10, 65613, 10, 65614, 10, 131072, 2, 131142, 536870914, 131143, 10, 131144, 10, 131145, 10, 131146, 10, 131147, 10, 131148, 10, 131149, 10, 131150, 10, 196608, 2, 196626, 9, 196678, 536870914, 196679, 10, 196680, 10, 196681, 10, 196682, 10, 196683, 10, 196684, 10, 196685, 10, 196686, 10, 262144, 2, 262162, 8, 262214, 536870914, 262215, 10, 262216, 10, 262217, 10, 262218, 10, 262219, 10, 262220, 10, 262221, 10, 262222, 10, 327680, 2, 327697, 536870921, 327698, 7, 327733, 9, 327750, 536870914, 327751, 10, 327752, 10, 327753, 10, 327754, 10, 327755, 10, 327756, 10, 327757, 10, 327758, 10, 393216, 2, 393233, 536870920, 393234, 7, 393257, 9, 393269, 7, 393286, 536870914, 393287, 10, 393288, 10, 393289, 10, 393290, 10, 393291, 10, 393292, 10, 393293, 10, 393294, 10, 458752, 2, 458769, 7, 458770, 8, 458790, 9, 458793, 8, 458805, 8, 458822, 536870914, 458823, 10, 458824, 10, 458825, 10, 458826, 10, 458827, 10, 458828, 10, 458829, 10, 458830, 10, 524288, 4, 524289, 1, 524304, 536870913, 524305, 536870918, 524306, 6, 524307, 5, 524308, 1, 524326, 8, 524329, 7, 524341, 7, 524358, 536870914, 524359, 10, 524360, 10, 524361, 10, 524362, 10, 524363, 10, 524364, 10, 524365, 10, 524366, 10, 589824, 10, 589825, 13, 589840, 536870914, 589841, 10, 589842, 10, 589843, 10, 589844, 2, 589862, 7, 589865, 7, 589876, 536870913, 589877, 6, 589878, 1, 589894, 536870914, 589895, 10, 589896, 10, 589897, 10, 589898, 10, 589899, 10, 589900, 10, 589901, 10, 589902, 10, 655360, 2, 655376, 536870914, 655377, 10, 655378, 10, 655379, 10, 655380, 2, 655398, 7, 655401, 8, 655412, 536870925, 655413, 11, 655414, 13, 655430, 536870914, 655431, 10, 655432, 10, 655433, 10, 655434, 10, 655435, 10, 655436, 10, 655437, 10, 655438, 10, 720896, 2, 720912, 536870914, 720913, 10, 720914, 10, 720915, 10, 720916, 2, 720934, 8, 720937, 7, 720958, 536870913, 720959, 5, 720960, 536870917, 720961, 5, 720962, 5, 720963, 536870917, 720964, 5, 720965, 0, 720966, 536870916, 720967, 10, 720968, 10, 720969, 10, 720970, 10, 720971, 10, 720972, 10, 720973, 10, 720974, 10, 786432, 2, 786437, 9, 786448, 536870914, 786449, 10, 786450, 10, 786451, 10, 786452, 2, 786464, 536870913, 786465, 1, 786470, 7, 786473, 7, 786474, 536870924, 786475, 1, 786494, 536870914, 786495, 10, 786496, 10, 786497, 10, 786498, 10, 786499, 10, 786500, 10, 786501, 10, 786502, 10, 786503, 10, 786504, 10, 786505, 10, 786506, 10, 786507, 10, 786508, 10, 786509, 10, 851968, 2, 851973, 7, 851984, 536870914, 851985, 10, 851986, 10, 851987, 10, 851988, 2, 851996, 536870913, 851997, 1, 852000, 536870914, 852001, 3, 852006, 7, 852009, 536870913, 852011, 2, 852030, 536870914, 852031, 10, 852032, 10, 852033, 10, 852034, 10, 852035, 10, 852036, 10, 852037, 10, 852038, 10, 852039, 10, 852040, 10, 852041, 10, 852042, 10, 852043, 10, 852044, 10, 852045, 10, 917504, 2, 917506, 9, 917509, 7, 917512, 536870921, 917520, 536870925, 917521, 11, 917522, 11, 917523, 11, 917524, 13, 917532, 536870925, 917533, 13, 917536, 536870914, 917537, 4, 917538, 1, 917540, 536870913, 917541, 0, 917542, 1, 917545, 536870914, 917546, 10, 917547, 4, 917548, 1, 917566, 536870914, 917567, 10, 917568, 10, 917569, 10, 917570, 10, 917571, 10, 917572, 10, 917573, 10, 917574, 10, 917575, 10, 917576, 10, 917577, 10, 917578, 10, 917579, 10, 917580, 10, 917581, 10, 983040, 2, 983042, 7, 983045, 7, 983048, 536870920, 983050, 536870913, 983051, 1, 983064, 536870913, 983065, 1, 983072, 536870914, 983073, 10, 983074, 4, 983075, 0, 983076, 536870916, 983077, 10, 983078, 4, 983079, 536870912, 983080, 536870912, 983081, 536870916, 983082, 10, 983083, 10, 983084, 2, 983095, 9, 983102, 536870914, 983103, 10, 983104, 10, 983105, 10, 983106, 10, 983107, 10, 983108, 10, 983109, 10, 983110, 10, 983111, 10, 983112, 10, 983113, 10, 983114, 10, 983115, 10, 983116, 10, 983117, 10, 1048576, 2, 1048578, 8, 1048581, 8, 1048584, 536870919, 1048586, 536870925, 1048587, 13, 1048600, 536870925, 1048601, 13, 1048604, 9, 1048608, 536870925, 1048609, 536870923, 1048610, 536870923, 1048611, 536870923, 1048612, 10, 1048613, 10, 1048614, 10, 1048615, 10, 1048616, 10, 1048617, 10, 1048618, 10, 1048619, 10, 1048620, 4, 1048621, 1, 1048630, 536870921, 1048631, 8, 1048638, 536870914, 1048639, 10, 1048640, 10, 1048641, 10, 1048642, 10, 1048643, 10, 1048644, 10, 1048645, 10, 1048646, 10, 1048647, 10, 1048648, 10, 1048649, 10, 1048650, 10, 1048651, 10, 1048652, 10, 1048653, 10, 1114112, 4, 1114113, 0, 1114114, 6, 1114115, 0, 1114116, 0, 1114117, 6, 1114118, 1, 1114120, 536870920, 1114128, 536870913, 1114129, 5, 1114130, 536870917, 1114131, 5, 1114132, 0, 1114133, 1, 1114140, 7, 1114141, 536870921, 1114148, 536870914, 1114149, 10, 1114150, 10, 1114151, 10, 1114152, 10, 1114153, 10, 1114154, 10, 1114155, 10, 1114156, 10, 1114157, 2, 1114166, 536870920, 1114167, 8, 1114174, 536870914, 1114175, 10, 1114176, 10, 1114177, 10, 1114178, 10, 1114179, 10, 1114180, 10, 1114181, 10, 1114182, 10, 1114183, 10, 1114184, 10, 1114185, 10, 1114186, 10, 1114187, 10, 1114188, 10, 1179648, 10, 1179649, 10, 1179650, 10, 1179651, 10, 1179652, 10, 1179653, 10, 1179654, 2, 1179656, 536870919, 1179663, 536870915, 1179665, 10, 1179666, 10, 1179667, 10, 1179668, 10, 1179669, 4, 1179670, 12, 1179675, 9, 1179676, 8, 1179677, 8, 1179684, 536870914, 1179685, 10, 1179686, 10, 1179687, 10, 1179688, 10, 1179689, 10, 1179690, 10, 1179691, 10, 1179692, 10, 1179693, 4, 1179694, 1, 1179701, 9, 1179702, 536870919, 1179703, 7, 1179710, 536870914, 1179711, 10, 1179712, 10, 1179713, 10, 1179714, 10, 1179715, 10, 1179716, 10, 1179717, 10, 1179718, 10, 1179719, 10, 1179720, 10, 1179721, 10, 1179722, 10, 1245184, 10, 1245185, 10, 1245186, 10, 1245187, 10, 1245188, 10, 1245189, 10, 1245190, 2, 1245192, 536870919, 1245199, 536870913, 1245200, 536870916, 1245201, 10, 1245202, 10, 1245203, 10, 1245204, 10, 1245205, 10, 1245207, 1, 1245211, 7, 1245212, 7, 1245213, 536870920, 1245220, 536870914, 1245221, 10, 1245222, 10, 1245223, 10, 1245224, 10, 1245225, 10, 1245226, 10, 1245227, 10, 1245228, 10, 1245229, 10, 1245230, 2, 1245237, 8, 1245238, 536870919, 1245239, 8, 1245240, 536870921, 1245246, 536870914, 1245247, 10, 1245248, 10, 1245249, 10, 1245250, 10, 1245251, 10, 1245252, 10, 1245253, 10, 1245254, 10, 1245255, 10, 1245256, 10, 1245257, 10, 1245258, 10, 1310720, 10, 1310721, 10, 1310722, 10, 1310723, 10, 1310724, 10, 1310725, 10, 1310726, 2, 1310728, 536870920, 1310730, 536870913, 1310731, 1, 1310734, 536870913, 1310735, 536870916, 1310736, 10, 1310737, 10, 1310738, 10, 1310739, 10, 1310740, 10, 1310741, 10, 1310742, 10, 1310743, 4, 1310744, 1, 1310747, 8, 1310748, 7, 1310749, 536870919, 1310756, 536870914, 1310757, 10, 1310758, 10, 1310759, 10, 1310760, 10, 1310761, 10, 1310762, 10, 1310763, 10, 1310764, 10, 1310765, 10, 1310766, 4, 1310767, 5, 1310768, 12, 1310773, 7, 1310774, 536870919, 1310775, 7, 1310776, 536870919, 1310782, 536870914, 1310783, 10, 1310784, 10, 1310785, 10, 1310786, 10, 1310787, 10, 1310788, 10, 1310789, 10, 1310790, 10, 1310791, 10, 1310792, 10, 1310793, 10, 1376256, 10, 1376257, 10, 1376258, 10, 1376259, 10, 1376260, 10, 1376261, 10, 1376262, 4, 1376263, 0, 1376264, 0, 1376265, 0, 1376266, 536870916, 1376267, 4, 1376268, 0, 1376269, 0, 1376270, 536870916, 1376271, 10, 1376272, 10, 1376273, 10, 1376274, 10, 1376275, 10, 1376276, 10, 1376277, 10, 1376278, 10, 1376279, 10, 1376280, 4, 1376281, 12, 1376283, 8, 1376284, 8, 1376285, 536870920, 1376287, 536870924, 1376288, 0, 1376289, 5, 1376290, 536870917, 1376291, 0, 1376292, 536870916, 1376293, 10, 1376294, 10, 1376295, 10, 1376296, 10, 1376297, 10, 1376298, 10, 1376299, 10, 1376300, 10, 1376301, 10, 1376302, 10, 1376303, 10, 1376305, 12, 1376309, 7, 1376310, 536870920, 1376311, 7, 1376312, 536870920, 1376318, 536870914, 1376319, 10, 1376320, 10, 1376321, 10, 1376322, 10, 1376323, 10, 1376324, 10, 1376325, 10, 1376326, 10, 1376327, 10, 1376328, 10, 1441792, 10, 1441793, 10, 1441794, 10, 1441795, 10, 1441796, 10, 1441797, 10, 1441798, 10, 1441799, 10, 1441800, 10, 1441801, 10, 1441802, 10, 1441803, 10, 1441804, 10, 1441805, 10, 1441806, 10, 1441807, 10, 1441808, 10, 1441809, 10, 1441810, 10, 1441811, 10, 1441812, 10, 1441813, 10, 1441814, 10, 1441815, 10, 1441816, 10, 1441818, 0, 1441819, 6, 1441820, 6, 1441821, 536870918, 1441822, 5, 1441824, 10, 1441825, 10, 1441826, 10, 1441827, 10, 1441828, 10, 1441829, 10, 1441830, 10, 1441831, 10, 1441832, 10, 1441833, 10, 1441834, 10, 1441835, 10, 1441836, 10, 1441837, 10, 1441838, 10, 1441839, 10, 1441840, 10, 1441842, 0, 1441843, 0, 1441844, 0, 1441845, 6, 1441846, 536870918, 1441847, 6, 1441848, 536870918, 1441849, 0, 1441850, 5, 1441851, 536870917, 1441852, 5, 1441853, 0, 1441854, 536870916, 1441855, 10, 1441856, 10, 1441857, 10, 1441858, 10, 1441859, 10, 1441860, 10, 1441861, 10, 1441862, 10, 1441863, 10, 1507328, 10, 1507329, 10, 1507330, 10, 1507331, 10, 1507332, 10, 1507333, 10, 1507334, 10, 1507335, 10, 1507336, 10, 1507337, 10, 1507338, 10, 1507339, 10, 1507340, 10, 1507341, 10, 1507342, 10, 1507343, 10, 1507344, 10, 1507345, 10, 1507346, 10, 1507347, 10, 1507348, 10, 1507349, 10, 1507350, 10, 1507351, 10, 1507352, 10, 1507353, 10, 1507354, 10, 1507355, 10, 1507356, 10, 1507357, 10, 1507358, 10, 1507359, 10, 1507360, 10, 1507361, 10, 1507362, 10, 1507363, 10, 1507364, 10, 1507365, 10, 1507366, 10, 1507367, 10, 1507368, 10, 1507369, 10, 1507370, 10, 1507371, 10, 1507372, 10, 1507373, 10, 1507374, 10, 1507375, 10, 1507376, 10, 1507377, 10, 1507378, 10, 1507379, 10, 1507380, 10, 1507381, 10, 1507382, 10, 1507383, 10, 1507384, 10, 1507385, 10, 1507386, 10, 1507387, 10, 1507388, 10, 1507389, 10, 1507390, 10, 1507391, 10, 1507392, 10, 1507393, 10, 1507394, 10, 1507395, 10, 1507396, 10, 1507397, 10, 1507398, 10, 1507399, 10, 1572864, 10, 1572865, 10, 1572866, 10, 1572867, 10, 1572868, 10, 1572869, 10, 1572870, 10, 1572871, 10, 1572872, 10, 1572873, 10, 1572874, 10, 1572875, 10, 1572876, 10, 1572877, 10, 1572878, 10, 1572879, 10, 1572880, 10, 1572881, 10, 1572882, 10, 1572883, 10, 1572884, 10, 1572885, 10, 1572886, 10, 1572887, 10, 1572888, 10, 1572889, 10, 1572890, 10, 1572891, 10, 1572892, 10, 1572893, 10, 1572894, 10, 1572895, 10, 1572896, 10, 1572897, 10, 1572898, 10, 1572899, 10, 1572900, 10, 1572901, 10, 1572902, 10, 1572903, 10, 1572904, 10, 1572905, 10, 1572906, 10, 1572907, 10, 1572908, 10, 1572909, 10, 1572910, 10, 1572911, 10, 1572912, 10, 1572913, 10, 1572914, 10, 1572915, 10, 1572916, 10, 1572917, 10, 1572918, 10, 1572919, 10, 1572920, 10, 1572921, 10, 1572922, 10, 1572923, 10, 1572924, 10, 1572925, 10, 1572926, 10, 1572927, 10, 1572928, 10, 1572929, 10, 1572930, 10, 1572931, 10, 1572932, 10, 1572933, 10, 1572934, 10, 1572935, 10, 1638400, 10, 1638401, 10, 1638402, 10, 1638403, 10, 1638404, 10, 1638405, 10, 1638406, 10, 1638407, 10, 1638408, 10, 1638409, 10, 1638410, 10, 1638411, 10, 1638412, 10, 1638413, 10, 1638414, 10, 1638415, 10, 1638416, 10, 1638417, 10, 1638418, 10, 1638419, 10, 1638420, 10, 1638421, 10, 1638422, 10, 1638423, 10, 1638424, 10, 1638425, 10, 1638426, 10, 1638427, 10, 1638428, 10, 1638429, 10, 1638430, 10, 1638431, 10, 1638432, 10, 1638433, 10, 1638434, 10, 1638435, 10, 1638436, 10, 1638437, 10, 1638438, 10, 1638439, 10, 1638440, 10, 1638441, 10, 1638442, 10, 1638443, 10, 1638444, 10, 1638445, 10, 1638446, 10, 1638447, 10, 1638448, 10, 1638449, 10, 1638450, 10, 1638451, 10, 1638452, 10, 1638453, 10, 1638454, 10, 1638455, 10, 1638456, 10, 1638457, 10, 1638458, 10, 1638459, 10, 1638460, 10, 1638461, 10, 1638462, 10, 1638463, 10, 1638464, 10, 1638465, 10, 1638466, 10, 1638467, 10, 1638468, 10, 1638469, 10, 1638470, 10, 1638471, 10, 1703952, 10, 1703953, 10, 1703954, 10, 1703955, 10, 1703956, 10, 1703957, 10, 1703958, 10, 1703959, 10, 1703960, 10, 1703961, 10, 1703962, 10, 1703963, 10, 1703964, 10, 1703965, 10, 1703966, 10, 1703967, 10, 1703968, 10, 1703969, 10, 1703970, 10, 1703971, 10, 1703972, 10, 1703973, 10, 1703974, 10, 1703975, 10, 1703976, 10, 1703977, 10, 1703978, 10, 1703979, 10, 1703980, 10, 1703981, 10, 1703982, 10, 1703983, 10, 1703984, 10, 1703985, 10, 1703986, 10, 1703987, 10, 1703988, 10, 1703989, 10, 1703990, 10, 1703991, 10, 1703992, 10, 1703993, 10, 1703994, 10, 1703995, 10, 1703996, 10, 1703997, 10, 1703998, 10, 1703999, 10, 1704000, 10, 1704001, 10, 1704002, 10, 1704003, 10, 1704004, 10, 1704005, 10, 1704006, 10, 1704007, 10, 1769488, 10, 1769489, 10, 1769490, 10, 1769491, 10, 1769492, 10, 1769493, 10, 1769494, 10, 1769495, 10, 1769496, 10, 1769497, 10, 1769498, 10, 1769499, 10, 1769500, 10, 1769501, 10, 1769502, 10, 1769503, 10, 1769504, 10, 1769505, 10, 1769506, 10, 1769507, 10, 1769508, 10, 1769509, 10, 1769510, 10, 1769511, 10, 1769512, 10, 1769513, 10, 1769514, 10, 1769515, 10, 1769516, 10, 1769517, 10, 1769518, 10, 1769519, 10, 1769520, 10, 1769521, 10, 1769522, 10, 1769523, 10, 1769524, 10, 1769525, 10, 1769526, 10, 1769527, 10, 1769528, 10, 1769529, 10, 1769530, 10, 1769531, 10, 1769532, 10, 1769533, 10, 1769534, 10, 1769535, 10, 1769536, 10, 1769537, 10, 1769538, 10, 1769539, 10, 1769540, 10, 1769541, 10 + 0, 2, 70, 536870914, 71, 10, 72, 10, 73, 10, 74, 10, 75, 10, 76, 10, 77, 10, 78, 10, 65536, 2, 65606, 536870914, 65607, 10, 65608, 10, 65609, 10, 65610, 10, 65611, 10, 65612, 10, 65613, 10, 65614, 10, 131072, 2, 131142, 536870914, 131143, 10, 131144, 10, 131145, 10, 131146, 10, 131147, 10, 131148, 10, 131149, 10, 131150, 10, 196608, 2, 196626, 9, 196678, 536870914, 196679, 10, 196680, 10, 196681, 10, 196682, 10, 196683, 10, 196684, 10, 196685, 10, 196686, 10, 262144, 2, 262162, 8, 262214, 536870914, 262215, 10, 262216, 10, 262217, 10, 262218, 10, 262219, 10, 262220, 10, 262221, 10, 262222, 10, 327680, 2, 327697, 536870921, 327698, 7, 327733, 9, 327750, 536870914, 327751, 10, 327752, 10, 327753, 10, 327754, 10, 327755, 10, 327756, 10, 327757, 10, 327758, 10, 393216, 2, 393233, 536870920, 393234, 7, 393257, 9, 393269, 7, 393286, 536870914, 393287, 10, 393288, 10, 393289, 10, 393290, 10, 393291, 10, 393292, 10, 393293, 10, 393294, 10, 458752, 2, 458769, 7, 458770, 8, 458790, 9, 458793, 8, 458805, 8, 458822, 536870914, 458823, 10, 458824, 10, 458825, 10, 458826, 10, 458827, 10, 458828, 10, 458829, 10, 458830, 10, 524288, 4, 524289, 1, 524304, 536870913, 524305, 536870918, 524306, 6, 524307, 5, 524308, 1, 524326, 8, 524329, 7, 524341, 7, 524358, 536870914, 524359, 10, 524360, 10, 524361, 10, 524362, 10, 524363, 10, 524364, 10, 524365, 10, 524366, 10, 589824, 10, 589825, 13, 589840, 536870914, 589841, 10, 589842, 10, 589843, 10, 589844, 2, 589862, 7, 589865, 7, 589876, 536870913, 589877, 6, 589878, 1, 589894, 536870914, 589895, 10, 589896, 10, 589897, 10, 589898, 10, 589899, 10, 589900, 10, 589901, 10, 589902, 10, 655360, 2, 655376, 536870914, 655377, 10, 655378, 10, 655379, 10, 655380, 2, 655398, 7, 655401, 8, 655412, 536870925, 655413, 11, 655414, 13, 655430, 536870914, 655431, 10, 655432, 10, 655433, 10, 655434, 10, 655435, 10, 655436, 10, 655437, 10, 655438, 10, 720896, 2, 720912, 536870914, 720913, 10, 720914, 10, 720915, 10, 720916, 2, 720934, 8, 720937, 7, 720958, 536870913, 720959, 5, 720960, 536870917, 720961, 5, 720962, 5, 720963, 536870917, 720964, 5, 720965, 0, 720966, 536870916, 720967, 10, 720968, 10, 720969, 10, 720970, 10, 720971, 10, 720972, 10, 720973, 10, 720974, 10, 786432, 2, 786437, 9, 786448, 536870914, 786449, 10, 786450, 10, 786451, 10, 786452, 2, 786464, 536870913, 786465, 1, 786470, 7, 786473, 7, 786474, 536870924, 786475, 1, 786494, 536870914, 786495, 10, 786496, 10, 786497, 10, 786498, 10, 786499, 10, 786500, 10, 786501, 10, 786502, 10, 786503, 10, 786504, 10, 786505, 10, 786506, 10, 786507, 10, 786508, 10, 786509, 10, 851968, 2, 851973, 7, 851984, 536870914, 851985, 10, 851986, 10, 851987, 10, 851988, 2, 851996, 536870913, 851997, 1, 852000, 536870914, 852001, 3, 852006, 7, 852009, 536870913, 852011, 2, 852030, 536870914, 852031, 10, 852032, 10, 852033, 10, 852034, 10, 852035, 10, 852036, 10, 852037, 10, 852038, 10, 852039, 10, 852040, 10, 852041, 10, 852042, 10, 852043, 10, 852044, 10, 852045, 10, 917504, 2, 917506, 9, 917509, 7, 917512, 536870921, 917520, 536870925, 917521, 11, 917522, 11, 917523, 11, 917524, 13, 917532, 536870925, 917533, 13, 917536, 536870914, 917537, 4, 917538, 1, 917540, 536870913, 917541, 0, 917542, 1, 917545, 536870914, 917546, 10, 917547, 4, 917548, 1, 917566, 536870914, 917567, 10, 917568, 10, 917569, 10, 917570, 10, 917571, 10, 917572, 10, 917573, 10, 917574, 10, 917575, 10, 917576, 10, 917577, 10, 917578, 10, 917579, 10, 917580, 10, 917581, 10, 983040, 2, 983042, 7, 983045, 7, 983048, 536870920, 983050, 536870913, 983051, 0, 983052, 1, 983064, 536870913, 983065, 1, 983072, 536870914, 983073, 10, 983074, 4, 983075, 0, 983076, 536870916, 983077, 10, 983078, 4, 983079, 536870912, 983080, 536870912, 983081, 536870916, 983082, 10, 983083, 10, 983084, 2, 983095, 9, 983102, 536870914, 983103, 10, 983104, 10, 983105, 10, 983106, 10, 983107, 10, 983108, 10, 983109, 10, 983110, 10, 983111, 10, 983112, 10, 983113, 10, 983114, 10, 983115, 10, 983116, 10, 983117, 10, 1048576, 2, 1048578, 8, 1048581, 8, 1048584, 536870919, 1048586, 536870914, 1048587, 536870922, 1048588, 2, 1048600, 536870925, 1048601, 13, 1048604, 9, 1048608, 536870925, 1048609, 536870923, 1048610, 536870923, 1048611, 536870923, 1048612, 10, 1048613, 10, 1048614, 10, 1048615, 10, 1048616, 10, 1048617, 10, 1048618, 10, 1048619, 10, 1048620, 4, 1048621, 1, 1048630, 536870921, 1048631, 8, 1048638, 536870914, 1048639, 10, 1048640, 10, 1048641, 10, 1048642, 10, 1048643, 10, 1048644, 10, 1048645, 10, 1048646, 10, 1048647, 10, 1048648, 10, 1048649, 10, 1048650, 10, 1048651, 10, 1048652, 10, 1048653, 10, 1114112, 4, 1114113, 0, 1114114, 6, 1114115, 0, 1114116, 0, 1114117, 6, 1114118, 1, 1114120, 536870920, 1114122, 536870925, 1114123, 11, 1114124, 13, 1114128, 536870913, 1114129, 5, 1114130, 536870917, 1114131, 5, 1114132, 0, 1114133, 1, 1114140, 7, 1114141, 536870921, 1114148, 536870914, 1114149, 10, 1114150, 10, 1114151, 10, 1114152, 10, 1114153, 10, 1114154, 10, 1114155, 10, 1114156, 10, 1114157, 2, 1114166, 536870920, 1114167, 8, 1114174, 536870914, 1114175, 10, 1114176, 10, 1114177, 10, 1114178, 10, 1114179, 10, 1114180, 10, 1114181, 10, 1114182, 10, 1114183, 10, 1114184, 10, 1114185, 10, 1114186, 10, 1114187, 10, 1114188, 10, 1179648, 10, 1179649, 10, 1179650, 10, 1179651, 10, 1179652, 10, 1179653, 10, 1179654, 2, 1179656, 536870919, 1179663, 536870915, 1179665, 10, 1179666, 10, 1179667, 10, 1179668, 10, 1179669, 4, 1179670, 12, 1179675, 9, 1179676, 8, 1179677, 8, 1179684, 536870914, 1179685, 10, 1179686, 10, 1179687, 10, 1179688, 10, 1179689, 10, 1179690, 10, 1179691, 10, 1179692, 10, 1179693, 4, 1179694, 1, 1179701, 9, 1179702, 536870919, 1179703, 7, 1179710, 536870914, 1179711, 10, 1179712, 10, 1179713, 10, 1179714, 10, 1179715, 10, 1179716, 10, 1179717, 10, 1179718, 10, 1179719, 10, 1179720, 10, 1179721, 10, 1179722, 10, 1245184, 10, 1245185, 10, 1245186, 10, 1245187, 10, 1245188, 10, 1245189, 10, 1245190, 2, 1245192, 536870919, 1245199, 536870913, 1245200, 536870916, 1245201, 10, 1245202, 10, 1245203, 10, 1245204, 10, 1245205, 10, 1245207, 1, 1245211, 7, 1245212, 7, 1245213, 536870920, 1245220, 536870914, 1245221, 10, 1245222, 10, 1245223, 10, 1245224, 10, 1245225, 10, 1245226, 10, 1245227, 10, 1245228, 10, 1245229, 10, 1245230, 2, 1245237, 8, 1245238, 536870919, 1245239, 8, 1245240, 536870921, 1245246, 536870914, 1245247, 10, 1245248, 10, 1245249, 10, 1245250, 10, 1245251, 10, 1245252, 10, 1245253, 10, 1245254, 10, 1245255, 10, 1245256, 10, 1245257, 10, 1245258, 10, 1310720, 10, 1310721, 10, 1310722, 10, 1310723, 10, 1310724, 10, 1310725, 10, 1310726, 2, 1310728, 536870920, 1310730, 536870913, 1310731, 1, 1310734, 536870913, 1310735, 536870916, 1310736, 10, 1310737, 10, 1310738, 10, 1310739, 10, 1310740, 10, 1310741, 10, 1310742, 10, 1310743, 4, 1310744, 1, 1310747, 8, 1310748, 7, 1310749, 536870919, 1310756, 536870914, 1310757, 10, 1310758, 10, 1310759, 10, 1310760, 10, 1310761, 10, 1310762, 10, 1310763, 10, 1310764, 10, 1310765, 10, 1310766, 4, 1310767, 5, 1310768, 12, 1310773, 7, 1310774, 536870919, 1310775, 7, 1310776, 536870919, 1310782, 536870914, 1310783, 10, 1310784, 10, 1310785, 10, 1310786, 10, 1310787, 10, 1310788, 10, 1310789, 10, 1310790, 10, 1310791, 10, 1310792, 10, 1310793, 10, 1376256, 10, 1376257, 10, 1376258, 10, 1376259, 10, 1376260, 10, 1376261, 10, 1376262, 4, 1376263, 0, 1376264, 0, 1376265, 0, 1376266, 536870916, 1376267, 4, 1376268, 0, 1376269, 0, 1376270, 536870916, 1376271, 10, 1376272, 10, 1376273, 10, 1376274, 10, 1376275, 10, 1376276, 10, 1376277, 10, 1376278, 10, 1376279, 10, 1376280, 4, 1376281, 12, 1376283, 8, 1376284, 8, 1376285, 536870920, 1376287, 536870924, 1376288, 0, 1376289, 5, 1376290, 536870917, 1376291, 0, 1376292, 536870916, 1376293, 10, 1376294, 10, 1376295, 10, 1376296, 10, 1376297, 10, 1376298, 10, 1376299, 10, 1376300, 10, 1376301, 10, 1376302, 10, 1376303, 10, 1376305, 12, 1376309, 7, 1376310, 536870920, 1376311, 7, 1376312, 536870920, 1376318, 536870914, 1376319, 10, 1376320, 10, 1376321, 10, 1376322, 10, 1376323, 10, 1376324, 10, 1376325, 10, 1376326, 10, 1376327, 10, 1376328, 10, 1441792, 10, 1441793, 10, 1441794, 10, 1441795, 10, 1441796, 10, 1441797, 10, 1441798, 10, 1441799, 10, 1441800, 10, 1441801, 10, 1441802, 10, 1441803, 10, 1441804, 10, 1441805, 10, 1441806, 10, 1441807, 10, 1441808, 10, 1441809, 10, 1441810, 10, 1441811, 10, 1441812, 10, 1441813, 10, 1441814, 10, 1441815, 10, 1441816, 10, 1441818, 0, 1441819, 6, 1441820, 6, 1441821, 536870918, 1441822, 5, 1441824, 10, 1441825, 10, 1441826, 10, 1441827, 10, 1441828, 10, 1441829, 10, 1441830, 10, 1441831, 10, 1441832, 10, 1441833, 10, 1441834, 10, 1441835, 10, 1441836, 10, 1441837, 10, 1441838, 10, 1441839, 10, 1441840, 10, 1441842, 0, 1441843, 0, 1441844, 0, 1441845, 6, 1441846, 536870918, 1441847, 6, 1441848, 536870918, 1441849, 0, 1441850, 5, 1441851, 536870917, 1441852, 5, 1441853, 0, 1441854, 536870916, 1441855, 10, 1441856, 10, 1441857, 10, 1441858, 10, 1441859, 10, 1441860, 10, 1441861, 10, 1441862, 10, 1441863, 10, 1507328, 10, 1507329, 10, 1507330, 10, 1507331, 10, 1507332, 10, 1507333, 10, 1507334, 10, 1507335, 10, 1507336, 10, 1507337, 10, 1507338, 10, 1507339, 10, 1507340, 10, 1507341, 10, 1507342, 10, 1507343, 10, 1507344, 10, 1507345, 10, 1507346, 10, 1507347, 10, 1507348, 10, 1507349, 10, 1507350, 10, 1507351, 10, 1507352, 10, 1507353, 10, 1507354, 10, 1507355, 10, 1507356, 10, 1507357, 10, 1507358, 10, 1507359, 10, 1507360, 10, 1507361, 10, 1507362, 10, 1507363, 10, 1507364, 10, 1507365, 10, 1507366, 10, 1507367, 10, 1507368, 10, 1507369, 10, 1507370, 10, 1507371, 10, 1507372, 10, 1507373, 10, 1507374, 10, 1507375, 10, 1507376, 10, 1507377, 10, 1507378, 10, 1507379, 10, 1507380, 10, 1507381, 10, 1507382, 10, 1507383, 10, 1507384, 10, 1507385, 10, 1507386, 10, 1507387, 10, 1507388, 10, 1507389, 10, 1507390, 10, 1507391, 10, 1507392, 10, 1507393, 10, 1507394, 10, 1507395, 10, 1507396, 10, 1507397, 10, 1507398, 10, 1507399, 10, 1572864, 10, 1572865, 10, 1572866, 10, 1572867, 10, 1572868, 10, 1572869, 10, 1572870, 10, 1572871, 10, 1572872, 10, 1572873, 10, 1572874, 10, 1572875, 10, 1572876, 10, 1572877, 10, 1572878, 10, 1572879, 10, 1572880, 10, 1572881, 10, 1572882, 10, 1572883, 10, 1572884, 10, 1572885, 10, 1572886, 10, 1572887, 10, 1572888, 10, 1572889, 10, 1572890, 10, 1572891, 10, 1572892, 10, 1572893, 10, 1572894, 10, 1572895, 10, 1572896, 10, 1572897, 10, 1572898, 10, 1572899, 10, 1572900, 10, 1572901, 10, 1572902, 10, 1572903, 10, 1572904, 10, 1572905, 10, 1572906, 10, 1572907, 10, 1572908, 10, 1572909, 10, 1572910, 10, 1572911, 10, 1572912, 10, 1572913, 10, 1572914, 10, 1572915, 10, 1572916, 10, 1572917, 10, 1572918, 10, 1572919, 10, 1572920, 10, 1572921, 10, 1572922, 10, 1572923, 10, 1572924, 10, 1572925, 10, 1572926, 10, 1572927, 10, 1572928, 10, 1572929, 10, 1572930, 10, 1572931, 10, 1572932, 10, 1572933, 10, 1572934, 10, 1572935, 10, 1638400, 10, 1638401, 10, 1638402, 10, 1638403, 10, 1638404, 10, 1638405, 10, 1638406, 10, 1638407, 10, 1638408, 10, 1638409, 10, 1638410, 10, 1638411, 10, 1638412, 10, 1638413, 10, 1638414, 10, 1638415, 10, 1638416, 10, 1638417, 10, 1638418, 10, 1638419, 10, 1638420, 10, 1638421, 10, 1638422, 10, 1638423, 10, 1638424, 10, 1638425, 10, 1638426, 10, 1638427, 10, 1638428, 10, 1638429, 10, 1638430, 10, 1638431, 10, 1638432, 10, 1638433, 10, 1638434, 10, 1638435, 10, 1638436, 10, 1638437, 10, 1638438, 10, 1638439, 10, 1638440, 10, 1638441, 10, 1638442, 10, 1638443, 10, 1638444, 10, 1638445, 10, 1638446, 10, 1638447, 10, 1638448, 10, 1638449, 10, 1638450, 10, 1638451, 10, 1638452, 10, 1638453, 10, 1638454, 10, 1638455, 10, 1638456, 10, 1638457, 10, 1638458, 10, 1638459, 10, 1638460, 10, 1638461, 10, 1638462, 10, 1638463, 10, 1638464, 10, 1638465, 10, 1638466, 10, 1638467, 10, 1638468, 10, 1638469, 10, 1638470, 10, 1638471, 10, 1703952, 10, 1703953, 10, 1703954, 10, 1703955, 10, 1703956, 10, 1703957, 10, 1703958, 10, 1703959, 10, 1703960, 10, 1703961, 10, 1703962, 10, 1703963, 10, 1703964, 10, 1703965, 10, 1703966, 10, 1703967, 10, 1703968, 10, 1703969, 10, 1703970, 10, 1703971, 10, 1703972, 10, 1703973, 10, 1703974, 10, 1703975, 10, 1703976, 10, 1703977, 10, 1703978, 10, 1703979, 10, 1703980, 10, 1703981, 10, 1703982, 10, 1703983, 10, 1703984, 10, 1703985, 10, 1703986, 10, 1703987, 10, 1703988, 10, 1703989, 10, 1703990, 10, 1703991, 10, 1703992, 10, 1703993, 10, 1703994, 10, 1703995, 10, 1703996, 10, 1703997, 10, 1703998, 10, 1703999, 10, 1704000, 10, 1704001, 10, 1704002, 10, 1704003, 10, 1704004, 10, 1704005, 10, 1704006, 10, 1704007, 10, 1769488, 10, 1769489, 10, 1769490, 10, 1769491, 10, 1769492, 10, 1769493, 10, 1769494, 10, 1769495, 10, 1769496, 10, 1769497, 10, 1769498, 10, 1769499, 10, 1769500, 10, 1769501, 10, 1769502, 10, 1769503, 10, 1769504, 10, 1769505, 10, 1769506, 10, 1769507, 10, 1769508, 10, 1769509, 10, 1769510, 10, 1769511, 10, 1769512, 10, 1769513, 10, 1769514, 10, 1769515, 10, 1769516, 10, 1769517, 10, 1769518, 10, 1769519, 10, 1769520, 10, 1769521, 10, 1769522, 10, 1769523, 10, 1769524, 10, 1769525, 10, 1769526, 10, 1769527, 10, 1769528, 10, 1769529, 10, 1769530, 10, 1769531, 10, 1769532, 10, 1769533, 10, 1769534, 10, 1769535, 10, 1769536, 10, 1769537, 10, 1769538, 10, 1769539, 10, 1769540, 10, 1769541, 10 "_edit_lock_" True @@ -308,103 +326,105 @@ 672, 1120 + "__editor_plugin_screen__" + "2D" "__editor_plugin_states__" - "Script" - - "current" - 2 - "sources" - - "res://enemy.gd" - "res://player.gd" - "res://coin.gd" - - "2D" + "ofs" + -34.3697, -21.6562 "pixel_snap" False "zoom" 3.794776 - "ofs" - -34.3697, -21.6562 "3D" + "default_light" + True "fov" 45 - "zfar" - 500 + "show_grid" + True + "show_origin" + True + "viewport_mode" + 1 "viewports" "distance" 4 + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "use_orthogonal" - False - "use_environment" - False - "pos" - 0, 0, 0 "distance" 4 + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "use_orthogonal" - False - "use_environment" - False - "pos" - 0, 0, 0 "distance" 4 + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "use_orthogonal" - False - "use_environment" - False - "pos" - 0, 0, 0 "distance" 4 + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "use_orthogonal" - False - "use_environment" - False - "pos" - 0, 0, 0 - "viewport_mode" - 1 - "default_light" - True - "show_grid" - True + "zfar" + 500 "znear" 0.1 - "show_origin" - True + + "Script" + + "current" + 2 + "sources" + + "res://enemy.gd" + "res://player.gd" + "res://coin.gd" + "__editor_run_settings__" @@ -414,8 +434,6 @@ "run_mode" 0 - "__editor_plugin_screen__" - "2D" 704, 1120 736, 1120 @@ -458,124 +476,217 @@ 4300.75, 541.058 4236.75, 541.058 4172.75, 541.058 - - 251.684, 1045.6 + + 1451.86, 742.969 + "__editor_plugin_screen__" + "2D" "__editor_plugin_states__" - "Script" - - "current" - 0 - "sources" - - "res://player.gd" - - "2D" + "ofs" + -210.652, -172.81 "pixel_snap" False "zoom" - 2.272073 - "use_snap" - False - "ofs" - -181.946, -86.2812 - "snap" - 10 + 1.360373 "3D" + "default_light" + True "fov" - 45 - "zfar" - 500 + 400 + "show_grid" + True + "show_origin" + True + "viewport_mode" + 1 "viewports" "distance" 4 + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "listener" - True + + + "distance" + 4 + "pos" + 0, 0, 0 "use_environment" False "use_orthogonal" False - "pos" - 0, 0, 0 + "x_rot" + 0 + "y_rot" + 0 "distance" 4 + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "listener" - False + + + "distance" + 4 + "pos" + 0, 0, 0 "use_environment" False "use_orthogonal" False - "pos" - 0, 0, 0 + "x_rot" + 0 + "y_rot" + 0 + + "zfar" + 500 + "znear" + 0.1 + + "Script" + + "current" + 0 + "sources" + + "res://moving_platform.gd" + "res://enemy.gd" + "res://player.gd" + "res://coin.gd" + + + + "__editor_run_settings__" + + "custom_args" + "-l $scene" + "run_mode" + 0 + + + 0, 140 + 5 + 624.824, 545.544 + 300, 0 + 10 + 3419.86, 739.662 + 450, 0 + + 2402.79, 849.52 + + "__editor_plugin_screen__" + "2D" + "__editor_plugin_states__" + + "2D" + + "ofs" + -116.979, -109.897 + "pixel_snap" + False + "zoom" + 2.050547 + + "3D" + + "default_light" + True + "fov" + 400 + "show_grid" + True + "show_origin" + True + "viewport_mode" + 1 + "viewports" + "distance" 4 + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "listener" - False + + + "distance" + 4 + "pos" + 0, 0, 0 "use_environment" False "use_orthogonal" False - "pos" - 0, 0, 0 + "x_rot" + 0 + "y_rot" + 0 "distance" 4 + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "listener" - False + + + "distance" + 4 + "pos" + 0, 0, 0 "use_environment" False "use_orthogonal" False - "pos" - 0, 0, 0 + "x_rot" + 0 + "y_rot" + 0 - "deflight_rot_y" - 0.628319 - "default_light" - True - "viewport_mode" - 1 - "ambient_light_color" - 0.15, 0.15, 0.15, 1 - "show_grid" - True + "zfar" + 500 "znear" 0.1 - "show_origin" - True - "deflight_rot_x" - 0.942478 - "default_srgb" - False "__editor_run_settings__" @@ -585,110 +696,130 @@ "run_mode" 0 - "__editor_plugin_screen__" - "Script" - - 1451.86, 742.969 + + 927.698, 1120.81 + "__editor_plugin_screen__" + "2D" "__editor_plugin_states__" - "Script" - - "current" - 0 - "sources" - - "res://moving_platform.gd" - "res://enemy.gd" - "res://player.gd" - "res://coin.gd" - - "2D" - "pixel_snap" + "ofs" + -133.699, -110.553 + "snap_grid" + False + "snap_offset" + 0, 0 + "snap_pixel" + False + "snap_relative" + False + "snap_rotation" False + "snap_rotation_offset" + 0 + "snap_rotation_step" + 0.261799 + "snap_show_grid" + False + "snap_step" + 10, 10 "zoom" - 1.360373 - "ofs" - -210.652, -172.81 + 2.050546 "3D" + "ambient_light_color" + 0.15, 0.15, 0.15, 1 + "default_light" + True + "default_srgb" + False + "deflight_rot_x" + 0.942478 + "deflight_rot_y" + 0.628319 "fov" - 400 - "zfar" - 500 + 45 + "show_grid" + True + "show_origin" + True + "viewport_mode" + 1 "viewports" "distance" 4 + "listener" + True + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "use_orthogonal" - False - "use_environment" - False - "pos" - 0, 0, 0 "distance" 4 + "listener" + False + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "use_orthogonal" - False - "use_environment" - False - "pos" - 0, 0, 0 "distance" 4 + "listener" + False + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "use_orthogonal" - False - "use_environment" - False - "pos" - 0, 0, 0 "distance" 4 + "listener" + False + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "use_orthogonal" - False - "use_environment" - False - "pos" - 0, 0, 0 - "viewport_mode" - 1 - "default_light" - True - "show_grid" - True + "zfar" + 500 "znear" 0.1 - "show_origin" - True "__editor_run_settings__" @@ -698,105 +829,127 @@ "run_mode" 0 - "__editor_plugin_screen__" - "2D" - 0, 140 - 5 - 624.824, 545.544 - 300, 0 - 10 - 3419.86, 739.662 - 450, 0 - - 2402.79, 849.52 + + 251.684, 1045.6 + "__editor_plugin_screen__" + "Script" "__editor_plugin_states__" "2D" + "ofs" + -181.946, -86.2812 "pixel_snap" False + "snap" + 10 + "use_snap" + False "zoom" - 2.050547 - "ofs" - -116.979, -109.897 + 2.272073 "3D" + "ambient_light_color" + 0.15, 0.15, 0.15, 1 + "default_light" + True + "default_srgb" + False + "deflight_rot_x" + 0.942478 + "deflight_rot_y" + 0.628319 "fov" - 400 - "zfar" - 500 + 45 + "show_grid" + True + "show_origin" + True + "viewport_mode" + 1 "viewports" "distance" 4 + "listener" + True + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "use_orthogonal" - False - "use_environment" - False - "pos" - 0, 0, 0 "distance" 4 + "listener" + False + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "use_orthogonal" - False - "use_environment" - False - "pos" - 0, 0, 0 "distance" 4 + "listener" + False + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "use_orthogonal" - False - "use_environment" - False - "pos" - 0, 0, 0 "distance" 4 + "listener" + False + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "use_orthogonal" - False - "use_environment" - False - "pos" - 0, 0, 0 - "viewport_mode" - 1 - "default_light" - True - "show_grid" - True + "zfar" + 500 "znear" 0.1 - "show_origin" - True + + "Script" + + "current" + 0 + "sources" + + "res://player.gd" + "__editor_run_settings__" @@ -806,109 +959,109 @@ "run_mode" 0 - "__editor_plugin_screen__" - "2D" 2 834.664, 1309.6 + "__editor_plugin_screen__" + "2D" "__editor_plugin_states__" - "Script" - - "current" - 0 - "sources" - - "res://enemy.gd" - - "2D" + "ofs" + -227.625, -197.9 "pixel_snap" False "zoom" 1.108033 - "ofs" - -227.625, -197.9 "3D" + "default_light" + True "fov" 45 - "zfar" - 500 + "show_grid" + True + "show_origin" + True + "viewport_mode" + 1 "viewports" "distance" 4 + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "use_orthogonal" - False - "use_environment" - False - "pos" - 0, 0, 0 "distance" 4 + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "use_orthogonal" - False - "use_environment" - False - "pos" - 0, 0, 0 "distance" 4 + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "use_orthogonal" - False - "use_environment" - False - "pos" - 0, 0, 0 "distance" 4 + "pos" + 0, 0, 0 + "use_environment" + False + "use_orthogonal" + False "x_rot" 0 "y_rot" 0 - "use_orthogonal" - False - "use_environment" - False - "pos" - 0, 0, 0 - "viewport_mode" - 1 - "default_light" - True - "show_grid" - True + "zfar" + 500 "znear" 0.1 - "show_origin" - True + + "Script" + + "current" + 0 + "sources" + + "res://enemy.gd" + "__editor_run_settings__" @@ -918,8 +1071,6 @@ "run_mode" 0 - "__editor_plugin_screen__" - "2D" 707.665, 1225.05 1125.21, 1053.06 @@ -933,55 +1084,57 @@ 2406.63, 815.115 + "__editor_plugin_screen__" + "2D" "__editor_plugin_states__" - "Script" - - "current" - 0 - "sources" - - "res://moving_platform.gd" - "res://enemy.gd" - "res://player.gd" - "res://coin.gd" - - "2D" - "zoom" - 1 "ofs" -5, -25 + "zoom" + 1 "3D" - "zfar" - 500 "fov" 45 - "window_mode" - 0 "window_0" - "distance" - 4 - "x_rot" - 0.337 "default_light" True - "y_rot" - -0.575 + "distance" + 4 + "pos" + 0, 0, 0 "show_grid" True "show_origin" True - "pos" - 0, 0, 0 + "x_rot" + 0.337 + "y_rot" + -0.575 + "window_mode" + 0 + "zfar" + 500 "znear" 0.1 + "Script" + + "current" + 0 + "sources" + + "res://moving_platform.gd" + "res://enemy.gd" + "res://player.gd" + "res://coin.gd" + + "__editor_run_settings__" @@ -990,8 +1143,6 @@ "run_mode" 0 - "__editor_plugin_screen__" - "2D" 12 -202 @@ -1002,10 +1153,8 @@ "This is a simple demo on how to make a platformer game with Godot."This version uses physics and the 2D physics engine for motion and collision.""The demo also shows the benefits of using the scene system, where coins,"enemies and the player are edited separatedly and instanced in the stage.""To edit the base tiles for the tileset, open the tileset_edit.xml file and follow "instructions."" -1 - "nodes" - -1, -1, 1, 0, -1, 2, 2, 0, 3, 1, 0, 0, 0, 5, 4, -1, 24, 2, 0, 6, 2, 7, 3, 8, 3, 9, 4, 10, 5, 11, 6, 12, 7, 13, 8, 14, 2, 15, 8, 16, 9, 17, 10, 18, 11, 19, 12, 20, 13, 21, 8, 22, 14, 23, 14, 24, 3, 25, 6, 26, 4, 27, 15, 3, 16, 0, 0, 0, 1, 28, -1, 2, 2, 0, 3, 17, 0, 2, 0, 30, 29, 18, 3, 2, 0, 10, 19, 3, 20, 0, 2, 0, 30, 31, 18, 3, 2, 0, 10, 21, 3, 20, 0, 2, 0, 30, 32, 18, 3, 2, 0, 10, 22, 3, 20, 0, 2, 0, 30, 33, 18, 3, 2, 0, 10, 23, 3, 20, 0, 2, 0, 30, 34, 18, 3, 2, 0, 10, 24, 3, 20, 0, 2, 0, 30, 35, 18, 3, 2, 0, 10, 25, 3, 20, 0, 2, 0, 30, 36, 18, 3, 2, 0, 10, 26, 3, 20, 0, 2, 0, 30, 37, 18, 3, 2, 0, 10, 27, 3, 20, 0, 2, 0, 30, 38, 18, 3, 2, 0, 10, 28, 3, 20, 0, 2, 0, 30, 39, 18, 3, 2, 0, 10, 29, 3, 20, 0, 2, 0, 30, 40, 18, 3, 2, 0, 10, 30, 3, 20, 0, 2, 0, 30, 41, 18, 3, 2, 0, 10, 31, 3, 20, 0, 2, 0, 30, 42, 18, 3, 2, 0, 10, 32, 3, 20, 0, 2, 0, 30, 43, 18, 3, 2, 0, 10, 33, 3, 20, 0, 2, 0, 30, 44, 18, 3, 2, 0, 10, 34, 3, 20, 0, 2, 0, 30, 45, 18, 3, 2, 0, 10, 35, 3, 20, 0, 2, 0, 30, 46, 18, 3, 2, 0, 10, 36, 3, 20, 0, 2, 0, 30, 47, 18, 3, 2, 0, 10, 37, 3, 20, 0, 2, 0, 30, 48, 18, 3, 2, 0, 10, 38, 3, 20, 0, 2, 0, 30, 49, 18, 3, 2, 0, 10, 39, 3, 20, 0, 2, 0, 30, 50, 18, 3, 2, 0, 10, 40, 3, 20, 0, 2, 0, 30, 51, 18, 3, 2, 0, 10, 41, 3, 20, 0, 2, 0, 30, 52, 18, 3, 2, 0, 10, 42, 3, 20, 0, 2, 0, 30, 53, 18, 3, 2, 0, 10, 43, 3, 20, 0, 2, 0, 30, 54, 18, 3, 2, 0, 10, 44, 3, 20, 0, 2, 0, 30, 55, 18, 3, 2, 0, 10, 45, 3, 20, 0, 2, 0, 30, 56, 18, 3, 2, 0, 10, 46, 3, 20, 0, 2, 0, 30, 57, 18, 3, 2, 0, 10, 47, 3, 20, 0, 2, 0, 30, 58, 18, 3, 2, 0, 10, 48, 3, 20, 0, 2, 0, 30, 59, 18, 3, 2, 0, 10, 49, 3, 20, 0, 2, 0, 30, 60, 18, 3, 2, 0, 10, 50, 3, 20, 0, 2, 0, 30, 61, 18, 3, 2, 0, 10, 51, 3, 20, 0, 2, 0, 30, 62, 18, 3, 2, 0, 10, 52, 3, 20, 0, 2, 0, 30, 63, 18, 3, 2, 0, 10, 53, 3, 20, 0, 2, 0, 30, 64, 18, 3, 2, 0, 10, 54, 3, 20, 0, 2, 0, 30, 65, 18, 3, 2, 0, 10, 55, 3, 20, 0, 2, 0, 30, 66, 18, 3, 2, 0, 10, 56, 3, 20, 0, 2, 0, 30, 67, 18, 3, 2, 0, 10, 57, 3, 20, 0, 2, 0, 30, 68, 18, 3, 2, 0, 10, 58, 3, 20, 0, 2, 0, 30, 69, 18, 3, 2, 0, 10, 59, 3, 20, 0, 2, 0, 30, 70, 18, 3, 2, 0, 10, 60, 3, 20, 0, 2, 0, 30, 71, 18, 3, 2, 0, 10, 61, 3, 20, 0, 0, 0, 73, 72, 62, 3, 2, 0, 10, 63, 3, 64, 0, 0, 0, 1, 74, -1, 1, 2, 0, 0, 46, 0, 76, 75, 65, 5, 2, 0, 10, 66, 3, 67, 77, 68, 78, 69, 0, 46, 0, 76, 79, 65, 5, 2, 0, 10, 70, 3, 67, 77, 71, 78, 72, 0, 46, 0, 76, 80, 65, 5, 2, 0, 10, 73, 3, 67, 77, 74, 78, 72, 0, 46, 0, 76, 81, 75, 3, 2, 0, 10, 76, 3, 77, 0, 0, 0, 83, 82, -1, 7, 2, 0, 84, 78, 85, 14, 86, 2, 87, 79, 88, 2, 89, 14, 0, 0, 0, 1, 90, -1, 1, 2, 0, 0, 52, 0, 73, 91, 80, 3, 2, 0, 10, 81, 3, 82, 0, 52, 0, 73, 92, 80, 3, 2, 0, 10, 83, 3, 82, 0, 52, 0, 73, 93, 80, 3, 2, 0, 10, 84, 3, 82, 0, 52, 0, 73, 94, 80, 3, 2, 0, 10, 85, 3, 82, 0, 52, 0, 73, 95, 80, 3, 2, 0, 10, 86, 3, 82, 0, 52, 0, 73, 96, 80, 3, 2, 0, 10, 87, 3, 82, 0, 52, 0, 73, 97, 80, 3, 2, 0, 10, 88, 3, 82, 0, 52, 0, 73, 98, 80, 3, 2, 0, 10, 89, 3, 82, 0, 52, 0, 73, 99, 80, 3, 2, 0, 10, 90, 3, 82, 0, 52, 0, 73, 100, 80, 3, 2, 0, 10, 91, 3, 82, 0, 52, 0, 73, 101, 80, 3, 2, 0, 10, 92, 3, 82, 0, 0, 0, 103, 102, 93, 2, 2, 0, 3, 94, 0, 0, 0, 104, 104, -1, 30, 2, 0, 6, 2, 7, 3, 8, 3, 9, 4, 105, 95, 106, 96, 107, 97, 108, 98, 109, 0, 110, 0, 111, 0, 112, 0, 113, 2, 114, 2, 115, 13, 116, 3, 117, 6, 118, 99, 119, 3, 120, 100, 121, 6, 122, 14, 123, 14, 124, 101, 125, 8, 126, 8, 127, 2, 128, 14, 129, 102, 0 - "conns" - + "version" + 1 diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp index 464b818384..0ba661b4c4 100644 --- a/servers/physics_2d/body_2d_sw.cpp +++ b/servers/physics_2d/body_2d_sw.cpp @@ -657,6 +657,7 @@ Body2DSW::Body2DSW() : CollisionObject2DSW(TYPE_BODY), active_list(this), inerti area_linear_damp=0; contact_count=0; gravity_scale=1.0; + using_one_way_cache=false; one_way_collision_max_depth=0.1; still_time=0; diff --git a/servers/physics_2d/body_2d_sw.h b/servers/physics_2d/body_2d_sw.h index ca4d80a15b..e34686f3ac 100644 --- a/servers/physics_2d/body_2d_sw.h +++ b/servers/physics_2d/body_2d_sw.h @@ -81,6 +81,7 @@ class Body2DSW : public CollisionObject2DSW { bool active; bool can_sleep; bool first_time_kinematic; + bool using_one_way_cache; void _update_inertia(); virtual void _shapes_changed(); Matrix32 new_transform; @@ -229,12 +230,17 @@ public: _FORCE_INLINE_ void set_continuous_collision_detection_mode(Physics2DServer::CCDMode p_mode) { continuous_cd_mode=p_mode; } _FORCE_INLINE_ Physics2DServer::CCDMode get_continuous_collision_detection_mode() const { return continuous_cd_mode; } - void set_one_way_collision_direction(const Vector2& p_dir) { one_way_collision_direction=p_dir; } + void set_one_way_collision_direction(const Vector2& p_dir) { + one_way_collision_direction=p_dir; + using_one_way_cache=one_way_collision_direction!=Vector2(); + } Vector2 get_one_way_collision_direction() const { return one_way_collision_direction; } void set_one_way_collision_max_depth(float p_depth) { one_way_collision_max_depth=p_depth; } float get_one_way_collision_max_depth() const { return one_way_collision_max_depth; } + _FORCE_INLINE_ bool is_using_one_way_collision() const { return using_one_way_cache; } + void set_space(Space2DSW *p_space); void update_inertias(); diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp index 8913e396d2..e8d37d346a 100644 --- a/servers/physics_2d/body_pair_2d_sw.cpp +++ b/servers/physics_2d/body_pair_2d_sw.cpp @@ -265,6 +265,8 @@ bool BodyPair2DSW::setup(float p_step) { } //faster to set than to check.. + bool prev_collided=collided; + collided = CollisionSolver2DSW::solve(shape_A_ptr,xform_A,motion_A,shape_B_ptr,xform_B,motion_B,_add_contact,this,&sep_axis); if (!collided) { @@ -285,6 +287,57 @@ bool BodyPair2DSW::setup(float p_step) { } + if (!prev_collided) { + + if (A->is_using_one_way_collision()) { + Vector2 direction = A->get_one_way_collision_direction(); + bool valid=false; + for(int i=0;iget_linear_velocity().dot(direction)<0) + continue; + + if (!c.reused) { + continue; + } + + valid=true; + } + + if (!valid) { + collided=false; + return false; + } + } + + if (B->is_using_one_way_collision()) { + Vector2 direction = B->get_one_way_collision_direction(); + bool valid=false; + for(int i=0;iget_linear_velocity().dot(direction)<0) + continue; + + if (!c.reused) { + continue; + } + + valid=true; + } + if (!valid) { + collided=false; + return false; + } + } + } + real_t max_penetration = space->get_contact_max_allowed_penetration(); float bias = 0.3f; -- cgit v1.2.3 From 2a4da03f103448a69c48ee66e415f8dd2d617f58 Mon Sep 17 00:00:00 2001 From: Antony Jones Date: Sun, 3 May 2015 15:18:56 -0600 Subject: Added Visual Studio project generation. Use "vsproj=yes" in command line. This does not set up NMAKE properly. --- SConstruct | 46 ++++++++++++ drivers/SCsub | 185 +++++++++++++++++++++++++------------------------ platform/windows/SCsub | 6 ++ 3 files changed, 146 insertions(+), 91 deletions(-) diff --git a/SConstruct b/SConstruct index 537bb0e395..11b35e0b4b 100644 --- a/SConstruct +++ b/SConstruct @@ -123,6 +123,7 @@ opts.Add('disable_3d', 'Disable 3D nodes for smaller executable (yes/no)', "no") opts.Add('disable_advanced_gui', 'Disable advance 3D gui nodes and behaviors (yes/no)', "no") opts.Add('colored', 'Enable colored output for the compilation (yes/no)', 'no') opts.Add('extra_suffix', 'Custom extra suffix added to the base filename of all generated binary files.', '') +opts.Add('vsproj', 'Generate Visual Studio Project. (yes/no)', 'no') # add platform specific options @@ -177,6 +178,25 @@ if selected_platform in platform_list: else: env = env_base.Clone() + if env['vsproj']=="yes": + env.vs_incs = [] + env.vs_srcs = [] + + def AddToVSProject( sources ): + for x in sources: + if type(x) == type(""): + fname = env.File(x).path + else: + fname = env.File(x)[0].path + pieces = fname.split(".") + if len(pieces)>0: + basename = pieces[0] + basename = basename.replace('\\\\','/') + env.vs_srcs = env.vs_srcs + [basename + ".cpp"] + env.vs_incs = env.vs_incs + [basename + ".h"] + #print basename + env.AddToVSProject = AddToVSProject + env.extra_suffix="" if env["extra_suffix"] != '' : @@ -330,6 +350,32 @@ if selected_platform in platform_list: SConscript("main/SCsub") SConscript("platform/"+selected_platform+"/SCsub"); # build selected platform + + # Microsoft Visual Studio Project Generation + if (env['vsproj'])=="yes": + + AddToVSProject(env.core_sources) + AddToVSProject(env.main_sources) + AddToVSProject(env.modules_sources) + AddToVSProject(env.scene_sources) + AddToVSProject(env.servers_sources) + AddToVSProject(env.tool_sources) + + debug_variants = ['Debug|Win32']+['Debug|x64'] + release_variants = ['Release|Win32']+['Release|x64'] + release_debug_variants = ['Release_Debug|Win32']+['Release_Debug|x64'] + variants = debug_variants + release_variants + release_debug_variants + debug_targets = ['Debug']+['Debug'] + release_targets = ['Release']+['Release'] + release_debug_targets = ['ReleaseDebug']+['ReleaseDebug'] + targets = debug_targets + release_targets + release_debug_targets + msvproj = env.MSVSProject(target = ['#godot' + env['MSVSPROJECTSUFFIX'] ], + incs = env.vs_incs, + srcs = env.vs_srcs, + runfile = targets, + buildtarget = targets, + auto_build_solution=1, + variant = variants) else: diff --git a/drivers/SCsub b/drivers/SCsub index a1a2191cbc..6ab0973625 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -1,91 +1,94 @@ -Import('env') - -env.drivers_sources=[] -#env.add_source_files(env.drivers_sources,"*.cpp") -env.Append(CPPPATH=["vorbis"]) -Export('env') - -SConscript('unix/SCsub'); -SConscript('alsa/SCsub'); -SConscript('pulseaudio/SCsub'); -SConscript('windows/SCsub'); -SConscript('gles2/SCsub'); -SConscript('gl_context/SCsub'); -SConscript('openssl/SCsub'); - -if (env["png"]=="yes"): - SConscript("png/SCsub"); -if (env["jpg"]=="yes"): - SConscript("jpg/SCsub"); -if (env["webp"]=="yes"): - SConscript("webp/SCsub"); -SConscript("dds/SCsub"); -SConscript("pvr/SCsub"); -SConscript("etc1/SCsub") -if (env["builtin_zlib"]=="yes"): - SConscript("builtin_zlib/SCsub"); -if (env["openssl"]=="builtin"): - SConscript("builtin_openssl2/SCsub"); - -SConscript("rtaudio/SCsub"); -SConscript("nedmalloc/SCsub"); -SConscript("trex/SCsub"); -SConscript("chibi/SCsub"); -if (env["vorbis"]=="yes" or env["speex"]=="yes" or env["theora"]=="yes"): - SConscript("ogg/SCsub"); -if (env["vorbis"]=="yes"): - SConscript("vorbis/SCsub"); -if (env["tools"]=="yes"): - SConscript("convex_decomp/SCsub"); - -if env["theora"]=="yes": - SConscript("theoraplayer/SCsub") -if (env["theora"]=="yes"): - SConscript("theora/SCsub"); -if (env['speex']=='yes'): - SConscript("speex/SCsub"); -if (env['musepack']=='yes'): - SConscript("mpc/SCsub"); -if (env["squish"]=="yes" and env["tools"]=="yes"): - SConscript("squish/SCsub"); - -num = 0 -cur_base = "" -total = len(env.drivers_sources) -max_src = 64 -list = [] -lib_list = [] - -import string - -for f in env.drivers_sources: - fname = "" - if type(f) == type(""): - fname = env.File(f).path - else: - fname = env.File(f)[0].path - #base = string.join(fname.split("/")[:-1], "/") - fname = fname.replace("\\", "/") - base = string.join(fname.split("/")[:2], "/") - if base != cur_base and len(list) > max_src: - lib = env.Library("drivers"+str(num), list) - lib_list.append(lib) - list = [] - num = num+1 - cur_base = base - list.append(f) - -if len(list) > 0: - lib = env.Library("drivers"+str(num), list) - lib_list.append(lib) - - -drivers_base=[] -env.add_source_files(drivers_base,"*.cpp") -lib_list.insert(0, env.Library("drivers", drivers_base)) - -env.Prepend(LIBS=lib_list) - -#lib = env.Library("drivers",env.drivers_sources) -#env.Prepend(LIBS=[lib]) - +Import('env') + +env.drivers_sources=[] +#env.add_source_files(env.drivers_sources,"*.cpp") +env.Append(CPPPATH=["vorbis"]) +Export('env') + +SConscript('unix/SCsub'); +SConscript('alsa/SCsub'); +SConscript('pulseaudio/SCsub'); +SConscript('windows/SCsub'); +SConscript('gles2/SCsub'); +SConscript('gl_context/SCsub'); +SConscript('openssl/SCsub'); + +if (env["png"]=="yes"): + SConscript("png/SCsub"); +if (env["jpg"]=="yes"): + SConscript("jpg/SCsub"); +if (env["webp"]=="yes"): + SConscript("webp/SCsub"); +SConscript("dds/SCsub"); +SConscript("pvr/SCsub"); +SConscript("etc1/SCsub") +if (env["builtin_zlib"]=="yes"): + SConscript("builtin_zlib/SCsub"); +if (env["openssl"]=="builtin"): + SConscript("builtin_openssl2/SCsub"); + +SConscript("rtaudio/SCsub"); +SConscript("nedmalloc/SCsub"); +SConscript("trex/SCsub"); +SConscript("chibi/SCsub"); +if (env["vorbis"]=="yes" or env["speex"]=="yes" or env["theora"]=="yes"): + SConscript("ogg/SCsub"); +if (env["vorbis"]=="yes"): + SConscript("vorbis/SCsub"); +if (env["tools"]=="yes"): + SConscript("convex_decomp/SCsub"); + +if env["theora"]=="yes": + SConscript("theoraplayer/SCsub") +if (env["theora"]=="yes"): + SConscript("theora/SCsub"); +if (env['speex']=='yes'): + SConscript("speex/SCsub"); +if (env['musepack']=='yes'): + SConscript("mpc/SCsub"); +if (env["squish"]=="yes" and env["tools"]=="yes"): + SConscript("squish/SCsub"); + +num = 0 +cur_base = "" +total = len(env.drivers_sources) +max_src = 64 +list = [] +lib_list = [] + +import string + +if env['vsproj']=="yes": + env.AddToVSProject(env.drivers_sources) + +for f in env.drivers_sources: + fname = "" + if type(f) == type(""): + fname = env.File(f).path + else: + fname = env.File(f)[0].path + #base = string.join(fname.split("/")[:-1], "/") + fname = fname.replace("\\", "/") + base = string.join(fname.split("/")[:2], "/") + if base != cur_base and len(list) > max_src: + lib = env.Library("drivers"+str(num), list) + lib_list.append(lib) + list = [] + num = num+1 + cur_base = base + list.append(f) + +if len(list) > 0: + lib = env.Library("drivers"+str(num), list) + lib_list.append(lib) + + +drivers_base=[] +env.add_source_files(drivers_base,"*.cpp") +lib_list.insert(0, env.Library("drivers", drivers_base)) + +env.Prepend(LIBS=lib_list) + +#lib = env.Library("drivers",env.drivers_sources) +#env.Prepend(LIBS=[lib]) + diff --git a/platform/windows/SCsub b/platform/windows/SCsub index a77428e954..1ad32e7989 100644 --- a/platform/windows/SCsub +++ b/platform/windows/SCsub @@ -12,3 +12,9 @@ common_win=[ ] env.Program('#bin/godot',['godot_win.cpp']+common_win,PROGSUFFIX=env["PROGSUFFIX"]) + +# Microsoft Visual Studio Project Generation +if (env['vsproj'])=="yes": + env.vs_srcs = env.vs_srcs + ["platform/windows/godot_win.cpp"] + for x in common_win: + env.vs_srcs = env.vs_srcs + ["platform/windows/" + x] -- cgit v1.2.3 From 04fb3402c59d6d55435d4eb83eda23707b5ddf9a Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 3 May 2015 20:31:50 -0300 Subject: -Make sure properties are exported the way they should in xml, fixes #1799 --- core/io/resource_format_xml.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index 5922d83907..4771c31de2 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -2563,7 +2563,7 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res List property_list; res->get_property_list(&property_list); - property_list.sort(); +// property_list.sort(); for(List::Element *PE = property_list.front();PE;PE=PE->next()) { -- cgit v1.2.3 From e7aa37fe757151e9e241728c628dde6ccb3e0c07 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 3 May 2015 22:37:10 -0300 Subject: improved kinematic motion, improved demos for kinematic motion --- demos/2d/kinematic_char/circle.png | Bin 0 -> 6107 bytes demos/2d/kinematic_char/colworld.scn | Bin 6596 -> 7459 bytes demos/2d/kinematic_char/long_obstacle.png | Bin 0 -> 534 bytes demos/2d/kinematic_char/player.gd | 33 +++++++++++---- scene/2d/physics_body_2d.cpp | 16 +++++++ scene/2d/physics_body_2d.h | 5 +++ scene/resources/theme.cpp | 18 +++++--- servers/physics_2d/space_2d_sw.cpp | 67 +++++++++++++++++------------- servers/physics_2d/space_2d_sw.h | 2 + 9 files changed, 97 insertions(+), 44 deletions(-) create mode 100644 demos/2d/kinematic_char/circle.png create mode 100644 demos/2d/kinematic_char/long_obstacle.png diff --git a/demos/2d/kinematic_char/circle.png b/demos/2d/kinematic_char/circle.png new file mode 100644 index 0000000000..ddb3ac4b9c Binary files /dev/null and b/demos/2d/kinematic_char/circle.png differ diff --git a/demos/2d/kinematic_char/colworld.scn b/demos/2d/kinematic_char/colworld.scn index 6c73e8b126..e66705368d 100644 Binary files a/demos/2d/kinematic_char/colworld.scn and b/demos/2d/kinematic_char/colworld.scn differ diff --git a/demos/2d/kinematic_char/long_obstacle.png b/demos/2d/kinematic_char/long_obstacle.png new file mode 100644 index 0000000000..88cb22daee Binary files /dev/null and b/demos/2d/kinematic_char/long_obstacle.png differ diff --git a/demos/2d/kinematic_char/player.gd b/demos/2d/kinematic_char/player.gd index e8b3cc8d00..3549ba3830 100644 --- a/demos/2d/kinematic_char/player.gd +++ b/demos/2d/kinematic_char/player.gd @@ -21,6 +21,8 @@ const STOP_FORCE = 1300 const JUMP_SPEED = 200 const JUMP_MAX_AIRBORNE_TIME=0.2 +const SLIDE_STOP_VELOCITY=1.0 #one pixel per second +const SLIDE_STOP_MIN_TRAVEL=1.0 #one pixel var velocity = Vector2() var on_air_time=100 var jumping=false @@ -86,16 +88,29 @@ func _fixed_process(delta): #char is on floor on_air_time=0 floor_velocity=get_collider_velocity() - #velocity.y=0 - #But we were moving and our motion was interrupted, - #so try to complete the motion by "sliding" - #by the normal - motion = n.slide(motion) - velocity = n.slide(velocity) - - #then move again - move(motion) + + if (on_air_time==0 and force.x==0 and get_travel().length() < SLIDE_STOP_MIN_TRAVEL and abs(velocity.x) < SLIDE_STOP_VELOCITY and get_collider_velocity()==Vector2()): + #Since this formula will always slide the character around, + #a special case must be considered to to stop it from moving + #if standing on an inclined floor. Conditions are: + # 1) Standin on floor (on_air_time==0) + # 2) Did not move more than one pixel (get_travel().length() < SLIDE_STOP_MIN_TRAVEL) + # 3) Not moving horizontally (abs(velocity.x) < SLIDE_STOP_VELOCITY) + # 4) Collider is not moving + + revert_motion() + velocity.y=0.0 + + else: + #For every other case of motion,our motion was interrupted. + #Try to complete the motion by "sliding" + #by the normal + + motion = n.slide(motion) + velocity = n.slide(velocity) + #then move again + move(motion) if (floor_velocity!=Vector2()): #if floor moves, move with floor diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 6fb798714f..9fd4a25e7f 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -925,6 +925,19 @@ Variant KinematicBody2D::_get_collider() const { return obj; } +void KinematicBody2D::revert_motion() { + + Matrix32 gt = get_global_transform(); + gt.elements[2]-=travel; + travel=Vector2(); + set_global_transform(gt); + +} + +Vector2 KinematicBody2D::get_travel() const { + + return travel; +} Vector2 KinematicBody2D::move(const Vector2& p_motion) { @@ -942,6 +955,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) { Matrix32 gt = get_global_transform(); gt.elements[2]+=result.motion; set_global_transform(gt); + travel=result.motion; return result.remainder; #else @@ -1173,6 +1187,8 @@ void KinematicBody2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("move_to","position"),&KinematicBody2D::move_to); ObjectTypeDB::bind_method(_MD("test_move","rel_vec"),&KinematicBody2D::test_move); + ObjectTypeDB::bind_method(_MD("get_travel"),&KinematicBody2D::get_travel); + ObjectTypeDB::bind_method(_MD("revert_motion"),&KinematicBody2D::revert_motion); ObjectTypeDB::bind_method(_MD("is_colliding"),&KinematicBody2D::is_colliding); diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 3cb94b95da..b6be07500f 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -280,6 +280,7 @@ class KinematicBody2D : public PhysicsBody2D { ObjectID collider; int collider_shape; Variant collider_metadata; + Vector2 travel; Variant _get_collider() const; @@ -294,6 +295,10 @@ public: bool test_move(const Vector2& p_motion); bool is_colliding() const; + + Vector2 get_travel() const; + void revert_motion(); + Vector2 get_collision_pos() const; Vector2 get_collision_normal() const; Vector2 get_collider_velocity() const; diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 8350bf8cc8..21bdb6c0ab 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -105,6 +105,9 @@ bool Theme::_get(const StringName& p_name,Variant &r_ret) const { void Theme::_get_property_list( List *p_list) const { + + List list; + const StringName *key=NULL; while((key=icon_map.next(key))) { @@ -113,7 +116,7 @@ void Theme::_get_property_list( List *p_list) const { while((key2=icon_map[*key].next(key2))) { - p_list->push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/icons/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "Texture" ) ); + list.push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/icons/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "Texture" ) ); } } @@ -125,7 +128,7 @@ void Theme::_get_property_list( List *p_list) const { while((key2=style_map[*key].next(key2))) { - p_list->push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/styles/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "StyleBox" ) ); + list.push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/styles/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "StyleBox" ) ); } } @@ -138,7 +141,7 @@ void Theme::_get_property_list( List *p_list) const { while((key2=font_map[*key].next(key2))) { - p_list->push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/fonts/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "Font" ) ); + list.push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/fonts/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "Font" ) ); } } @@ -150,7 +153,7 @@ void Theme::_get_property_list( List *p_list) const { while((key2=color_map[*key].next(key2))) { - p_list->push_back( PropertyInfo( Variant::COLOR, String()+*key+"/colors/"+*key2 ) ); + list.push_back( PropertyInfo( Variant::COLOR, String()+*key+"/colors/"+*key2 ) ); } } @@ -162,9 +165,14 @@ void Theme::_get_property_list( List *p_list) const { while((key2=constant_map[*key].next(key2))) { - p_list->push_back( PropertyInfo( Variant::INT, String()+*key+"/constants/"+*key2 ) ); + list.push_back( PropertyInfo( Variant::INT, String()+*key+"/constants/"+*key2 ) ); } } + + list.sort(); + for(List::Element *E=list.front();E;E=E->next()) { + p_list->push_back(E->get()); + } } diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 40e7b19f6f..b38cf0c2df 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -555,38 +555,10 @@ Physics2DDirectSpaceStateSW::Physics2DDirectSpaceStateSW() { +int Space2DSW::_cull_aabb_for_body(Body2DSW *p_body,const Rect2& p_aabb) { -bool Space2DSW::test_body_motion(Body2DSW *p_body,const Vector2&p_motion,float p_margin,Physics2DServer::MotionResult *r_result) { - - //give me back regular physics engine logic - //this is madness - //and most people using this function will think - //what it does is simpler than using physics - //this took about a week to get right.. - //but is it right? who knows at this point.. - - Rect2 body_aabb; - - for(int i=0;iget_shape_count();i++) { - - if (i==0) - body_aabb=p_body->get_shape_aabb(i); - else - body_aabb=body_aabb.merge(p_body->get_shape_aabb(i)); - } - - body_aabb=body_aabb.grow(p_margin); - - { - //add motion - Rect2 motion_aabb=body_aabb; - motion_aabb.pos+=p_motion; - body_aabb=body_aabb.merge(motion_aabb); - } - - - int amount = broadphase->cull_aabb(body_aabb,intersection_query_results,INTERSECTION_QUERY_MAX,intersection_query_subindex_results); + int amount = broadphase->cull_aabb(p_aabb,intersection_query_results,INTERSECTION_QUERY_MAX,intersection_query_subindex_results); for(int i=0;iget_shape_count();i++) { + + if (i==0) + body_aabb=p_body->get_shape_aabb(i); + else + body_aabb=body_aabb.merge(p_body->get_shape_aabb(i)); + } + + body_aabb=body_aabb.grow(p_margin); + + Matrix32 body_transform = p_body->get_transform(); { @@ -642,6 +639,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body,const Vector2&p_motion,float p bool collided=false; + int amount = _cull_aabb_for_body(p_body,body_aabb); for(int j=0;jget_shape_count();j++) { if (p_body->is_shape_set_as_trigger(j)) @@ -694,6 +692,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body,const Vector2&p_motion,float p } body_transform.elements[2]+=recover_motion; + body_aabb.pos+=recover_motion; recover_attempts--; @@ -709,7 +708,11 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body,const Vector2&p_motion,float p { // STEP 2 ATTEMPT MOTION + Rect2 motion_aabb=body_aabb; + motion_aabb.pos+=p_motion; + motion_aabb=motion_aabb.merge(body_aabb); + int amount = _cull_aabb_for_body(p_body,motion_aabb); for(int j=0;jget_shape_count();j++) { @@ -847,6 +850,10 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body,const Vector2&p_motion,float p Matrix32 body_shape_xform = ugt * p_body->get_shape_transform(best_shape); Shape2DSW *body_shape = p_body->get_shape(best_shape); + body_aabb.pos+=p_motion*unsafe; + + int amount = _cull_aabb_for_body(p_body,body_aabb); + for(int i=0;i Date: Mon, 4 May 2015 00:53:33 -0300 Subject: added return keyword, fixes #1797 --- core/variant.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/variant.cpp b/core/variant.cpp index fe6a6b3e4f..5e2ab962a6 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -532,7 +532,7 @@ bool Variant::is_zero() const { } break; case QUAT: { - *reinterpret_cast(_data._mem)==Quat(); + return *reinterpret_cast(_data._mem)==Quat(); } break; case MATRIX3: { -- cgit v1.2.3 From 9b01f5954afbfa61169a7afd2c3d329e7a2882de Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 4 May 2015 00:55:21 -0300 Subject: solve invalid pointer, fixes #1793 --- core/io/resource_format_xml.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index 4771c31de2..9de33e7ef3 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -309,6 +309,7 @@ Error ResourceInteractiveLoaderXML::_parse_array_element(Vector &buff,bool buff_max++; buff.resize(buff_max); + buffptr=buff.ptr(); } -- cgit v1.2.3 From a76709d24038442880f3174e15e84d5317e61d9f Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 4 May 2015 10:17:24 -0300 Subject: -vec3 uniforms should now work, fixes #1773 --- core/io/resource_loader.cpp | 44 ++++++++++++++++++++++++++++++++------- demos/2d/kinematic_char/player.gd | 7 ++++++- demos/2d/platformer/stage.xml | 16 ++++++-------- scene/resources/shader_graph.cpp | 2 +- 4 files changed, 49 insertions(+), 20 deletions(-) diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 7e441cea1f..03b6c9759b 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -117,6 +117,7 @@ Ref ResourceFormatLoader::load_interactive(const Stri RES ResourceFormatLoader::load(const String &p_path,const String& p_original_path) { + String path=p_path; //or this must be implemented Ref ril = load_interactive(p_path); @@ -150,9 +151,13 @@ void ResourceFormatLoader::get_dependencies(const String& p_path,List *p RES ResourceLoader::load(const String &p_path,const String& p_type_hint,bool p_no_cache) { - String local_path = Globals::get_singleton()->localize_path(p_path); + String local_path; + if (p_path.is_rel_path()) + local_path="res://"+p_path; + else + local_path = Globals::get_singleton()->localize_path(p_path); - local_path=find_complete_path(p_path,p_type_hint); + local_path=find_complete_path(local_path,p_type_hint); ERR_FAIL_COND_V(local_path=="",RES()); if (!p_no_cache && ResourceCache::has(local_path)) { @@ -209,7 +214,11 @@ RES ResourceLoader::load(const String &p_path,const String& p_type_hint,bool p_n Ref ResourceLoader::load_import_metadata(const String &p_path) { - String local_path = Globals::get_singleton()->localize_path(p_path); + String local_path; + if (p_path.is_rel_path()) + local_path="res://"+p_path; + else + local_path = Globals::get_singleton()->localize_path(p_path); String extension=p_path.extension(); bool found=false; @@ -283,9 +292,13 @@ Ref ResourceLoader::load_interactive(const String &p_ - String local_path = Globals::get_singleton()->localize_path(p_path); + String local_path; + if (p_path.is_rel_path()) + local_path="res://"+p_path; + else + local_path = Globals::get_singleton()->localize_path(p_path); - local_path=find_complete_path(p_path,p_type_hint); + local_path=find_complete_path(local_path,p_type_hint); ERR_FAIL_COND_V(local_path=="",Ref()); @@ -340,7 +353,13 @@ void ResourceLoader::add_resource_format_loader(ResourceFormatLoader *p_format_l void ResourceLoader::get_dependencies(const String& p_path,List *p_dependencies) { - String local_path = Globals::get_singleton()->localize_path(p_path); + + String local_path; + if (p_path.is_rel_path()) + local_path="res://"+p_path; + else + local_path = Globals::get_singleton()->localize_path(p_path); + String remapped_path = PathRemap::get_singleton()->get_remap(local_path); String extension=remapped_path.extension(); @@ -359,7 +378,11 @@ void ResourceLoader::get_dependencies(const String& p_path,List *p_depen String ResourceLoader::guess_full_filename(const String &p_path,const String& p_type) { - String local_path = Globals::get_singleton()->localize_path(p_path); + String local_path; + if (p_path.is_rel_path()) + local_path="res://"+p_path; + else + local_path = Globals::get_singleton()->localize_path(p_path); return find_complete_path(local_path,p_type); @@ -367,7 +390,12 @@ String ResourceLoader::guess_full_filename(const String &p_path,const String& p_ String ResourceLoader::get_resource_type(const String &p_path) { - String local_path = Globals::get_singleton()->localize_path(p_path); + String local_path; + if (p_path.is_rel_path()) + local_path="res://"+p_path; + else + local_path = Globals::get_singleton()->localize_path(p_path); + String remapped_path = PathRemap::get_singleton()->get_remap(local_path); String extension=remapped_path.extension(); diff --git a/demos/2d/kinematic_char/player.gd b/demos/2d/kinematic_char/player.gd index 3549ba3830..ddc0271de0 100644 --- a/demos/2d/kinematic_char/player.gd +++ b/demos/2d/kinematic_char/player.gd @@ -23,6 +23,7 @@ const JUMP_MAX_AIRBORNE_TIME=0.2 const SLIDE_STOP_VELOCITY=1.0 #one pixel per second const SLIDE_STOP_MIN_TRAVEL=1.0 #one pixel + var velocity = Vector2() var on_air_time=100 var jumping=false @@ -94,7 +95,7 @@ func _fixed_process(delta): #Since this formula will always slide the character around, #a special case must be considered to to stop it from moving #if standing on an inclined floor. Conditions are: - # 1) Standin on floor (on_air_time==0) + # 1) Standing on floor (on_air_time==0) # 2) Did not move more than one pixel (get_travel().length() < SLIDE_STOP_MIN_TRAVEL) # 3) Not moving horizontally (abs(velocity.x) < SLIDE_STOP_VELOCITY) # 4) Collider is not moving @@ -117,9 +118,13 @@ func _fixed_process(delta): move(floor_velocity*delta) if (jumping and velocity.y>0): + #if falling, no longer jumping jumping=false if (on_air_time "node_count" 67 "nodes" - -1, -1, 1, 0, -1, 2, 2, 0, 3, 1, 0, 0, 0, 5, 4, -1, 25, 2, 0, 6, 2, 7, 3, 8, 3, 9, 4, 10, 5, 11, 6, 12, 7, 13, 8, 14, 2, 15, 8, 16, 9, 17, 10, 18, 11, 19, 12, 20, 13, 21, 8, 22, 14, 23, 14, 24, 3, 25, 6, 26, 4, 27, 4, 28, 15, 3, 16, 0, 0, 0, 1, 29, -1, 2, 2, 0, 3, 17, 0, 2, 0, 31, 30, 18, 3, 2, 0, 10, 19, 3, 20, 0, 2, 0, 31, 32, 18, 3, 2, 0, 10, 21, 3, 20, 0, 2, 0, 31, 33, 18, 3, 2, 0, 10, 22, 3, 20, 0, 2, 0, 31, 34, 18, 3, 2, 0, 10, 23, 3, 20, 0, 2, 0, 31, 35, 18, 3, 2, 0, 10, 24, 3, 20, 0, 2, 0, 31, 36, 18, 3, 2, 0, 10, 25, 3, 20, 0, 2, 0, 31, 37, 18, 3, 2, 0, 10, 26, 3, 20, 0, 2, 0, 31, 38, 18, 3, 2, 0, 10, 27, 3, 20, 0, 2, 0, 31, 39, 18, 3, 2, 0, 10, 28, 3, 20, 0, 2, 0, 31, 40, 18, 3, 2, 0, 10, 29, 3, 20, 0, 2, 0, 31, 41, 18, 3, 2, 0, 10, 30, 3, 20, 0, 2, 0, 31, 42, 18, 3, 2, 0, 10, 31, 3, 20, 0, 2, 0, 31, 43, 18, 3, 2, 0, 10, 32, 3, 20, 0, 2, 0, 31, 44, 18, 3, 2, 0, 10, 33, 3, 20, 0, 2, 0, 31, 45, 18, 3, 2, 0, 10, 34, 3, 20, 0, 2, 0, 31, 46, 18, 3, 2, 0, 10, 35, 3, 20, 0, 2, 0, 31, 47, 18, 3, 2, 0, 10, 36, 3, 20, 0, 2, 0, 31, 48, 18, 3, 2, 0, 10, 37, 3, 20, 0, 2, 0, 31, 49, 18, 3, 2, 0, 10, 38, 3, 20, 0, 2, 0, 31, 50, 18, 3, 2, 0, 10, 39, 3, 20, 0, 2, 0, 31, 51, 18, 3, 2, 0, 10, 40, 3, 20, 0, 2, 0, 31, 52, 18, 3, 2, 0, 10, 41, 3, 20, 0, 2, 0, 31, 53, 18, 3, 2, 0, 10, 42, 3, 20, 0, 2, 0, 31, 54, 18, 3, 2, 0, 10, 43, 3, 20, 0, 2, 0, 31, 55, 18, 3, 2, 0, 10, 44, 3, 20, 0, 2, 0, 31, 56, 18, 3, 2, 0, 10, 45, 3, 20, 0, 2, 0, 31, 57, 18, 3, 2, 0, 10, 46, 3, 20, 0, 2, 0, 31, 58, 18, 3, 2, 0, 10, 47, 3, 20, 0, 2, 0, 31, 59, 18, 3, 2, 0, 10, 48, 3, 20, 0, 2, 0, 31, 60, 18, 3, 2, 0, 10, 49, 3, 20, 0, 2, 0, 31, 61, 18, 3, 2, 0, 10, 50, 3, 20, 0, 2, 0, 31, 62, 18, 3, 2, 0, 10, 51, 3, 20, 0, 2, 0, 31, 63, 18, 3, 2, 0, 10, 52, 3, 20, 0, 2, 0, 31, 64, 18, 3, 2, 0, 10, 53, 3, 20, 0, 2, 0, 31, 65, 18, 3, 2, 0, 10, 54, 3, 20, 0, 2, 0, 31, 66, 18, 3, 2, 0, 10, 55, 3, 20, 0, 2, 0, 31, 67, 18, 3, 2, 0, 10, 56, 3, 20, 0, 2, 0, 31, 68, 18, 3, 2, 0, 10, 57, 3, 20, 0, 2, 0, 31, 69, 18, 3, 2, 0, 10, 58, 3, 20, 0, 2, 0, 31, 70, 18, 3, 2, 0, 10, 59, 3, 20, 0, 2, 0, 31, 71, 18, 3, 2, 0, 10, 60, 3, 20, 0, 2, 0, 31, 72, 18, 3, 2, 0, 10, 61, 3, 20, 0, 0, 0, 1, 73, -1, 1, 2, 0, 0, 45, 0, 75, 74, 62, 5, 2, 0, 10, 63, 3, 64, 76, 65, 77, 66, 0, 45, 0, 75, 78, 62, 5, 2, 0, 10, 67, 3, 64, 76, 68, 77, 69, 0, 45, 0, 75, 79, 62, 5, 2, 0, 10, 70, 3, 64, 76, 71, 77, 69, 0, 45, 0, 75, 80, 72, 3, 2, 0, 10, 73, 3, 74, 0, 45, 0, 82, 81, 75, 3, 2, 0, 10, 76, 3, 77, 0, 0, 0, 84, 83, 78, 3, 2, 0, 10, 79, 3, 80, 0, 0, 0, 86, 85, -1, 7, 2, 0, 87, 81, 88, 14, 89, 2, 90, 82, 91, 2, 92, 14, 0, 0, 0, 1, 93, -1, 1, 2, 0, 0, 53, 0, 84, 94, 83, 3, 2, 0, 10, 84, 3, 85, 0, 53, 0, 84, 95, 83, 3, 2, 0, 10, 86, 3, 85, 0, 53, 0, 84, 96, 83, 3, 2, 0, 10, 87, 3, 85, 0, 53, 0, 84, 97, 83, 3, 2, 0, 10, 88, 3, 85, 0, 53, 0, 84, 98, 83, 3, 2, 0, 10, 89, 3, 85, 0, 53, 0, 84, 99, 83, 3, 2, 0, 10, 90, 3, 85, 0, 53, 0, 84, 100, 83, 3, 2, 0, 10, 91, 3, 85, 0, 53, 0, 84, 101, 83, 3, 2, 0, 10, 92, 3, 85, 0, 53, 0, 84, 102, 83, 3, 2, 0, 10, 93, 3, 85, 0, 53, 0, 84, 103, 83, 3, 2, 0, 10, 94, 3, 85, 0, 53, 0, 84, 104, 83, 3, 2, 0, 10, 95, 3, 85, 0, 0, 0, 106, 105, 96, 2, 2, 0, 3, 97, 0, 0, 0, 107, 107, -1, 30, 2, 0, 6, 2, 7, 3, 8, 3, 9, 4, 108, 98, 109, 99, 110, 100, 111, 101, 112, 0, 113, 0, 114, 0, 115, 0, 116, 2, 117, 2, 118, 13, 119, 3, 120, 6, 121, 102, 122, 3, 123, 103, 124, 6, 125, 14, 126, 14, 127, 104, 128, 8, 129, 8, 130, 2, 131, 14, 132, 105, 0 + -1, -1, 1, 0, -1, 2, 2, 0, 3, 1, 0, 0, 0, 5, 4, -1, 25, 2, 0, 6, 2, 7, 3, 8, 3, 9, 4, 10, 5, 11, 6, 12, 7, 13, 8, 14, 2, 15, 8, 16, 9, 17, 10, 18, 11, 19, 12, 20, 13, 21, 8, 22, 14, 23, 14, 24, 3, 25, 6, 26, 4, 27, 4, 28, 15, 3, 16, 0, 0, 0, 1, 29, -1, 1, 2, 0, 0, 2, 0, 31, 30, 17, 3, 2, 0, 10, 18, 3, 19, 0, 2, 0, 31, 32, 17, 3, 2, 0, 10, 20, 3, 19, 0, 2, 0, 31, 33, 17, 3, 2, 0, 10, 21, 3, 19, 0, 2, 0, 31, 34, 17, 3, 2, 0, 10, 22, 3, 19, 0, 2, 0, 31, 35, 17, 3, 2, 0, 10, 23, 3, 19, 0, 2, 0, 31, 36, 17, 3, 2, 0, 10, 24, 3, 19, 0, 2, 0, 31, 37, 17, 3, 2, 0, 10, 25, 3, 19, 0, 2, 0, 31, 38, 17, 3, 2, 0, 10, 26, 3, 19, 0, 2, 0, 31, 39, 17, 3, 2, 0, 10, 27, 3, 19, 0, 2, 0, 31, 40, 17, 3, 2, 0, 10, 28, 3, 19, 0, 2, 0, 31, 41, 17, 3, 2, 0, 10, 29, 3, 19, 0, 2, 0, 31, 42, 17, 3, 2, 0, 10, 30, 3, 19, 0, 2, 0, 31, 43, 17, 3, 2, 0, 10, 31, 3, 19, 0, 2, 0, 31, 44, 17, 3, 2, 0, 10, 32, 3, 19, 0, 2, 0, 31, 45, 17, 3, 2, 0, 10, 33, 3, 19, 0, 2, 0, 31, 46, 17, 3, 2, 0, 10, 34, 3, 19, 0, 2, 0, 31, 47, 17, 3, 2, 0, 10, 35, 3, 19, 0, 2, 0, 31, 48, 17, 3, 2, 0, 10, 36, 3, 19, 0, 2, 0, 31, 49, 17, 3, 2, 0, 10, 37, 3, 19, 0, 2, 0, 31, 50, 17, 3, 2, 0, 10, 38, 3, 19, 0, 2, 0, 31, 51, 17, 3, 2, 0, 10, 39, 3, 19, 0, 2, 0, 31, 52, 17, 3, 2, 0, 10, 40, 3, 19, 0, 2, 0, 31, 53, 17, 3, 2, 0, 10, 41, 3, 19, 0, 2, 0, 31, 54, 17, 3, 2, 0, 10, 42, 3, 19, 0, 2, 0, 31, 55, 17, 3, 2, 0, 10, 43, 3, 19, 0, 2, 0, 31, 56, 17, 3, 2, 0, 10, 44, 3, 19, 0, 2, 0, 31, 57, 17, 3, 2, 0, 10, 45, 3, 19, 0, 2, 0, 31, 58, 17, 3, 2, 0, 10, 46, 3, 19, 0, 2, 0, 31, 59, 17, 3, 2, 0, 10, 47, 3, 19, 0, 2, 0, 31, 60, 17, 3, 2, 0, 10, 48, 3, 19, 0, 2, 0, 31, 61, 17, 3, 2, 0, 10, 49, 3, 19, 0, 2, 0, 31, 62, 17, 3, 2, 0, 10, 50, 3, 19, 0, 2, 0, 31, 63, 17, 3, 2, 0, 10, 51, 3, 19, 0, 2, 0, 31, 64, 17, 3, 2, 0, 10, 52, 3, 19, 0, 2, 0, 31, 65, 17, 3, 2, 0, 10, 53, 3, 19, 0, 2, 0, 31, 66, 17, 3, 2, 0, 10, 54, 3, 19, 0, 2, 0, 31, 67, 17, 3, 2, 0, 10, 55, 3, 19, 0, 2, 0, 31, 68, 17, 3, 2, 0, 10, 56, 3, 19, 0, 2, 0, 31, 69, 17, 3, 2, 0, 10, 57, 3, 19, 0, 2, 0, 31, 70, 17, 3, 2, 0, 10, 58, 3, 19, 0, 2, 0, 31, 71, 17, 3, 2, 0, 10, 59, 3, 19, 0, 2, 0, 31, 72, 17, 3, 2, 0, 10, 60, 3, 19, 0, 0, 0, 1, 73, -1, 1, 2, 0, 0, 45, 0, 75, 74, 61, 5, 2, 0, 10, 62, 3, 63, 76, 64, 77, 65, 0, 45, 0, 75, 78, 61, 5, 2, 0, 10, 66, 3, 63, 76, 67, 77, 68, 0, 45, 0, 75, 79, 61, 5, 2, 0, 10, 69, 3, 63, 76, 70, 77, 68, 0, 45, 0, 75, 80, 71, 3, 2, 0, 10, 72, 3, 73, 0, 45, 0, 82, 81, 74, 3, 2, 0, 10, 75, 3, 76, 0, 0, 0, 84, 83, 77, 3, 2, 0, 10, 78, 3, 79, 0, 0, 0, 86, 85, -1, 7, 2, 0, 87, 80, 88, 14, 89, 2, 90, 81, 91, 2, 92, 14, 0, 0, 0, 1, 93, -1, 1, 2, 0, 0, 53, 0, 84, 94, 82, 3, 2, 0, 10, 83, 3, 84, 0, 53, 0, 84, 95, 82, 3, 2, 0, 10, 85, 3, 84, 0, 53, 0, 84, 96, 82, 3, 2, 0, 10, 86, 3, 84, 0, 53, 0, 84, 97, 82, 3, 2, 0, 10, 87, 3, 84, 0, 53, 0, 84, 98, 82, 3, 2, 0, 10, 88, 3, 84, 0, 53, 0, 84, 99, 82, 3, 2, 0, 10, 89, 3, 84, 0, 53, 0, 84, 100, 82, 3, 2, 0, 10, 90, 3, 84, 0, 53, 0, 84, 101, 82, 3, 2, 0, 10, 91, 3, 84, 0, 53, 0, 84, 102, 82, 3, 2, 0, 10, 92, 3, 84, 0, 53, 0, 84, 103, 82, 3, 2, 0, 10, 93, 3, 84, 0, 53, 0, 84, 104, 82, 3, 2, 0, 10, 94, 3, 84, 0, 0, 0, 106, 105, 95, 2, 2, 0, 3, 96, 0, 0, 0, 107, 107, -1, 30, 2, 0, 6, 2, 7, 3, 8, 3, 9, 4, 108, 97, 109, 98, 110, 99, 111, 100, 112, 0, 113, 0, 114, 0, 115, 0, 116, 2, 117, 2, 118, 13, 119, 3, 120, 6, 121, 101, 122, 3, 123, 102, 124, 6, 125, 14, 126, 14, 127, 103, 128, 8, 129, 8, 130, 2, 131, 14, 132, 104, 0 "variants" - + "" "__editor_plugin_screen__" @@ -283,7 +283,7 @@ "Script" "current" - 2 + 0 "sources" "res://moving_platform.gd" @@ -319,12 +319,8 @@ "_edit_lock_" True - - "_editor_collapsed" - True - - 672, 1120 + 672, 1179 "__editor_plugin_screen__" "2D" @@ -435,8 +431,8 @@ 0 - 704, 1120 - 736, 1120 + 704, 1179 + 736, 1179 1120, 992 1152, 992 1184, 992 diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index 131b0e193f..58a402f006 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -2378,7 +2378,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vectorparam1; Vector3 dv=p_node->param2; - code +="uniform float "+name+"=vec3("+rtos(dv.x)+","+rtos(dv.y)+","+rtos(dv.z)+");\n"; + code +="uniform vec3 "+name+"=vec3("+rtos(dv.x)+","+rtos(dv.y)+","+rtos(dv.z)+");\n"; code += OUTNAME(p_node->id,0)+"="+name+";\n"; }break; case NODE_RGB_INPUT: { -- cgit v1.2.3 From f4caddbc23983a48b14c1801bfb254976546b869 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 4 May 2015 10:53:54 -0300 Subject: -corrected frac() and hyperbolic sin,cos,tan when running on PC (GLSL120), fixes #1775 --- drivers/gles2/shader_compiler_gles2.cpp | 61 ++++++++++++++++++++++++++++++--- drivers/gles2/shader_compiler_gles2.h | 7 ++++ scene/resources/shader_graph.cpp | 2 +- 3 files changed, 65 insertions(+), 5 deletions(-) diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index 10da30acca..157f2e398b 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -431,6 +431,42 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a // code="get_texpos(gl_ProjectionMatrixInverse * texture2D( depth_texture, clamp(("+dump_node_code(onode->arguments[1],p_level)+").xy,vec2(0.0),vec2(1.0))*gl_LightSource[5].specular.zw+gl_LightSource[5].specular.xy)"; //code="(texture2D( screen_texture, ("+dump_node_code(onode->arguments[1],p_level)+").xy).rgb"; break; + } else if (custom_h && callfunc=="cosh_custom") { + + if (!cosh_used) { + global_code= "float cosh_custom(float val)\n"\ + "{\n"\ + " float tmp = exp(val);\n"\ + " float cosH = (tmp + 1.0 / tmp) / 2.0;\n"\ + " return cosH;\n"\ + "}\n"+global_code; + cosh_used=true; + } + code="cosh_custom("+dump_node_code(onode->arguments[1],p_level)+""; + } else if (custom_h && callfunc=="sinh_custom") { + + if (!sinh_used) { + global_code= "float sinh_custom(float val)\n"\ + "{\n"\ + " float tmp = exp(val);\n"\ + " float sinH = (tmp - 1.0 / tmp) / 2.0;\n"\ + " return sinH;\n"\ + "}\n"+global_code; + sinh_used=true; + } + code="sinh_custom("+dump_node_code(onode->arguments[1],p_level)+""; + } else if (custom_h && callfunc=="tanh_custom") { + + if (!tanh_used) { + global_code= "float tanh_custom(float val)\n"\ + "{\n"\ + " float tmp = exp(val);\n"\ + " float tanH = (tmp - 1.0 / tmp) / (tmp + 1.0 / tmp);\n"\ + " return tanH;\n"\ + "}\n"+global_code; + tanh_used=true; + } + code="tanh_custom("+dump_node_code(onode->arguments[1],p_level)+""; } else { @@ -634,6 +670,9 @@ Error ShaderCompilerGLES2::compile(const String& p_code, ShaderLanguage::ShaderT r_flags.use_var2_interp=false; r_flags.uses_normalmap=false; r_flags.uses_normal=false; + sinh_used=false; + tanh_used=false; + cosh_used=false; String error; int errline,errcol; @@ -662,12 +701,18 @@ Error ShaderCompilerGLES2::compile(const String& p_code, ShaderLanguage::ShaderT r_flags.uses_shadow_color=uses_shadow_color; r_code_line=code; r_globals_line=global_code; - return OK; } ShaderCompilerGLES2::ShaderCompilerGLES2() { +#ifdef GLEW_ENABLED + //use custom functions because they are not supported in GLSL120 + custom_h=true; +#else + custom_h=false; +#endif + replace_table["bool"]= "bool"; replace_table["float" ]= "float"; replace_table["vec2" ]= "vec2"; @@ -686,9 +731,17 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { replace_table["acos" ]= "acos"; replace_table["atan" ]= "atan"; replace_table["atan2"]= "atan"; - replace_table["sinh" ]= "sinh"; - replace_table["cosh" ]= "cosh"; - replace_table["tanh" ]= "tanh"; + + if (custom_h) { + replace_table["sinh" ]= "sinh_custom"; + replace_table["cosh" ]= "cosh_custom"; + replace_table["tanh" ]= "tanh_custom"; + } else { + replace_table["sinh" ]= "sinh"; + replace_table["cosh" ]= "cosh"; + replace_table["tanh" ]= "tanh"; + } + replace_table["pow" ]= "pow"; replace_table["exp" ]= "exp"; replace_table["log" ]= "log"; diff --git a/drivers/gles2/shader_compiler_gles2.h b/drivers/gles2/shader_compiler_gles2.h index 6dfc213994..43902a7536 100644 --- a/drivers/gles2/shader_compiler_gles2.h +++ b/drivers/gles2/shader_compiler_gles2.h @@ -56,6 +56,13 @@ private: bool uses_worldvec; bool vertex_code_writes_vertex; bool uses_shadow_color; + + bool sinh_used; + bool tanh_used; + bool cosh_used; + + bool custom_h; + Flags *flags; StringName vname_discard; diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index 58a402f006..24d5978856 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -2160,7 +2160,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector Date: Mon, 4 May 2015 11:17:11 -0300 Subject: -invalidated string -> int automatic conversion, fixes #1788 --- core/variant.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/variant.cpp b/core/variant.cpp index 5e2ab962a6..c06afb2984 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -214,7 +214,7 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) { static const Type valid[]={ INT, REAL, - STRING, + //STRING, NIL, }; @@ -225,7 +225,7 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) { static const Type valid[]={ BOOL, REAL, - STRING, + //STRING, NIL, }; @@ -237,7 +237,7 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) { static const Type valid[]={ BOOL, INT, - STRING, + //STRING, NIL, }; -- cgit v1.2.3 From 7f5b744b92256e42aa3c700ee88d8318732935c6 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 4 May 2015 13:12:05 -0300 Subject: small unicode fixes --- drivers/windows/dir_access_windows.cpp | 4 ++-- platform/windows/os_windows.cpp | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 4c265a1ab2..53dd3f49db 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -197,7 +197,7 @@ Error DirAccessWindows::change_dir(String p_dir) { if (worked) { GetCurrentDirectoryW(2048,real_current_dir_name); - current_dir=real_current_dir_name; // TODO, utf8 parser + current_dir=real_current_dir_name; current_dir=current_dir.replace("\\","/"); } //else { @@ -218,7 +218,7 @@ Error DirAccessWindows::change_dir(String p_dir) { if (worked) { GetCurrentDirectoryA(2048,real_current_dir_name); - current_dir=real_current_dir_name; // TODO, utf8 parser + current_dir=real_current_dir_name; current_dir=current_dir.replace("\\","/"); }// else { diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 414c250bd4..534d62664b 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2110,12 +2110,13 @@ bool OS_Windows::has_environment(const String& p_var) const { String OS_Windows::get_environment(const String& p_var) const { - char* val = getenv(p_var.utf8().get_data()); - if (val) - return val; - + wchar_t wval[0x7Fff]; // MSDN says 32767 char is the maximum + int wlen = GetEnvironmentVariableW(p_var.c_str(),wval,0x7Fff); + if ( wlen > 0 ) { + return wval; + } return ""; -}; +} String OS_Windows::get_stdin_string(bool p_block) { -- cgit v1.2.3 From f3542ff8381fe7e67f39ff004d98c5b40f331fed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20P=C3=A9rez?= Date: Mon, 4 May 2015 19:54:17 +0200 Subject: Wrong use of | instead of || --- scene/gui/text_edit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 1e82432165..a87d8eea5f 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -489,7 +489,7 @@ void TextEdit::_notification(int p_what) { CharType cc = text[i][j]; //ignore any brackets inside a string - if (cc== '"' | cc == '\'') { + if (cc== '"' || cc == '\'') { CharType quotation = cc; do { j++; @@ -560,7 +560,7 @@ void TextEdit::_notification(int p_what) { CharType cc = text[i][j]; //ignore any brackets inside a string - if (cc== '"' | cc == '\'') { + if (cc== '"' || cc == '\'') { CharType quotation = cc; do { j--; -- cgit v1.2.3 From 2a02d3f96f8fa3ed844a9abf58c0bf4d8023ebcc Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 4 May 2015 15:06:41 -0300 Subject: fix font import path on windows, closes #1675 --- core/ustring.cpp | 11 ++++++++--- scene/gui/file_dialog.cpp | 1 - tools/editor/editor_import_export.cpp | 1 + tools/editor/io_plugins/editor_font_import_plugin.cpp | 7 +++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core/ustring.cpp b/core/ustring.cpp index ffd22c1f8f..5df95ac4c2 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3297,8 +3297,11 @@ String String::path_to_file(const String& p_path) const { String src=this->replace("\\","/").get_base_dir(); String dst=p_path.replace("\\","/").get_base_dir(); - - return src.path_to(dst)+p_path.get_file(); + String rel = src.path_to(dst); + if (rel==dst) // failed + return p_path; + else + return rel+p_path.get_file(); } String String::path_to(const String& p_path) const { @@ -3333,7 +3336,9 @@ String String::path_to(const String& p_path) const { String src_begin=src.get_slice("/",0); String dst_begin=dst.get_slice("/",0); - ERR_FAIL_COND_V(src_begin!=dst_begin,p_path); //return dst absolute path + if (src_begin!=dst_begin) + return p_path; //impossible to do this + base=src_begin; src=src.substr(src_begin.length(),src.length()); dst=dst.substr(dst_begin.length(),dst.length()); diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 50ce657d2e..13cf87ac2b 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -92,7 +92,6 @@ void FileDialog::_file_entered(const String& p_file) { } void FileDialog::_save_confirm_pressed() { - String f=dir_access->get_current_dir().plus_file(file->get_text()); emit_signal("file_selected",f); hide(); diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index d76009a72a..4e6435b22e 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -47,6 +47,7 @@ String EditorImportPlugin::validate_source_path(const String& p_path) { String rp = Globals::get_singleton()->get_resource_path(); if (!rp.ends_with("/")) rp+="/"; + return rp.path_to_file(gp); } diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp index b0ff6f6e74..375333ddf6 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -406,7 +406,10 @@ class EditorFontImportDialog : public ConfirmationDialog { imd->set_option(opt,v); } - imd->add_source(EditorImportPlugin::validate_source_path(source->get_line_edit()->get_text())); + String src_path = EditorImportPlugin::validate_source_path(source->get_line_edit()->get_text()); + //print_line("pre src path "+source->get_line_edit()->get_text()); + //print_line("src path "+src_path); + imd->add_source(src_path); imd->set_option("font/size",font_size->get_val()); return imd; @@ -1018,7 +1021,7 @@ Ref EditorFontImportPlugin::generate_font(const Refbitmap.rows; int p = slot->bitmap.pitch; - print_line("W: "+itos(w)+" P: "+itos(slot->bitmap.pitch)); + //print_line("W: "+itos(w)+" P: "+itos(slot->bitmap.pitch)); if (font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD) { -- cgit v1.2.3 From 43c41fc9f9f96a2e30224a2b454af109ce07fbb1 Mon Sep 17 00:00:00 2001 From: yg2f Date: Mon, 4 May 2015 20:26:49 +0200 Subject: fixes issue #1693 winmain and main unicode makes WinMain() and main() accepts unicode characters into arguments --- platform/windows/godot_win.cpp | 107 ++++++++++------------------------------- 1 file changed, 25 insertions(+), 82 deletions(-) diff --git a/platform/windows/godot_win.cpp b/platform/windows/godot_win.cpp index 0e74f63510..81c90d9dd0 100644 --- a/platform/windows/godot_win.cpp +++ b/platform/windows/godot_win.cpp @@ -115,29 +115,24 @@ PCHAR* return argv; } -char* mb_to_utf8(const char* mbs) { - - int wlen = MultiByteToWideChar(CP_ACP,0,mbs,-1,NULL,0); // returns 0 if failed - wchar_t *wbuf = new wchar_t[wlen + 1]; - MultiByteToWideChar(CP_ACP,0,mbs,-1,wbuf,wlen); - wbuf[wlen]=0; - - int ulen = WideCharToMultiByte(CP_UTF8,0,wbuf,-1,NULL,0,NULL,NULL); +char* wc_to_utf8(const wchar_t* wc) { + int ulen = WideCharToMultiByte(CP_UTF8,0,wc,-1,NULL,0,NULL,NULL); char * ubuf = new char[ulen + 1]; - WideCharToMultiByte(CP_UTF8,0,wbuf,-1,ubuf,ulen,NULL,NULL); + WideCharToMultiByte(CP_UTF8,0,wc,-1,ubuf,ulen,NULL,NULL); ubuf[ulen] = 0; return ubuf; } -int main(int argc, char** argv) { +int widechar_main(int argc, wchar_t** argv) { OS_Windows os(NULL); setlocale(LC_CTYPE, ""); char ** argv_utf8 = new char*[argc]; + for(int i=0; i Date: Mon, 4 May 2015 18:30:57 -0300 Subject: -More strict argument type-checking, will make many bugs visible, fixes #1809 -added NOTIFICATION_INSTANCED --- core/method_bind.h | 2 +- core/variant.cpp | 260 ++++++++++++++++++++++++++++++++++++++- core/variant.h | 3 +- demos/2d/platformer/enemy.gd | 2 +- demos/3d/platformer/enemy.gd | 2 +- scene/main/node.h | 1 + scene/resources/packed_scene.cpp | 2 + 7 files changed, 263 insertions(+), 9 deletions(-) diff --git a/core/method_bind.h b/core/method_bind.h index d32050cc5d..49c64bd11c 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -98,7 +98,7 @@ struct VariantCaster {\ #define CHECK_ARG(m_arg)\ if ((m_arg-1)get_type(),argtype)) {\ + if (!Variant::can_convert_strict(p_args[m_arg-1]->get_type(),argtype)) {\ r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;\ r_error.argument=m_arg-1;\ r_error.expected=argtype;\ diff --git a/core/variant.cpp b/core/variant.cpp index c06afb2984..f49b202a5b 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -214,7 +214,7 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) { static const Type valid[]={ INT, REAL, - //STRING, + STRING, NIL, }; @@ -225,7 +225,7 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) { static const Type valid[]={ BOOL, REAL, - //STRING, + STRING, NIL, }; @@ -237,7 +237,7 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) { static const Type valid[]={ BOOL, INT, - //STRING, + STRING, NIL, }; @@ -258,12 +258,12 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) { case MATRIX32: { - static const Type invalid[]={ + static const Type valid[]={ TRANSFORM, NIL }; - invalid_types=invalid; + valid_types=valid; } break; case QUAT: { @@ -299,6 +299,256 @@ bool Variant::can_convert(Variant::Type p_type_from,Variant::Type p_type_to) { } break; + case COLOR: { + + static const Type valid[] = { + //STRING, + //INT, + NIL, + }; + + valid_types = valid; + + } break; + + case _RID: { + + static const Type valid[]={ + OBJECT, + NIL + }; + + valid_types=valid; + } break; + case OBJECT: { + + static const Type valid[]={ + NIL + }; + + valid_types=valid; + } break; + case NODE_PATH: { + + static const Type valid[]={ + STRING, + NIL + }; + + valid_types=valid; + } break; + case ARRAY: { + + + static const Type valid[]={ + RAW_ARRAY, + INT_ARRAY, + STRING_ARRAY, + REAL_ARRAY, + COLOR_ARRAY, + VECTOR2_ARRAY, + VECTOR3_ARRAY, + NIL + }; + + valid_types=valid; + } break; + // arrays + case RAW_ARRAY: { + + static const Type valid[]={ + ARRAY, + NIL + }; + + valid_types=valid; + } break; + case INT_ARRAY: { + + static const Type valid[]={ + ARRAY, + NIL + }; + valid_types=valid; + } break; + case REAL_ARRAY: { + + static const Type valid[]={ + ARRAY, + NIL + }; + + valid_types=valid; + } break; + case STRING_ARRAY: { + + static const Type valid[]={ + ARRAY, + NIL + }; + valid_types=valid; + } break; + case VECTOR2_ARRAY: { + + static const Type valid[]={ + ARRAY, + NIL + }; + valid_types=valid; + + } break; + case VECTOR3_ARRAY: { + + static const Type valid[]={ + ARRAY, + NIL + }; + valid_types=valid; + + } break; + case COLOR_ARRAY: { + + static const Type valid[]={ + ARRAY, + NIL + }; + + valid_types=valid; + + } break; + default: {} + } + + + if (valid_types) { + + int i=0; + while(valid_types[i]!=NIL) { + + if (p_type_from==valid_types[i]) + return true; + i++; + } + } else if (invalid_types) { + + + int i=0; + while(invalid_types[i]!=NIL) { + + if (p_type_from==invalid_types[i]) + return false; + i++; + } + } + + return false; + +} + +bool Variant::can_convert_strict(Variant::Type p_type_from,Variant::Type p_type_to) { + + if (p_type_from==p_type_to) + return true; + if (p_type_to==NIL && p_type_from!=NIL) //nil can convert to anything + return true; + + if (p_type_from == NIL) { + return (p_type_to == OBJECT); + }; + + const Type *valid_types=NULL; + const Type *invalid_types=NULL; + + switch(p_type_to) { + case BOOL: { + + static const Type valid[]={ + //INT, + //REAL, + //STRING, + NIL, + }; + + valid_types=valid; + } break; + case INT: { + + static const Type valid[]={ + //BOOL, + REAL, + //STRING, + NIL, + }; + + valid_types=valid; + + } break; + case REAL: { + + static const Type valid[]={ + //BOOL, + INT, + //STRING, + NIL, + }; + + valid_types=valid; + + } break; + case STRING: { + + + static const Type valid[]={ + NODE_PATH, + NIL + }; + + valid_types=valid; + } break; + case MATRIX32: { + + + static const Type valid[]={ + TRANSFORM, + NIL + }; + + valid_types=valid; + } break; + case QUAT: { + + static const Type valid[]={ + MATRIX3, + NIL + }; + + valid_types=valid; + + } break; + case MATRIX3: { + + static const Type valid[]={ + QUAT, + NIL + }; + + valid_types=valid; + + + } break; + case TRANSFORM: { + + static const Type valid[]={ + MATRIX32, + QUAT, + MATRIX3, + NIL + }; + + valid_types=valid; + + } break; + case COLOR: { static const Type valid[] = { diff --git a/core/variant.h b/core/variant.h index 85c7b92c0d..5f338ef667 100644 --- a/core/variant.h +++ b/core/variant.h @@ -165,7 +165,8 @@ public: _FORCE_INLINE_ Type get_type() const { return type; } static String get_type_name(Variant::Type p_type); - static bool can_convert(Type p_type_from,Type p_type_to); + static bool can_convert(Type p_type_from, Type p_type_to); + static bool can_convert_strict(Type p_type_from, Type p_type_to); diff --git a/demos/2d/platformer/enemy.gd b/demos/2d/platformer/enemy.gd index b4e70477a8..a264cd0cff 100644 --- a/demos/2d/platformer/enemy.gd +++ b/demos/2d/platformer/enemy.gd @@ -56,7 +56,7 @@ func _integrate_forces(s): state=STATE_DYING #lv=s.get_contact_local_normal(i)*400 s.set_angular_velocity(sign(dp.x)*33.0) - set_friction(true) + set_friction(1) cc.disable() get_node("sound").play("hit") diff --git a/demos/3d/platformer/enemy.gd b/demos/3d/platformer/enemy.gd index 1d0e0315d9..cbbb2fe725 100644 --- a/demos/3d/platformer/enemy.gd +++ b/demos/3d/platformer/enemy.gd @@ -45,7 +45,7 @@ func _integrate_forces(state): state.set_angular_velocity( -dp.cross(up).normalized() *33.0) get_node("AnimationPlayer").play("impact") get_node("AnimationPlayer").queue("explode") - set_friction(true) + set_friction(1) cc.disabled=true get_node("sound").play("hit") return diff --git a/scene/main/node.h b/scene/main/node.h index aeada3c5bb..4d0a84d347 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -170,6 +170,7 @@ public: NOTIFICATION_PROCESS = 17, NOTIFICATION_PARENTED=18, NOTIFICATION_UNPARENTED=19, + NOTIFICATION_INSTANCED=20, }; /* NODE/TREE */ diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 9f36510739..a1cb1205e5 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -182,6 +182,8 @@ Node *PackedScene::instance(bool p_gen_edit_state) const { if (get_path()!="" && get_path().find("::")==-1) s->set_filename(get_path()); + + s->notification(Node::NOTIFICATION_INSTANCED); return ret_nodes[0]; } -- cgit v1.2.3 From ba61a1dfd3d89c0c1b2b56ea079f4ad14efb1715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20P=C3=A9rez?= Date: Mon, 4 May 2015 23:57:55 +0200 Subject: Fixes Theora build Changes memcpy() -> copymem() --- drivers/theoraplayer/video_stream_theoraplayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/theoraplayer/video_stream_theoraplayer.cpp b/drivers/theoraplayer/video_stream_theoraplayer.cpp index ecafda9d84..ef1f5651ab 100644 --- a/drivers/theoraplayer/video_stream_theoraplayer.cpp +++ b/drivers/theoraplayer/video_stream_theoraplayer.cpp @@ -388,7 +388,7 @@ void VideoStreamTheoraplayer::pop_frame(Ref p_tex) { { DVector::Write wr = data.write(); uint8_t* ptr = wr.ptr(); - memcpy(ptr, f->getBuffer(), imgsize); + copymem(ptr, f->getBuffer(), imgsize); } /* for (int i=0; i Date: Mon, 4 May 2015 23:32:40 -0300 Subject: Proper support for code editor autosaving (disabled by default) --- tools/editor/editor_settings.cpp | 2 +- tools/editor/plugins/script_editor_plugin.cpp | 40 ++++++++++++++++++++++++++- tools/editor/plugins/script_editor_plugin.h | 4 +++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 52eeb1fefd..9a4505efed 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -408,7 +408,7 @@ void EditorSettings::_load_defaults() { set("text_editor/idle_parse_delay",2); set("text_editor/create_signal_callbacks",true); - set("text_editor/autosave_interval_seconds",60); + set("text_editor/autosave_interval_secs",0); set("text_editor/font",""); hints["text_editor/font"]=PropertyInfo(Variant::STRING,"text_editor/font",PROPERTY_HINT_GLOBAL_FILE,"*.fnt"); set("text_editor/auto_brace_complete", false); diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 7deb856fa6..e6e311cfa1 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -130,6 +130,7 @@ void ScriptEditorQuickOpen::_bind_methods() { ObjectTypeDB::bind_method(_MD("_confirmed"),&ScriptEditorQuickOpen::_confirmed); ObjectTypeDB::bind_method(_MD("_sbox_input"),&ScriptEditorQuickOpen::_sbox_input); + ADD_SIGNAL(MethodInfo("goto_line",PropertyInfo(Variant::INT,"line"))); } @@ -1089,6 +1090,18 @@ void ScriptEditor::_notification(int p_what) { editor->connect("stop_pressed",this,"_editor_stop"); editor->connect("script_add_function_request",this,"_add_callback"); editor->connect("resource_saved",this,"_res_saved_callback"); + autosave_timer->connect("timeout",this,"_autosave_scripts"); + { + float autosave_time = EditorSettings::get_singleton()->get("text_editor/autosave_interval_secs"); + if (autosave_time>0) { + autosave_timer->set_wait_time(autosave_time); + autosave_timer->start(); + } else { + autosave_timer->stop(); + } + } + + EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed"); } @@ -1339,7 +1352,8 @@ void ScriptEditor::_bind_methods() { ObjectTypeDB::bind_method("_breaked",&ScriptEditor::_breaked); ObjectTypeDB::bind_method("_show_debugger",&ScriptEditor::_show_debugger); ObjectTypeDB::bind_method("_get_debug_tooltip",&ScriptEditor::_get_debug_tooltip); - + ObjectTypeDB::bind_method("_autosave_scripts",&ScriptEditor::_autosave_scripts); + ObjectTypeDB::bind_method("_editor_settings_changed",&ScriptEditor::_editor_settings_changed); } @@ -1568,6 +1582,25 @@ void ScriptEditor::_add_callback(Object *p_obj, const String& p_function, const } +void ScriptEditor::_editor_settings_changed() { + + print_line("settings changed"); + float autosave_time = EditorSettings::get_singleton()->get("text_editor/autosave_interval_secs"); + if (autosave_time>0) { + autosave_timer->set_wait_time(autosave_time); + autosave_timer->start(); + } else { + autosave_timer->stop(); + } + +} + +void ScriptEditor::_autosave_scripts() { + + print_line("autosaving"); + save_external_data(); +} + ScriptEditor::ScriptEditor(EditorNode *p_editor) { editor=p_editor; @@ -1718,6 +1751,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { v_split->add_child(debugger); debugger->connect("breaked",this,"_breaked"); + + autosave_timer = memnew( Timer ); + autosave_timer->set_one_shot(false); + add_child(autosave_timer); + // debugger_gui->hide(); } diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h index 7526138112..acfdd1e966 100644 --- a/tools/editor/plugins/script_editor_plugin.h +++ b/tools/editor/plugins/script_editor_plugin.h @@ -154,6 +154,7 @@ class ScriptEditor : public VBoxContainer { MenuButton *window_menu; MenuButton *debug_menu; MenuButton *help_menu; + Timer *autosave_timer; uint64_t idle; TabContainer *tab_container; @@ -195,6 +196,9 @@ class ScriptEditor : public VBoxContainer { void _show_debugger(bool p_show); void _update_window_menu(); + void _editor_settings_changed(); + void _autosave_scripts(); + static ScriptEditor *script_editor; protected: void _notification(int p_what); -- cgit v1.2.3 From 6d0914dfc5d439701d93e42da26d4be95f6eda80 Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Tue, 5 May 2015 11:12:17 +0800 Subject: Spine: add feature to insert/remove interpolates while updating --- scene/animation/tween.cpp | 216 +++++++++++++++++++++++++++++++++++++++++++--- scene/animation/tween.h | 21 +++++ 2 files changed, 226 insertions(+), 11 deletions(-) diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index a7a4129a5f..73d93e50ec 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -29,6 +29,81 @@ #include "tween.h" #include "method_bind_ext.inc" +void Tween::_add_pending_command(StringName p_key + ,const Variant& p_arg1 ,const Variant& p_arg2 ,const Variant& p_arg3 ,const Variant& p_arg4 ,const Variant& p_arg5 + ,const Variant& p_arg6 ,const Variant& p_arg7 ,const Variant& p_arg8 ,const Variant& p_arg9 ,const Variant& p_arg10 +) { + + pending_commands.push_back(PendingCommand()); + PendingCommand& cmd = pending_commands.back()->get(); + + cmd.key = p_key; + int& count = cmd.args; + if(p_arg10.get_type() != Variant::NIL) + count = 10; + else if(p_arg9.get_type() != Variant::NIL) + count = 9; + else if(p_arg8.get_type() != Variant::NIL) + count = 8; + else if(p_arg7.get_type() != Variant::NIL) + count = 7; + else if(p_arg6.get_type() != Variant::NIL) + count = 6; + else if(p_arg5.get_type() != Variant::NIL) + count = 5; + else if(p_arg4.get_type() != Variant::NIL) + count = 4; + else if(p_arg3.get_type() != Variant::NIL) + count = 3; + else if(p_arg2.get_type() != Variant::NIL) + count = 2; + else if(p_arg1.get_type() != Variant::NIL) + count = 1; + if(count > 0) + cmd.arg[0] = p_arg1; + if(count > 1) + cmd.arg[1] = p_arg2; + if(count > 2) + cmd.arg[2] = p_arg3; + if(count > 3) + cmd.arg[3] = p_arg4; + if(count > 4) + cmd.arg[4] = p_arg5; + if(count > 5) + cmd.arg[5] = p_arg6; + if(count > 6) + cmd.arg[6] = p_arg7; + if(count > 7) + cmd.arg[7] = p_arg8; + if(count > 8) + cmd.arg[8] = p_arg9; + if(count > 9) + cmd.arg[9] = p_arg10; +} + +void Tween::_process_pending_commands() { + + for(List::Element *E=pending_commands.front();E;E=E->next()) { + + PendingCommand& cmd = E->get(); + Variant::CallError err; + Variant *arg[10] = { + &cmd.arg[0], + &cmd.arg[1], + &cmd.arg[2], + &cmd.arg[3], + &cmd.arg[4], + &cmd.arg[5], + &cmd.arg[6], + &cmd.arg[7], + &cmd.arg[8], + &cmd.arg[9], + }; + this->call(cmd.key, (const Variant **) arg, cmd.args, err); + } + pending_commands.clear(); +} + bool Tween::_set(const StringName& p_name, const Variant& p_value) { String name=p_name; @@ -456,6 +531,8 @@ bool Tween::_apply_tween_value(InterpolateData& p_data, Variant& value) { void Tween::_tween_process(float p_delta) { + _process_pending_commands(); + if (speed_scale == 0) return; p_delta *= speed_scale; @@ -551,8 +628,12 @@ void Tween::_tween_process(float p_delta) { _apply_tween_value(data, result); - if(data.finish) + if (data.finish) { emit_signal("tween_complete",object,data.key); + // not repeat mode, remove completed action + if (!repeat) + call_deferred("remove", object, data.key); + } } pending_update --; } @@ -734,7 +815,10 @@ bool Tween::resume_all() { bool Tween::remove(Object *p_object, String p_key) { - ERR_FAIL_COND_V(pending_update != 0, false); + if(pending_update != 0) { + call_deferred("remove", p_object, p_key); + return true; + } for(List::Element *E=interpolates.front();E;E=E->next()) { InterpolateData& data = E->get(); @@ -751,7 +835,10 @@ bool Tween::remove(Object *p_object, String p_key) { bool Tween::remove_all() { - ERR_FAIL_COND_V(pending_update != 0, false); + if(pending_update != 0) { + call_deferred("remove_all"); + return true; + } set_active(false); _set_process(false); interpolates.clear(); @@ -940,7 +1027,19 @@ bool Tween::interpolate_property(Object *p_object , EaseType p_ease_type , real_t p_delay ) { - ERR_FAIL_COND_V(pending_update != 0, false); + if(pending_update != 0) { + _add_pending_command("interpolate_property" + , p_object + , p_property + , p_initial_val + , p_final_val + , p_times_in_sec + , p_trans_type + , p_ease_type + , p_delay + ); + return true; + } // convert INT to REAL is better for interpolaters if(p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t(); if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); @@ -987,7 +1086,19 @@ bool Tween::interpolate_method(Object *p_object , EaseType p_ease_type , real_t p_delay ) { - ERR_FAIL_COND_V(pending_update != 0, false); + if(pending_update != 0) { + _add_pending_command("interpolate_method" + , p_object + , p_method + , p_initial_val + , p_final_val + , p_times_in_sec + , p_trans_type + , p_ease_type + , p_delay + ); + return true; + } // convert INT to REAL is better for interpolaters if(p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t(); if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); @@ -999,6 +1110,7 @@ bool Tween::interpolate_method(Object *p_object ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false); ERR_FAIL_COND_V(p_delay < 0, false); + ERR_EXPLAIN("Object has no method named: %s" + p_method); ERR_FAIL_COND_V(!p_object->has_method(p_method), false); InterpolateData data; @@ -1029,10 +1141,23 @@ bool Tween::interpolate_callback(Object *p_object , VARIANT_ARG_DECLARE ) { - ERR_FAIL_COND_V(pending_update != 0, false); + if(pending_update != 0) { + _add_pending_command("interpolate_callback" + , p_object + , p_times_in_sec + , p_callback + , p_arg1 + , p_arg2 + , p_arg3 + , p_arg4 + , p_arg5 + ); + return true; + } ERR_FAIL_COND_V(p_object == NULL, false); ERR_FAIL_COND_V(p_times_in_sec < 0, false); + ERR_EXPLAIN("Object has no callback named: %s" + p_callback); ERR_FAIL_COND_V(!p_object->has_method(p_callback), false); InterpolateData data; @@ -1080,10 +1205,23 @@ bool Tween::interpolate_deferred_callback(Object *p_object , VARIANT_ARG_DECLARE ) { - ERR_FAIL_COND_V(pending_update != 0, false); + if(pending_update != 0) { + _add_pending_command("interpolate_deferred_callback" + , p_object + , p_times_in_sec + , p_callback + , p_arg1 + , p_arg2 + , p_arg3 + , p_arg4 + , p_arg5 + ); + return true; + } ERR_FAIL_COND_V(p_object == NULL, false); ERR_FAIL_COND_V(p_times_in_sec < 0, false); + ERR_EXPLAIN("Object has no callback named: %s" + p_callback); ERR_FAIL_COND_V(!p_object->has_method(p_callback), false); InterpolateData data; @@ -1135,7 +1273,20 @@ bool Tween::follow_property(Object *p_object , EaseType p_ease_type , real_t p_delay ) { - ERR_FAIL_COND_V(pending_update != 0, false); + if(pending_update != 0) { + _add_pending_command("follow_property" + , p_object + , p_property + , p_initial_val + , p_target + , p_target_property + , p_times_in_sec + , p_trans_type + , p_ease_type + , p_delay + ); + return true; + } // convert INT to REAL is better for interpolaters if(p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t(); @@ -1188,7 +1339,20 @@ bool Tween::follow_method(Object *p_object , EaseType p_ease_type , real_t p_delay ) { - ERR_FAIL_COND_V(pending_update != 0, false); + if(pending_update != 0) { + _add_pending_command("follow_method" + , p_object + , p_method + , p_initial_val + , p_target + , p_target_method + , p_times_in_sec + , p_trans_type + , p_ease_type + , p_delay + ); + return true; + } // convert INT to REAL is better for interpolaters if(p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t(); @@ -1199,7 +1363,9 @@ bool Tween::follow_method(Object *p_object ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false); ERR_FAIL_COND_V(p_delay < 0, false); + ERR_EXPLAIN("Object has no method named: %s" + p_method); ERR_FAIL_COND_V(!p_object->has_method(p_method), false); + ERR_EXPLAIN("Target has no method named: %s" + p_target_method); ERR_FAIL_COND_V(!p_target->has_method(p_target_method), false); Variant::CallError error; @@ -1240,7 +1406,20 @@ bool Tween::targeting_property(Object *p_object , EaseType p_ease_type , real_t p_delay ) { - ERR_FAIL_COND_V(pending_update != 0, false); + if(pending_update != 0) { + _add_pending_command("targeting_property" + , p_object + , p_property + , p_initial + , p_initial_property + , p_final_val + , p_times_in_sec + , p_trans_type + , p_ease_type + , p_delay + ); + return true; + } // convert INT to REAL is better for interpolaters if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); @@ -1298,7 +1477,20 @@ bool Tween::targeting_method(Object *p_object , EaseType p_ease_type , real_t p_delay ) { - ERR_FAIL_COND_V(pending_update != 0, false); + if(pending_update != 0) { + _add_pending_command("targeting_method" + , p_object + , p_method + , p_initial + , p_initial_method + , p_final_val + , p_times_in_sec + , p_trans_type + , p_ease_type + , p_delay + ); + return true; + } // convert INT to REAL is better for interpolaters if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); @@ -1309,7 +1501,9 @@ bool Tween::targeting_method(Object *p_object ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false); ERR_FAIL_COND_V(p_delay < 0, false); + ERR_EXPLAIN("Object has no method named: %s" + p_method); ERR_FAIL_COND_V(!p_object->has_method(p_method), false); + ERR_EXPLAIN("Initial Object has no method named: %s" + p_initial_method); ERR_FAIL_COND_V(!p_initial->has_method(p_initial_method), false); Variant::CallError error; diff --git a/scene/animation/tween.h b/scene/animation/tween.h index 76402bcd73..d504c63d8a 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -110,6 +110,27 @@ private: List interpolates; + struct PendingCommand { + StringName key; + int args; + Variant arg[10]; + }; + List pending_commands; + + void _add_pending_command(StringName p_key + ,const Variant& p_arg1=Variant() + ,const Variant& p_arg2=Variant() + ,const Variant& p_arg3=Variant() + ,const Variant& p_arg4=Variant() + ,const Variant& p_arg5=Variant() + ,const Variant& p_arg6=Variant() + ,const Variant& p_arg7=Variant() + ,const Variant& p_arg8=Variant() + ,const Variant& p_arg9=Variant() + ,const Variant& p_arg10=Variant() + ); + void _process_pending_commands(); + typedef real_t (*interpolater)(real_t t, real_t b, real_t c, real_t d); static interpolater interpolaters[TRANS_COUNT][EASE_COUNT]; -- cgit v1.2.3 From 74b0e0c296ac438df2f0826482310e788d0ba898 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 5 May 2015 00:17:22 -0300 Subject: fix crash in editor when using alt+arrows to indent, thanks adolson and romulox_x --- scene/gui/text_edit.cpp | 3 +++ tools/editor/plugins/script_editor_plugin.cpp | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 75174a85de..681c33652e 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3494,6 +3494,9 @@ void TextEdit::set_line(int line, String new_text) return; _remove_text(line, 0, line, text[line].length()); _insert_text(line, 0, new_text); + if (cursor.line==line) { + cursor.column=MIN(cursor.column,new_text.length()); + } } void TextEdit::insert_at(const String &p_text, int at) diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index e6e311cfa1..edc5d460e7 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -816,11 +816,11 @@ void ScriptEditor::_menu_option(int p_option) { if (scr.is_null()) return; - int begin, end; - begin = tx->get_selection_from_line(); + if (tx->is_selection_active()) { - end = tx->get_selection_to_line(); + int begin = tx->get_selection_from_line(); + int end = tx->get_selection_to_line(); for (int i = begin; i <= end; i++) { String line_text = tx->get_line(i); @@ -840,7 +840,7 @@ void ScriptEditor::_menu_option(int p_option) { } else { - begin = tx->cursor_get_line(); + int begin = tx->cursor_get_line(); String line_text = tx->get_line(begin); // begins with tab if (line_text.begins_with("\t")) @@ -866,11 +866,10 @@ void ScriptEditor::_menu_option(int p_option) { if (scr.is_null()) return; - int begin, end; - begin = tx->get_selection_from_line(); if (tx->is_selection_active()) { - end = tx->get_selection_to_line(); + int begin = tx->get_selection_from_line(); + int end = tx->get_selection_to_line(); for (int i = begin; i <= end; i++) { String line_text = tx->get_line(i); @@ -880,7 +879,7 @@ void ScriptEditor::_menu_option(int p_option) { } else { - begin = tx->cursor_get_line(); + int begin = tx->cursor_get_line(); String line_text = tx->get_line(begin); line_text = '\t' + line_text; tx->set_line(begin, line_text); @@ -913,11 +912,12 @@ void ScriptEditor::_menu_option(int p_option) { if (scr.is_null()) return; - int begin, end; - begin = tx->get_selection_from_line(); + + if (tx->is_selection_active()) { - end = tx->get_selection_to_line(); + int begin = tx->get_selection_from_line(); + int end = tx->get_selection_to_line(); for (int i = begin; i <= end; i++) { String line_text = tx->get_line(i); @@ -931,7 +931,7 @@ void ScriptEditor::_menu_option(int p_option) { } else { - begin = tx->cursor_get_line(); + int begin = tx->cursor_get_line(); String line_text = tx->get_line(begin); if (line_text.begins_with("#")) -- cgit v1.2.3 From 36932a006541b9c3614fbceca331b2dae38a011f Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 5 May 2015 00:37:06 -0300 Subject: avoid crash on some cases of richtextlabel fill, but odd behavior persists, #1803 --- scene/gui/rich_text_label.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 4be53839be..3489b02598 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -268,7 +268,9 @@ if (m_height > line_height) {\ } if (found_space) { - fw+=l.offset_caches[line]/l.space_caches[line]; + int ln = MIN(l.offset_caches.size()-1,line); + + fw+=l.offset_caches[ln]/l.space_caches[ln]; } } -- cgit v1.2.3 From 0995a230f627e0c953f7fe299be3c6c7449bd0be Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 5 May 2015 00:39:14 -0300 Subject: up version to rc2 --- version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.py b/version.py index 577bc73208..03c76b704b 100644 --- a/version.py +++ b/version.py @@ -2,6 +2,6 @@ short_name="godot" name="Godot Engine" major=1 minor=1 -status="rc1" +status="rc2" -- cgit v1.2.3 From 1d619fad86d0f74afa783b63864b16c12e34d173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20P=C3=A9rez?= Date: Tue, 5 May 2015 12:02:47 +0200 Subject: Really fixes fullscreen mode in OS X, even during startup --- platform/osx/os_osx.mm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index dd19dbbff6..03e643db6f 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -966,8 +966,10 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi [NSApp activateIgnoringOtherApps:YES]; - [window_object makeKeyAndOrderFront:nil]; + [window_object makeKeyAndOrderFront:nil]; + if (p_desired.fullscreen) + set_window_fullscreen(true); /*** END OSX INITIALIZATION ***/ /*** END OSX INITIALIZATION ***/ @@ -1310,14 +1312,20 @@ void OS_OSX::set_window_size(const Size2 p_size) { void OS_OSX::set_window_fullscreen(bool p_enabled) { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + [window_object toggleFullScreen:nil]; +#else [window_object performZoom:nil]; +#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ zoomed = p_enabled; }; bool OS_OSX::is_window_fullscreen() const { +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 if ( [window_object respondsToSelector:@selector(isZoomed)] ) return [window_object isZoomed]; +#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ return zoomed; }; -- cgit v1.2.3 From bc3c14a76b988a50e65328a932316c2e630a7ae6 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 5 May 2015 09:53:37 -0300 Subject: Made type-checking for arguments less trict between bool, int real. Fixes #1816 --- core/variant.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/variant.cpp b/core/variant.cpp index f49b202a5b..d7817ac268 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -463,8 +463,8 @@ bool Variant::can_convert_strict(Variant::Type p_type_from,Variant::Type p_type_ case BOOL: { static const Type valid[]={ - //INT, - //REAL, + INT, + REAL, //STRING, NIL, }; @@ -474,7 +474,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from,Variant::Type p_type_ case INT: { static const Type valid[]={ - //BOOL, + BOOL, REAL, //STRING, NIL, @@ -486,7 +486,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from,Variant::Type p_type_ case REAL: { static const Type valid[]={ - //BOOL, + BOOL, INT, //STRING, NIL, -- cgit v1.2.3 From 734d539a7dbef428402fb232ca7623a215ac3f64 Mon Sep 17 00:00:00 2001 From: Guilherme Felipe Date: Tue, 5 May 2015 15:34:40 -0300 Subject: Change the order of the filter --- core/globals.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/globals.cpp b/core/globals.cpp index b128914de5..23d8c16ace 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -1381,7 +1381,7 @@ Globals::Globals() { set("application/name","" ); set("application/main_scene",""); - custom_prop_info["application/main_scene"]=PropertyInfo(Variant::STRING,"application/main_scene",PROPERTY_HINT_FILE,"xml,res,scn,xscn"); + custom_prop_info["application/main_scene"]=PropertyInfo(Variant::STRING,"application/main_scene",PROPERTY_HINT_FILE,"scn,res,xscn,xml"); set("application/disable_stdout",false); set("application/use_shared_user_dir",true); -- cgit v1.2.3 From 605b783708f9270670c38d9ad39d7ae88d38101b Mon Sep 17 00:00:00 2001 From: "Daniel T. Borelli" Date: Tue, 28 Apr 2015 22:11:04 -0300 Subject: fix delete packed data --- main/main.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index a822418eaa..aa4a4b8919 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -748,8 +748,6 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas if (file_access_network_client) memdelete(file_access_network_client); - if (packed_data) - memdelete( packed_data ); #ifdef MINIZIP_ENABLED if (zip_packed_data) memdelete( zip_packed_data ); -- cgit v1.2.3 From 670d77813f8ded38685eee98f83dc796227a59b7 Mon Sep 17 00:00:00 2001 From: ehriche Date: Wed, 6 May 2015 00:41:41 +0200 Subject: PhysicsServerSW::body_is_shape_set_as_trigger - missing return statement --- servers/physics/physics_server_sw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp index 2b4a137e11..03d5b7afa1 100644 --- a/servers/physics/physics_server_sw.cpp +++ b/servers/physics/physics_server_sw.cpp @@ -551,7 +551,7 @@ bool PhysicsServerSW::body_is_shape_set_as_trigger(RID p_body, int p_shape_idx) ERR_FAIL_COND_V(!body,false); ERR_FAIL_INDEX_V(p_shape_idx,body->get_shape_count(),false); - body->is_shape_set_as_trigger(p_shape_idx); + return body->is_shape_set_as_trigger(p_shape_idx); } -- cgit v1.2.3 From edce27fc0328531461f68dd974a72c759e4bcc85 Mon Sep 17 00:00:00 2001 From: ehriche Date: Wed, 6 May 2015 00:43:24 +0200 Subject: minor fixes in drivers mpc and vorbis. --- drivers/mpc/mpc_reader.c | 1 + drivers/vorbis/psy.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mpc/mpc_reader.c b/drivers/mpc/mpc_reader.c index e1d151fe50..550c5ecb54 100644 --- a/drivers/mpc/mpc_reader.c +++ b/drivers/mpc/mpc_reader.c @@ -36,6 +36,7 @@ #include #include "internal.h" #include +#include // memset() #define STDIO_MAGIC 0xF34B963C ///< Just a random safe-check value... typedef struct mpc_reader_stdio_t { diff --git a/drivers/vorbis/psy.c b/drivers/vorbis/psy.c index 9a86151cec..29d2824372 100644 --- a/drivers/vorbis/psy.c +++ b/drivers/vorbis/psy.c @@ -1160,7 +1160,7 @@ void _vp_couple_quantize_normalize(int blobno, However, this is a temporary patch. by Aoyumi @ 2004/04/18 */ - /*float derate = (1.0 - de*((float)(j-limit+i) / (float)(n-limit))); + /*float derate = (1.0 - de*((float)(j-limit+i) / (float)(n-limit))); */ /* elliptical if(reM[j]+reA[j]<0){ reM[j] = - (qeM[j] = (fabs(reM[j])+fabs(reA[j]))*derate*derate); -- cgit v1.2.3 From d177e0f64a03fdafd3401456639834c76dfbf32b Mon Sep 17 00:00:00 2001 From: ehriche Date: Wed, 6 May 2015 00:46:02 +0200 Subject: fixed issue with format string in PCKPacker::flush --- tools/pck/pck_packer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/pck/pck_packer.cpp b/tools/pck/pck_packer.cpp index 09611b3a93..d398fefb5f 100644 --- a/tools/pck/pck_packer.cpp +++ b/tools/pck/pck_packer.cpp @@ -136,7 +136,7 @@ Error PCKPacker::flush(bool p_verbose) { count += 1; if (p_verbose) { if (count % 100 == 0) { - printf("%i/%i (%.2f\%)\r", count, files.size(), float(count) / files.size() * 100); + printf("%i/%i (%.2f)\r", count, files.size(), float(count) / files.size() * 100); fflush(stdout); }; }; -- cgit v1.2.3 From dcc93a33fdc8c1362545107a604e67e60a061489 Mon Sep 17 00:00:00 2001 From: ehriche Date: Wed, 6 May 2015 00:49:00 +0200 Subject: fixed SpatialEditor::_init_indications. loopcounter "i" used ambiguous --- tools/editor/plugins/spatial_editor_plugin.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 4dae60399b..ac2ea9799e 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -3172,11 +3172,11 @@ void SpatialEditor::_init_indicators() { int arrow_sides=6; - for(int i = 0; i < 7 ; i++) { + for(int k = 0; k < 7 ; k++) { - Matrix3 ma(ivec,Math_PI*2*float(i)/arrow_sides); - Matrix3 mb(ivec,Math_PI*2*float(i+1)/arrow_sides); + Matrix3 ma(ivec,Math_PI*2*float(k)/arrow_sides); + Matrix3 mb(ivec,Math_PI*2*float(k+1)/arrow_sides); for(int j=0;j Date: Wed, 6 May 2015 00:51:49 +0200 Subject: added notes to resolve undefined behavior of calculations in tweening interpolators in future. --- scene/animation/tween_interpolaters.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scene/animation/tween_interpolaters.cpp b/scene/animation/tween_interpolaters.cpp index c052d752f8..9128d220de 100644 --- a/scene/animation/tween_interpolaters.cpp +++ b/scene/animation/tween_interpolaters.cpp @@ -285,18 +285,18 @@ namespace cubic { namespace circ { static real_t in(real_t t, real_t b, real_t c, real_t d) { - return -c * (sqrt(1 - (t /= d) * t) - 1) + b; + return -c * (sqrt(1 - (t /= d) * t) - 1) + b; // TODO: ehrich: operation with t is undefined } static real_t out(real_t t, real_t b, real_t c, real_t d) { - return c * sqrt(1 - (t = t / d - 1) * t) + b; + return c * sqrt(1 - (t = t / d - 1) * t) + b; // TODO: ehrich: operation with t is undefined } static real_t in_out(real_t t, real_t b, real_t c, real_t d) { if ((t /= d / 2) < 1) return -c / 2 * (sqrt(1 - t * t) - 1) + b; - return c / 2 * (sqrt(1 - t * (t -= 2)) + 1) + b; + return c / 2 * (sqrt(1 - t * (t -= 2)) + 1) + b; // TODO: ehrich: operation with t is undefined } static real_t out_in(real_t t, real_t b, real_t c, real_t d) @@ -364,15 +364,15 @@ namespace back { static real_t out(real_t t, real_t b, real_t c, real_t d) { float s = 1.70158f; - return c * ((t = t / d- 1) * t * ((s + 1) * t + s) + 1) + b; + return c * ((t = t / d- 1) * t * ((s + 1) * t + s) + 1) + b; // TODO: ehrich: operation with t is undefined } static real_t in_out(real_t t, real_t b, real_t c, real_t d) { float s = 1.70158f; - if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525f)) + 1) * t - s)) + b; + if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525f)) + 1) * t - s)) + b; // TODO: ehrich: operation with s is undefined float postFix = t -= 2; - return c / 2 * ((postFix) * t * (((s *= (1.525f)) + 1) * t + s) + 2) + b; + return c / 2 * ((postFix) * t * (((s *= (1.525f)) + 1) * t + s) + 2) + b; // TODO: ehrich: operation with s is undefined } static real_t out_in(real_t t, real_t b, real_t c, real_t d) -- cgit v1.2.3 From 897a1aade5332753d9fda950d80495798cdc85b4 Mon Sep 17 00:00:00 2001 From: ehriche Date: Wed, 6 May 2015 00:56:59 +0200 Subject: optional formal changes --- core/io/resource_format_xml.cpp | 2 +- core/math/math_funcs.cpp | 7 ++++--- platform/x11/os_x11.cpp | 4 ++-- scene/2d/camera_2d.cpp | 3 +-- scene/gui/line_edit.cpp | 2 +- scene/gui/text_edit.cpp | 4 ++-- servers/physics/collision_object_sw.h | 4 +++- servers/visual/rasterizer.h | 10 +++++----- servers/visual/visual_server_raster.cpp | 2 +- tools/docdump/doc_dump.cpp | 2 +- tools/editor/animation_editor.cpp | 2 +- tools/editor/editor_file_system.cpp | 8 ++++---- tools/editor/io_plugins/editor_texture_import_plugin.cpp | 2 ++ tools/editor/plugins/shader_graph_editor_plugin.cpp | 1 - tools/editor/spatial_editor_gizmos.cpp | 3 ++- 15 files changed, 30 insertions(+), 26 deletions(-) diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index 9de33e7ef3..3e625ba6fd 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -1850,7 +1850,7 @@ void ResourceFormatSaverXMLInstance::escape(String& p_str) { p_str=p_str.replace(">","<"); p_str=p_str.replace("'","'"); p_str=p_str.replace("\"","""); - for (int i=1;i<32;i++) { + for (char i=1;i<32;i++) { char chr[2]={i,0}; const char hexn[16]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp index 6ad5c7499b..3c94ac5bc7 100644 --- a/core/math/math_funcs.cpp +++ b/core/math/math_funcs.cpp @@ -36,8 +36,9 @@ uint32_t Math::default_seed=1; #define PHI 0x9e3779b9 -static uint32_t Q[4096], c = 362436; - +#if 0 +static uint32_t Q[4096]; +#endif uint32_t Math::rand_from_seed(uint32_t *seed) { @@ -269,7 +270,7 @@ bool Math::is_inf(double p_val) { uint32_t Math::larger_prime(uint32_t p_val) { - static const int primes[] = { + static const uint32_t primes[] = { 5, 13, 23, diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 67ec33f3a3..28427fa2f0 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -317,8 +317,8 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi /* set the name and class hints for the window manager to use */ classHint = XAllocClassHint(); if (classHint) { - classHint->res_name = "Godot"; - classHint->res_class = "Godot"; + classHint->res_name = (char *)"Godot"; + classHint->res_class = (char *)"Godot"; } XSetClassHint(x11_display, x11_window, classHint); XFree(classHint); diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 27a512845c..70b88a6611 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -132,8 +132,7 @@ Matrix32 Camera2D::get_camera_transform() { } - Point2 screen_offset = (centered ? (screen_size * 0.5 * zoom) : Point2());; - screen_offset; + Point2 screen_offset = (centered ? (screen_size * 0.5 * zoom) : Point2()); float angle = get_global_transform().get_rotation(); if(rotating){ diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 14aa3da85f..fec9e401f1 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -272,7 +272,7 @@ void LineEdit::_input_event(InputEvent p_event) { if (editable) { selection_delete(); - CharType ucodestr[2]={k.unicode,0}; + CharType ucodestr[2]={(CharType)k.unicode,0}; append_at_cursor(ucodestr); emit_signal("text_changed",text); _change_notify("text"); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 681c33652e..db8fbf7a63 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1440,7 +1440,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { } else { //different char, go back - const CharType chr[2] = {k.unicode, 0}; + const CharType chr[2] = {(CharType)k.unicode, 0}; if(auto_brace_completion_enabled && _is_pair_symbol(chr[0])) { _consume_pair_symbol(chr[0]); } else { @@ -2062,7 +2062,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { if (readonly) break; - const CharType chr[2] = {k.unicode, 0}; + const CharType chr[2] = {(CharType)k.unicode, 0}; if(auto_brace_completion_enabled && _is_pair_symbol(chr[0])) { _consume_pair_symbol(chr[0]); diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h index 70fc3e8fcb..c018ab6224 100644 --- a/servers/physics/collision_object_sw.h +++ b/servers/physics/collision_object_sw.h @@ -34,8 +34,10 @@ #include "self_list.h" #include "broad_phase_sw.h" -#define MAX_OBJECT_DISTANCE 10000000 +#ifdef DEBUG_ENABLED +#define MAX_OBJECT_DISTANCE 10000000.0 #define MAX_OBJECT_DISTANCE_X2 (MAX_OBJECT_DISTANCE*MAX_OBJECT_DISTANCE) +#endif class SpaceSW; diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 81862fb3a6..79365f7db6 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -863,17 +863,17 @@ public: if (polygon->indices != NULL) { r.pos=polygon->points[polygon->indices[0]]; - for (int i=1; icount; i++) { + for (int i=1; ipoints[polygon->indices[i]]); - }; + } } else { r.pos=polygon->points[0]; - for (int i=1; icount; i++) { + for (int i=1; ipoints[i]); - }; - }; + } + } } break; case CanvasItem::Command::TYPE_CIRCLE: { diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index 6556f8bc42..a547da9b61 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -7281,7 +7281,7 @@ void VisualServerRaster::_draw_viewports() { if (r.size.width==0) r.size.width=window_w; if (r.size.height==0) - r.size.height=window_w; + r.size.height=window_h; _draw_viewport(vp,r.pos.x,r.pos.y,r.size.width,r.size.height); diff --git a/tools/docdump/doc_dump.cpp b/tools/docdump/doc_dump.cpp index d10f6c9ce3..17aff3dc74 100644 --- a/tools/docdump/doc_dump.cpp +++ b/tools/docdump/doc_dump.cpp @@ -65,7 +65,7 @@ static String _escape_string(const String& p_str) { ret=ret.replace(">","<"); ret=ret.replace("'","'"); ret=ret.replace("\"","""); - for (int i=1;i<32;i++) { + for (char i=1;i<32;i++) { char chr[2]={i,0}; ret=ret.replace(chr,"&#"+String::num(i)+";"); diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp index 39eec4e69b..63ab186a38 100644 --- a/tools/editor/animation_editor.cpp +++ b/tools/editor/animation_editor.cpp @@ -1375,7 +1375,7 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { if (p_input.is_action("ui_up")) selected_track--; if (v_scroll->is_visible() && p_input.is_action("ui_page_up")) - selected_track--;; + selected_track--; if (selected_track<0) selected_track=0; diff --git a/tools/editor/editor_file_system.cpp b/tools/editor/editor_file_system.cpp index 94e887c3e7..8e96123c36 100644 --- a/tools/editor/editor_file_system.cpp +++ b/tools/editor/editor_file_system.cpp @@ -940,19 +940,19 @@ String EditorFileSystem::get_file_type(const String& p_file) const { EditorFileSystemDirectory *EditorFileSystem::get_path(const String& p_path) { if (!filesystem || scanning) - return false; + return NULL; String f = Globals::get_singleton()->localize_path(p_path); if (!f.begins_with("res://")) - return false; + return NULL; f=f.substr(6,f.length()); f=f.replace("\\","/"); if (f==String()) - return filesystem; + return filesystem; if (f.ends_with("/")) f=f.substr(0,f.length()-1); @@ -960,7 +960,7 @@ EditorFileSystemDirectory *EditorFileSystem::get_path(const String& p_path) { Vector path = f.split("/"); if (path.size()==0) - return false; + return NULL; EditorFileSystemDirectory *fs=filesystem; diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index 64b5d5b337..3add30d81e 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -51,6 +51,7 @@ static const char *flag_names[]={ NULL }; +#if 0 // not used static const char *flag_short_names[]={ "Stream", "FixBorder", @@ -65,6 +66,7 @@ static const char *flag_short_names[]={ "Anisoropic", NULL }; +#endif void EditorImportTextureOptions::set_format(EditorTextureImportPlugin::ImageFormat p_format) { diff --git a/tools/editor/plugins/shader_graph_editor_plugin.cpp b/tools/editor/plugins/shader_graph_editor_plugin.cpp index 1db901e56b..03fcbffa24 100644 --- a/tools/editor/plugins/shader_graph_editor_plugin.cpp +++ b/tools/editor/plugins/shader_graph_editor_plugin.cpp @@ -539,7 +539,6 @@ void GraphCurveMapEdit::_plot_curve(const Vector2& p_a,const Vector2& p_b,const if ((lastx != newx) || (lasty != newy)) { #if 0 - /* if(fix255) { /* use fixed array size (for the curve graph) */ diff --git a/tools/editor/spatial_editor_gizmos.cpp b/tools/editor/spatial_editor_gizmos.cpp index f9d92c8d81..521a10bbd0 100644 --- a/tools/editor/spatial_editor_gizmos.cpp +++ b/tools/editor/spatial_editor_gizmos.cpp @@ -1257,7 +1257,8 @@ void SkeletonSpatialGizmo::redraw() { //find closest axis int closest=-1; - float closest_d; + float closest_d = 0.0; + for(int j=0;j<3;j++) { float dp = Math::abs(grests[parent].basis[j].normalized().dot(d)); if (j==0 || dp>closest_d) -- cgit v1.2.3 From b89cd136a9ce85d1ecf397e8129897a5bd2dd839 Mon Sep 17 00:00:00 2001 From: ehriche Date: Wed, 6 May 2015 01:03:05 +0200 Subject: fixed ColorRgb attribute init order of struct --- drivers/pvr/ColorRgba.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pvr/ColorRgba.h b/drivers/pvr/ColorRgba.h index 6b46d65e3c..0701420566 100644 --- a/drivers/pvr/ColorRgba.h +++ b/drivers/pvr/ColorRgba.h @@ -11,21 +11,21 @@ public: ColorRgb() - : r(0) + : b(0) , g(0) - , b(0) { + , r(0) { } ColorRgb(T red, T green, T blue) - : r(red) + : b(blue) , g(green) - , b(blue) { + , r(red) { } ColorRgb(const ColorRgb &x) - : r(x.r) + : b(x.b) , g(x.g) - , b(x.b) { + , r(x.r) { } ColorRgb operator *(int x) { -- cgit v1.2.3 From ac9263c680076eed36887a681cb59fdcce6c6f73 Mon Sep 17 00:00:00 2001 From: ehriche Date: Wed, 6 May 2015 01:39:42 +0200 Subject: clearified parenthesis of if construct --- scene/gui/label.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 1751d335ee..dac21275dc 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -433,7 +433,7 @@ void Label::regenerate_word_cache() { } - if ((autowrap && line_width>=width && (last && last->char_pos >= 0 || not_latin)) || insert_newline) { + if ((autowrap && (line_width >= width) && ((last && last->char_pos >= 0) || not_latin)) || insert_newline) { if (not_latin) { if (current_word_size>0) { WordCache *wc = memnew( WordCache ); -- cgit v1.2.3 From 979b931995df4c7da80702ce9652862267b1023d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20P=C3=A9rez?= Date: Wed, 6 May 2015 12:53:55 +0200 Subject: Better OS X fullscreen support, without the nasty startup effect --- platform/osx/os_osx.mm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 03e643db6f..eb2a12cdef 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -969,7 +969,7 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi [window_object makeKeyAndOrderFront:nil]; if (p_desired.fullscreen) - set_window_fullscreen(true); + zoomed = true; /*** END OSX INITIALIZATION ***/ /*** END OSX INITIALIZATION ***/ @@ -1312,11 +1312,13 @@ void OS_OSX::set_window_size(const Size2 p_size) { void OS_OSX::set_window_fullscreen(bool p_enabled) { + if (zoomed != p_enabled) { #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 - [window_object toggleFullScreen:nil]; + [window_object toggleFullScreen:nil]; #else - [window_object performZoom:nil]; + [window_object performZoom:nil]; #endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ + } zoomed = p_enabled; }; @@ -1517,6 +1519,11 @@ void OS_OSX::run() { main_loop->init(); + if (zoomed) { + zoomed = false; + set_window_fullscreen(true); + } + // uint64_t last_ticks=get_ticks_usec(); // int frames=0; -- cgit v1.2.3 From 9de37817bcd0fb53384539d1b1a772541cabaca1 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 6 May 2015 09:45:25 -0300 Subject: -removed dynamic_cast on CheckBox, fixes #1830 --- scene/gui/check_box.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp index 309152ba8f..2aa82bc5f5 100644 --- a/scene/gui/check_box.cpp +++ b/scene/gui/check_box.cpp @@ -59,7 +59,7 @@ bool CheckBox::is_radio() Node* parent = this; do { parent = parent->get_parent(); - if (dynamic_cast< ButtonGroup* >(parent)) + if (parent->cast_to()) break; } while (parent); -- cgit v1.2.3 From 2f4c435bfaf4bf8c9353433ef00eff228169c013 Mon Sep 17 00:00:00 2001 From: yg2f Date: Wed, 6 May 2015 23:08:06 +0200 Subject: update rtaudio to latest version update rtaudio from latest version availbale on github --- drivers/rtaudio/RtAudio.cpp | 358 ++++++++++++++++++++++++++++---------------- drivers/rtaudio/RtAudio.h | 3 +- 2 files changed, 227 insertions(+), 134 deletions(-) diff --git a/drivers/rtaudio/RtAudio.cpp b/drivers/rtaudio/RtAudio.cpp index 04e7b4422e..8876f72e21 100644 --- a/drivers/rtaudio/RtAudio.cpp +++ b/drivers/rtaudio/RtAudio.cpp @@ -46,6 +46,7 @@ #include #include #include +#include // Static variable definitions. const unsigned int RtApi::MAX_SAMPLE_RATES = 14; @@ -63,6 +64,22 @@ const unsigned int RtApi::SAMPLE_RATES[] = { #define MUTEX_DESTROY(A) DeleteCriticalSection(A) #define MUTEX_LOCK(A) EnterCriticalSection(A) #define MUTEX_UNLOCK(A) LeaveCriticalSection(A) + + #include "tchar.h" + + static std::string convertCharPointerToStdString(const char *text) + { + return std::string(text); + } + + static std::string convertCharPointerToStdString(const wchar_t *text) + { + int length = WideCharToMultiByte(CP_UTF8, 0, text, -1, NULL, 0, NULL, NULL); + std::string s( length-1, '\0' ); + WideCharToMultiByte(CP_UTF8, 0, text, -1, &s[0], length, NULL, NULL); + return s; + } + #elif defined(__LINUX_ALSA__) || defined(__LINUX_PULSE__) || defined(__UNIX_JACK__) || defined(__LINUX_OSS__) || defined(__MACOSX_CORE__) // pthread API #define MUTEX_INITIALIZE(A) pthread_mutex_init(A, NULL) @@ -184,7 +201,7 @@ RtAudio :: RtAudio( RtAudio::Api api ) getCompiledApi( apis ); for ( unsigned int i=0; igetDeviceCount() ) break; + if ( rtapi_ && rtapi_->getDeviceCount() ) break; } if ( rtapi_ ) return; @@ -766,9 +783,14 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device ) bool haveValueRange = false; info.sampleRates.clear(); for ( UInt32 i=0; i info.preferredSampleRate ) ) + info.preferredSampleRate = tmpSr; + + } else { haveValueRange = true; if ( rangeList[i].mMinimum > minimumRate ) minimumRate = rangeList[i].mMinimum; if ( rangeList[i].mMaximum < maximumRate ) maximumRate = rangeList[i].mMaximum; @@ -777,8 +799,12 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device ) if ( haveValueRange ) { for ( unsigned int k=0; k= (unsigned int) minimumRate && SAMPLE_RATES[k] <= (unsigned int) maximumRate ) + if ( SAMPLE_RATES[k] >= (unsigned int) minimumRate && SAMPLE_RATES[k] <= (unsigned int) maximumRate ) { info.sampleRates.push_back( SAMPLE_RATES[k] ); + + if ( !info.preferredSampleRate || ( SAMPLE_RATES[k] <= 48000 && SAMPLE_RATES[k] > info.preferredSampleRate ) ) + info.preferredSampleRate = SAMPLE_RATES[k]; + } } } @@ -1385,6 +1411,18 @@ void RtApiCore :: closeStream( void ) CoreHandle *handle = (CoreHandle *) stream_.apiHandle; if ( stream_.mode == OUTPUT || stream_.mode == DUPLEX ) { + if (handle) { + AudioObjectPropertyAddress property = { kAudioHardwarePropertyDevices, + kAudioObjectPropertyScopeGlobal, + kAudioObjectPropertyElementMaster }; + + property.mSelector = kAudioDeviceProcessorOverload; + property.mScope = kAudioObjectPropertyScopeGlobal; + if (AudioObjectRemovePropertyListener( handle->id[0], &property, xrunListener, (void *) handle ) != noErr) { + errorText_ = "RtApiCore::closeStream(): error removing property listener!"; + error( RtAudioError::WARNING ); + } + } if ( stream_.state == STREAM_RUNNING ) AudioDeviceStop( handle->id[0], callbackHandler ); #if defined( MAC_OS_X_VERSION_10_5 ) && ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 ) @@ -1396,6 +1434,18 @@ void RtApiCore :: closeStream( void ) } if ( stream_.mode == INPUT || ( stream_.mode == DUPLEX && stream_.device[0] != stream_.device[1] ) ) { + if (handle) { + AudioObjectPropertyAddress property = { kAudioHardwarePropertyDevices, + kAudioObjectPropertyScopeGlobal, + kAudioObjectPropertyElementMaster }; + + property.mSelector = kAudioDeviceProcessorOverload; + property.mScope = kAudioObjectPropertyScopeGlobal; + if (AudioObjectRemovePropertyListener( handle->id[1], &property, xrunListener, (void *) handle ) != noErr) { + errorText_ = "RtApiCore::closeStream(): error removing property listener!"; + error( RtAudioError::WARNING ); + } + } if ( stream_.state == STREAM_RUNNING ) AudioDeviceStop( handle->id[1], callbackHandler ); #if defined( MAC_OS_X_VERSION_10_5 ) && ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 ) @@ -1989,7 +2039,9 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device ) // Get the current jack server sample rate. info.sampleRates.clear(); - info.sampleRates.push_back( jack_get_sample_rate( client ) ); + + info.preferredSampleRate = jack_get_sample_rate( client ); + info.sampleRates.push_back( info.preferredSampleRate ); // Count the available ports containing the client name as device // channels. Jack "input ports" equal RtAudio output channels. @@ -2769,8 +2821,12 @@ RtAudio::DeviceInfo RtApiAsio :: getDeviceInfo( unsigned int device ) info.sampleRates.clear(); for ( unsigned int i=0; i info.preferredSampleRate ) ) + info.preferredSampleRate = SAMPLE_RATES[i]; + } } // Determine supported data types ... just check first channel and assume rest are the same. @@ -2829,9 +2885,12 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne unsigned int firstChannel, unsigned int sampleRate, RtAudioFormat format, unsigned int *bufferSize, RtAudio::StreamOptions *options ) -{ +{//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + bool isDuplexInput = mode == INPUT && stream_.mode == OUTPUT; + // For ASIO, a duplex stream MUST use the same driver. - if ( mode == INPUT && stream_.mode == OUTPUT && stream_.device[0] != device ) { + if ( isDuplexInput && stream_.device[0] != device ) { errorText_ = "RtApiAsio::probeDeviceOpen: an ASIO duplex stream must use the same device for input and output!"; return FAILURE; } @@ -2845,7 +2904,7 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne } // Only load the driver once for duplex stream. - if ( mode != INPUT || stream_.mode != OUTPUT ) { + if ( !isDuplexInput ) { // The getDeviceInfo() function will not work when a stream is open // because ASIO does not allow multiple devices to run at the same // time. Thus, we'll probe the system before opening a stream and @@ -2866,22 +2925,26 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne } } + // keep them before any "goto error", they are used for error cleanup + goto device boundary checks + bool buffersAllocated = false; + AsioHandle *handle = (AsioHandle *) stream_.apiHandle; + unsigned int nChannels; + + // Check the device channel count. long inputChannels, outputChannels; result = ASIOGetChannels( &inputChannels, &outputChannels ); if ( result != ASE_OK ) { - drivers.removeCurrentDriver(); errorStream_ << "RtApiAsio::probeDeviceOpen: error (" << getAsioErrorString( result ) << ") getting channel count (" << driverName << ")."; errorText_ = errorStream_.str(); - return FAILURE; + goto error; } if ( ( mode == OUTPUT && (channels+firstChannel) > (unsigned int) outputChannels) || ( mode == INPUT && (channels+firstChannel) > (unsigned int) inputChannels) ) { - drivers.removeCurrentDriver(); errorStream_ << "RtApiAsio::probeDeviceOpen: driver (" << driverName << ") does not support requested channel count (" << channels << ") + offset (" << firstChannel << ")."; errorText_ = errorStream_.str(); - return FAILURE; + goto error; } stream_.nDeviceChannels[mode] = channels; stream_.nUserChannels[mode] = channels; @@ -2890,30 +2953,27 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne // Verify the sample rate is supported. result = ASIOCanSampleRate( (ASIOSampleRate) sampleRate ); if ( result != ASE_OK ) { - drivers.removeCurrentDriver(); errorStream_ << "RtApiAsio::probeDeviceOpen: driver (" << driverName << ") does not support requested sample rate (" << sampleRate << ")."; errorText_ = errorStream_.str(); - return FAILURE; + goto error; } // Get the current sample rate ASIOSampleRate currentRate; result = ASIOGetSampleRate( ¤tRate ); if ( result != ASE_OK ) { - drivers.removeCurrentDriver(); errorStream_ << "RtApiAsio::probeDeviceOpen: driver (" << driverName << ") error getting sample rate."; errorText_ = errorStream_.str(); - return FAILURE; + goto error; } // Set the sample rate only if necessary if ( currentRate != sampleRate ) { result = ASIOSetSampleRate( (ASIOSampleRate) sampleRate ); if ( result != ASE_OK ) { - drivers.removeCurrentDriver(); errorStream_ << "RtApiAsio::probeDeviceOpen: driver (" << driverName << ") error setting sample rate (" << sampleRate << ")."; errorText_ = errorStream_.str(); - return FAILURE; + goto error; } } @@ -2924,10 +2984,9 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne else channelInfo.isInput = true; result = ASIOGetChannelInfo( &channelInfo ); if ( result != ASE_OK ) { - drivers.removeCurrentDriver(); errorStream_ << "RtApiAsio::probeDeviceOpen: driver (" << driverName << ") error (" << getAsioErrorString( result ) << ") getting data format."; errorText_ = errorStream_.str(); - return FAILURE; + goto error; } // Assuming WINDOWS host is always little-endian. @@ -2956,10 +3015,9 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne } if ( stream_.deviceFormat[mode] == 0 ) { - drivers.removeCurrentDriver(); errorStream_ << "RtApiAsio::probeDeviceOpen: driver (" << driverName << ") data format not supported by RtAudio."; errorText_ = errorStream_.str(); - return FAILURE; + goto error; } // Set the buffer size. For a duplex stream, this will end up @@ -2968,49 +3026,63 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne long minSize, maxSize, preferSize, granularity; result = ASIOGetBufferSize( &minSize, &maxSize, &preferSize, &granularity ); if ( result != ASE_OK ) { - drivers.removeCurrentDriver(); errorStream_ << "RtApiAsio::probeDeviceOpen: driver (" << driverName << ") error (" << getAsioErrorString( result ) << ") getting buffer size."; errorText_ = errorStream_.str(); - return FAILURE; + goto error; } - if ( *bufferSize < (unsigned int) minSize ) *bufferSize = (unsigned int) minSize; - else if ( *bufferSize > (unsigned int) maxSize ) *bufferSize = (unsigned int) maxSize; - else if ( granularity == -1 ) { - // Make sure bufferSize is a power of two. - int log2_of_min_size = 0; - int log2_of_max_size = 0; + if ( isDuplexInput ) { + // When this is the duplex input (output was opened before), then we have to use the same + // buffersize as the output, because it might use the preferred buffer size, which most + // likely wasn't passed as input to this. The buffer sizes have to be identically anyway, + // So instead of throwing an error, make them equal. The caller uses the reference + // to the "bufferSize" param as usual to set up processing buffers. - for ( unsigned int i = 0; i < sizeof(long) * 8; i++ ) { - if ( minSize & ((long)1 << i) ) log2_of_min_size = i; - if ( maxSize & ((long)1 << i) ) log2_of_max_size = i; - } + *bufferSize = stream_.bufferSize; - long min_delta = std::abs( (long)*bufferSize - ((long)1 << log2_of_min_size) ); - int min_delta_num = log2_of_min_size; + } else { + if ( *bufferSize == 0 ) *bufferSize = preferSize; + else if ( *bufferSize < (unsigned int) minSize ) *bufferSize = (unsigned int) minSize; + else if ( *bufferSize > (unsigned int) maxSize ) *bufferSize = (unsigned int) maxSize; + else if ( granularity == -1 ) { + // Make sure bufferSize is a power of two. + int log2_of_min_size = 0; + int log2_of_max_size = 0; - for (int i = log2_of_min_size + 1; i <= log2_of_max_size; i++) { - long current_delta = std::abs( (long)*bufferSize - ((long)1 << i) ); - if (current_delta < min_delta) { - min_delta = current_delta; - min_delta_num = i; + for ( unsigned int i = 0; i < sizeof(long) * 8; i++ ) { + if ( minSize & ((long)1 << i) ) log2_of_min_size = i; + if ( maxSize & ((long)1 << i) ) log2_of_max_size = i; } - } - *bufferSize = ( (unsigned int)1 << min_delta_num ); - if ( *bufferSize < (unsigned int) minSize ) *bufferSize = (unsigned int) minSize; - else if ( *bufferSize > (unsigned int) maxSize ) *bufferSize = (unsigned int) maxSize; - } - else if ( granularity != 0 ) { - // Set to an even multiple of granularity, rounding up. - *bufferSize = (*bufferSize + granularity-1) / granularity * granularity; + long min_delta = std::abs( (long)*bufferSize - ((long)1 << log2_of_min_size) ); + int min_delta_num = log2_of_min_size; + + for (int i = log2_of_min_size + 1; i <= log2_of_max_size; i++) { + long current_delta = std::abs( (long)*bufferSize - ((long)1 << i) ); + if (current_delta < min_delta) { + min_delta = current_delta; + min_delta_num = i; + } + } + + *bufferSize = ( (unsigned int)1 << min_delta_num ); + if ( *bufferSize < (unsigned int) minSize ) *bufferSize = (unsigned int) minSize; + else if ( *bufferSize > (unsigned int) maxSize ) *bufferSize = (unsigned int) maxSize; + } + else if ( granularity != 0 ) { + // Set to an even multiple of granularity, rounding up. + *bufferSize = (*bufferSize + granularity-1) / granularity * granularity; + } } - if ( mode == INPUT && stream_.mode == OUTPUT && stream_.bufferSize != *bufferSize ) { - drivers.removeCurrentDriver(); + /* + // we don't use it anymore, see above! + // Just left it here for the case... + if ( isDuplexInput && stream_.bufferSize != *bufferSize ) { errorText_ = "RtApiAsio::probeDeviceOpen: input/output buffersize discrepancy!"; - return FAILURE; + goto error; } + */ stream_.bufferSize = *bufferSize; stream_.nBuffers = 2; @@ -3022,16 +3094,13 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne stream_.deviceInterleaved[mode] = false; // Allocate, if necessary, our AsioHandle structure for the stream. - AsioHandle *handle = (AsioHandle *) stream_.apiHandle; if ( handle == 0 ) { try { handle = new AsioHandle; } catch ( std::bad_alloc& ) { - //if ( handle == NULL ) { - drivers.removeCurrentDriver(); errorText_ = "RtApiAsio::probeDeviceOpen: error allocating AsioHandle memory."; - return FAILURE; + goto error; } handle->bufferInfos = 0; @@ -3046,15 +3115,14 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne // Create the ASIO internal buffers. Since RtAudio sets up input // and output separately, we'll have to dispose of previously // created output buffers for a duplex stream. - long inputLatency, outputLatency; if ( mode == INPUT && stream_.mode == OUTPUT ) { ASIODisposeBuffers(); if ( handle->bufferInfos ) free( handle->bufferInfos ); } // Allocate, initialize, and save the bufferInfos in our stream callbackInfo structure. - bool buffersAllocated = false; - unsigned int i, nChannels = stream_.nDeviceChannels[0] + stream_.nDeviceChannels[1]; + unsigned int i; + nChannels = stream_.nDeviceChannels[0] + stream_.nDeviceChannels[1]; handle->bufferInfos = (ASIOBufferInfo *) malloc( nChannels * sizeof(ASIOBufferInfo) ); if ( handle->bufferInfos == NULL ) { errorStream_ << "RtApiAsio::probeDeviceOpen: error allocating bufferInfo memory for driver (" << driverName << ")."; @@ -3075,18 +3143,37 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne infos->buffers[0] = infos->buffers[1] = 0; } + // prepare for callbacks + stream_.sampleRate = sampleRate; + stream_.device[mode] = device; + stream_.mode = isDuplexInput ? DUPLEX : mode; + + // store this class instance before registering callbacks, that are going to use it + asioCallbackInfo = &stream_.callbackInfo; + stream_.callbackInfo.object = (void *) this; + // Set up the ASIO callback structure and create the ASIO data buffers. asioCallbacks.bufferSwitch = &bufferSwitch; asioCallbacks.sampleRateDidChange = &sampleRateChanged; asioCallbacks.asioMessage = &asioMessages; asioCallbacks.bufferSwitchTimeInfo = NULL; result = ASIOCreateBuffers( handle->bufferInfos, nChannels, stream_.bufferSize, &asioCallbacks ); + if ( result != ASE_OK ) { + // Standard method failed. This can happen with strict/misbehaving drivers that return valid buffer size ranges + // but only accept the preferred buffer size as parameter for ASIOCreateBuffers. eg. Creatives ASIO driver + // in that case, let's be naïve and try that instead + *bufferSize = preferSize; + stream_.bufferSize = *bufferSize; + result = ASIOCreateBuffers( handle->bufferInfos, nChannels, stream_.bufferSize, &asioCallbacks ); + } + if ( result != ASE_OK ) { errorStream_ << "RtApiAsio::probeDeviceOpen: driver (" << driverName << ") error (" << getAsioErrorString( result ) << ") creating buffers."; errorText_ = errorStream_.str(); goto error; } - buffersAllocated = true; + buffersAllocated = true; + stream_.state = STREAM_STOPPED; // Set flags for buffer conversion. stream_.doConvertBuffer[mode] = false; @@ -3109,11 +3196,9 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne bool makeBuffer = true; bufferBytes = stream_.nDeviceChannels[mode] * formatBytes( stream_.deviceFormat[mode] ); - if ( mode == INPUT ) { - if ( stream_.mode == OUTPUT && stream_.deviceBuffer ) { - unsigned long bytesOut = stream_.nDeviceChannels[0] * formatBytes( stream_.deviceFormat[0] ); - if ( bufferBytes <= bytesOut ) makeBuffer = false; - } + if ( isDuplexInput && stream_.deviceBuffer ) { + unsigned long bytesOut = stream_.nDeviceChannels[0] * formatBytes( stream_.deviceFormat[0] ); + if ( bufferBytes <= bytesOut ) makeBuffer = false; } if ( makeBuffer ) { @@ -3127,18 +3212,8 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne } } - stream_.sampleRate = sampleRate; - stream_.device[mode] = device; - stream_.state = STREAM_STOPPED; - asioCallbackInfo = &stream_.callbackInfo; - stream_.callbackInfo.object = (void *) this; - if ( stream_.mode == OUTPUT && mode == INPUT ) - // We had already set up an output stream. - stream_.mode = DUPLEX; - else - stream_.mode = mode; - // Determine device latencies + long inputLatency, outputLatency; result = ASIOGetLatencies( &inputLatency, &outputLatency ); if ( result != ASE_OK ) { errorStream_ << "RtApiAsio::probeDeviceOpen: driver (" << driverName << ") error (" << getAsioErrorString( result ) << ") getting latency."; @@ -3158,32 +3233,38 @@ bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne return SUCCESS; error: - if ( buffersAllocated ) - ASIODisposeBuffers(); - drivers.removeCurrentDriver(); + if ( !isDuplexInput ) { + // the cleanup for error in the duplex input, is done by RtApi::openStream + // So we clean up for single channel only - if ( handle ) { - CloseHandle( handle->condition ); - if ( handle->bufferInfos ) - free( handle->bufferInfos ); - delete handle; - stream_.apiHandle = 0; - } + if ( buffersAllocated ) + ASIODisposeBuffers(); - for ( int i=0; i<2; i++ ) { - if ( stream_.userBuffer[i] ) { - free( stream_.userBuffer[i] ); - stream_.userBuffer[i] = 0; + drivers.removeCurrentDriver(); + + if ( handle ) { + CloseHandle( handle->condition ); + if ( handle->bufferInfos ) + free( handle->bufferInfos ); + + delete handle; + stream_.apiHandle = 0; } - } - if ( stream_.deviceBuffer ) { - free( stream_.deviceBuffer ); - stream_.deviceBuffer = 0; + + if ( stream_.userBuffer[mode] ) { + free( stream_.userBuffer[mode] ); + stream_.userBuffer[mode] = 0; + } + + if ( stream_.deviceBuffer ) { + free( stream_.deviceBuffer ); + stream_.deviceBuffer = 0; + } } return FAILURE; -} +}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void RtApiAsio :: closeStream() { @@ -3635,12 +3716,12 @@ public: outIndex_( 0 ) {} ~WasapiBuffer() { - delete buffer_; + free( buffer_ ); } // sets the length of the internal ring buffer void setBufferSize( unsigned int bufferSize, unsigned int formatBytes ) { - delete buffer_; + free( buffer_ ); buffer_ = ( char* ) calloc( bufferSize, formatBytes ); @@ -3799,7 +3880,7 @@ void convertBufferWasapi( char* outBuffer, float sampleStep = 1.0f / sampleRatio; float inSampleFraction = 0.0f; - outSampleCount = ( unsigned int ) ( inSampleCount * sampleRatio ); + outSampleCount = ( unsigned int ) roundf( inSampleCount * sampleRatio ); // frame-by-frame, copy each relative input sample into it's corresponding output sample for ( unsigned int outSample = 0; outSample < outSampleCount; outSample++ ) @@ -3945,7 +4026,6 @@ RtAudio::DeviceInfo RtApiWasapi::getDeviceInfo( unsigned int device ) RtAudio::DeviceInfo info; unsigned int captureDeviceCount = 0; unsigned int renderDeviceCount = 0; - std::wstring deviceName; std::string defaultDeviceName; bool isCaptureDevice = false; @@ -4048,8 +4128,7 @@ RtAudio::DeviceInfo RtApiWasapi::getDeviceInfo( unsigned int device ) goto Exit; } - deviceName = defaultDeviceNameProp.pwszVal; - defaultDeviceName = std::string( deviceName.begin(), deviceName.end() ); + defaultDeviceName = convertCharPointerToStdString(defaultDeviceNameProp.pwszVal); // name hr = devicePtr->OpenPropertyStore( STGM_READ, &devicePropStore ); @@ -4066,8 +4145,7 @@ RtAudio::DeviceInfo RtApiWasapi::getDeviceInfo( unsigned int device ) goto Exit; } - deviceName = deviceNameProp.pwszVal; - info.name = std::string( deviceName.begin(), deviceName.end() ); + info.name =convertCharPointerToStdString(deviceNameProp.pwszVal); // is default if ( isCaptureDevice ) { @@ -4110,6 +4188,7 @@ RtAudio::DeviceInfo RtApiWasapi::getDeviceInfo( unsigned int device ) for ( unsigned int i = 0; i < MAX_SAMPLE_RATES; i++ ) { info.sampleRates.push_back( SAMPLE_RATES[i] ); } + info.preferredSampleRate = deviceFormat->nSamplesPerSec; // native format info.nativeFormats = 0; @@ -5245,14 +5324,11 @@ unsigned int RtApiDs :: getDeviceCount( void ) error( RtAudioError::WARNING ); } - // Clean out any devices that may have disappeared. - std::vector< int > indices; - for ( unsigned int i=0; i(dsDevices.size()); } @@ -5308,8 +5384,12 @@ RtAudio::DeviceInfo RtApiDs :: getDeviceInfo( unsigned int device ) info.sampleRates.clear(); for ( unsigned int k=0; k= (unsigned int) outCaps.dwMinSecondarySampleRate && - SAMPLE_RATES[k] <= (unsigned int) outCaps.dwMaxSecondarySampleRate ) + SAMPLE_RATES[k] <= (unsigned int) outCaps.dwMaxSecondarySampleRate ) { info.sampleRates.push_back( SAMPLE_RATES[k] ); + + if ( !info.preferredSampleRate || ( SAMPLE_RATES[k] <= 48000 && SAMPLE_RATES[k] > info.preferredSampleRate ) ) + info.preferredSampleRate = SAMPLE_RATES[k]; + } } // Get format information. @@ -6264,6 +6344,7 @@ void RtApiDs :: callbackEvent() if ( FAILED( result ) ) { errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") getting current write position!"; errorText_ = errorStream_.str(); + MUTEX_UNLOCK( &stream_.mutex ); error( RtAudioError::SYSTEM_ERROR ); return; } @@ -6271,6 +6352,7 @@ void RtApiDs :: callbackEvent() if ( FAILED( result ) ) { errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") getting current read position!"; errorText_ = errorStream_.str(); + MUTEX_UNLOCK( &stream_.mutex ); error( RtAudioError::SYSTEM_ERROR ); return; } @@ -6279,6 +6361,7 @@ void RtApiDs :: callbackEvent() if ( FAILED( result ) ) { errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") getting current write position!"; errorText_ = errorStream_.str(); + MUTEX_UNLOCK( &stream_.mutex ); error( RtAudioError::SYSTEM_ERROR ); return; } @@ -6286,6 +6369,7 @@ void RtApiDs :: callbackEvent() if ( FAILED( result ) ) { errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") getting current read position!"; errorText_ = errorStream_.str(); + MUTEX_UNLOCK( &stream_.mutex ); error( RtAudioError::SYSTEM_ERROR ); return; } @@ -6307,6 +6391,7 @@ void RtApiDs :: callbackEvent() if ( FAILED( result ) ) { errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") getting current write position!"; errorText_ = errorStream_.str(); + MUTEX_UNLOCK( &stream_.mutex ); error( RtAudioError::SYSTEM_ERROR ); return; } @@ -6399,6 +6484,7 @@ void RtApiDs :: callbackEvent() if ( FAILED( result ) ) { errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") locking buffer during playback!"; errorText_ = errorStream_.str(); + MUTEX_UNLOCK( &stream_.mutex ); error( RtAudioError::SYSTEM_ERROR ); return; } @@ -6412,6 +6498,7 @@ void RtApiDs :: callbackEvent() if ( FAILED( result ) ) { errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") unlocking buffer during playback!"; errorText_ = errorStream_.str(); + MUTEX_UNLOCK( &stream_.mutex ); error( RtAudioError::SYSTEM_ERROR ); return; } @@ -6448,6 +6535,7 @@ void RtApiDs :: callbackEvent() if ( FAILED( result ) ) { errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") getting current read position!"; errorText_ = errorStream_.str(); + MUTEX_UNLOCK( &stream_.mutex ); error( RtAudioError::SYSTEM_ERROR ); return; } @@ -6509,6 +6597,7 @@ void RtApiDs :: callbackEvent() if ( FAILED( result ) ) { errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") getting current read position!"; errorText_ = errorStream_.str(); + MUTEX_UNLOCK( &stream_.mutex ); error( RtAudioError::SYSTEM_ERROR ); return; } @@ -6523,6 +6612,7 @@ void RtApiDs :: callbackEvent() if ( FAILED( result ) ) { errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") locking capture buffer!"; errorText_ = errorStream_.str(); + MUTEX_UNLOCK( &stream_.mutex ); error( RtAudioError::SYSTEM_ERROR ); return; } @@ -6544,6 +6634,7 @@ void RtApiDs :: callbackEvent() if ( FAILED( result ) ) { errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") unlocking capture buffer!"; errorText_ = errorStream_.str(); + MUTEX_UNLOCK( &stream_.mutex ); error( RtAudioError::SYSTEM_ERROR ); return; } @@ -6582,21 +6673,6 @@ static unsigned __stdcall callbackHandler( void *ptr ) return 0; } -#include "tchar.h" - -static std::string convertTChar( LPCTSTR name ) -{ -#if defined( UNICODE ) || defined( _UNICODE ) - int length = WideCharToMultiByte(CP_UTF8, 0, name, -1, NULL, 0, NULL, NULL); - std::string s( length-1, '\0' ); - WideCharToMultiByte(CP_UTF8, 0, name, -1, &s[0], length, NULL, NULL); -#else - std::string s( name ); -#endif - - return s; -} - static BOOL CALLBACK deviceQueryCallback( LPGUID lpguid, LPCTSTR description, LPCTSTR /*module*/, @@ -6638,7 +6714,7 @@ static BOOL CALLBACK deviceQueryCallback( LPGUID lpguid, } // If good device, then save its name and guid. - std::string name = convertTChar( description ); + std::string name = convertCharPointerToStdString( description ); //if ( name == "Primary Sound Driver" || name == "Primary Sound Capture Driver" ) if ( lpguid == NULL ) name = "Default Device"; @@ -6820,6 +6896,7 @@ RtAudio::DeviceInfo RtApiAlsa :: getDeviceInfo( unsigned int device ) // Count cards and devices card = -1; + subdevice = -1; snd_card_next( &card ); while ( card >= 0 ) { sprintf( name, "hw:%d", card ); @@ -7033,8 +7110,12 @@ RtAudio::DeviceInfo RtApiAlsa :: getDeviceInfo( unsigned int device ) // Test our discrete set of sample rate values. info.sampleRates.clear(); for ( unsigned int i=0; i info.preferredSampleRate ) ) + info.preferredSampleRate = SAMPLE_RATES[i]; + } } if ( info.sampleRates.size() == 0 ) { snd_pcm_close( phandle ); @@ -7959,6 +8040,8 @@ void RtApiAlsa :: callbackEvent() errorStream_ << "RtApiAlsa::callbackEvent: error preparing device after underrun, " << snd_strerror( result ) << "."; errorText_ = errorStream_.str(); } + else + errorText_ = "RtApiAlsa::callbackEvent: audio write error, underrun."; } else { errorStream_ << "RtApiAlsa::callbackEvent: error, current state is " << snd_pcm_state_name( state ) << ", " << snd_strerror( result ) << "."; @@ -8067,6 +8150,7 @@ RtAudio::DeviceInfo RtApiPulse::getDeviceInfo( unsigned int /*device*/ ) for ( const unsigned int *sr = SUPPORTED_SAMPLERATES; *sr; ++sr ) info.sampleRates.push_back( *sr ); + info.preferredSampleRate = 48000; info.nativeFormats = RTAUDIO_SINT16 | RTAUDIO_SINT32 | RTAUDIO_FLOAT32; return info; @@ -8429,7 +8513,7 @@ bool RtApiPulse::probeDeviceOpen( unsigned int device, StreamMode mode, pah = static_cast( stream_.apiHandle ); int error; - if ( !options->streamName.empty() ) streamName = options->streamName; + if ( options && !options->streamName.empty() ) streamName = options->streamName; switch ( mode ) { case INPUT: pa_buffer_attr buffer_attr; @@ -8635,6 +8719,10 @@ RtAudio::DeviceInfo RtApiOss :: getDeviceInfo( unsigned int device ) for ( unsigned int k=0; k info.preferredSampleRate ) ) + info.preferredSampleRate = SAMPLE_RATES[k]; + break; } } @@ -8643,8 +8731,12 @@ RtAudio::DeviceInfo RtApiOss :: getDeviceInfo( unsigned int device ) else { // Check min and max rate values; for ( unsigned int k=0; k= (int) SAMPLE_RATES[k] ) + if ( ainfo.min_rate <= (int) SAMPLE_RATES[k] && ainfo.max_rate >= (int) SAMPLE_RATES[k] ) { info.sampleRates.push_back( SAMPLE_RATES[k] ); + + if ( !info.preferredSampleRate || ( SAMPLE_RATES[k] <= 48000 && SAMPLE_RATES[k] > info.preferredSampleRate ) ) + info.preferredSampleRate = SAMPLE_RATES[k]; + } } } diff --git a/drivers/rtaudio/RtAudio.h b/drivers/rtaudio/RtAudio.h index 1f1b63072c..7d45d36529 100644 --- a/drivers/rtaudio/RtAudio.h +++ b/drivers/rtaudio/RtAudio.h @@ -310,12 +310,13 @@ class RtAudio bool isDefaultOutput; /*!< true if this is the default output device. */ bool isDefaultInput; /*!< true if this is the default input device. */ std::vector sampleRates; /*!< Supported sample rates (queried from list of standard rates). */ + unsigned int preferredSampleRate; /*!< Preferred sample rate, eg. for WASAPI the system sample rate. */ RtAudioFormat nativeFormats; /*!< Bit mask of supported data formats. */ // Default constructor. DeviceInfo() :probed(false), outputChannels(0), inputChannels(0), duplexChannels(0), - isDefaultOutput(false), isDefaultInput(false), nativeFormats(0) {} + isDefaultOutput(false), isDefaultInput(false), preferredSampleRate(0), nativeFormats(0) {} }; //! The structure for specifying input or ouput stream parameters. -- cgit v1.2.3 From 93095014fd87f1a33bdeaeb1f05eaab9342320bc Mon Sep 17 00:00:00 2001 From: "Daniel T. Borelli" Date: Wed, 6 May 2015 20:37:25 -0300 Subject: Fix segment violation MINIZIP_ENABLED --- core/io/file_access_pack.cpp | 4 +++- main/main.cpp | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index bf1211f2b3..339a6d0528 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -92,7 +92,9 @@ void PackedData::add_path(const String& pkg_path, const String& path, uint64_t o void PackedData::add_pack_source(PackSource *p_source) { - sources.push_back(p_source); + if (p_source != NULL) { + sources.push_back(p_source); + } }; PackedData *PackedData::singleton=NULL; diff --git a/main/main.cpp b/main/main.cpp index aa4a4b8919..1469ce4618 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -251,7 +251,14 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas packed_data = memnew(PackedData); #ifdef MINIZIP_ENABLED + + //XXX: always get_singleton() == 0x0 zip_packed_data = ZipArchive::get_singleton(); + //TODO: remove this temporary fix + if (!zip_packed_data) { + zip_packed_data = memnew(ZipArchive); + } + packed_data->add_pack_source(zip_packed_data); #endif @@ -748,10 +755,12 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas if (file_access_network_client) memdelete(file_access_network_client); -#ifdef MINIZIP_ENABLED - if (zip_packed_data) - memdelete( zip_packed_data ); -#endif +// Note 1: *zip_packed_data live into *packed_data +// Note 2: PackedData::~PackedData destroy this. +//#ifdef MINIZIP_ENABLED +// if (zip_packed_data) +// memdelete( zip_packed_data ); +//#endif unregister_core_types(); -- cgit v1.2.3 From ead2dd3db59d22b013da608c002e31603be16169 Mon Sep 17 00:00:00 2001 From: Nicolas Laurito Date: Wed, 6 May 2015 23:53:20 -0300 Subject: Delete line without functionality --- demos/2d/kinematic_char/player.gd | 2 -- 1 file changed, 2 deletions(-) diff --git a/demos/2d/kinematic_char/player.gd b/demos/2d/kinematic_char/player.gd index ddc0271de0..329382408b 100644 --- a/demos/2d/kinematic_char/player.gd +++ b/demos/2d/kinematic_char/player.gd @@ -34,8 +34,6 @@ func _fixed_process(delta): #create forces var force = Vector2(0,GRAVITY) - - var stop = velocity.x!=0.0 var walk_left = Input.is_action_pressed("move_left") var walk_right = Input.is_action_pressed("move_right") -- cgit v1.2.3 From 48afa1d2847bdf7d23c21a76494c4789d3bdc9e1 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Wed, 6 May 2015 23:07:11 -0400 Subject: window_management input fix --- demos/misc/window_management/control.gd | 10 +++++++++- demos/misc/window_management/window_management.scn | Bin 5129 -> 5132 bytes 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd index 5eb5817619..1609dda699 100644 --- a/demos/misc/window_management/control.gd +++ b/demos/misc/window_management/control.gd @@ -1,6 +1,8 @@ extends Control +var mousepos + func _fixed_process(delta): var modetext = "Mode:\n" @@ -31,7 +33,7 @@ func _fixed_process(delta): get_node("Label_Size").set_text(str("Size:\n", OS.get_window_size() ) ) - get_node("Label_MousePosition").set_text(str("Mouse Position:\n", Input.get_mouse_pos() ) ) + get_node("Label_MousePosition").set_text(str("Mouse Position:\n", mousepos ) ) get_node("Label_Screen_Count").set_text( str("Screen_Count:\n", OS.get_screen_count() ) ) @@ -126,6 +128,12 @@ func check_wm_api(): func _ready(): if( check_wm_api() ): set_fixed_process(true) + set_process_input(true) + + +func _input(ev): + if (ev.type==InputEvent.MOUSE_MOTION): + mousepos = ev.pos func _on_Button_MoveTo_pressed(): diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn index c7d6260df6..8db43b6638 100644 Binary files a/demos/misc/window_management/window_management.scn and b/demos/misc/window_management/window_management.scn differ -- cgit v1.2.3 From 786b5e3545ea45557c699d74732d62cbcb2337a0 Mon Sep 17 00:00:00 2001 From: yg2f Date: Thu, 7 May 2015 18:10:30 +0200 Subject: fixes_demo3d_shaders_materials_missing_light add the missing animated light to the demo 3d "shaders materials" --- demos/3d/shader_materials/shader_materials.scn | Bin 5494 -> 6382 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/demos/3d/shader_materials/shader_materials.scn b/demos/3d/shader_materials/shader_materials.scn index d6a3efe73f..243c6c8f06 100644 Binary files a/demos/3d/shader_materials/shader_materials.scn and b/demos/3d/shader_materials/shader_materials.scn differ -- cgit v1.2.3 From 32c0a962491fd6d4125688b03b33efda20f5600d Mon Sep 17 00:00:00 2001 From: yg2f Date: Thu, 7 May 2015 18:29:38 +0200 Subject: add_missing_textures_to_particles --- demos/3d/platformer/coin.scn | Bin 6013 -> 6791 bytes demos/3d/platformer/enemy.scn | Bin 36976 -> 37784 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/demos/3d/platformer/coin.scn b/demos/3d/platformer/coin.scn index 449bb0f895..a4148b4060 100644 Binary files a/demos/3d/platformer/coin.scn and b/demos/3d/platformer/coin.scn differ diff --git a/demos/3d/platformer/enemy.scn b/demos/3d/platformer/enemy.scn index b3f69af600..06d725061d 100644 Binary files a/demos/3d/platformer/enemy.scn and b/demos/3d/platformer/enemy.scn differ -- cgit v1.2.3 From 1a7d370fcf7382a9e248925a7eef12d28e0bb9e3 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 9 May 2015 13:05:34 -0300 Subject: -Corrected DirAccessWindows functions, fixes #1872, properly fixes #791. --- drivers/windows/dir_access_windows.cpp | 36 ++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index f548beaa38..7c81e8e051 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -191,9 +191,9 @@ Error DirAccessWindows::make_dir(String p_dir) { #else - //p_dir=fix_path(p_dir); + p_dir=fix_path(p_dir); - p_dir.replace("/","\\"); + //p_dir.replace("/","\\"); bool success; int err; @@ -250,14 +250,14 @@ bool DirAccessWindows::file_exists(String p_file) { p_file=fix_path(p_file); - p_file.replace("/","\\"); + //p_file.replace("/","\\"); - WIN32_FILE_ATTRIBUTE_DATA fileInfo; + //WIN32_FILE_ATTRIBUTE_DATA fileInfo; DWORD fileAttr; - fileAttr = GetFileAttributesExW(p_file.c_str(), GetFileExInfoStandard, &fileInfo); - if (0 == fileAttr) + fileAttr = GetFileAttributesW(p_file.c_str()); + if (INVALID_FILE_ATTRIBUTES == fileAttr) return false; return !(fileAttr&FILE_ATTRIBUTE_DIRECTORY); @@ -273,17 +273,16 @@ bool DirAccessWindows::dir_exists(String p_dir) { else p_dir=fix_path(p_dir); - p_dir.replace("/","\\"); + //p_dir.replace("/","\\"); - WIN32_FILE_ATTRIBUTE_DATA fileInfo; + //WIN32_FILE_ATTRIBUTE_DATA fileInfo; DWORD fileAttr; - fileAttr = GetFileAttributesExW(p_dir.c_str(), GetFileExInfoStandard, &fileInfo); - if (0 == fileAttr) - return false; - + fileAttr = GetFileAttributesW(p_dir.c_str()); + if (INVALID_FILE_ATTRIBUTES == fileAttr) + return false; return (fileAttr&FILE_ATTRIBUTE_DIRECTORY); } @@ -314,12 +313,15 @@ Error DirAccessWindows::remove(String p_path) { p_path=fix_path(p_path); printf("erasing %s\n",p_path.utf8().get_data()); - WIN32_FILE_ATTRIBUTE_DATA fileInfo; - DWORD fileAttr = GetFileAttributesExW(p_path.c_str(), GetFileExInfoStandard, &fileInfo); - if (fileAttr == INVALID_FILE_ATTRIBUTES) - return FAILED; + //WIN32_FILE_ATTRIBUTE_DATA fileInfo; + //DWORD fileAttr = GetFileAttributesExW(p_path.c_str(), GetFileExInfoStandard, &fileInfo); + + DWORD fileAttr; - if (fileAttr & FILE_ATTRIBUTE_DIRECTORY) + fileAttr = GetFileAttributesW(p_path.c_str()); + if (INVALID_FILE_ATTRIBUTES == fileAttr) + return FAILED; + if ((fileAttr&FILE_ATTRIBUTE_DIRECTORY)) return ::_wrmdir(p_path.c_str())==0?OK:FAILED; else return ::_wunlink(p_path.c_str())==0?OK:FAILED; -- cgit v1.2.3 From 1310e09c737c90b0754b9b4515958b57625631fd Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 9 May 2015 13:11:59 -0300 Subject: corrected copyright date in project manager, fixes #1870 --- tools/editor/project_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index c54e036a85..00956919b7 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -940,7 +940,7 @@ ProjectManager::ProjectManager() { String cp; cp.push_back(0xA9); cp.push_back(0); - l->set_text(cp+" 2008-2014 Juan Linietsky, Ariel Manzur."); + l->set_text(cp+" 2008-2015 Juan Linietsky, Ariel Manzur."); l->set_align(Label::ALIGN_CENTER); vb->add_child(l); -- cgit v1.2.3 From 65d48d6d39452e003381de7e2b0758f6580be197 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 9 May 2015 18:09:58 -0300 Subject: -Added prints() function, fixes #1132, #1859 -Tabs work inside built-in log window, fixes #1867 --- modules/gdscript/gd_functions.cpp | 24 ++++++++++++++++++++++++ modules/gdscript/gd_functions.h | 1 + modules/gdscript/gd_tokenizer.cpp | 2 +- scene/gui/rich_text_label.cpp | 10 ++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index e014921364..37ddb2bc41 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -88,6 +88,7 @@ const char *GDFunctions::get_func_name(Function p_func) { "str", "print", "printt", + "prints", "printerr", "printraw", "var2str", @@ -561,6 +562,22 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_ret=Variant(); + } break; + case TEXT_PRINT_SPACED: { + + String str; + for(int i=0;ioperator String(); + } + + //str+="\n"; + print_line(str); + r_ret=Variant(); + + } break; case TEXT_PRINTERR: { @@ -1251,6 +1268,13 @@ MethodInfo GDFunctions::get_info(Function p_func) { mi.return_val.type=Variant::NIL; return mi; + } break; + case TEXT_PRINT_SPACED: { + + MethodInfo mi("prints",PropertyInfo(Variant::NIL,"what"),PropertyInfo(Variant::NIL,"...")); + mi.return_val.type=Variant::NIL; + return mi; + } break; case TEXT_PRINTERR: { diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gd_functions.h index ecd7d158be..ad35a628d5 100644 --- a/modules/gdscript/gd_functions.h +++ b/modules/gdscript/gd_functions.h @@ -84,6 +84,7 @@ public: TEXT_STR, TEXT_PRINT, TEXT_PRINT_TABBED, + TEXT_PRINT_SPACED, TEXT_PRINTERR, TEXT_PRINTRAW, VAR_TO_STR, diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index 56b283aa32..0745baafe6 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -1036,7 +1036,7 @@ void GDTokenizerText::advance(int p_amount) { ////////////////////////////////////////////////////////////////////////////////////////////////////// -#define BYTECODE_VERSION 3 +#define BYTECODE_VERSION 4 Error GDTokenizerBuffer::set_code_buffer(const Vector & p_buffer) { diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 3489b02598..6b2e5aea78 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -235,6 +235,9 @@ if (m_height > line_height) {\ while (c[end]!=0 && !(end && c[end-1]==' ' && c[end]!=' ')) { int cw = font->get_char_size(c[end],c[end+1]).width; + if (c[end]=='\t') { + cw=tab_size*font->get_char_size(' ').width; + } w+=cw; if (c[end]==' ') { @@ -292,6 +295,9 @@ if (m_height > line_height) {\ int cw=font->get_char_size(c[i],c[i+1]).x; + if (c[i]=='\t') { + cw=tab_size*font->get_char_size(' ').width; + } if (p_click_pos.x-cw/2>pofs) { @@ -332,6 +338,10 @@ if (m_height > line_height) {\ cw=font->draw_char(ci,Point2(pofs,y+lh-(fh-ascent)),c[i],c[i+1],color); } + if (c[i]=='\t') { + cw=tab_size*font->get_char_size(' ').width; + } + //print_line("draw char: "+String::chr(c[i])); -- cgit v1.2.3 From e090c06ae27f737239ae7cf6f8c56747b47506bd Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 9 May 2015 18:17:43 -0300 Subject: particles in navmesh demo are nice again --- demos/3d/navmesh/navmesh.scn | Bin 37856 -> 38129 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/demos/3d/navmesh/navmesh.scn b/demos/3d/navmesh/navmesh.scn index 73df340b1e..1202985dec 100644 Binary files a/demos/3d/navmesh/navmesh.scn and b/demos/3d/navmesh/navmesh.scn differ -- cgit v1.2.3 From d1e4d6e997d2c2f753ee510fcd13dee08b214968 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 9 May 2015 18:29:55 -0300 Subject: -fix clip+center alignment on Button, fixes #1865 --- scene/gui/button.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 57dd29ad07..5b837d699c 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -115,6 +115,8 @@ void Button::_notification(int p_what) { text_ofs.y+=style->get_offset().y; } break; case ALIGN_CENTER: { + if (text_ofs.x<0) + text_ofs.x=0; text_ofs+=icon_ofs; text_ofs+=style->get_offset(); } break; -- cgit v1.2.3 From 9e14f971bc7e6d364d89a34f28e7c0c2017d16f5 Mon Sep 17 00:00:00 2001 From: Antony Date: Sat, 9 May 2015 15:46:59 -0600 Subject: Change windows build to use CFlag /Od so that you get the full debug experience. Without this flag set, Visual Studio lets you use breakpoints, but the watch and locals is pretty much useless. --- platform/windows/detect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 9cdf04797c..298fa3bc78 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -204,7 +204,7 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['/Zi','/DDEBUG_ENABLED','/DDEBUG_MEMORY_ENABLED','/DD3D_DEBUG_INFO','/O1']) + env.Append(CCFLAGS=['/Zi','/DDEBUG_ENABLED','/DDEBUG_MEMORY_ENABLED','/DD3D_DEBUG_INFO','/Od']) env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) env.Append(LINKFLAGS=['/DEBUG']) -- cgit v1.2.3 From 8f4b6ff870d8e608ff056fee8c7043716bdd48d8 Mon Sep 17 00:00:00 2001 From: Nicolas Laurito Date: Sat, 9 May 2015 19:09:30 -0300 Subject: Deleted unused variable Deleted the var GRAVITY because it is unused. The gravity is used at line 237, but it's gotten from the Physics2DDirectBodyState parameter. --- demos/2d/platformer/player.gd | 1 - 1 file changed, 1 deletion(-) diff --git a/demos/2d/platformer/player.gd b/demos/2d/platformer/player.gd index b08105212c..9ee189df21 100644 --- a/demos/2d/platformer/player.gd +++ b/demos/2d/platformer/player.gd @@ -33,7 +33,6 @@ var shooting=false var WALK_ACCEL = 800.0 var WALK_DEACCEL= 800.0 var WALK_MAX_VELOCITY= 200.0 -var GRAVITY = 700.0 var AIR_ACCEL = 200.0 var AIR_DEACCEL= 200.0 var JUMP_VELOCITY=460 -- cgit v1.2.3 From ef8a402f71e92992e236504490a1533fa9f5d2b2 Mon Sep 17 00:00:00 2001 From: Nicolas Laurito Date: Sun, 10 May 2015 00:46:16 -0300 Subject: Remove focus from restart button, fixes #1850 Fixes a problem where the restart button would keep focus after being pressed, making the tetris' pieces impossible to rotate without activating the button again. --- demos/2d/tetris/grid.gd | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/2d/tetris/grid.gd b/demos/2d/tetris/grid.gd index dc89300881..8708d168e4 100644 --- a/demos/2d/tetris/grid.gd +++ b/demos/2d/tetris/grid.gd @@ -143,6 +143,7 @@ func restart_pressed(): cells.clear() get_node("gameover").set_text("") piece_active=true + get_node("../restart").release_focus() update() -- cgit v1.2.3 From bd1e54a8b75348fe948ef92f07a55815cc005b78 Mon Sep 17 00:00:00 2001 From: Hearto Lazor Date: Sun, 10 May 2015 10:00:26 -0400 Subject: - Implemented support for fixed process on timer. Useful for cooldowns without the influence from framerate similar to animation player (idle/fixed mode), where idle mode = old timer, fixed mode = fixed process implementation: Example of the behaviour with a stream of bullets with timers on different frame rates: https://gfycat.com/HeartyImpressiveIndiancow - A change for more uniform ticks on fixed/idle without this fix: http://i.imgur.com/0TMQ6CG.png with this fix: http://i.imgur.com/3zYx16c.png --- scene/main/timer.cpp | 69 +++++++++++++++++++++++++++++++++++++++++++++------- scene/main/timer.h | 14 +++++++++++ 2 files changed, 74 insertions(+), 9 deletions(-) diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index 2e3e7db0ad..3a80382a40 100644 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -45,14 +45,14 @@ void Timer::_notification(int p_what) { } } break; case NOTIFICATION_PROCESS: { - - if (!is_processing()) + if (timer_process_mode == TIMER_PROCESS_FIXED || !is_processing()) return; time_left -= get_process_delta_time(); if (time_left<0) { if (!one_shot) - time_left=wait_time+time_left; + //time_left=wait_time+time_left; + time_left = wait_time; else stop(); @@ -60,13 +60,27 @@ void Timer::_notification(int p_what) { } } break; + case NOTIFICATION_FIXED_PROCESS: { + if (timer_process_mode == TIMER_PROCESS_IDLE || !is_fixed_processing()) + return; + time_left -= get_fixed_process_delta_time(); + + if (time_left<0) { + if (!one_shot) + //time_left = wait_time + time_left; + time_left = wait_time; + else + stop(); + emit_signal("timeout"); + } + + } break; } } void Timer::set_wait_time(float p_time) { - ERR_EXPLAIN("time should be greater than zero."); ERR_FAIL_COND(p_time<=0); wait_time=p_time; @@ -96,14 +110,13 @@ bool Timer::has_autostart() const { } void Timer::start() { - time_left=wait_time; - set_process(true); + _set_process(true); } void Timer::stop() { time_left=-1; - set_process(false); + _set_process(false); autostart=false; } @@ -112,6 +125,41 @@ float Timer::get_time_left() const { return time_left >0 ? time_left : 0; } +void Timer::set_timer_process_mode(TimerProcessMode p_mode) { + + if (timer_process_mode == p_mode) + return; + + switch (timer_process_mode) { + case TIMER_PROCESS_FIXED: + if (is_fixed_processing()) { + set_fixed_process(false); + set_process(true); + } + break; + case TIMER_PROCESS_IDLE: + if (is_processing()) { + set_process(false); + set_fixed_process(true); + } + break; + } + timer_process_mode = p_mode; +} + +Timer::TimerProcessMode Timer::get_timer_process_mode() const{ + + return timer_process_mode; +} + + +void Timer::_set_process(bool p_process, bool p_force) +{ + switch (timer_process_mode) { + case TIMER_PROCESS_FIXED: set_fixed_process(p_process); break; + case TIMER_PROCESS_IDLE: set_process(p_process); break; + } +} void Timer::_bind_methods() { @@ -129,8 +177,12 @@ void Timer::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_time_left"),&Timer::get_time_left); + ObjectTypeDB::bind_method(_MD("set_timer_process_mode", "mode"), &Timer::set_timer_process_mode); + ObjectTypeDB::bind_method(_MD("get_timer_process_mode"), &Timer::get_timer_process_mode); + ADD_SIGNAL( MethodInfo("timeout") ); + ADD_PROPERTY(PropertyInfo(Variant::INT, "process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_timer_process_mode"), _SCS("get_timer_process_mode")); ADD_PROPERTY( PropertyInfo(Variant::REAL, "wait_time", PROPERTY_HINT_EXP_RANGE, "0.01,4096,0.01" ), _SCS("set_wait_time"), _SCS("get_wait_time") ); ADD_PROPERTY( PropertyInfo(Variant::BOOL, "one_shot" ), _SCS("set_one_shot"), _SCS("is_one_shot") ); ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autostart" ), _SCS("set_autostart"), _SCS("has_autostart") ); @@ -138,8 +190,7 @@ void Timer::_bind_methods() { } Timer::Timer() { - - + timer_process_mode = TIMER_PROCESS_IDLE; autostart=false; wait_time=1; one_shot=false; diff --git a/scene/main/timer.h b/scene/main/timer.h index 021638ccfc..4b9cecba84 100644 --- a/scene/main/timer.h +++ b/scene/main/timer.h @@ -46,6 +46,11 @@ protected: static void _bind_methods(); public: + enum TimerProcessMode { + TIMER_PROCESS_FIXED, + TIMER_PROCESS_IDLE, + }; + void set_wait_time(float p_time); float get_wait_time() const; @@ -60,7 +65,16 @@ public: float get_time_left() const; + void set_timer_process_mode(TimerProcessMode p_mode); + TimerProcessMode get_timer_process_mode() const; Timer(); + +private: + TimerProcessMode timer_process_mode; + void _set_process(bool p_process, bool p_force = false); + }; +VARIANT_ENUM_CAST(Timer::TimerProcessMode); + #endif // TIMER_H -- cgit v1.2.3 From 9b692b174b06ebb80d6e5a82309b9c9fc44c797d Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 10 May 2015 15:45:33 -0300 Subject: -convert to subscene keeps signal connections, fixes #1863 --- core/object.cpp | 17 +++++++++++++++++ core/object.h | 1 + scene/main/node.cpp | 36 ++++++++++++++++++++++++++++++++++++ scene/main/node.h | 1 + 4 files changed, 55 insertions(+) diff --git a/core/object.cpp b/core/object.cpp index 07e24655c2..c1904d05d7 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1282,6 +1282,23 @@ void Object::get_signal_list(List *p_signals ) const { } } + +void Object::get_all_signal_connections(List *p_connections) const { + + const StringName *S=NULL; + + while((S=signal_map.next(S))) { + + const Signal *s=&signal_map[*S]; + + for(int i=0;islot_map.size();i++) { + + p_connections->push_back(s->slot_map.getv(i).conn); + } + } + +} + void Object::get_signal_connection_list(const StringName& p_signal,List *p_connections) const { const Signal *s=signal_map.getptr(p_signal); diff --git a/core/object.h b/core/object.h index 44464ab199..fc64b91412 100644 --- a/core/object.h +++ b/core/object.h @@ -574,6 +574,7 @@ public: void emit_signal(const StringName& p_name,VARIANT_ARG_LIST); void get_signal_list(List *p_signals ) const; void get_signal_connection_list(const StringName& p_signal,List *p_connections) const; + void get_all_signal_connections(List *p_connections) const; Error connect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method,const Vector& p_binds=Vector(),uint32_t p_flags=0); void disconnect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index e0181b9238..5c60b9fbff 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1417,6 +1417,41 @@ void Node::_duplicate_and_reown(Node* p_new_parent, const Map& p_re } + +void Node::_duplicate_signals(const Node* p_original,Node* p_copy) const { + + if (this!=p_original && get_owner()!=p_original) + return; + + List conns; + get_all_signal_connections(&conns); + + for (List::Element *E=conns.front();E;E=E->next()) { + + if (E->get().flags&CONNECT_PERSIST) { + //user connected + NodePath p = p_original->get_path_to(this); + Node *copy = p_copy->get_node(p); + + Node *target = E->get().target->cast_to(); + if (!target) + continue; + NodePath ptarget = p_original->get_path_to(target); + Node *copytarget = p_copy->get_node(ptarget); + + if (copy && copytarget) { + copy->connect(E->get().signal,copytarget,E->get().method,E->get().binds,CONNECT_PERSIST); + } + } + } + + for(int i=0;i_duplicate_signals(p_original,p_copy); + } + +} + + Node *Node::duplicate_and_reown(const Map& p_reown_map) const { @@ -1455,6 +1490,7 @@ Node *Node::duplicate_and_reown(const Map& p_reown_map) const { get_child(i)->_duplicate_and_reown(node,p_reown_map); } + _duplicate_signals(this,node); return node; } diff --git a/scene/main/node.h b/scene/main/node.h index 4d0a84d347..be32c4e726 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -126,6 +126,7 @@ private: void _propagate_pause_owner(Node*p_owner); Array _get_node_and_resource(const NodePath& p_path); + void _duplicate_signals(const Node* p_original,Node* p_copy) const; void _duplicate_and_reown(Node* p_new_parent, const Map& p_reown_map) const; Array _get_children() const; Array _get_groups() const; -- cgit v1.2.3 From 421b4fec3e6d50b764227a7f0b76c93c0be0ff46 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 10 May 2015 15:58:08 -0300 Subject: -compatibility option for physicsbody layers, fixes #1842 --- scene/2d/physics_body_2d.cpp | 14 ++++++++++++++ scene/2d/physics_body_2d.h | 5 +++++ tools/editor/plugins/spatial_editor_plugin.cpp | 1 + 3 files changed, 20 insertions(+) diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 9fd4a25e7f..3d2917d843 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -68,18 +68,32 @@ float PhysicsBody2D::get_one_way_collision_max_depth() const{ } +void PhysicsBody2D::_set_layers(uint32_t p_mask) { + + set_layer_mask(p_mask); + set_collision_mask(p_mask); +} + +uint32_t PhysicsBody2D::_get_layers() const{ + + return get_layer_mask(); +} + void PhysicsBody2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody2D::set_layer_mask); ObjectTypeDB::bind_method(_MD("get_layer_mask"),&PhysicsBody2D::get_layer_mask); ObjectTypeDB::bind_method(_MD("set_collision_mask","mask"),&PhysicsBody2D::set_collision_mask); ObjectTypeDB::bind_method(_MD("get_collision_mask"),&PhysicsBody2D::get_collision_mask); + ObjectTypeDB::bind_method(_MD("_set_layers","mask"),&PhysicsBody2D::_set_layers); + ObjectTypeDB::bind_method(_MD("_get_layers"),&PhysicsBody2D::_get_layers); ObjectTypeDB::bind_method(_MD("set_one_way_collision_direction","dir"),&PhysicsBody2D::set_one_way_collision_direction); ObjectTypeDB::bind_method(_MD("get_one_way_collision_direction"),&PhysicsBody2D::get_one_way_collision_direction); ObjectTypeDB::bind_method(_MD("set_one_way_collision_max_depth","depth"),&PhysicsBody2D::set_one_way_collision_max_depth); ObjectTypeDB::bind_method(_MD("get_one_way_collision_max_depth"),&PhysicsBody2D::get_one_way_collision_max_depth); ObjectTypeDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::add_collision_exception_with); ObjectTypeDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::remove_collision_exception_with); + ADD_PROPERTY(PropertyInfo(Variant::INT,"layers",PROPERTY_HINT_ALL_FLAGS,"",0),_SCS("_set_layers"),_SCS("_get_layers")); //for backwards compat ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask")); ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"one_way_collision/direction"),_SCS("set_one_way_collision_direction"),_SCS("get_one_way_collision_direction")); diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index b6be07500f..03f95959b6 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -42,6 +42,11 @@ class PhysicsBody2D : public CollisionObject2D { uint32_t collision_mask; Vector2 one_way_collision_direction; float one_way_collision_max_depth; + + + void _set_layers(uint32_t p_mask); + uint32_t _get_layers() const; + protected: void _notification(int p_what); diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index ac2ea9799e..0b3f3e0626 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -3372,6 +3372,7 @@ void SpatialEditor::_notification(int p_what) { tool_button[SpatialEditor::TOOL_MODE_ROTATE]->set_icon( get_icon("ToolRotate","EditorIcons") ); tool_button[SpatialEditor::TOOL_MODE_SCALE]->set_icon( get_icon("ToolScale","EditorIcons") ); instance_button->set_icon( get_icon("SpatialAdd","EditorIcons") ); + instance_button->hide(); view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT),get_icon("Panels1","EditorIcons")); -- cgit v1.2.3 From a2b8b92a6e8f9bf49c437eaa4b638f7e51b87161 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 10 May 2015 18:14:38 -0300 Subject: -fixed some glitches in isometric light demo, closes #1858 --- demos/2d/isometric_light/cubio.scn | Bin 7003 -> 7006 bytes demos/2d/isometric_light/map.scn | Bin 8634 -> 8661 bytes demos/2d/isometric_light/tileset.res | Bin 2781 -> 2779 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/demos/2d/isometric_light/cubio.scn b/demos/2d/isometric_light/cubio.scn index c52b7dfd4b..fc931b0c8d 100644 Binary files a/demos/2d/isometric_light/cubio.scn and b/demos/2d/isometric_light/cubio.scn differ diff --git a/demos/2d/isometric_light/map.scn b/demos/2d/isometric_light/map.scn index c1d11f8e4c..89002f991f 100644 Binary files a/demos/2d/isometric_light/map.scn and b/demos/2d/isometric_light/map.scn differ diff --git a/demos/2d/isometric_light/tileset.res b/demos/2d/isometric_light/tileset.res index dab6f36f57..f64a4e32bd 100644 Binary files a/demos/2d/isometric_light/tileset.res and b/demos/2d/isometric_light/tileset.res differ -- cgit v1.2.3 From 32b1b472af379b3ea3b155a38158f08aed1e92e1 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 10 May 2015 19:24:09 -0300 Subject: -improved one-way collision handling in both dynamic and character bodies for 2D, fixes #1854 --- servers/physics_2d/body_pair_2d_sw.cpp | 15 ++++++++++++--- servers/physics_2d/body_pair_2d_sw.h | 1 + servers/physics_2d/space_2d_sw.cpp | 7 ++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp index e8d37d346a..6bfed134e6 100644 --- a/servers/physics_2d/body_pair_2d_sw.cpp +++ b/servers/physics_2d/body_pair_2d_sw.cpp @@ -265,7 +265,7 @@ bool BodyPair2DSW::setup(float p_step) { } //faster to set than to check.. - bool prev_collided=collided; + //bool prev_collided=collided; collided = CollisionSolver2DSW::solve(shape_A_ptr,xform_A,motion_A,shape_B_ptr,xform_B,motion_B,_add_contact,this,&sep_axis); if (!collided) { @@ -282,12 +282,18 @@ bool BodyPair2DSW::setup(float p_step) { collided=true; } - if (!collided) + if (!collided) { + oneway_disabled=false; return false; + } } - if (!prev_collided) { + if (oneway_disabled) + return false; + + //if (!prev_collided) { + { if (A->is_using_one_way_collision()) { Vector2 direction = A->get_one_way_collision_direction(); @@ -309,6 +315,7 @@ bool BodyPair2DSW::setup(float p_step) { if (!valid) { collided=false; + oneway_disabled=true; return false; } } @@ -333,6 +340,7 @@ bool BodyPair2DSW::setup(float p_step) { } if (!valid) { collided=false; + oneway_disabled=true; return false; } } @@ -525,6 +533,7 @@ BodyPair2DSW::BodyPair2DSW(Body2DSW *p_A, int p_shape_A,Body2DSW *p_B, int p_sha B->add_constraint(this,1); contact_count=0; collided=false; + oneway_disabled=false; } diff --git a/servers/physics_2d/body_pair_2d_sw.h b/servers/physics_2d/body_pair_2d_sw.h index 2365512036..a7fa287be4 100644 --- a/servers/physics_2d/body_pair_2d_sw.h +++ b/servers/physics_2d/body_pair_2d_sw.h @@ -76,6 +76,7 @@ class BodyPair2DSW : public Constraint2DSW { Contact contacts[MAX_CONTACTS]; int contact_count; bool collided; + bool oneway_disabled; int cc; diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index b38cf0c2df..9b69ab299d 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -655,7 +655,12 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body,const Vector2&p_motion,float p if (col_obj->get_type()==CollisionObject2DSW::TYPE_BODY) { const Body2DSW *body=static_cast(col_obj); - cbk.valid_dir=body->get_one_way_collision_direction(); + + Vector2 cdir = body->get_one_way_collision_direction(); + if (cdir!=Vector2() && p_motion.dot(cdir)<0) + continue; + + cbk.valid_dir=cdir; cbk.valid_depth=body->get_one_way_collision_max_depth(); } else { cbk.valid_dir=Vector2(); -- cgit v1.2.3 From b777bf5ff5c3891daa0f93987ca12d0d7d053c2b Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 11 May 2015 00:40:23 -0300 Subject: -Updated isometric 2d demo to work using the new isometric support, fixes #1849 --- demos/2d/isometric/bastiles.res | Bin 1840 -> 2918 bytes demos/2d/isometric/dungeon.scn | Bin 4721 -> 2841 bytes demos/2d/isometric/tileset.scn | Bin 2305 -> 2565 bytes demos/2d/isometric/troll.scn | Bin 1839 -> 2100 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/demos/2d/isometric/bastiles.res b/demos/2d/isometric/bastiles.res index 2161c88f1e..50f3c78321 100644 Binary files a/demos/2d/isometric/bastiles.res and b/demos/2d/isometric/bastiles.res differ diff --git a/demos/2d/isometric/dungeon.scn b/demos/2d/isometric/dungeon.scn index 58c530d5c5..64efc257c0 100644 Binary files a/demos/2d/isometric/dungeon.scn and b/demos/2d/isometric/dungeon.scn differ diff --git a/demos/2d/isometric/tileset.scn b/demos/2d/isometric/tileset.scn index edb0bc0276..c04ea5382c 100644 Binary files a/demos/2d/isometric/tileset.scn and b/demos/2d/isometric/tileset.scn differ diff --git a/demos/2d/isometric/troll.scn b/demos/2d/isometric/troll.scn index f5d87c3631..19b566fe05 100644 Binary files a/demos/2d/isometric/troll.scn and b/demos/2d/isometric/troll.scn differ -- cgit v1.2.3