From 549d344f0fef5e5748ded69b6a037698ff55f8bc Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 19 Sep 2014 18:39:50 -0300 Subject: [PATCH] Fixing Issues... - #672 (default user:// in $HOME/.godot/app_userdata (linux/osx) and $APPDATA/Godot/app_userdata (Windows) - #676 (draw both tiles and octants in order from top to bottom, left to right ) - #686 (unicode escape sequences work now) - #702 (was not a bug, but a test was added to see if bodies went too far away) --- core/globals.cpp | 1 + core/os/dir_access.cpp | 45 +-- core/os/os.cpp | 2 +- demos/2d/particles/particles.xml | 56 ++-- drivers/unix/os_unix.cpp | 8 +- modules/gdscript/gd_parser.cpp | 8 + modules/gdscript/gd_tokenizer.cpp | 22 +- platform/windows/os_windows.cpp | 6 +- scene/2d/particles_2d.cpp | 8 +- scene/2d/particles_2d.h | 3 +- scene/2d/tile_map.cpp | 20 +- scene/2d/tile_map.h | 8 +- scene/3d/spatial.cpp | 12 +- scene/3d/spatial.h | 1 + scene/gui/text_edit.cpp | 4 +- scene/resources/shader_graph.cpp | 289 ++++++++++++++---- scene/resources/shader_graph.h | 123 ++++---- servers/physics/collision_object_sw.h | 17 +- servers/physics/collision_solver_sw.cpp | 3 + .../editor/plugins/spatial_editor_plugin.cpp | 42 ++- tools/editor/plugins/spatial_editor_plugin.h | 3 + tools/editor/spatial_editor_gizmos.h | 2 +- 22 files changed, 504 insertions(+), 179 deletions(-) diff --git a/core/globals.cpp b/core/globals.cpp index ccda457f46b..5be53fd8538 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -1381,6 +1381,7 @@ Globals::Globals() { set("application/main_scene",""); custom_prop_info["application/main_scene"]=PropertyInfo(Variant::STRING,"application/main_scene",PROPERTY_HINT_FILE,"xml,res,scn,xscn"); set("application/disable_stdout",false); + set("application/use_shared_user_dir",true); key.key.scancode=KEY_RETURN; diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index 496ebdfa279..3ab4d4bb7f6 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -130,35 +130,46 @@ Error DirAccess::make_dir_recursive(String p_dir) { if (p_dir.length() < 1) { return OK; }; + + String full_dir; Globals* g = Globals::get_singleton(); - String cur = normalize_path(g->globalize_path(get_current_dir())); - if (cur[cur.length()-1] != '/') { - cur = cur + "/"; - }; - String dir = normalize_path(g->globalize_path(p_dir)); - if (dir.length() < 1) { - return OK; - }; - if (dir[dir.length()-1] != '/') { - dir = dir + "/"; - }; + if (!p_dir.is_abs_path()) { + //append current - ERR_FAIL_COND_V(dir.find(cur) != 0, FAILED); + String cur = normalize_path(g->globalize_path(get_current_dir())); + if (cur[cur.length()-1] != '/') { + cur = cur + "/"; + }; - String rel = dir.substr(cur.length(), (dir.length() - cur.length())); + full_dir=(cur+"/"+p_dir).simplify_path(); + } else { + //validate and use given + String dir = normalize_path(g->globalize_path(p_dir)); + if (dir.length() < 1) { + return OK; + }; + if (dir[dir.length()-1] != '/') { + dir = dir + "/"; + }; + full_dir=dir; + } + + int slices = full_dir.get_slice_count("/"); int pos = 0; - while (pos < rel.length()) { + while (pos < full_dir.length()) { - int n = rel.find("/", pos); + int n = full_dir.find("/", pos); if (n < 0) { - n = rel.length(); + n = full_dir.length(); }; pos = n + 1; if (pos > 1) { - Error err = make_dir(rel.substr(0, pos -1)); + String to_create = full_dir.substr(0, pos -1); + //print_line("MKDIR: "+to_create); + Error err = make_dir(to_create); if (err != OK && err != ERR_ALREADY_EXISTS) { ERR_FAIL_V(err); diff --git a/core/os/os.cpp b/core/os/os.cpp index 11290409d5e..819ecd2f229 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -386,7 +386,7 @@ void OS::_ensure_data_dir() { } da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - Error err = da->make_dir(dd); + Error err = da->make_dir_recursive(dd); if (err!=OK) { ERR_EXPLAIN("Error attempting to create data dir: "+dd); } diff --git a/demos/2d/particles/particles.xml b/demos/2d/particles/particles.xml index 56cd1aba06d..c8f7596b86d 100644 --- a/demos/2d/particles/particles.xml +++ b/demos/2d/particles/particles.xml @@ -1,21 +1,21 @@ - - - - + + + + "names" - + "Node" + "_import_path" "__meta__" "Fire" "Particles2D" - "process/process" "visibility/visible" "visibility/opacity" "visibility/self_opacity" - "visibility/on_top" + "visibility/behind_parent" "visibility/blend_mode" "transform/pos" "transform/rot" @@ -30,6 +30,8 @@ "config/half_extents" "config/local_space" "config/explosiveness" + "config/flip_h" + "config/flip_v" "config/texture" "params/direction" "params/spread" @@ -41,6 +43,7 @@ "params/radial_accel" "params/tangential_accel" "params/damping" + "params/initial_angle" "params/initial_size" "params/final_size" "params/hue_variation" @@ -54,6 +57,7 @@ "randomness/radial_accel" "randomness/tangential_accel" "randomness/damping" + "randomness/initial_angle" "randomness/initial_size" "randomness/final_size" "randomness/hue_variation" @@ -79,7 +83,8 @@ "node_count" 6 "variants" - + + "" "__editor_plugin_states__" @@ -88,9 +93,13 @@ "pixel_snap" False "zoom" - 0.598737 + 0.440127 + "use_snap" + False "ofs" - 15.9452, 2.06145 + -193.367, -173.288 + "snap" + 10 "3D" @@ -181,6 +190,7 @@ True 1 + False 1 165.787, 527.801 -179.790649 @@ -189,13 +199,13 @@ 0 0, 0 15, 15 - False - + 20 180 80 0.7 0.3 + 2 3 1, 1, 1, 0 0.1 @@ -206,7 +216,7 @@ 377.396, 543.147 176.575912 4 - + 20.907272 47.151516 3 @@ -214,30 +224,36 @@ 1, 1, 1, 1 0, 0, 0, 0 593.848, 531.064 - 2 40, 40 - + + 0.01 9.8 15.515152 - 1, 0.477876, 0.60177, 1 + 45 + 100 + 4 + 1, 1, 1, 0.870518 + 1, 0.47451, 0.6, 1 0.5 - 0.533333, 0.752212, 1, 1 - 0, 1, 0.699115, 0 + 0.529412, 0.74902, 1, 1 + 0, 1, 0.698039, 0 613.467, 182.62 0.05 184.546997 366.300415 - 4 0.886275, 0.401015, 0, 1 1, 0.679866, 0.432123, 0.12654 192.975, 141.598 170 128, 128 0 + 1, 0.477876, 0.60177, 1 + 0.533333, 0.752212, 1, 1 + 0, 1, 0.699115, 0 -0.125, -0.03125, 0.65625, -0.148438, 0.609375, 0.0234375, -0.757812, 0.375, 0.265625, 0.078125, 0.632812, 0.382812, 0.671875, 0.414062, 0.367188, -0.226562, 0.75, -0.125, 0.4375, 0.421875, 0.335938, -0.148438, -0.125, 0.257812, -0.171875, 0.359375, -0.601562, -0.265625, 0.375, 0.382812, -0.296875, 0.09375, -0.664062, -0.21875, -0.554688, -0.226562, -0.320312, 0.367188, -0.320312, -0.257812, 0, -0.257812, 0.578125, -0.25, -0.164062, 0.109375, -0.578125, -0.015625, -0.445312, 0, 0.273438, 0.101562, 0.320312, 0.03125, -0.125, 0.0703125, -0.570312, 0.289062, 0.257812, -0.09375, -0.585938, 0.179688, -0.664062, 0.0234375, -0.25, -0.0859375, 0.6875, -0.109375, 0.234375, 0, -0.5, -0.265625, 0.710938, 0.335938, 0.609375, -0.046875, 0.664062, -0.210938, -0.242188, -0.21875, -0.484375, -0.257812, -0.453125, 0.414062, 0.609375, -0.203125, 0.289062, 0.132812, -0.03125, -0.257812, -0.492188, -0.1875, 0.5625, -0.140625, -0.5625, 0.148438, -0.257812, -0.234375, -0.140625, 0.15625, -0.5625, 0.109375, 0.132812, 0.398438, -0.640625, -0.25, -0.585938, 0.304688, -0.328125, -0.257812, 0.226562, 0.148438, -0.546875, 0.210938, 0.625, 0.179688, 0.648438, -0.0078125, 0.367188, 0.328125, 0.265625, 0.0546875, -0.59375, -0.273438, -0.203125, 0.21875, 0.570312, -0.21875, -0.695312, 0.078125, -0.375, 0.03125, -0.164062, 0.0390625, 0.265625, 0.226562, -0.625, -0.109375, 0.203125, -0.132812, -0.671875, 0.328125, 0.625, -0.179688, -0.640625, 0.0859375, 0.65625, 0, -0.242188, 0.414062, 0.242188, 0.25, -0.148438, -0.0625, 0.390625, -0.25, 0.664062, 0.351562, 0.320312, 0.203125, -0.546875, 0.335938, 0.328125, -0.148438, 0.609375, -0.0625, -0.171875, 0.046875, -0.578125, 0.0546875, -0.304688, -0.28125, 0.734375, -0.0546875, 0.679688, 0.390625, -0.460938, 0.0859375, -0.703125, 0.101562, -0.140625, 0.234375, -0.507812, 0.078125, -0.25, 0.304688, -0.046875, 0.359375, 0.1875, 0.0703125, -0.570312, 0.242188, 0.65625, 0.0859375, -0.203125, -0.265625, -0.164062, -0.179688, 0.367188, -0.1875, -0.601562, -0.101562, -0.117188, -0.210938, -0.546875, 0.109375, -0.585938, -0.28125, -0.59375, -0.03125, 0.3125, -0.179688, 0.414062, 0.429688, -0.476562, -0.195312, -0.0703125, -0.21875, -0.5625, 0.304688, -0.609375, 0.226562, 0.429688, 0.429688, 0.203125, 0.242188, 0.078125, 0.367188, 0.242188, 0.03125, 0.601562, -0.0390625, 0.328125, 0.03125, -0.53125, -0.195312, -0.53125, -0.210938, 0.3125, -0.257812, 0.445312, -0.273438, 0.273438, -0.273438, -0.695312, -0.179688, 0.234375, -0.15625, -0.546875, -0.242188, -0.234375, -0.125, 0.734375, -0.226562, 0.367188, -0.234375, -0.15625, 0.046875, -0.445312, -0.226562, 0.625, 0.03125, -0.0859375, 0.210938, -0.648438, 0.296875, 0.335938, -0.109375, 0.625, -0.078125, 0.601562, 0.351562, 0.242188, 0.140625, 0.0234375, -0.273438, -0.679688, -0.109375, 0.640625, 0.15625, 0.171875, 0.0859375, -0.273438, -0.273438, -0.242188, 0.34375, 0.179688, 0.15625, -0.179688, -0.117188, 0.671875, 0.03125, -0.640625, 0.304688, 0.109375, -0.242188, -0.210938, 0.382812, -0.0859375, 0.0078125, -0.695312, 0.078125, 0.296875, 0.320312, 0.304688, -0.226562, 0.257812, -0.0234375, -0.203125, -0.015625, -0.648438, 0.335938, -0.703125, -0.132812, -0.273438, -0.210938, -0.15625, -0.273438, -0.0390625, 0.335938, 0.617188, 0.179688, 0.34375, 0.390625, -0.210938, -0.132812, -0.226562, -0.117188, 0.617188, -0.289062, 0.125, -0.21875, 0.71875, -0.164062, -0.570312, 0.1875, -0.1875, 0.382812, 0.640625, -0.296875, -0.125, 0.109375, 0.671875, 0.289062, -0.515625, 0.382812, 0.359375, -0.179688, 0.726562, -0.226562, 0.25, 0.320312, -0.328125, 0, -0.117188, -0.234375, -0.210938, -0.148438, -0.546875, -0.117188, 0.359375, 0.429688, -0.15625, -0.226562, 0.632812, -0.257812, -0.28125, -0.273438, 0.265625, 0.015625, -0.765625, 0.351562, 0.703125, 0.421875, -0.585938, 0.0078125, 0.28125, 0.109375, 0.304688, 0.171875, 0.65625, 0.421875, 0.078125, 0.382812, 0.179688, 0.25, -0.382812, 0.0703125, 0.585938, -0.140625, -0.109375, 0.382812, -0.59375, -0.09375, 0.4375, 0.398438, -0.132812, 0.0234375, -0.625, 0.0078125, -0.210938, -0.21875, -0.25, 0.257812, 0.257812, 0.398438, 0.625, 0.195312, 0.148438, -0.234375, -0.476562, 0.398438, -0.210938, 0.046875, 0.695312, -0.101562, 0.695312, 0.140625, -0.492188, -0.1875, 0.25, -0.09375, -0.195312, -0.195312, -0.328125, 0.0703125, -0.242188, -0.0625, 0.296875, 0.34375, -0.632812, 0.0078125, -0.265625, 0.09375, 0.421875, -0.203125, 0.171875, 0.03125, -0.09375, -0.0703125, 0.289062, 0.0859375, -0.609375, 0.390625, -0.554688, 0.257812, -0.6875, 0.0078125, 0.304688, 0.414062, 0.226562, 0.390625, -0.21875, -0.28125, 0.265625, 0.320312, -0.671875, 0.234375, -0.210938, 0.03125, 0.679688, -0.0234375, 0.359375, -0.203125, 0.3125, 0.289062, 0.671875, 0.140625, -0.78125, 0.414062, -0.546875, 0.40625, 0.625, 0.367188, 0.0859375, 0.421875, 0.1875, -0.09375, 0.617188, 0.40625, -0.078125, -0.0390625, 0.695312, 0.0859375, -0.6875, -0.265625, 0.421875, -0.265625, 0.601562, -0.0234375, -0.3125, -0.265625, -0.078125, 0.046875, 0.617188, 0.164062, 0.273438, -0.03125, -0.695312, -0.015625, -0.5625, 0.164062, -0.578125, 0.265625, -0.726562, 0.421875, -0.078125, -0.25, -0.171875, 0.171875, -0.234375, -0.0390625, 0.257812, 0.429688, -0.179688, -0.117188, 0.351562, -0.03125, -0.78125, -0.234375, -0.546875, -0.171875, -0.460938, -0.234375, -0.164062, 0.09375, -0.65625, 0.398438, -0.445312, 0.0859375, -0.71875, -0.226562, 0.671875, 0.101562, -0.46875, -0.195312, -0.71875, -0.265625, 0.617188, 0.125, -0.78125, -0.21875, -0.226562, -0.15625, 0.21875, 0.0234375, 0.289062, 0.101562, 0.648438, -0.171875, 0.390625, -0.273438, -0.257812, 0.078125, -0.21875, 0, 0.65625, -0.203125, -0.679688, 0.171875, -0.1875, 0.328125, -0.46875, -0.28125, 0.273438, 0, 0.664062, 0.296875, -0.140625, 0.335938, -0.625, 0.382812, -0.34375, -0.21875, -0.171875, -0.25, -0.546875, -0.117188, -0.117188, -0.203125, -0.1875, 0.351562, -0.585938, -0.109375, -0.203125, -0.0625, -0.570312, 0.03125, -0.5625, -0.109375, 0.601562, -0.195312, 0.3125, 0.140625, -0.101562, 0.25, 0.25, 0.3125, 0.125, -0.203125, -0.09375, -0.140625, -0.242188, 0.414062, 0.664062, -0.0625, -0.21875, -0.078125, 0.6875, -0.210938, -0.140625, 0.015625, -0.632812, -0.25, -0.109375, 0.234375, -0.695312, 0.015625, -0.3125, -0.28125, 0.296875, -0.0234375, 0.296875, 0.203125, -0.125, 0.234375, 0.570312, 0.390625, -0.554688, 0.203125, -0.5625, 0.351562, -0.15625, 0.21875, -0.375, 0.0390625, -0.226562, -0.140625, 0.695312, 0.164062, 0.632812, 0.367188, -0.328125, -0.210938, -0.59375, 0.34375, 0.304688, -0.242188, -0.34375, 0.0703125, -0.679688, -0.179688, 0.664062, 0.101562, 0.34375, 0.171875, -0.695312, -0.078125, -0.242188, -0.0546875, 0.304688, -0.234375, -0.0078125, -0.21875, -0.632812, 0.203125, 0.625, 0.03125, -0.414062, 0.015625, 0.273438, -0.078125, 0.695312, 0.28125, 0.34375, 0.101562, -0.164062, 0.289062, -0.1875, 0.273438, -0.203125, 0.0703125, 0.734375, -0.171875, -0.59375, 0.34375, -0.15625, 0.210938, 0.429688, 0.375, -0.234375, 0.34375, 0.617188, 0.101562, 0.703125, 0, -0.578125, 0.148438, 0.21875, -0.171875, -0.304688, 0.375, -0.65625, -0.09375, -0.101562, 0.25, -0.4375, 0.03125, -0.242188, 0.421875, -0.546875, 0.0625, -0.632812, -0.148438, -0.125, 0.179688, 0.179688, 0.304688, -0.265625, 0.078125, -0.289062, 0.421875, -0.585938, 0.1875, -0.289062, 0.34375, 0.273438, 0.367188, -0.109375, 0.117188, 0.34375, 0.046875, -0.0625, 0.320312, 0.6875, -0.234375, -0.523438, 0.320312, -0.09375, -0.242188, -0.65625, 0.25, -0.609375, -0.117188, -0.140625, 0.140625, 0.28125, -0.09375, -0.625, -0.28125, 0.34375, 0.328125, 0.265625, 0.109375, -0.609375, 0.0078125, -0.078125, -0.234375, -0.289062, -0.203125, 0.289062, 0.289062, -0.0859375, 0.0078125, -0.101562, -0.28125, -0.625, -0.101562, -0.546875, 0.382812, -0.539062, -0.195312, -0.210938, 0.046875, -0.492188, 0.390625, -0.664062, -0.0703125, 0.71875, -0.101562, -0.140625, -0.046875, 0.695312, 0.289062, -0.710938, 0.429688, -0.703125, 0.3125, -0.203125, 0.109375, 0.421875, -0.273438, 0.304688, 0.21875, 0.328125, 0.257812, -0.632812, -0.0703125, 0.320312, -0.140625, 0.265625, -0.203125, -0.109375, -0.179688, 0.25, -0.210938, 0.65625, 0.109375, -0.648438, -0.0625, -0.0859375, 0.375, -0.429688, 0.398438, 0.320312, 0.3125, -0.0703125, 0.265625, 0.648438, 0.0078125, 0.320312, 0.335938, 0.398438, 0.421875, -0.101562, -0.0625, -0.296875, 0.40625, 0.695312, -0.0390625, 0.335938, 0.21875, -0.546875, 0.117188, -0.476562, 0.390625, -0.648438, 0.117188, -0.078125, -0.28125, 0.328125, 0.289062, -0.226562, 0.179688, 0.226562, 0.375, -0.429688, 0.382812, -0.0546875, 0.34375, 0.59375, -0.125, 0.632812, 0.265625, 0.226562, 0.3125, -0.523438, -0.140625, -0.546875, 0.046875, 0.242188, -0.148438, -0.648438, 0.0234375, -0.289062, 0, -0.546875, 0.101562, -0.125, -0.0625, -0.492188, 0.367188, 0.328125, 0.15625, -0.351562, 0.0546875, -0.609375, 0.414062, -0.296875, 0.09375, 0.671875, -0.203125, -0.257812, -0.273438, -0.335938, 0.414062, 0.65625, -0.195312, -0.601562, -0.101562, -0.203125, -0.078125, 0.210938, 0.242188, 0.296875, 0.335938, -0.578125, 0.40625, -0.664062, -0.078125, -0.0859375, 0.390625, 0.171875, 0.304688, -0.6875, 0.390625, -0.554688, 0.0078125, -0.570312, -0.179688, -0.210938, -0.09375, 0.726562, -0.03125, -0.546875, -0.0859375, -0.265625, -0.171875, -0.65625, 0.179688, -0.171875, 0.257812, -0.164062, -0.171875, 0.203125, 0.335938, -0.640625, 0.21875, 0.390625, 0.375, 0.6875, -0.234375, 0.742188, 0.34375, -0.0546875, 0.351562, -0.632812, 0.195312, 0.671875, -0.21875, 0.195312, 0.015625, 0.226562, 0.117188, -0.507812, 0.078125, -0.140625, -0.15625, 0.703125, -0.28125, 0.226562, -0.140625, 0.328125, 0.421875, 0.3125, 0.1875, 0.703125, 0.078125, 0.351562, 0.289062, 0.21875, -0.242188, -0.328125, 0, 0.171875, 0.101562, -0.304688, -0.242188, -0.210938, 0.078125, 0.625, -0.0078125, 0.25, 0.242188, -0.664062, 0.117188, 0.203125, -0.140625, 0.226562, 0.429688, 0.328125, -0.203125, -0.679688, 0.0703125, -0.195312, -0.148438, -0.523438, 0.328125, 0.382812, -0.257812, 0.578125, -0.171875, 0.65625, 0.320312, -0.632812, -0.148438, 0.703125, 0.0703125, -0.53125, 0.398438, -0.414062, 0.03125, -0.0859375, 0.0546875, -0.53125, 0.335938, 0.304688, 0.429688, -0.234375, -0.148438, -0.375, 0.046875, -0.148438, 0.289062, -0.0390625, 0.421875, 0.226562, -0.125, -0.570312, 0.398438, -0.0703125, -0.0234375, 0.257812, -0.132812 "nodes" - -1, -1, 0, 0, -1, 1, 1, 0, 0, 0, 0, 3, 2, -1, 56, 4, 1, 5, 1, 6, 2, 7, 2, 8, 1, 9, 3, 10, 4, 11, 5, 12, 6, 13, 7, 14, 2, 15, 2, 16, 8, 17, 8, 18, 1, 19, 9, 20, 10, 21, 11, 22, 2, 23, 12, 24, 8, 25, 8, 26, 13, 27, 8, 28, 8, 29, 14, 30, 15, 31, 8, 32, 8, 33, 8, 34, 16, 35, 17, 36, 8, 37, 8, 38, 8, 39, 8, 40, 8, 41, 8, 42, 8, 43, 8, 44, 8, 45, 8, 46, 8, 47, 8, 48, 8, 49, 8, 50, 18, 51, 8, 52, 19, 53, 20, 54, 21, 55, 2, 56, 22, 57, 2, 58, 23, 59, 24, 0, 0, 0, 3, 60, -1, 55, 4, 1, 5, 1, 6, 2, 7, 2, 8, 1, 10, 25, 11, 26, 12, 6, 13, 7, 14, 27, 15, 2, 16, 8, 17, 8, 18, 1, 19, 9, 20, 9, 21, 11, 22, 2, 23, 28, 24, 8, 25, 29, 26, 30, 27, 2, 28, 8, 29, 8, 30, 8, 31, 8, 32, 8, 33, 8, 34, 2, 35, 31, 36, 8, 37, 8, 38, 8, 39, 8, 40, 2, 41, 8, 42, 8, 43, 8, 44, 8, 45, 8, 46, 8, 47, 8, 48, 8, 49, 8, 50, 18, 51, 8, 52, 19, 53, 32, 54, 33, 55, 2, 56, 34, 57, 2, 58, 23, 59, 24, 0, 0, 0, 3, 61, -1, 55, 4, 1, 5, 1, 6, 2, 7, 2, 8, 1, 10, 35, 11, 8, 12, 6, 13, 7, 14, 36, 15, 2, 16, 8, 17, 8, 18, 1, 19, 9, 20, 37, 21, 11, 22, 2, 23, 38, 24, 8, 25, 14, 26, 13, 27, 17, 28, 8, 29, 8, 30, 39, 31, 8, 32, 40, 33, 8, 34, 31, 35, 2, 36, 8, 37, 8, 38, 8, 39, 8, 40, 2, 41, 8, 42, 8, 43, 8, 44, 8, 45, 8, 46, 8, 47, 8, 48, 8, 49, 8, 50, 18, 51, 8, 52, 41, 53, 42, 54, 43, 55, 2, 56, 44, 57, 2, 58, 23, 59, 24, 0, 0, 0, 3, 62, -1, 56, 4, 1, 5, 1, 6, 2, 7, 2, 8, 11, 9, 3, 10, 45, 11, 5, 12, 6, 13, 7, 14, 36, 15, 36, 16, 8, 17, 8, 18, 1, 19, 9, 20, 10, 21, 11, 22, 46, 23, 28, 24, 8, 25, 14, 26, 47, 27, 8, 28, 8, 29, 14, 30, 15, 31, 8, 32, 8, 33, 48, 34, 16, 35, 31, 36, 8, 37, 8, 38, 8, 39, 8, 40, 8, 41, 8, 42, 8, 43, 8, 44, 8, 45, 8, 46, 8, 47, 8, 48, 8, 49, 8, 50, 49, 51, 8, 52, 19, 53, 20, 54, 50, 55, 16, 56, 51, 57, 2, 58, 34, 59, 24, 0, 0, 0, 3, 63, -1, 55, 4, 1, 5, 1, 6, 2, 7, 2, 8, 1, 10, 52, 11, 8, 12, 6, 13, 53, 14, 20, 15, 2, 16, 8, 17, 8, 18, 1, 19, 9, 20, 54, 21, 11, 22, 2, 23, 38, 24, 8, 25, 14, 26, 8, 27, 36, 28, 8, 29, 8, 30, 8, 31, 8, 32, 8, 33, 8, 34, 2, 35, 2, 36, 8, 37, 8, 38, 8, 39, 8, 40, 2, 41, 8, 42, 8, 43, 8, 44, 8, 45, 8, 46, 8, 47, 8, 48, 8, 49, 8, 50, 55, 51, 8, 52, 41, 53, 42, 54, 43, 55, 2, 56, 44, 57, 2, 58, 23, 59, 56, 0 + -1, -1, 0, 0, -1, 2, 1, 0, 2, 1, 0, 0, 0, 4, 3, -1, 60, 1, 0, 5, 2, 6, 3, 7, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12, 8, 13, 9, 14, 3, 15, 3, 16, 10, 17, 10, 18, 2, 19, 11, 20, 12, 21, 4, 22, 3, 23, 4, 24, 4, 25, 13, 26, 10, 27, 10, 28, 14, 29, 10, 30, 10, 31, 15, 32, 16, 33, 10, 34, 10, 35, 10, 36, 15, 37, 17, 38, 18, 39, 10, 40, 10, 41, 10, 42, 10, 43, 10, 44, 10, 45, 10, 46, 10, 47, 10, 48, 10, 49, 10, 50, 19, 51, 10, 52, 10, 53, 10, 54, 20, 55, 10, 56, 21, 57, 22, 58, 23, 59, 3, 60, 24, 61, 3, 62, 25, 63, 26, 0, 0, 0, 4, 64, -1, 59, 1, 0, 5, 2, 6, 3, 7, 3, 8, 4, 10, 27, 11, 28, 12, 8, 13, 9, 14, 29, 15, 3, 16, 10, 17, 10, 18, 2, 19, 11, 20, 11, 21, 4, 22, 3, 23, 4, 24, 4, 25, 30, 26, 10, 27, 31, 28, 32, 29, 3, 30, 10, 31, 10, 32, 10, 33, 10, 34, 10, 35, 10, 36, 15, 37, 3, 38, 33, 39, 10, 40, 10, 41, 10, 42, 10, 43, 3, 44, 10, 45, 10, 46, 10, 47, 10, 48, 10, 49, 10, 50, 3, 51, 10, 52, 10, 53, 10, 54, 20, 55, 10, 56, 21, 57, 34, 58, 35, 59, 3, 60, 36, 61, 3, 62, 25, 63, 26, 0, 0, 0, 4, 65, -1, 59, 1, 0, 5, 2, 6, 3, 7, 3, 8, 4, 10, 37, 11, 10, 12, 8, 13, 9, 14, 19, 15, 3, 16, 10, 17, 10, 18, 2, 19, 11, 20, 38, 21, 4, 22, 3, 23, 4, 24, 4, 25, 39, 26, 10, 27, 15, 28, 14, 29, 18, 30, 40, 31, 10, 32, 41, 33, 10, 34, 42, 35, 10, 36, 43, 37, 33, 38, 3, 39, 10, 40, 10, 41, 10, 42, 10, 43, 3, 44, 44, 45, 10, 46, 10, 47, 10, 48, 10, 49, 10, 50, 3, 51, 10, 52, 10, 53, 10, 54, 45, 55, 10, 56, 46, 57, 22, 58, 47, 59, 48, 60, 49, 61, 3, 62, 50, 63, 26, 0, 0, 0, 4, 66, -1, 60, 1, 0, 5, 2, 6, 3, 7, 3, 8, 2, 9, 5, 10, 51, 11, 7, 12, 8, 13, 9, 14, 19, 15, 19, 16, 10, 17, 10, 18, 2, 19, 11, 20, 12, 21, 4, 22, 52, 23, 4, 24, 4, 25, 30, 26, 10, 27, 15, 28, 53, 29, 10, 30, 10, 31, 15, 32, 16, 33, 10, 34, 10, 35, 54, 36, 3, 37, 17, 38, 33, 39, 10, 40, 10, 41, 10, 42, 10, 43, 10, 44, 10, 45, 10, 46, 10, 47, 10, 48, 10, 49, 10, 50, 10, 51, 10, 52, 10, 53, 10, 54, 45, 55, 10, 56, 21, 57, 22, 58, 55, 59, 17, 60, 56, 61, 3, 62, 36, 63, 26, 0, 0, 0, 4, 67, -1, 59, 1, 0, 5, 2, 6, 3, 7, 3, 8, 4, 10, 57, 11, 10, 12, 8, 13, 58, 14, 22, 15, 3, 16, 10, 17, 10, 18, 2, 19, 11, 20, 59, 21, 4, 22, 3, 23, 4, 24, 4, 25, 39, 26, 10, 27, 15, 28, 10, 29, 19, 30, 10, 31, 10, 32, 10, 33, 10, 34, 10, 35, 10, 36, 3, 37, 3, 38, 3, 39, 10, 40, 10, 41, 10, 42, 10, 43, 3, 44, 10, 45, 10, 46, 10, 47, 10, 48, 10, 49, 10, 50, 10, 51, 10, 52, 10, 53, 10, 54, 60, 55, 10, 56, 61, 57, 48, 58, 62, 59, 3, 60, 63, 61, 3, 62, 25, 63, 64, 0 "conns" diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 1af37e2a60d..ef4cf644fdc 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -382,9 +382,15 @@ String OS_Unix::get_data_dir() const { String an = Globals::get_singleton()->get("application/name"); if (an!="") { + + if (has_environment("HOME")) { - return get_environment("HOME")+"/."+an; + bool use_godot = Globals::get_singleton()->get("application/use_shared_user_dir"); + if (use_godot) + return get_environment("HOME")+"/.godot/app_userdata/"+an; + else + return get_environment("HOME")+"/."+an; } } diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index ef9e85a8c22..143a81d48a1 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -2089,6 +2089,7 @@ void GDParser::_parse_class(ClassNode *p_class) { current_export=PropertyInfo(); _set_error("Expected a string constant in enumeration hint."); + return; } String c = tokenizer->get_token_constant(); @@ -2106,6 +2107,7 @@ void GDParser::_parse_class(ClassNode *p_class) { if (tokenizer->get_token()!=GDTokenizer::TK_COMMA) { current_export=PropertyInfo(); _set_error("Expected ')' or ',' in enumeration hint."); + return; } tokenizer->advance(); @@ -2122,6 +2124,7 @@ void GDParser::_parse_class(ClassNode *p_class) { current_export=PropertyInfo(); _set_error("Expected a range in numeric hint."); + return; } //enumeration @@ -2139,6 +2142,7 @@ void GDParser::_parse_class(ClassNode *p_class) { current_export=PropertyInfo(); _set_error("Expected ',' or ')' in numeric range hint."); + return; } tokenizer->advance(); @@ -2147,6 +2151,7 @@ void GDParser::_parse_class(ClassNode *p_class) { current_export=PropertyInfo(); _set_error("Expected a number as upper bound in numeric range hint."); + return; } current_export.hint_string+=","+tokenizer->get_token_constant().operator String(); @@ -2159,6 +2164,7 @@ void GDParser::_parse_class(ClassNode *p_class) { current_export=PropertyInfo(); _set_error("Expected ',' or ')' in numeric range hint."); + return; } tokenizer->advance(); @@ -2167,6 +2173,7 @@ void GDParser::_parse_class(ClassNode *p_class) { current_export=PropertyInfo(); _set_error("Expected a number as step in numeric range hint."); + return; } current_export.hint_string+=","+tokenizer->get_token_constant().operator String(); @@ -2185,6 +2192,7 @@ void GDParser::_parse_class(ClassNode *p_class) { current_export=PropertyInfo(); _set_error("Expected a string constant in enumeration hint."); + return; } String c = tokenizer->get_token_constant(); diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index f73c895d74d..bd0beb31384 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -565,22 +565,21 @@ void GDTokenizerText::_advance() { case '\'': res='\''; break; case '\"': res='\"'; break; case '\\': res='\\'; break; - case 'x': { - //hexnumbarh - oct is deprecated + case '/': res='/'; break; //wtf - int read=0; + case 'u': { + //hexnumbarh - oct is deprecated + i+=1; for(int j=0;j<4;j++) { CharType c = GETCHAR(i+j); if (c==0) { _make_error("Unterminated String"); return; } - if (!_is_hex(c)) { - if (j==0 || !(j&1)) { - _make_error("Malformed hex constant in string"); - return; - } else - break; + if (!((c>='0' && c<='9') || (c>='a' && c<='f') || (c>='A' && c<='F'))) { + + _make_error("Malformed hex constant in string"); + return; } CharType v; if (c>='0' && c<='9') { @@ -599,10 +598,9 @@ void GDTokenizerText::_advance() { res<<=4; res|=v; - read++; - } - i+=read-1; + } + i+=3; } break; default: { diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 7f86f3bb984..a12cd674038 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1835,7 +1835,11 @@ String OS_Windows::get_data_dir() const { if (has_environment("APPDATA")) { - return (OS::get_singleton()->get_environment("APPDATA")+"\\"+an).replace("\\","/"); // windows path to unix path to be consistent with get_resource_path + bool use_godot = Globals::get_singleton()->get("application/use_shared_user_dir"); + if (use_godot) + return (OS::get_singleton()->get_environment("APPDATA")+"/"+an).replace("\\","/"); + else + return (OS::get_singleton()->get_environment("APPDATA")+"/Godot/app_userdata/"+an).replace("\\","/"); } } diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index 3d7aa58c6d3..4aa6151df38 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -352,7 +352,7 @@ void Particles2D::_process_particles(float p_delta) { p.velocity*=param[PARAM_LINEAR_VELOCITY]+param[PARAM_LINEAR_VELOCITY]*_rand_from_seed(&rand_seed)*randomness[PARAM_LINEAR_VELOCITY]; p.velocity+=initial_velocity; p.active=true; - p.rot=0; + p.rot=Math::deg2rad(param[PARAM_INITIAL_ANGLE]+param[PARAM_INITIAL_ANGLE]*randomness[PARAM_INITIAL_ANGLE]*_rand_from_seed(&rand_seed)); active_count++; @@ -632,6 +632,7 @@ static const char* _particlesframe_property_names[Particles2D::PARAM_MAX]={ "params/radial_accel", "params/tangential_accel", "params/damping", + "params/initial_angle", "params/initial_size", "params/final_size", "params/hue_variation" @@ -647,7 +648,8 @@ static const char* _particlesframe_property_rnames[Particles2D::PARAM_MAX]={ "randomness/gravity_strength", "randomness/radial_accel", "randomness/tangential_accel", - "randomness/damping", + "randomness/damping", + "randomness/initial_angle", "randomness/initial_size", "randomness/final_size", "randomness/hue_variation" @@ -664,6 +666,7 @@ static const char* _particlesframe_property_ranges[Particles2D::PARAM_MAX]={ "-128,128,0.01", "-128,128,0.01", "0,1024,0.001", + "0,360,0.01", "0,1024,0.01", "0,1024,0.01", "0,1,0.01" @@ -1041,6 +1044,7 @@ Particles2D::Particles2D() { set_param(PARAM_GRAVITY_STRENGTH,9.8); set_param(PARAM_RADIAL_ACCEL,0); set_param(PARAM_TANGENTIAL_ACCEL,0); + set_param(PARAM_INITIAL_ANGLE,0.0); set_param(PARAM_INITIAL_SIZE,1.0); set_param(PARAM_FINAL_SIZE,1.0); diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h index f562e826e08..47bd078a7af 100644 --- a/scene/2d/particles_2d.h +++ b/scene/2d/particles_2d.h @@ -87,7 +87,7 @@ public: enum Parameter { PARAM_DIRECTION, PARAM_SPREAD, - PARAM_LINEAR_VELOCITY, + PARAM_LINEAR_VELOCITY, PARAM_SPIN_VELOCITY, PARAM_ORBIT_VELOCITY, PARAM_GRAVITY_DIRECTION, @@ -95,6 +95,7 @@ public: PARAM_RADIAL_ACCEL, PARAM_TANGENTIAL_ACCEL, PARAM_DAMPING, + PARAM_INITIAL_ANGLE, PARAM_INITIAL_SIZE, PARAM_FINAL_SIZE, PARAM_HUE_VARIATION, diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index c4879cf0652..d32c6df7a46 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -269,6 +269,20 @@ void TileMap::_update_dirty_quadrants() { pending_update=false; + if (quadrant_order_dirty) { + + for (Map::Element *E=quadrant_map.front();E;E=E->next()) { + + Quadrant &q=E->get(); + if (q.canvas_item.is_valid()) { + VS::get_singleton()->canvas_item_raise(q.canvas_item); + } + + } + + quadrant_order_dirty=false; + } + _recompute_rect_cache(); } @@ -329,6 +343,7 @@ Map::Element *TileMap::_create_quadrant(const q.pos=Vector2(p_qk.x,p_qk.y)*quadrant_size*cell_size; rect_cache_dirty=true; + quadrant_order_dirty=true; return quadrant_map.insert(p_qk,q); } @@ -387,8 +402,9 @@ void TileMap::set_cell(int p_x,int p_y,int p_tile,bool p_flip_x,bool p_flip_y) { if (!E) { E=tile_map.insert(pk,Cell()); - if (!Q) + if (!Q) { Q=_create_quadrant(qk); + } Quadrant &q=Q->get(); q.cells.insert(pk); } else { @@ -510,6 +526,7 @@ void TileMap::_set_tile_data(const DVector& p_data) { // if (x<-20 || y <-20 || x>4000 || y>4000) // continue; set_cell(x,y,v,flip_h,flip_v); + } } @@ -658,6 +675,7 @@ TileMap::TileMap() { rect_cache_dirty=true; pending_update=false; + quadrant_order_dirty=false; quadrant_size=16; cell_size=64; center_x=false; diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 4b4d9489234..d21437e30f9 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -50,12 +50,13 @@ class TileMap : public Node2D { int16_t x; int16_t y; }; - uint32_t key; - bool operator<(const PosKey& pk) const { return key Spatial::get_gizmo() const { void Spatial::_update_gizmo() { data.gizmo_dirty=false; - if (data.gizmo.is_valid()) - data.gizmo->redraw(); + if (data.gizmo.is_valid()) { + if (is_visible()) + data.gizmo->redraw(); + else + data.gizmo->clear(); + } } @@ -511,6 +515,10 @@ void Spatial::_propagate_visibility_changed() { notification(NOTIFICATION_VISIBILITY_CHANGED); emit_signal(SceneStringNames::get_singleton()->visibility_changed); _change_notify("visibility/visible"); +#ifdef TOOLS_ENABLED + if (data.gizmo.is_valid()) + _update_gizmo(); +#endif for (List::Element*E=data.children.front();E;E=E->next()) { diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h index f2ec26eb581..7036ef63caa 100644 --- a/scene/3d/spatial.h +++ b/scene/3d/spatial.h @@ -45,6 +45,7 @@ public: virtual void create()=0; virtual void transform()=0; + virtual void clear()=0; virtual void redraw()=0; virtual void free()=0; diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 0b797e7df39..4095ddeb377 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1184,7 +1184,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { if (k.mod.shift) { for(int i=0;i0 && txt[i-1]=='\n') || (i==0 && selection.from_column==0)) && (txt[i]=='\t' || txt[i]==' ')) { + if (((i>0 && txt[i-1]=='\n') || (i==0 /*&& selection.from_column==0*/)) && (txt[i]=='\t' || txt[i]==' ')) { txt.remove(i); //i--; } @@ -1193,7 +1193,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { for(int i=0;i0 && txt[i-1]=='\n') || (i==0 && selection.from_column==0))) { + if (((i>0 && txt[i-1]=='\n') || (i==0 /*&& selection.from_column==0*/))) { txt=txt.insert(i,"\t"); //i--; } diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index 72677463737..df5fee81a8f 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -27,11 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "shader_graph.h" -#if 0 -void Shader::_set(const String& p_name, const Variant& p_value) { +# if 0 +void ShaderGraph::_set(const String& p_name, const Variant& p_value) { if (p_name.begins_with("nodes/")) { int idx=p_name.get_slice("/",1).to_int(); @@ -39,11 +39,12 @@ void Shader::_set(const String& p_name, const Variant& p_value) { ERR_FAIL_COND(!data.has("type")); String type=data["type"]; - VS::ShaderNodeType node_type=VS::NODE_TYPE_MAX; + + VS::NodeType node_type=VS::NODE_TYPE_MAX; for(int i=0;i *p_list) const { +void ShaderGraph::_get_property_list( List *p_list) const { List nodes; get_node_list(&nodes); @@ -114,7 +116,9 @@ void Shader::_get_property_list( List *p_list) const { } -Array Shader::_get_connections_helper() const { +#endif +#if 0 +Array ShaderGraph::_get_connections_helper() const { Array connections_ret; List connections; @@ -136,23 +140,23 @@ Array Shader::_get_connections_helper() const { return connections_ret; } -void Shader::_bind_methods() { +void ShaderGraph::_bind_methods() { - ObjectTypeDB::bind_method(_MD("node_add"),&Shader::node_add ); - ObjectTypeDB::bind_method(_MD("node_remove"),&Shader::node_remove ); - ObjectTypeDB::bind_method(_MD("node_set_param"),&Shader::node_set_param ); - ObjectTypeDB::bind_method(_MD("node_set_pos"),&Shader::node_set_pos ); + ObjectTypeDB::bind_method(_MD("node_add"),&ShaderGraph::node_add ); + ObjectTypeDB::bind_method(_MD("node_remove"),&ShaderGraph::node_remove ); + ObjectTypeDB::bind_method(_MD("node_set_param"),&ShaderGraph::node_set_param ); + ObjectTypeDB::bind_method(_MD("node_set_pos"),&ShaderGraph::node_set_pos ); - ObjectTypeDB::bind_method(_MD("node_get_pos"),&Shader::node_get_pos ); - ObjectTypeDB::bind_method(_MD("node_get_param"),&Shader::node_get_type); - ObjectTypeDB::bind_method(_MD("node_get_type"),&Shader::node_get_param); + ObjectTypeDB::bind_method(_MD("node_get_pos"),&ShaderGraph::node_get_pos ); + ObjectTypeDB::bind_method(_MD("node_get_param"),&ShaderGraph::node_get_type); + ObjectTypeDB::bind_method(_MD("node_get_type"),&ShaderGraph::node_get_param); - ObjectTypeDB::bind_method(_MD("connect"),&Shader::connect ); - ObjectTypeDB::bind_method(_MD("disconnect"),&Shader::disconnect ); + ObjectTypeDB::bind_method(_MD("connect"),&ShaderGraph::connect ); + ObjectTypeDB::bind_method(_MD("disconnect"),&ShaderGraph::disconnect ); - ObjectTypeDB::bind_method(_MD("get_connections"),&Shader::_get_connections_helper ); + ObjectTypeDB::bind_method(_MD("get_connections"),&ShaderGraph::_get_connections_helper ); - ObjectTypeDB::bind_method(_MD("clear"),&Shader::clear ); + ObjectTypeDB::bind_method(_MD("clear"),&ShaderGraph::clear ); BIND_CONSTANT( NODE_IN ); ///< param 0: name BIND_CONSTANT( NODE_OUT ); ///< param 0: name @@ -210,57 +214,221 @@ void Shader::_bind_methods() { BIND_CONSTANT( NODE_TYPE_MAX ); } -void Shader::node_add(NodeType p_type,int p_id) { +void ShaderGraph::node_add(NodeType p_type,int p_id) { - VisualServer::get_singleton()->shader_node_add(shader,(VS::ShaderNodeType)p_type,p_id); -#ifdef TOOLS_ENABLED - positions[p_id]=Point2(); -#endif + + ERR_FAIL_COND( node_map.has(p_id ) ); + ERR_FAIL_INDEX( p_type, NODE_TYPE_MAX ); + Node node; + + node.type=p_type; + node.id=p_id; + node.x=0; + node.y=0; + + node_map[p_id]=node; + +} + +void ShaderGraph::node_set_pos(int p_id, const Vector2& p_pos) { + + ERR_FAIL_COND(!node_map.has(p_id)); + node_map[p_id].x=p_pos.x; + node_map[p_id].y=p_pos.y; +} +Vector2 ShaderGraph::node_get_pos(int p_id) const { + + ERR_FAIL_COND_V(!node_map.has(p_id),Vector2()); + return Vector2(node_map[p_id].x,node_map[p_id].y); +} + + +void ShaderGraph::node_remove(int p_id) { + + ERR_FAIL_COND(!node_map.has(p_id)); + + //erase connections associated with node + List::Element *N,*E=connections.front(); + while(E) { + N=E->next(); + const Connection &c = E->get(); + if (c.src_id==p_id || c.dst_id==p_id) { + + connections.erase(E); + } + E=N; + } + + node_map.erase(p_id); +} + +void ShaderGraph::node_change_type(int p_id, NodeType p_type) { + + ERR_FAIL_COND(!node_map.has(p_id)); + node_map[p_id].type=p_type; + node_map[p_id].param=Variant(); + +} + +void ShaderGraph::node_set_param(int p_id, const Variant& p_value) { + + ERR_FAIL_COND(!node_map.has(p_id)); + node_map[p_id].param=p_value; +} + +void ShaderGraph::get_node_list(List *p_node_list) const { + + Map::Element *E = node_map.front(); + + while(E) { + + p_node_list->push_back(E->key()); + E=E->next(); + } +} + + +ShaderGraph::NodeType ShaderGraph::node_get_type(int p_id) const { + + ERR_FAIL_COND_V(!node_map.has(p_id),NODE_TYPE_MAX); + return node_map[p_id].type; +} + +Variant ShaderGraph::node_get_param(int p_id) const { + + ERR_FAIL_COND_V(!node_map.has(p_id),Variant()); + return node_map[p_id].param; +} + + +Error ShaderGraph::connect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) { + + ERR_FAIL_COND_V(p_src_id==p_dst_id, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(!node_map.has(p_src_id), ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(!node_map.has(p_dst_id), ERR_INVALID_PARAMETER); + NodeType type_src=node_map[p_src_id].type; + NodeType type_dst=node_map[p_dst_id].type; + //ERR_FAIL_INDEX_V( p_src_slot, VisualServer::shader_get_output_count(type_src), ERR_INVALID_PARAMETER ); + //ERR_FAIL_INDEX_V( p_dst_slot, VisualServer::shader_get_input_count(type_dst), ERR_INVALID_PARAMETER ); + //ERR_FAIL_COND_V(VisualServer::shader_is_output_vector(type_src,p_src_slot) != VisualServer::shader_is_input_vector(type_dst,p_dst_slot), ERR_INVALID_PARAMETER ); + + + List::Element *E=connections.front(); + while(E) { + const Connection &c = E->get(); + ERR_FAIL_COND_V(c.dst_slot==p_dst_slot && c.dst_id == p_dst_id, ERR_ALREADY_EXISTS); + + E=E->next(); + } + + Connection c; + c.src_slot=p_src_slot; + c.src_id=p_src_id; + c.dst_slot=p_dst_slot; + c.dst_id=p_dst_id; + + connections.push_back(c); + + return OK; +} + +bool ShaderGraph::is_connected(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) const { + + const List::Element *E=connections.front(); + while(E) { + const Connection &c = E->get(); + if (c.dst_slot==p_dst_slot && c.dst_id == p_dst_id && c.src_slot==p_src_slot && c.src_id == p_src_id) + return true; + + E=E->next(); + } + + return false; +} + +void ShaderGraph::disconnect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) { + + List::Element *N,*E=connections.front(); + while(E) { + N=E->next(); + const Connection &c = E->get(); + if (c.src_slot==p_src_slot && c.src_id==p_src_id && c.dst_slot==p_dst_slot && c.dst_id == p_dst_id) { + + connections.erase(E); + } + E=N; + } + + +} + +void ShaderGraph::get_connections(List *p_connections) const { + + const List::Element*E=connections.front(); + while(E) { + p_connections->push_back(E->get()); + E=E->next(); + } + + +} + + +void ShaderGraph::clear() { + + connections.clear(); + node_map.clear(); +} + + +#if 0 +void ShaderGraph::node_add(NodeType p_type,int p_id) { + + ShaderNode sn; + sn.type=p_type; + nodes[p_id]=sn; version++; } -void Shader::node_remove(int p_id) { +void ShaderGraph::node_remove(int p_id) { - VisualServer::get_singleton()->shader_node_remove(shader,p_id); -#ifdef TOOLS_ENABLED - positions.erase(p_id); -#endif + nodes.erase(p_id); } -void Shader::node_set_param( int p_id, const Variant& p_value) { +void ShaderGraph::node_set_param( int p_id, const Variant& p_value) { VisualServer::get_singleton()->shader_node_set_param(shader,p_id,p_value); version++; } -void Shader::get_node_list(List *p_node_list) const { +void ShaderGraph::get_node_list(List *p_node_list) const { VisualServer::get_singleton()->shader_get_node_list(shader,p_node_list); } -Shader::NodeType Shader::node_get_type(int p_id) const { +ShaderGraph::NodeType ShaderGraph::node_get_type(int p_id) const { return (NodeType)VisualServer::get_singleton()->shader_node_get_type(shader,p_id); } -Variant Shader::node_get_param(int p_id) const { +Variant ShaderGraph::node_get_param(int p_id) const { return VisualServer::get_singleton()->shader_node_get_param(shader,p_id); } -void Shader::connect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) { +void ShaderGraph::connect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) { VisualServer::get_singleton()->shader_connect(shader,p_src_id,p_src_slot,p_dst_id,p_dst_slot); version++; } -void Shader::disconnect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) { +void ShaderGraph::disconnect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) { VisualServer::get_singleton()->shader_disconnect(shader,p_src_id,p_src_slot,p_dst_id,p_dst_slot); version++; } -void Shader::get_connections(List *p_connections) const { +void ShaderGraph::get_connections(List *p_connections) const { - List connections; + List connections; VisualServer::get_singleton()->shader_get_connections(shader,&connections); - for( List::Element *E=connections.front();E;E=E->next()) { + for( List::Element *E=connections.front();E;E=E->next()) { Connection c; c.src_id=E->get().src_id; @@ -271,7 +439,7 @@ void Shader::get_connections(List *p_connections) const { } } -void Shader::node_set_pos(int p_id,const Point2& p_pos) { +void ShaderGraph::node_set_pos(int p_id,const Point2& p_pos) { #ifdef TOOLS_ENABLED ERR_FAIL_COND(!positions.has(p_id)); @@ -279,36 +447,33 @@ void Shader::node_set_pos(int p_id,const Point2& p_pos) { #endif } -Point2 Shader::node_get_pos(int p_id) const { +Point2 ShaderGraph::node_get_pos(int p_id) const { #ifdef TOOLS_ENABLED ERR_FAIL_COND_V(!positions.has(p_id),Point2()); return positions[p_id]; #endif } -void Shader::clear() { +void ShaderGraph::clear() { VisualServer::get_singleton()->shader_clear(shader); version++; } +#endif -Shader::Shader() { +ShaderGraph::ShaderGraph() { - shader = VisualServer::get_singleton()->shader_create(); + //shader = VisualServer::get_singleton()->shader_create(); version = 1; } -Shader::~Shader() { +ShaderGraph::~ShaderGraph() { - VisualServer::get_singleton()->free(shader); + //VisualServer::get_singleton()->free(shader); } -ShaderGraph::ShaderGraph() -{ -} - - -void VisualServer::shader_get_default_input_nodes(ShaderType p_type,List *p_inputs) { +#if 0 +void ShaderGraph::shader_get_default_input_nodes(Mode p_type,List *p_inputs) { switch(p_type) { @@ -341,7 +506,7 @@ void VisualServer::shader_get_default_input_nodes(ShaderType p_type,List *p_outputs) { +void ShaderGraph::shader_get_default_output_nodes(ShaderGraphType p_type,List *p_outputs) { switch(p_type) { @@ -377,7 +542,7 @@ void VisualServer::shader_get_default_output_nodes(ShaderType p_type,List positions; - uint64_t version; - -protected: - - bool _set(const StringName& p_name, const Variant& p_value); - bool _get(const StringName& p_name,Variant &r_ret) const; - void _get_property_list( List *p_list) const; - - static void _bind_methods(); - - Array _get_connections_helper() const; public: @@ -116,18 +103,13 @@ public: NODE_TYPE_MAX }; - void node_add(NodeType p_type,int p_id); - void node_remove(int p_id); - void node_set_param( int p_id, const Variant& p_value); - void node_set_pos(int p_id,const Point2& p_pos); - Point2 node_get_pos(int p_id) const; + enum ShaderType { + SHADER_VERTEX, + SHADER_FRAGMENT, + SHADER_LIGHT + }; - void get_node_list(List *p_node_list) const; - NodeType node_get_type(int p_id) const; - Variant node_get_param(int p_id) const; - - void connect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot); - void disconnect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot); +private: struct Connection { @@ -137,40 +119,79 @@ public: int dst_slot; }; - void get_connections(List *p_connections) const; + struct Node { + + int16_t x,y; + NodeType type; + Variant param; + int id; + mutable int order; // used for sorting + mutable bool out_valid; + mutable bool in_valid; + }; + + struct ShaderData { + Map node_map; + List connections; + } shader[3]; + uint64_t version; + +protected: + +/* bool _set(const StringName& p_name, const Variant& p_value); + bool _get(const StringName& p_name,Variant &r_ret) const; + void _get_property_list( List *p_list) const;*/ + + static void _bind_methods(); + + Array _get_connections_helper() const; + +public: + + + void node_add(ShaderType p_which, NodeType p_type,int p_id); + void node_remove(ShaderType p_which,int p_id); + void node_set_param(ShaderType p_which, int p_id, const Variant& p_value); + void node_set_pos(ShaderType p_which,int p_id,const Point2& p_pos); + void node_change_type(ShaderType p_which,int p_id, NodeType p_type); + Point2 node_get_pos(ShaderType p_which,int p_id) const; + + void get_node_list(ShaderType p_which,List *p_node_list) const; + NodeType node_get_type(ShaderType p_which,int p_id) const; + Variant node_get_param(ShaderType p_which,int p_id) const; + + Error connect(ShaderType p_which,int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot); + bool is_connected(ShaderType p_which,int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) const; + void disconnect(ShaderType p_which,int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot); + + void get_connections(ShaderType p_which,List *p_connections) const; void clear(); - virtual RID get_rid() const { return shader; } - uint64_t get_version() const { return version; } - Shader(); - ~Shader(); + static void get_default_input_nodes(Mode p_type,List *p_inputs); + static void get_default_output_nodes(Mode p_type,List *p_outputs); + + static PropertyInfo node_get_type_info(NodeType p_type); + static int get_input_count(NodeType p_type); + static int get_output_count(NodeType p_type); + static String get_input_name(NodeType p_type,int p_input); + static String get_output_name(NodeType p_type,int p_output); + static bool is_input_vector(NodeType p_type,int p_input); + static bool is_output_vector(NodeType p_type,int p_input); + + + ShaderGraph(); + ~ShaderGraph(); }; -enum ShaderType { - SHADER_VERTEX, - SHADER_FRAGMENT, - SHADER_POST_PROCESS -}; //helper functions -static void shader_get_default_input_nodes(ShaderType p_type,List *p_inputs); -static void shader_get_default_output_nodes(ShaderType p_type,List *p_outputs); - -static PropertyInfo shader_node_get_type_info(ShaderNodeType p_type); -static int shader_get_input_count(ShaderNodeType p_type); -static int shader_get_output_count(ShaderNodeType p_type); -static String shader_get_input_name(ShaderNodeType p_type,int p_input); -static String shader_get_output_name(ShaderNodeType p_type,int p_output); -static bool shader_is_input_vector(ShaderNodeType p_type,int p_input); -static bool shader_is_output_vector(ShaderNodeType p_type,int p_input); -VARIANT_ENUM_CAST( Shader::NodeType ); +VARIANT_ENUM_CAST( ShaderGraph::NodeType ); #endif - #endif // SHADER_GRAPH_H diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h index 558a48f6fd1..e717cc257c9 100644 --- a/servers/physics/collision_object_sw.h +++ b/servers/physics/collision_object_sw.h @@ -34,6 +34,9 @@ #include "self_list.h" #include "broad_phase_sw.h" +#define MAX_OBJECT_DISTANCE 10000000 +#define MAX_OBJECT_DISTANCE_X2 (MAX_OBJECT_DISTANCE*MAX_OBJECT_DISTANCE) + class SpaceSW; class CollisionObjectSW : public ShapeOwnerSW { @@ -72,7 +75,19 @@ protected: void _update_shapes_with_motion(const Vector3& p_motion); void _unregister_shapes(); - _FORCE_INLINE_ void _set_transform(const Transform& p_transform,bool p_update_shapes=true) { transform=p_transform; if (p_update_shapes) _update_shapes(); } + _FORCE_INLINE_ void _set_transform(const Transform& p_transform,bool p_update_shapes=true) { + +#ifdef DEBUG_ENABLED + + if (p_transform.origin.length_squared() > MAX_OBJECT_DISTANCE_X2) { + ERR_EXPLAIN("Object went too far away (more than "+itos(MAX_OBJECT_DISTANCE)+"mts from origin)."); + ERR_FAIL(); + } +#endif + + transform=p_transform; if (p_update_shapes) _update_shapes(); + + } _FORCE_INLINE_ void _set_inv_transform(const Transform& p_transform) { inv_transform=p_transform; } void _set_static(bool p_static); diff --git a/servers/physics/collision_solver_sw.cpp b/servers/physics/collision_solver_sw.cpp index 673f2d43857..56f2784145e 100644 --- a/servers/physics/collision_solver_sw.cpp +++ b/servers/physics/collision_solver_sw.cpp @@ -180,6 +180,7 @@ bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A,const Transform& } concave_B->cull(local_aabb,concave_callback,&cinfo); + //print_line("COL AABB TESTS: "+itos(cinfo.aabb_tests)); return cinfo.collided; } @@ -346,6 +347,8 @@ bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A,const Transform& } + //print_line("DIST AABB TESTS: "+itos(cinfo.aabb_tests)); + return !cinfo.collided; } else { diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 95622f72f3a..a5cddc20e6a 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -2086,7 +2086,19 @@ void SpatialEditorViewport::_bind_methods(){ } +void SpatialEditorViewport::reset() { + orthogonal=false; + message_time=0; + message=""; + last_message=""; + + cursor.x_rot=0; + cursor.y_rot=0; + cursor.distance=4; + cursor.region_select=false; + +} SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index) { @@ -3270,6 +3282,34 @@ void SpatialEditor::_bind_methods() { ADD_SIGNAL( MethodInfo("transform_key_request") ); +} + +void SpatialEditor::clear() { + + settings_fov->set_text(EDITOR_DEF("3d_editor/default_fov",60.0)); + settings_znear->set_text(EDITOR_DEF("3d_editor/default_z_near",0.1)); + settings_zfar->set_text(EDITOR_DEF("3d_editor/default_z_far",1500.0)); + + for(int i=0;i<4;i++) { + viewports[i]->reset(); + } + + _menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT); + _menu_item_pressed(MENU_VIEW_DISPLAY_NORMAL); + + + VisualServer::get_singleton()->instance_geometry_set_flag(origin_instance,VS::INSTANCE_FLAG_VISIBLE,true); + view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN), true); + for(int i=0;i<3;++i) { + if (grid_enable[i]) { + VisualServer::get_singleton()->instance_geometry_set_flag(grid_instance[i],VS::INSTANCE_FLAG_VISIBLE,true); + grid_visible[i]=true; + } + } + + view_menu->get_popup()->set_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_GRID), true ); + + } SpatialEditor::SpatialEditor(EditorNode *p_editor) { @@ -3501,7 +3541,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { settings_zfar->set_anchor( MARGIN_RIGHT, ANCHOR_END ); settings_zfar->set_begin( Point2(15,102) ); settings_zfar->set_end( Point2(15,115) ); - settings_zfar->set_text(EDITOR_DEF("3d_editor/default_z_far",500.0)); + settings_zfar->set_text(EDITOR_DEF("3d_editor/default_z_far",1500.0)); settings_dialog->add_child(settings_zfar); //settings_dialog->get_cancel()->hide(); diff --git a/tools/editor/plugins/spatial_editor_plugin.h b/tools/editor/plugins/spatial_editor_plugin.h index bdeac2e4efe..4bbddbac58a 100644 --- a/tools/editor/plugins/spatial_editor_plugin.h +++ b/tools/editor/plugins/spatial_editor_plugin.h @@ -222,6 +222,7 @@ public: void set_can_preview(Camera* p_preview); void set_state(const Dictionary& p_state); Dictionary get_state() const; + void reset(); @@ -477,6 +478,7 @@ public: Camera *get_camera() { return NULL; } void edit(Spatial *p_spatial); + void clear(); SpatialEditor(EditorNode *p_editor); ~SpatialEditor(); }; @@ -502,6 +504,7 @@ public: virtual Dictionary get_state() const; virtual void set_state(const Dictionary& p_state); + virtual void clear() { spatial_editor->clear(); } SpatialEditorPlugin(EditorNode *p_node); diff --git a/tools/editor/spatial_editor_gizmos.h b/tools/editor/spatial_editor_gizmos.h index ac31eb19e92..55e40c7b7cb 100644 --- a/tools/editor/spatial_editor_gizmos.h +++ b/tools/editor/spatial_editor_gizmos.h @@ -94,7 +94,6 @@ class SpatialGizmoTool : public SpatialEditorGizmo { Vector instances; Spatial *spatial_node; protected: - void clear(); void add_lines(const Vector &p_lines,const Ref& p_material,bool p_billboard=false); void add_mesh(const Ref& p_mesh,bool p_billboard=false,const RID& p_skeleton=RID()); void add_collision_segments(const Vector &p_lines); @@ -110,6 +109,7 @@ public: virtual bool intersect_frustum(const Camera *p_camera,const Vector &p_frustum); virtual bool intersect_ray(const Camera *p_camera,const Point2& p_point, Vector3& r_pos, Vector3& r_normal,int *r_gizmo_handle=NULL,bool p_sec_first=false); + void clear(); void create(); void transform(); //void redraw();