diff options
41 files changed, 307 insertions, 219 deletions
diff --git a/core/os/os.h b/core/os/os.h index dd783408e8..12c0222ad4 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -254,7 +254,7 @@ public: virtual String get_executable_path() const; virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false) = 0; - virtual Error kill(const ProcessID &p_pid) = 0; + virtual Error kill(const ProcessID &p_pid, const int p_max_wait_msec = -1) = 0; virtual int get_process_id() const; virtual Error shell_open(String p_uri); diff --git a/core/reference.h b/core/reference.h index 0d6b1ced6e..25e02180fa 100644 --- a/core/reference.h +++ b/core/reference.h @@ -87,6 +87,13 @@ class Ref { //virtual Reference * get_reference() const { return reference; } public: + _FORCE_INLINE_ bool operator==(const T *p_ptr) const { + return reference == p_ptr; + } + _FORCE_INLINE_ bool operator!=(const T *p_ptr) const { + return reference != p_ptr; + } + _FORCE_INLINE_ bool operator<(const Ref<T> &p_r) const { return reference < p_r.reference; diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 45d7748382..1c50df75f5 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -1920,9 +1920,9 @@ void register_variant_methods() { transform_x.set(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0); _VariantCall::add_variant_constant(Variant::TRANSFORM, "FLIP_Z", transform_z); - _VariantCall::add_variant_constant(Variant::PLANE, "X", Plane(Vector3(1, 0, 0), 0)); - _VariantCall::add_variant_constant(Variant::PLANE, "Y", Plane(Vector3(0, 1, 0), 0)); - _VariantCall::add_variant_constant(Variant::PLANE, "Z", Plane(Vector3(0, 0, 1), 0)); + _VariantCall::add_variant_constant(Variant::PLANE, "PLANE_YZ", Plane(Vector3(1, 0, 0), 0)); + _VariantCall::add_variant_constant(Variant::PLANE, "PLANE_XZ", Plane(Vector3(0, 1, 0), 0)); + _VariantCall::add_variant_constant(Variant::PLANE, "PLANE_XY", Plane(Vector3(0, 0, 1), 0)); _VariantCall::add_variant_constant(Variant::QUAT, "IDENTITY", Quat(0, 0, 0, 1)); } diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 05dfd69f58..8aab4cb521 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -329,7 +329,7 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo return OK; } -Error OS_Unix::kill(const ProcessID &p_pid) { +Error OS_Unix::kill(const ProcessID &p_pid, const int p_max_wait_msec) { int ret = ::kill(p_pid, SIGKILL); if (!ret) { diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index 95b74d23ff..c5240231fa 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -91,7 +91,7 @@ public: virtual uint64_t get_ticks_usec() const; virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false); - virtual Error kill(const ProcessID &p_pid); + virtual Error kill(const ProcessID &p_pid, const int p_max_wait_msec = -1); virtual int get_process_id() const; virtual bool has_environment(const String &p_var) const; diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 65c41ef579..50b3810e52 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -624,6 +624,22 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) { class_desc->pop(); } +String EditorHelp::_fix_constant(const String &p_constant) const { + + if (p_constant.strip_edges() == "4294967295") { + return "0xFFFFFFFF"; + } + + if (p_constant.strip_edges() == "2147483647") { + return "0x7FFFFFFF"; + } + if (p_constant.strip_edges() == "1048575") { + return "0xfffff"; + } + + return p_constant; +} + void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview) { method_line[p_method.name] = class_desc->get_line_count() - 2; //gets overridden if description @@ -673,7 +689,7 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview class_desc->push_color(symbol_color); class_desc->add_text("="); class_desc->pop(); - _add_text(p_method.arguments[j].default_value); + _add_text(_fix_constant(p_method.arguments[j].default_value)); } class_desc->pop(); diff --git a/editor/editor_help.h b/editor/editor_help.h index dbea97e98b..ad81a39945 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -244,6 +244,8 @@ class EditorHelp : public VBoxContainer { void _unhandled_key_input(const Ref<InputEvent> &p_ev); + String _fix_constant(const String &p_constant) const; + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index ca6e57844c..0ca70c41fa 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4592,6 +4592,10 @@ EditorNode::EditorNode() { VisualServer::get_singleton()->textures_keep_original(true); VisualServer::get_singleton()->set_debug_generate_wireframes(true); + PhysicsServer::get_singleton()->set_active(false); // no physics by default if editor + Physics2DServer::get_singleton()->set_active(false); // no physics by default if editor + ScriptServer::set_scripting_enabled(false); // no scripting by default if editor + EditorHelp::generate_doc(); //before any editor classes are crated SceneState::set_disable_placeholders(true); ResourceLoader::clear_translation_remaps(); //no remaps using during editor @@ -5681,10 +5685,6 @@ EditorNode::EditorNode() { _edit_current(); current = NULL; - PhysicsServer::get_singleton()->set_active(false); // no physics by default if editor - Physics2DServer::get_singleton()->set_active(false); // no physics by default if editor - ScriptServer::set_scripting_enabled(false); // no scripting by default if editor - reference_resource_mem = true; save_external_resources_mem = true; diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index 749cf6aa2b..072bd948e1 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -181,8 +181,8 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li void EditorRun::stop() { if (status != STATUS_STOP && pid != 0) { - - OS::get_singleton()->kill(pid); + const int max_wait_msec = GLOBAL_DEF("editor/stop_max_wait_msec", 10000); + OS::get_singleton()->kill(pid, max_wait_msec); } status = STATUS_STOP; diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index 1106464edf..5373015654 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -4,11 +4,10 @@ #include "scene/animation/animation_blend_tree.h" StringName AnimationNodeBlendSpace1DEditor::get_blend_position_path() const { - StringName path = AnimationTreeEditor::get_singleton()->get_base_path()+"blend_position"; + StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + "blend_position"; return path; } - void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; @@ -55,7 +54,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven continue; int idx = menu->get_item_count(); - menu->add_item(vformat("Add %s", name),idx); + menu->add_item(vformat("Add %s", name), idx); menu->set_item_metadata(idx, E->get()); } @@ -136,7 +135,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven blend_pos *= blend_space->get_max_space() - blend_space->get_min_space(); blend_pos += blend_space->get_min_space(); - AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(),blend_pos); + AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(), blend_pos); blend_space_draw->update(); } @@ -159,7 +158,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven blend_pos *= blend_space->get_max_space() - blend_space->get_min_space(); blend_pos += blend_space->get_min_space(); - AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(),blend_pos); + AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(), blend_pos); blend_space_draw->update(); } @@ -258,7 +257,6 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() { float point = AnimationTreeEditor::get_singleton()->get_tree()->get(get_blend_position_path()); - point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space()); point *= s.width; @@ -501,8 +499,6 @@ void AnimationNodeBlendSpace1DEditor::_open_editor() { } } - - void AnimationNodeBlendSpace1DEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { error_panel->add_style_override("panel", get_stylebox("bg", "Tree")); @@ -514,7 +510,6 @@ void AnimationNodeBlendSpace1DEditor::_notification(int p_what) { tool_erase->set_icon(get_icon("Remove", "EditorIcons")); snap->set_icon(get_icon("SnapGrid", "EditorIcons")); open_editor->set_icon(get_icon("Edit", "EditorIcons")); - } if (p_what == NOTIFICATION_PROCESS) { @@ -536,7 +531,7 @@ void AnimationNodeBlendSpace1DEditor::_notification(int p_what) { } } - if (p_what==NOTIFICATION_VISIBILITY_CHANGED) { + if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { set_process(is_visible_in_tree()); } } @@ -561,22 +556,17 @@ void AnimationNodeBlendSpace1DEditor::_bind_methods() { ClassDB::bind_method("_open_editor", &AnimationNodeBlendSpace1DEditor::_open_editor); ClassDB::bind_method("_file_opened", &AnimationNodeBlendSpace1DEditor::_file_opened); - - - } bool AnimationNodeBlendSpace1DEditor::can_edit(const Ref<AnimationNode> &p_node) { - Ref<AnimationNodeBlendSpace1D> b1d=p_node; + Ref<AnimationNodeBlendSpace1D> b1d = p_node; return b1d.is_valid(); } void AnimationNodeBlendSpace1DEditor::edit(const Ref<AnimationNode> &p_node) { - - - blend_space=p_node; + blend_space = p_node; if (!blend_space.is_null()) { _update_space(); @@ -595,7 +585,6 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() { Ref<ButtonGroup> bg; bg.instance(); - tool_blend = memnew(ToolButton); tool_blend->set_toggle_mode(true); tool_blend->set_button_group(bg); diff --git a/editor/plugins/animation_blend_space_1d_editor.h b/editor/plugins/animation_blend_space_1d_editor.h index f040f6dcab..278357b9c7 100644 --- a/editor/plugins/animation_blend_space_1d_editor.h +++ b/editor/plugins/animation_blend_space_1d_editor.h @@ -3,13 +3,13 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" +#include "editor/plugins/animation_tree_editor_plugin.h" #include "editor/property_editor.h" #include "scene/animation/animation_blend_space_1d.h" #include "scene/gui/button.h" #include "scene/gui/graph_edit.h" #include "scene/gui/popup.h" #include "scene/gui/tree.h" -#include "editor/plugins/animation_tree_editor_plugin.h" class AnimationNodeBlendSpace1DEditor : public AnimationTreeNodeEditorPlugin { diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index e008971e5c..e5476aaf08 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -13,7 +13,7 @@ bool AnimationNodeBlendSpace2DEditor::can_edit(const Ref<AnimationNode> &p_node) { - Ref<AnimationNodeBlendSpace2D> bs2d=p_node; + Ref<AnimationNodeBlendSpace2D> bs2d = p_node; return bs2d.is_valid(); } @@ -27,7 +27,7 @@ void AnimationNodeBlendSpace2DEditor::edit(const Ref<AnimationNode> &p_node) { } StringName AnimationNodeBlendSpace2DEditor::get_blend_position_path() const { - StringName path = AnimationTreeEditor::get_singleton()->get_base_path()+"blend_position"; + StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + "blend_position"; return path; } @@ -73,7 +73,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven if (name == "Animation") continue; // nope int idx = menu->get_item_count(); - menu->add_item(vformat("Add %s", name),idx); + menu->add_item(vformat("Add %s", name), idx); menu->set_item_metadata(idx, E->get()); } @@ -85,7 +85,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven menu->add_separator(); menu->add_item(TTR("Load.."), MENU_LOAD_FILE); - menu->set_global_position(blend_space_draw->get_global_transform().xform(mb->get_position())); menu->popup(); add_point_pos = (mb->get_position() / blend_space_draw->get_size()); @@ -211,7 +210,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven blend_pos *= (blend_space->get_max_space() - blend_space->get_min_space()); blend_pos += blend_space->get_min_space(); - AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(),blend_pos); + AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(), blend_pos); blend_space_draw->update(); } @@ -246,7 +245,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven blend_pos *= (blend_space->get_max_space() - blend_space->get_min_space()); blend_pos += blend_space->get_min_space(); - AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(),blend_pos); + AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(), blend_pos); blend_space_draw->update(); } @@ -750,12 +749,11 @@ void AnimationNodeBlendSpace2DEditor::_notification(int p_what) { } } - if (p_what==NOTIFICATION_VISIBILITY_CHANGED) { + if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { set_process(is_visible_in_tree()); } } - void AnimationNodeBlendSpace2DEditor::_open_editor() { if (selected_point >= 0 && selected_point < blend_space->get_blend_point_count()) { @@ -804,7 +802,6 @@ void AnimationNodeBlendSpace2DEditor::_bind_methods() { ClassDB::bind_method("_auto_triangles_toggled", &AnimationNodeBlendSpace2DEditor::_auto_triangles_toggled); ClassDB::bind_method("_file_opened", &AnimationNodeBlendSpace2DEditor::_file_opened); - } AnimationNodeBlendSpace2DEditor *AnimationNodeBlendSpace2DEditor::singleton = NULL; @@ -1019,4 +1016,3 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() { dragging_selected = false; dragging_selected_attempt = false; } - diff --git a/editor/plugins/animation_blend_space_2d_editor.h b/editor/plugins/animation_blend_space_2d_editor.h index ae684985f3..0bf1e25d7a 100644 --- a/editor/plugins/animation_blend_space_2d_editor.h +++ b/editor/plugins/animation_blend_space_2d_editor.h @@ -3,13 +3,13 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" +#include "editor/plugins/animation_tree_editor_plugin.h" #include "editor/property_editor.h" #include "scene/animation/animation_blend_space_2d.h" #include "scene/gui/button.h" #include "scene/gui/graph_edit.h" #include "scene/gui/popup.h" #include "scene/gui/tree.h" -#include "editor/plugins/animation_tree_editor_plugin.h" /** @author Juan Linietsky <reduzio@gmail.com> */ @@ -20,7 +20,6 @@ class AnimationNodeBlendSpace2DEditor : public AnimationTreeNodeEditorPlugin { Ref<AnimationNodeBlendSpace2D> blend_space; - PanelContainer *panel; ToolButton *tool_blend; ToolButton *tool_select; @@ -119,5 +118,4 @@ public: AnimationNodeBlendSpace2DEditor(); }; - #endif // ANIMATION_BLEND_SPACE_2D_EDITOR_H diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 3d14db7d0e..0ba42cb101 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -426,6 +426,9 @@ void TileMapEditor::_update_palette() { Ref<Texture> tex = tileset->tile_get_texture(entries[i].id); if (tex.is_valid()) { + Color color = tileset->tile_get_modulate(entries[i].id); + palette->set_item_icon_modulate(palette->get_item_count() - 1, color); + Rect2 region = tileset->tile_get_region(entries[i].id); if (tileset->tile_get_tile_mode(entries[i].id) == TileSet::AUTO_TILE || tileset->tile_get_tile_mode(entries[i].id) == TileSet::ATLAS_TILE) { @@ -759,10 +762,13 @@ void TileMapEditor::_draw_cell(int p_cell, const Point2i &p_point, bool p_flip_h rect.position = p_xform.xform(rect.position); rect.size *= sc; + Color modulate = node->get_tileset()->tile_get_modulate(p_cell); + modulate.a = 0.5; + if (r.has_no_area()) - canvas_item_editor->draw_texture_rect(t, rect, false, Color(1, 1, 1, 0.5), p_transpose); + canvas_item_editor->draw_texture_rect(t, rect, false, modulate, p_transpose); else - canvas_item_editor->draw_texture_rect_region(t, rect, r, Color(1, 1, 1, 0.5), p_transpose); + canvas_item_editor->draw_texture_rect_region(t, rect, r, modulate, p_transpose); } void TileMapEditor::_draw_fill_preview(int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Transform2D &p_xform) { diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 20ddfa99a8..64638cdb1e 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -3655,7 +3655,7 @@ void NavigationMeshSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_collision_segments(lines); } - ////// +////// #define BODY_A_RADIUS 0.25 #define BODY_B_RADIUS 0.27 diff --git a/modules/mono/glue/cs_files/Plane.cs b/modules/mono/glue/cs_files/Plane.cs index 1020f06bf5..9611dce11e 100644 --- a/modules/mono/glue/cs_files/Plane.cs +++ b/modules/mono/glue/cs_files/Plane.cs @@ -145,6 +145,15 @@ namespace Godot return point - _normal * DistanceTo(point); } + // Constants + private static readonly Plane _planeYZ = new Plane(1, 0, 0, 0); + private static readonly Plane _planeXZ = new Plane(0, 1, 0, 0); + private static readonly Plane _planeXY = new Plane(0, 0, 1, 0); + + public static Plane PlaneYZ { get { return _planeYZ; } } + public static Plane PlaneXZ { get { return _planeXZ; } } + public static Plane PlaneXY { get { return _planeXY; } } + // Constructors public Plane(real_t a, real_t b, real_t c, real_t d) { diff --git a/modules/mono/mono_gd/gd_mono_assembly.cpp b/modules/mono/mono_gd/gd_mono_assembly.cpp index 9d3bee2176..27ce39b6d7 100644 --- a/modules/mono/mono_gd/gd_mono_assembly.cpp +++ b/modules/mono/mono_gd/gd_mono_assembly.cpp @@ -42,8 +42,25 @@ #include "gd_mono_class.h" bool GDMonoAssembly::no_search = false; +bool GDMonoAssembly::in_preload = false; + Vector<String> GDMonoAssembly::search_dirs; +void GDMonoAssembly::assembly_load_hook(MonoAssembly *assembly, void *user_data) { + + if (no_search) + return; + + // If our search and preload hooks fail to load the assembly themselves, the mono runtime still might. + // Just do Assembly.LoadFrom("/Full/Path/On/Disk.dll"); + // In this case, we wouldn't have the assembly known in GDMono, which causes crashes + // if any class inside the assembly is looked up by Godot. + // And causing a lookup like that is as easy as throwing an exception defined in it... + // No, we can't make the assembly load hooks smart enough because they get passed a MonoAssemblyName* only, + // not the disk path passed to say Assembly.LoadFrom(). + _wrap_mono_assembly(assembly); +} + MonoAssembly *GDMonoAssembly::assembly_search_hook(MonoAssemblyName *aname, void *user_data) { return GDMonoAssembly::_search_hook(aname, user_data, false); } @@ -111,6 +128,8 @@ MonoAssembly *GDMonoAssembly::_search_hook(MonoAssemblyName *aname, void *user_d return res ? res->get_assembly() : NULL; } +static _THREAD_LOCAL_(MonoImage *) image_corlib_loading = NULL; + MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **assemblies_path, void *user_data, bool refonly) { (void)user_data; // UNUSED @@ -138,16 +157,38 @@ MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **asse } } + { + // If we find the assembly here, we load it with `mono_assembly_load_from_full`, + // which in turn invokes load hooks before returning the MonoAssembly to us. + // One of the load hooks is `load_aot_module`. This hook can end up calling preload hooks + // again for the same assembly in certain in certain circumstances (the `do_load_image` part). + // If this is the case and we return NULL due to the no_search condition below, + // it will result in an internal crash later on. Therefore we need to return the assembly we didn't + // get yet from `mono_assembly_load_from_full`. Luckily we have the image, which already got it. + // This must be done here. If done in search hooks, it would cause `mono_assembly_load_from_full` + // to think another MonoAssembly for this assembly was already loaded, making it delete its own, + // when in fact both pointers were the same... This hooks thing is confusing. + if (image_corlib_loading) { + return mono_image_get_assembly(image_corlib_loading); + } + } + + if (no_search) + return NULL; + + no_search = true; + in_preload = true; + String name = mono_assembly_name_get_name(aname); bool has_extension = name.ends_with(".dll"); + GDMonoAssembly *res = NULL; if (has_extension ? name == "mscorlib.dll" : name == "mscorlib") { GDMonoAssembly **stored_assembly = GDMono::get_singleton()->get_loaded_assembly(has_extension ? name.get_basename() : name); if (stored_assembly) return (*stored_assembly)->get_assembly(); String path; - GDMonoAssembly *res = NULL; for (int i = 0; i < search_dirs.size(); i++) { const String &search_dir = search_dirs[i]; @@ -168,11 +209,12 @@ MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **asse } } } - - return res ? res->get_assembly() : NULL; } - return NULL; + no_search = false; + in_preload = false; + + return res ? res->get_assembly() : NULL; } GDMonoAssembly *GDMonoAssembly::_load_assembly_from(const String &p_name, const String &p_path, bool p_refonly) { @@ -192,12 +234,30 @@ GDMonoAssembly *GDMonoAssembly::_load_assembly_from(const String &p_name, const return assembly; } +void GDMonoAssembly::_wrap_mono_assembly(MonoAssembly *assembly) { + String name = mono_assembly_name_get_name(mono_assembly_get_name(assembly)); + + MonoImage *image = mono_assembly_get_image(assembly); + + GDMonoAssembly *gdassembly = memnew(GDMonoAssembly(name, mono_image_get_filename(image))); + Error err = gdassembly->wrapper_for_image(image); + + if (err != OK) { + memdelete(gdassembly); + ERR_FAIL(); + } + + MonoDomain *domain = mono_domain_get(); + GDMono::get_singleton()->add_assembly(domain ? mono_domain_get_id(domain) : 0, gdassembly); +} + void GDMonoAssembly::initialize() { mono_install_assembly_search_hook(&assembly_search_hook, NULL); mono_install_assembly_refonly_search_hook(&assembly_refonly_search_hook, NULL); mono_install_assembly_preload_hook(&assembly_preload_hook, NULL); mono_install_assembly_refonly_preload_hook(&assembly_refonly_preload_hook, NULL); + mono_install_assembly_load_hook(&assembly_load_hook, NULL); } Error GDMonoAssembly::load(bool p_refonly) { @@ -241,8 +301,16 @@ no_pdb: #endif + bool is_corlib_preload = in_preload && name == "mscorlib"; + + if (is_corlib_preload) + image_corlib_loading = image; + assembly = mono_assembly_load_from_full(image, image_filename.utf8().get_data(), &status, refonly); + if (is_corlib_preload) + image_corlib_loading = NULL; + ERR_FAIL_COND_V(status != MONO_IMAGE_OK || assembly == NULL, ERR_FILE_CANT_OPEN); loaded = true; diff --git a/modules/mono/mono_gd/gd_mono_assembly.h b/modules/mono/mono_gd/gd_mono_assembly.h index 5cf744a5a2..2c6d367fc6 100644 --- a/modules/mono/mono_gd/gd_mono_assembly.h +++ b/modules/mono/mono_gd/gd_mono_assembly.h @@ -89,8 +89,10 @@ class GDMonoAssembly { #endif static bool no_search; + static bool in_preload; static Vector<String> search_dirs; + static void assembly_load_hook(MonoAssembly *assembly, void *user_data); static MonoAssembly *assembly_search_hook(MonoAssemblyName *aname, void *user_data); static MonoAssembly *assembly_refonly_search_hook(MonoAssemblyName *aname, void *user_data); static MonoAssembly *assembly_preload_hook(MonoAssemblyName *aname, char **assemblies_path, void *user_data); @@ -100,6 +102,7 @@ class GDMonoAssembly { static MonoAssembly *_preload_hook(MonoAssemblyName *aname, char **assemblies_path, void *user_data, bool refonly); static GDMonoAssembly *_load_assembly_from(const String &p_name, const String &p_path, bool p_refonly); + static void _wrap_mono_assembly(MonoAssembly *assembly); friend class GDMono; static void initialize(); diff --git a/modules/mono/utils/thread_local.cpp b/modules/mono/utils/thread_local.cpp index ae9f130518..a0e28fca5f 100644 --- a/modules/mono/utils/thread_local.cpp +++ b/modules/mono/utils/thread_local.cpp @@ -69,7 +69,7 @@ struct ThreadLocalStorage::Impl { #define _CALLBACK_FUNC_ #endif - Impl(void (_CALLBACK_FUNC_ *p_destr_callback_func)(void *)) { + Impl(void(_CALLBACK_FUNC_ *p_destr_callback_func)(void *)) { #ifdef WINDOWS_ENABLED dwFlsIndex = FlsAlloc(p_destr_callback_func); ERR_FAIL_COND(dwFlsIndex == FLS_OUT_OF_INDEXES); @@ -95,7 +95,7 @@ void ThreadLocalStorage::set_value(void *p_value) const { pimpl->set_value(p_value); } -void ThreadLocalStorage::alloc(void (_CALLBACK_FUNC_ *p_destr_callback)(void *)) { +void ThreadLocalStorage::alloc(void(_CALLBACK_FUNC_ *p_destr_callback)(void *)) { pimpl = memnew(ThreadLocalStorage::Impl(p_destr_callback)); } diff --git a/modules/mono/utils/thread_local.h b/modules/mono/utils/thread_local.h index 783e40dc01..84dae1d86b 100644 --- a/modules/mono/utils/thread_local.h +++ b/modules/mono/utils/thread_local.h @@ -76,7 +76,7 @@ struct ThreadLocalStorage { void *get_value() const; void set_value(void *p_value) const; - void alloc(void (_CALLBACK_FUNC_ *p_dest_callback)(void *)); + void alloc(void(_CALLBACK_FUNC_ *p_dest_callback)(void *)); void free(); private: @@ -95,7 +95,6 @@ class ThreadLocal { memdelete(static_cast<T *>(tls_data)); } - T *_tls_get_value() const { void *tls_data = storage.get_value(); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index d5bb85c035..ca3bbedef2 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -190,6 +190,28 @@ BOOL WINAPI HandlerRoutine(_In_ DWORD dwCtrlType) { } } +BOOL CALLBACK _CloseWindowsEnum(HWND hWnd, LPARAM lParam) { + DWORD dwID; + + GetWindowThreadProcessId(hWnd, &dwID); + + if (dwID == (DWORD)lParam) { + PostMessage(hWnd, WM_CLOSE, 0, 0); + } + + return TRUE; +} + +bool _close_gracefully(const PROCESS_INFORMATION &pi, const DWORD dwStopWaitMsec) { + if (!EnumWindows(_CloseWindowsEnum, pi.dwProcessId)) + return false; + + if (WaitForSingleObject(pi.hProcess, dwStopWaitMsec) != WAIT_OBJECT_0) + return false; + + return true; +} + void OS_Windows::initialize_debugging() { SetConsoleCtrlHandler(HandlerRoutine, TRUE); @@ -2322,20 +2344,26 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, return OK; }; -Error OS_Windows::kill(const ProcessID &p_pid) { - +Error OS_Windows::kill(const ProcessID &p_pid, const int p_max_wait_msec) { ERR_FAIL_COND_V(!process_map->has(p_pid), FAILED); const PROCESS_INFORMATION pi = (*process_map)[p_pid].pi; process_map->erase(p_pid); - const int ret = TerminateProcess(pi.hProcess, 0); + Error result; + + if (p_max_wait_msec != -1 && _close_gracefully(pi, p_max_wait_msec)) { + result = OK; + } else { + const int ret = TerminateProcess(pi.hProcess, 0); + result = ret != 0 ? OK : FAILED; + } CloseHandle(pi.hProcess); CloseHandle(pi.hThread); - return ret != 0 ? OK : FAILED; -}; + return result; +} int OS_Windows::get_process_id() const { return _getpid(); diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 69c7d851b8..8e39e4c990 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -258,7 +258,7 @@ public: virtual uint64_t get_ticks_usec() const; virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false); - virtual Error kill(const ProcessID &p_pid); + virtual Error kill(const ProcessID &p_pid, const int p_stop_max_wait_msec = -1); virtual int get_process_id() const; virtual bool has_environment(const String &p_var) const; diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index 507499a324..559e041dbf 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -296,6 +296,7 @@ float AudioStreamPlayer2D::get_volume_db() const { } void AudioStreamPlayer2D::set_pitch_scale(float p_pitch_scale) { + ERR_FAIL_COND(p_pitch_scale <= 0.0); pitch_scale = p_pitch_scale; } float AudioStreamPlayer2D::get_pitch_scale() const { diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index a035d9021f..7f7e3542ed 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -349,23 +349,12 @@ void CanvasItem::_update_callback() { Transform2D CanvasItem::get_global_transform_with_canvas() const { - const CanvasItem *ci = this; - Transform2D xform; - const CanvasItem *last_valid = NULL; - - while (ci) { - - last_valid = ci; - xform = ci->get_transform() * xform; - ci = ci->get_parent_item(); - } - - if (last_valid->canvas_layer) - return last_valid->canvas_layer->get_transform() * xform; + if (canvas_layer) + return canvas_layer->get_transform() * get_global_transform(); else if (is_inside_tree()) - return get_viewport()->get_canvas_transform() * xform; - - return xform; + return get_viewport()->get_canvas_transform() * get_global_transform(); + else + return get_global_transform(); } Transform2D CanvasItem::get_global_transform() const { diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 1e6a251c9c..85f8564ac2 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -139,6 +139,8 @@ class CanvasItem : public Node { GDCLASS(CanvasItem, Node); + friend class CanvasLayer; + public: enum BlendMode { diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index 1e2184bd41..52d04ac10a 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -38,7 +38,7 @@ void CollisionObject2D::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { - Transform2D global_transform = get_global_transform(); + Transform2D global_transform = get_global_transform_with_canvas(); if (area) Physics2DServer::get_singleton()->area_set_transform(rid, global_transform); @@ -64,7 +64,7 @@ void CollisionObject2D::_notification(int p_what) { } break; case NOTIFICATION_TRANSFORM_CHANGED: { - Transform2D global_transform = get_global_transform(); + Transform2D global_transform = get_global_transform_with_canvas(); if (only_update_transform_changes && global_transform == last_transform) { return; diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 02213e07d0..66686f10a8 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -35,19 +35,6 @@ #include "engine.h" #include "math_funcs.h" #include "scene/scene_string_names.h" -void PhysicsBody2D::_notification(int p_what) { - - /* - switch(p_what) { - - case NOTIFICATION_TRANSFORM_CHANGED: { - - Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_TRANSFORM,get_global_transform()); - - } break; - } - */ -} void PhysicsBody2D::_set_layers(uint32_t p_mask) { @@ -436,7 +423,7 @@ bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia, Physics2DServer::MotionResult *r = NULL; if (p_result.is_valid()) r = p_result->get_result_ptr(); - return Physics2DServer::get_singleton()->body_test_motion(get_rid(), get_global_transform(), p_motion, p_infinite_inertia, p_margin, r); + return Physics2DServer::get_singleton()->body_test_motion(get_rid(), get_global_transform_with_canvas(), p_motion, p_infinite_inertia, p_margin, r); } void RigidBody2D::_direct_state_changed(Object *p_state) { @@ -449,7 +436,7 @@ void RigidBody2D::_direct_state_changed(Object *p_state) { set_block_transform_notify(true); // don't want notify (would feedback loop) if (mode != MODE_KINEMATIC) - set_global_transform(state->get_transform()); + set_global_transform(get_canvas_transform().affine_inverse() * state->get_transform()); linear_velocity = state->get_linear_velocity(); angular_velocity = state->get_angular_velocity(); if (sleeping != state->is_sleeping()) { @@ -1144,7 +1131,7 @@ bool KinematicBody2D::separate_raycast_shapes(bool p_infinite_inertia, Collision Physics2DServer::SeparationResult sep_res[8]; //max 8 rays - Transform2D gt = get_global_transform(); + Transform2D gt = get_global_transform_with_canvas(); Vector2 recover; int hits = Physics2DServer::get_singleton()->body_test_ray_separation(get_rid(), gt, p_infinite_inertia, recover, sep_res, 8, margin); @@ -1158,7 +1145,7 @@ bool KinematicBody2D::separate_raycast_shapes(bool p_infinite_inertia, Collision } gt.elements[2] += recover; - set_global_transform(gt); + set_global_transform(get_canvas_transform().affine_inverse() * gt); if (deepest != -1) { r_collision.collider = sep_res[deepest].collider_id; @@ -1179,7 +1166,7 @@ bool KinematicBody2D::separate_raycast_shapes(bool p_infinite_inertia, Collision bool KinematicBody2D::move_and_collide(const Vector2 &p_motion, bool p_infinite_inertia, Collision &r_collision, bool p_exclude_raycast_shapes, bool p_test_only) { - Transform2D gt = get_global_transform(); + Transform2D gt = get_global_transform_with_canvas(); Physics2DServer::MotionResult result; bool colliding = Physics2DServer::get_singleton()->body_test_motion(get_rid(), gt, p_motion, p_infinite_inertia, margin, &result, p_exclude_raycast_shapes); @@ -1198,7 +1185,7 @@ bool KinematicBody2D::move_and_collide(const Vector2 &p_motion, bool p_infinite_ if (!p_test_only) { gt.elements[2] += result.motion; - set_global_transform(gt); + set_global_transform(get_canvas_transform().affine_inverse() * gt); } return colliding; @@ -1272,9 +1259,9 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const if (p_stop_on_slope) { if (Vector2() == lv_n + p_floor_direction) { - Transform2D gt = get_global_transform(); + Transform2D gt = get_global_transform_with_canvas(); gt.elements[2] -= collision.travel; - set_global_transform(gt); + set_global_transform(get_canvas_transform().affine_inverse() * gt); return Vector2(); } } @@ -1323,7 +1310,7 @@ Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_veloci } Collision col; - Transform2D gt = get_global_transform(); + Transform2D gt = get_global_transform_with_canvas(); if (move_and_collide(p_snap, p_infinite_inertia, col, false, true)) { gt.elements[2] += col.travel; @@ -1332,7 +1319,7 @@ Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_veloci on_floor_body = col.collider_rid; floor_velocity = col.collider_vel; } - set_global_transform(gt); + set_global_transform(get_canvas_transform().affine_inverse() * gt); } return ret; @@ -1429,22 +1416,22 @@ void KinematicBody2D::_direct_state_changed(Object *p_state) { last_valid_transform = state->get_transform(); set_notify_local_transform(false); - set_global_transform(last_valid_transform); + set_global_transform(get_canvas_transform().affine_inverse() * last_valid_transform); set_notify_local_transform(true); } void KinematicBody2D::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - last_valid_transform = get_global_transform(); + last_valid_transform = get_global_transform_with_canvas(); } if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) { //used by sync to physics, send the new transform to the physics - Transform2D new_transform = get_global_transform(); + Transform2D new_transform = get_global_transform_with_canvas(); Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_TRANSFORM, new_transform); //but then revert changes set_notify_local_transform(false); - set_global_transform(last_valid_transform); + set_global_transform(get_canvas_transform().affine_inverse() * last_valid_transform); set_notify_local_transform(true); } } diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 852963a721..0900438e3c 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -49,7 +49,6 @@ class PhysicsBody2D : public CollisionObject2D { uint32_t _get_layers() const; protected: - void _notification(int p_what); PhysicsBody2D(Physics2DServer::BodyMode p_mode); static void _bind_methods(); diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index 5f0ac3dd80..8504a18f54 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -626,6 +626,7 @@ float AudioStreamPlayer3D::get_max_db() const { } void AudioStreamPlayer3D::set_pitch_scale(float p_pitch_scale) { + ERR_FAIL_COND(p_pitch_scale <= 0.0); pitch_scale = p_pitch_scale; } float AudioStreamPlayer3D::get_pitch_scale() const { diff --git a/scene/animation/animation_blend_space_1d.cpp b/scene/animation/animation_blend_space_1d.cpp index 2bde8a16c9..289cf7a3a7 100644 --- a/scene/animation/animation_blend_space_1d.cpp +++ b/scene/animation/animation_blend_space_1d.cpp @@ -1,8 +1,7 @@ #include "animation_blend_space_1d.h" - void AnimationNodeBlendSpace1D::get_parameter_list(List<PropertyInfo> *r_list) const { - r_list->push_back(PropertyInfo(Variant::REAL,blend_position)); + r_list->push_back(PropertyInfo(Variant::REAL, blend_position)); } Variant AnimationNodeBlendSpace1D::get_parameter_default_value(const StringName &p_parameter) const { return 0; @@ -64,10 +63,10 @@ void AnimationNodeBlendSpace1D::_bind_methods() { } void AnimationNodeBlendSpace1D::get_child_nodes(List<ChildNode> *r_child_nodes) { - for(int i=0;i<blend_points_used;i++) { + for (int i = 0; i < blend_points_used; i++) { ChildNode cn; - cn.name=itos(i); - cn.node=blend_points[i].node; + cn.name = itos(i); + cn.node = blend_points[i].node; r_child_nodes->push_back(cn); } } @@ -89,12 +88,10 @@ void AnimationNodeBlendSpace1D::add_blend_point(const Ref<AnimationRootNode> &p_ blend_points[p_at_index].node = p_node; blend_points[p_at_index].position = p_position; - blend_points[p_at_index].node->connect("tree_changed",this,"_tree_changed",varray(),CONNECT_REFERENCE_COUNTED); + blend_points[p_at_index].node->connect("tree_changed", this, "_tree_changed", varray(), CONNECT_REFERENCE_COUNTED); blend_points_used++; emit_signal("tree_changed"); - - } void AnimationNodeBlendSpace1D::set_blend_point_position(int p_point, float p_position) { @@ -108,14 +105,13 @@ void AnimationNodeBlendSpace1D::set_blend_point_node(int p_point, const Ref<Anim ERR_FAIL_COND(p_node.is_null()); if (blend_points[p_point].node.is_valid()) { - blend_points[p_point].node->disconnect("tree_changed",this,"_tree_changed"); + blend_points[p_point].node->disconnect("tree_changed", this, "_tree_changed"); } blend_points[p_point].node = p_node; - blend_points[p_point].node->connect("tree_changed",this,"_tree_changed",varray(),CONNECT_REFERENCE_COUNTED); + blend_points[p_point].node->connect("tree_changed", this, "_tree_changed", varray(), CONNECT_REFERENCE_COUNTED); emit_signal("tree_changed"); - } float AnimationNodeBlendSpace1D::get_blend_point_position(int p_point) const { @@ -131,16 +127,14 @@ Ref<AnimationRootNode> AnimationNodeBlendSpace1D::get_blend_point_node(int p_poi void AnimationNodeBlendSpace1D::remove_blend_point(int p_point) { ERR_FAIL_INDEX(p_point, blend_points_used); - blend_points[p_point].node->disconnect("tree_changed",this,"_tree_changed"); + blend_points[p_point].node->disconnect("tree_changed", this, "_tree_changed"); for (int i = p_point; i < blend_points_used - 1; i++) { blend_points[i] = blend_points[i + 1]; } - blend_points_used--; emit_signal("tree_changed"); - } int AnimationNodeBlendSpace1D::get_blend_point_count() const { @@ -180,7 +174,6 @@ float AnimationNodeBlendSpace1D::get_snap() const { return snap; } - void AnimationNodeBlendSpace1D::set_value_label(const String &p_label) { value_label = p_label; } @@ -203,10 +196,9 @@ float AnimationNodeBlendSpace1D::process(float p_time, bool p_seek) { return 0.0; } - if (blend_points_used == 1) { // only one point available, just play that animation - return blend_node(blend_points[0].name,blend_points[0].node, p_time, p_seek, 1.0, FILTER_IGNORE, false); + return blend_node(blend_points[0].name, blend_points[0].node, p_time, p_seek, 1.0, FILTER_IGNORE, false); } float blend_pos = get_parameter(blend_position); @@ -277,7 +269,7 @@ float AnimationNodeBlendSpace1D::process(float p_time, bool p_seek) { float max_time_remaining = 0.0; for (int i = 0; i < blend_points_used; i++) { - float remaining = blend_node(blend_points[i].name,blend_points[i].node, p_time, p_seek, weights[i], FILTER_IGNORE, false); + float remaining = blend_node(blend_points[i].name, blend_points[i].node, p_time, p_seek, weights[i], FILTER_IGNORE, false); max_time_remaining = MAX(max_time_remaining, remaining); } @@ -291,8 +283,8 @@ String AnimationNodeBlendSpace1D::get_caption() const { AnimationNodeBlendSpace1D::AnimationNodeBlendSpace1D() { - for(int i=0;i<MAX_BLEND_POINTS;i++) { - blend_points[i].name=itos(i); + for (int i = 0; i < MAX_BLEND_POINTS; i++) { + blend_points[i].name = itos(i); } blend_points_used = 0; max_space = 1; @@ -301,9 +293,8 @@ AnimationNodeBlendSpace1D::AnimationNodeBlendSpace1D() { snap = 0.1; value_label = "value"; - blend_position="blend_position"; + blend_position = "blend_position"; } AnimationNodeBlendSpace1D::~AnimationNodeBlendSpace1D() { - } diff --git a/scene/animation/animation_blend_space_1d.h b/scene/animation/animation_blend_space_1d.h index b47accf973..f4e20f0d70 100644 --- a/scene/animation/animation_blend_space_1d.h +++ b/scene/animation/animation_blend_space_1d.h @@ -37,13 +37,11 @@ protected: static void _bind_methods(); public: - virtual void get_parameter_list(List<PropertyInfo> *r_list) const; virtual Variant get_parameter_default_value(const StringName &p_parameter) const; virtual void get_child_nodes(List<ChildNode> *r_child_nodes); - void add_blend_point(const Ref<AnimationRootNode> &p_node, float p_position, int p_at_index = -1); void set_blend_point_position(int p_point, float p_position); void set_blend_point_node(int p_point, const Ref<AnimationRootNode> &p_node); diff --git a/scene/animation/animation_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp index bce1477d4e..3dc7f2a86f 100644 --- a/scene/animation/animation_blend_space_2d.cpp +++ b/scene/animation/animation_blend_space_2d.cpp @@ -1,20 +1,18 @@ #include "animation_blend_space_2d.h" #include "math/delaunay.h" - void AnimationNodeBlendSpace2D::get_parameter_list(List<PropertyInfo> *r_list) const { - r_list->push_back(PropertyInfo(Variant::VECTOR2,blend_position)); + r_list->push_back(PropertyInfo(Variant::VECTOR2, blend_position)); } Variant AnimationNodeBlendSpace2D::get_parameter_default_value(const StringName &p_parameter) const { return Vector2(); } - void AnimationNodeBlendSpace2D::get_child_nodes(List<ChildNode> *r_child_nodes) { - for(int i=0;i<blend_points_used;i++) { + for (int i = 0; i < blend_points_used; i++) { ChildNode cn; - cn.name=itos(i); - cn.node=blend_points[i].node; + cn.name = itos(i); + cn.node = blend_points[i].node; r_child_nodes->push_back(cn); } } @@ -41,15 +39,13 @@ void AnimationNodeBlendSpace2D::add_blend_point(const Ref<AnimationRootNode> &p_ blend_points[p_at_index].node = p_node; blend_points[p_at_index].position = p_position; - blend_points[p_at_index].node->connect("tree_changed",this,"_tree_changed",varray(),CONNECT_REFERENCE_COUNTED); + blend_points[p_at_index].node->connect("tree_changed", this, "_tree_changed", varray(), CONNECT_REFERENCE_COUNTED); blend_points_used++; - if (auto_triangles) { trianges_dirty = true; } emit_signal("tree_changed"); - } void AnimationNodeBlendSpace2D::set_blend_point_position(int p_point, const Vector2 &p_position) { @@ -64,13 +60,12 @@ void AnimationNodeBlendSpace2D::set_blend_point_node(int p_point, const Ref<Anim ERR_FAIL_COND(p_node.is_null()); if (blend_points[p_point].node.is_valid()) { - blend_points[p_point].node->disconnect("tree_changed",this,"_tree_changed"); + blend_points[p_point].node->disconnect("tree_changed", this, "_tree_changed"); } blend_points[p_point].node = p_node; - blend_points[p_point].node->connect("tree_changed",this,"_tree_changed",varray(),CONNECT_REFERENCE_COUNTED); + blend_points[p_point].node->connect("tree_changed", this, "_tree_changed", varray(), CONNECT_REFERENCE_COUNTED); emit_signal("tree_changed"); - } Vector2 AnimationNodeBlendSpace2D::get_blend_point_position(int p_point) const { ERR_FAIL_INDEX_V(p_point, blend_points_used, Vector2()); @@ -83,7 +78,7 @@ Ref<AnimationRootNode> AnimationNodeBlendSpace2D::get_blend_point_node(int p_poi void AnimationNodeBlendSpace2D::remove_blend_point(int p_point) { ERR_FAIL_INDEX(p_point, blend_points_used); - blend_points[p_point].node->disconnect("tree_changed",this,"_tree_changed"); + blend_points[p_point].node->disconnect("tree_changed", this, "_tree_changed"); for (int i = 0; i < triangles.size(); i++) { bool erase = false; @@ -107,7 +102,6 @@ void AnimationNodeBlendSpace2D::remove_blend_point(int p_point) { } blend_points_used--; emit_signal("tree_changed"); - } int AnimationNodeBlendSpace2D::get_blend_point_count() const { @@ -451,7 +445,7 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) { for (int j = 0; j < 3; j++) { if (i == triangle_points[j]) { //blend with the given weight - float t = blend_node(blend_points[i].name,blend_points[i].node, p_time, p_seek, blend_weights[j], FILTER_IGNORE, false); + float t = blend_node(blend_points[i].name, blend_points[i].node, p_time, p_seek, blend_weights[j], FILTER_IGNORE, false); if (first || t < mind) { mind = t; first = false; @@ -463,7 +457,7 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) { if (!found) { //ignore - blend_node(blend_points[i].name,blend_points[i].node, p_time, p_seek, 0, FILTER_IGNORE, false); + blend_node(blend_points[i].name, blend_points[i].node, p_time, p_seek, 0, FILTER_IGNORE, false); } } return mind; @@ -491,7 +485,6 @@ void AnimationNodeBlendSpace2D::set_auto_triangles(bool p_enable) { } } - bool AnimationNodeBlendSpace2D::get_auto_triangles() const { return auto_triangles; } @@ -562,8 +555,8 @@ void AnimationNodeBlendSpace2D::_bind_methods() { AnimationNodeBlendSpace2D::AnimationNodeBlendSpace2D() { - for(int i=0;i<MAX_BLEND_POINTS;i++) { - blend_points[i].name=itos(i); + for (int i = 0; i < MAX_BLEND_POINTS; i++) { + blend_points[i].name = itos(i); } auto_triangles = true; blend_points_used = 0; @@ -577,6 +570,4 @@ AnimationNodeBlendSpace2D::AnimationNodeBlendSpace2D() { } AnimationNodeBlendSpace2D::~AnimationNodeBlendSpace2D() { - - } diff --git a/scene/animation/animation_blend_space_2d.h b/scene/animation/animation_blend_space_2d.h index 342909531b..3e1c66c924 100644 --- a/scene/animation/animation_blend_space_2d.h +++ b/scene/animation/animation_blend_space_2d.h @@ -45,13 +45,11 @@ class AnimationNodeBlendSpace2D : public AnimationRootNode { void _tree_changed(); - protected: virtual void _validate_property(PropertyInfo &property) const; static void _bind_methods(); public: - virtual void get_parameter_list(List<PropertyInfo> *r_list) const; virtual Variant get_parameter_default_value(const StringName &p_parameter) const; diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 68b0602c67..1513010a8a 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -5,36 +5,32 @@ #include "scene/scene_string_names.h" #include "servers/audio/audio_stream.h" - - void AnimationNode::get_parameter_list(List<PropertyInfo> *r_list) const { - } Variant AnimationNode::get_parameter_default_value(const StringName &p_parameter) const { return Variant(); } -void AnimationNode::set_parameter(const StringName& p_name, const Variant& p_value) { +void AnimationNode::set_parameter(const StringName &p_name, const Variant &p_value) { ERR_FAIL_COND(!state); ERR_FAIL_COND(!state->tree->property_parent_map.has(base_path)); ERR_FAIL_COND(!state->tree->property_parent_map[base_path].has(p_name)); StringName path = state->tree->property_parent_map[base_path][p_name]; - state->tree->property_map[path]=p_value; + state->tree->property_map[path] = p_value; } -Variant AnimationNode::get_parameter(const StringName& p_name) const { - ERR_FAIL_COND_V(!state,Variant()); - ERR_FAIL_COND_V(!state->tree->property_parent_map.has(base_path),Variant()); - ERR_FAIL_COND_V(!state->tree->property_parent_map[base_path].has(p_name),Variant()); +Variant AnimationNode::get_parameter(const StringName &p_name) const { + ERR_FAIL_COND_V(!state, Variant()); + ERR_FAIL_COND_V(!state->tree->property_parent_map.has(base_path), Variant()); + ERR_FAIL_COND_V(!state->tree->property_parent_map[base_path].has(p_name), Variant()); StringName path = state->tree->property_parent_map[base_path][p_name]; return state->tree->property_map[path]; } void AnimationNode::get_child_nodes(List<ChildNode> *r_child_nodes) { - } void AnimationNode::blend_animation(const StringName &p_animation, float p_time, float p_delta, bool p_seeked, float p_blend) { @@ -46,7 +42,7 @@ void AnimationNode::blend_animation(const StringName &p_animation, float p_time, if (animation.is_null()) { - AnimationNodeBlendTree* btree = Object::cast_to<AnimationNodeBlendTree>(parent); + AnimationNodeBlendTree *btree = Object::cast_to<AnimationNodeBlendTree>(parent); if (btree) { String name = btree->get_node_name(Ref<AnimationNodeAnimation>(this)); make_invalid(vformat(RTR("In node '%s', invalid animation: '%s'."), name, p_animation)); @@ -69,11 +65,11 @@ void AnimationNode::blend_animation(const StringName &p_animation, float p_time, state->animation_states.push_back(anim_state); } -float AnimationNode::_pre_process(const StringName& p_base_path, AnimationNode *p_parent, State *p_state, float p_time, bool p_seek, const Vector<StringName>& p_connections) { +float AnimationNode::_pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, float p_time, bool p_seek, const Vector<StringName> &p_connections) { base_path = p_base_path; parent = p_parent; - connections=p_connections; + connections = p_connections; state = p_state; float t = process(p_time, p_seek); @@ -99,8 +95,8 @@ float AnimationNode::blend_input(int p_input, float p_time, bool p_seek, float p ERR_FAIL_INDEX_V(p_input, inputs.size(), 0); ERR_FAIL_COND_V(!state, 0); - AnimationNodeBlendTree* blend_tree = Object::cast_to<AnimationNodeBlendTree>(parent); - ERR_FAIL_COND_V(!blend_tree,0); + AnimationNodeBlendTree *blend_tree = Object::cast_to<AnimationNodeBlendTree>(parent); + ERR_FAIL_COND_V(!blend_tree, 0); StringName node_name = connections[p_input]; @@ -114,15 +110,15 @@ float AnimationNode::blend_input(int p_input, float p_time, bool p_seek, float p //inputs.write[p_input].last_pass = state->last_pass; float activity; - return _blend_node(node_name,blend_tree->get_node_connection_array(node_name),NULL,node, p_time, p_seek, p_blend, p_filter, p_optimize, &activity); + return _blend_node(node_name, blend_tree->get_node_connection_array(node_name), NULL, node, p_time, p_seek, p_blend, p_filter, p_optimize, &activity); } -float AnimationNode::blend_node(const StringName& p_sub_path,Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize) { +float AnimationNode::blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize) { - return _blend_node(p_sub_path,Vector<StringName>(),this,p_node, p_time, p_seek, p_blend, p_filter, p_optimize); + return _blend_node(p_sub_path, Vector<StringName>(), this, p_node, p_time, p_seek, p_blend, p_filter, p_optimize); } -float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<StringName>& p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize, float *r_max) { +float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize, float *r_max) { ERR_FAIL_COND_V(!p_node.is_valid(), 0); ERR_FAIL_COND_V(!state, 0); @@ -229,13 +225,13 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin //this is the slowest part of processing, but as strings process in powers of 2, and the paths always exist, it will not result in that many allocations if (p_new_parent) { new_parent = p_new_parent; - new_path = String(base_path)+String(p_subpath)+"/"; + new_path = String(base_path) + String(p_subpath) + "/"; } else { - ERR_FAIL_COND_V(!parent,0); + ERR_FAIL_COND_V(!parent, 0); new_parent = parent; - new_path = String(parent->base_path) + String(p_subpath)+"/"; + new_path = String(parent->base_path) + String(p_subpath) + "/"; } - return p_node->_pre_process(new_path,new_parent,state, p_time, p_seek, p_connections); + return p_node->_pre_process(new_path, new_parent, state, p_time, p_seek, p_connections); } int AnimationNode::get_input_count() const { @@ -247,7 +243,6 @@ String AnimationNode::get_input_name(int p_input) { return inputs[p_input].name; } - String AnimationNode::get_caption() const { if (get_script_instance()) { @@ -313,8 +308,6 @@ bool AnimationNode::has_filter() const { return false; } - - Array AnimationNode::_get_filters() const { Array paths; @@ -358,16 +351,15 @@ void AnimationNode::_bind_methods() { ClassDB::bind_method(D_METHOD("set_filter_enabled", "enable"), &AnimationNode::set_filter_enabled); ClassDB::bind_method(D_METHOD("is_filter_enabled"), &AnimationNode::is_filter_enabled); - ClassDB::bind_method(D_METHOD("_set_filters", "filters"), &AnimationNode::_set_filters); ClassDB::bind_method(D_METHOD("_get_filters"), &AnimationNode::_get_filters); ClassDB::bind_method(D_METHOD("blend_animation", "animation", "time", "delta", "seeked", "blend"), &AnimationNode::blend_animation); - ClassDB::bind_method(D_METHOD("blend_node", "name","node", "time", "seek", "blend", "filter", "optimize"), &AnimationNode::blend_node, DEFVAL(FILTER_IGNORE), DEFVAL(true)); + ClassDB::bind_method(D_METHOD("blend_node", "name", "node", "time", "seek", "blend", "filter", "optimize"), &AnimationNode::blend_node, DEFVAL(FILTER_IGNORE), DEFVAL(true)); ClassDB::bind_method(D_METHOD("blend_input", "input_index", "time", "seek", "blend", "filter", "optimize"), &AnimationNode::blend_input, DEFVAL(FILTER_IGNORE), DEFVAL(true)); - ClassDB::bind_method(D_METHOD("set_parameter","name","value"), &AnimationNode::set_parameter); - ClassDB::bind_method(D_METHOD("get_parameter","name"), &AnimationNode::get_parameter); + ClassDB::bind_method(D_METHOD("set_parameter", "name", "value"), &AnimationNode::set_parameter); + ClassDB::bind_method(D_METHOD("get_parameter", "name"), &AnimationNode::get_parameter); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "filter_enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_filter_enabled", "is_filter_enabled"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "filters", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_filters", "_get_filters"); @@ -398,16 +390,16 @@ AnimationNode::AnimationNode() { void AnimationTree::set_tree_root(const Ref<AnimationNode> &p_root) { if (root.is_valid()) { - root->disconnect("tree_changed",this,"_tree_changed"); + root->disconnect("tree_changed", this, "_tree_changed"); } root = p_root; if (root.is_valid()) { - root->connect("tree_changed",this,"_tree_changed"); + root->connect("tree_changed", this, "_tree_changed"); } - properties_dirty=true; + properties_dirty = true; update_configuration_warning(); } @@ -738,11 +730,11 @@ void AnimationTree::_process_graph(float p_delta) { if (started) { //if started, seek - root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path,NULL,&state, 0, true,Vector<StringName>()); + root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, NULL, &state, 0, true, Vector<StringName>()); started = false; } - root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path,NULL,&state, p_delta, false,Vector<StringName>()); + root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, NULL, &state, p_delta, false, Vector<StringName>()); } if (!state.valid) { @@ -1284,27 +1276,27 @@ void AnimationTree::_tree_changed() { } call_deferred("_update_properties"); - properties_dirty=true; + properties_dirty = true; } -void AnimationTree::_update_properties_for_node(const String& p_base_path,Ref<AnimationNode> node) { +void AnimationTree::_update_properties_for_node(const String &p_base_path, Ref<AnimationNode> node) { if (!property_parent_map.has(p_base_path)) { - property_parent_map[p_base_path]=HashMap<StringName, StringName>(); + property_parent_map[p_base_path] = HashMap<StringName, StringName>(); } List<PropertyInfo> plist; node->get_parameter_list(&plist); - for(List<PropertyInfo>::Element *E=plist.front();E;E=E->next()) { + for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { PropertyInfo pinfo = E->get(); StringName key = pinfo.name; - if (!property_map.has(p_base_path +key)) { + if (!property_map.has(p_base_path + key)) { property_map[p_base_path + key] = node->get_parameter_default_value(key); } - property_parent_map[p_base_path][key]=p_base_path+key; + property_parent_map[p_base_path][key] = p_base_path + key; pinfo.name = p_base_path + key; properties.push_back(pinfo); @@ -1313,8 +1305,8 @@ void AnimationTree::_update_properties_for_node(const String& p_base_path,Ref<An List<AnimationNode::ChildNode> children; node->get_child_nodes(&children); - for (List<AnimationNode::ChildNode>::Element *E=children.front();E;E=E->next()) { - _update_properties_for_node(p_base_path+E->get().name+"/",E->get().node); + for (List<AnimationNode::ChildNode>::Element *E = children.front(); E; E = E->next()) { + _update_properties_for_node(p_base_path + E->get().name + "/", E->get().node); } } @@ -1327,7 +1319,7 @@ void AnimationTree::_update_properties() { property_parent_map.clear(); if (root.is_valid()) { - _update_properties_for_node(SceneStringNames::get_singleton()->parameters_base_path,root); + _update_properties_for_node(SceneStringNames::get_singleton()->parameters_base_path, root); } properties_dirty = false; @@ -1341,7 +1333,7 @@ bool AnimationTree::_set(const StringName &p_name, const Variant &p_value) { } if (property_map.has(p_name)) { - property_map[p_name]=p_value; + property_map[p_name] = p_value; #ifdef TOOLS_ENABLED _change_notify(p_name.operator String().utf8().get_data()); #endif @@ -1353,39 +1345,38 @@ bool AnimationTree::_set(const StringName &p_name, const Variant &p_value) { bool AnimationTree::_get(const StringName &p_name, Variant &r_ret) const { if (properties_dirty) { - const_cast<AnimationTree*>(this)->_update_properties(); + const_cast<AnimationTree *>(this)->_update_properties(); } if (property_map.has(p_name)) { - r_ret=property_map[p_name]; + r_ret = property_map[p_name]; return true; } return false; - } void AnimationTree::_get_property_list(List<PropertyInfo> *p_list) const { if (properties_dirty) { - const_cast<AnimationTree*>(this)->_update_properties(); + const_cast<AnimationTree *>(this)->_update_properties(); } - for (const List<PropertyInfo>::Element *E=properties.front();E;E=E->next()) { + for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { p_list->push_back(E->get()); } } -void AnimationTree::rename_parameter(const String& p_base,const String& p_new_base) { +void AnimationTree::rename_parameter(const String &p_base, const String &p_new_base) { //rename values first - for (const List<PropertyInfo>::Element *E=properties.front();E;E=E->next()) { + for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { if (E->get().name.begins_with(p_base)) { - String new_name = E->get().name.replace_first(p_base,p_new_base); - property_map[new_name]=property_map[E->get().name]; + String new_name = E->get().name.replace_first(p_base, p_new_base); + property_map[new_name] = property_map[E->get().name]; } } //update tree second - properties_dirty=true; + properties_dirty = true; _update_properties(); } @@ -1410,8 +1401,7 @@ void AnimationTree::_bind_methods() { ClassDB::bind_method(D_METHOD("_tree_changed"), &AnimationTree::_tree_changed); ClassDB::bind_method(D_METHOD("_update_properties"), &AnimationTree::_update_properties); - ClassDB::bind_method(D_METHOD("rename_parameter","old_name","new_name"), &AnimationTree::rename_parameter); - + ClassDB::bind_method(D_METHOD("rename_parameter", "old_name", "new_name"), &AnimationTree::rename_parameter); ClassDB::bind_method(D_METHOD("advance", "delta"), &AnimationTree::advance); @@ -1440,5 +1430,4 @@ AnimationTree::AnimationTree() { } AnimationTree::~AnimationTree() { - } diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp index 863b278b62..7a9f2bd8d0 100644 --- a/scene/audio/audio_player.cpp +++ b/scene/audio/audio_player.cpp @@ -192,6 +192,7 @@ float AudioStreamPlayer::get_volume_db() const { } void AudioStreamPlayer::set_pitch_scale(float p_pitch_scale) { + ERR_FAIL_COND(p_pitch_scale <= 0.0); pitch_scale = p_pitch_scale; } float AudioStreamPlayer::get_pitch_scale() const { diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp index a2e890e7a7..c044443b51 100644 --- a/scene/main/canvas_layer.cpp +++ b/scene/main/canvas_layer.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "canvas_layer.h" +#include "scene/2d/canvas_item.h" #include "viewport.h" void CanvasLayer::set_layer(int p_xform) { @@ -62,6 +63,24 @@ void CanvasLayer::_update_xform() { transform.set_origin(ofs); if (viewport.is_valid()) VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform); + + if (!is_inside_tree()) + return; + + _notify_xform(this); +} + +void CanvasLayer::_notify_xform(Node *p_node) { + + for (int i = 0; i < p_node->get_child_count(); i++) { + + CanvasItem *ci = Object::cast_to<CanvasItem>(p_node->get_child(i)); + if (ci) { + ci->_notify_transform(ci); + } else { + _notify_xform(p_node->get_child(i)); + } + } } void CanvasLayer::_update_locrotscale() { diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h index aae23fbb12..fd347c4739 100644 --- a/scene/main/canvas_layer.h +++ b/scene/main/canvas_layer.h @@ -56,6 +56,7 @@ class CanvasLayer : public Node { int sort_index; void _update_xform(); + void _notify_xform(Node *p_node); void _update_locrotscale(); protected: diff --git a/scene/main/node.cpp b/scene/main/node.cpp index d6a80bfb1a..f6905e7c2e 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -240,7 +240,7 @@ void Node::_propagate_enter_tree() { void Node::_propagate_exit_tree() { -//block while removing children + //block while removing children #ifdef DEBUG_ENABLED diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index d6c22d5664..143a1438ea 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -34,7 +34,7 @@ void Material::set_next_pass(const Ref<Material> &p_pass) { - ERR_FAIL_COND(p_pass.ptr() == this); + ERR_FAIL_COND(p_pass == this); if (next_pass == p_pass) return; diff --git a/servers/audio/effects/audio_effect_pitch_shift.cpp b/servers/audio/effects/audio_effect_pitch_shift.cpp index ddd0a0db6b..c6d1217308 100644 --- a/servers/audio/effects/audio_effect_pitch_shift.cpp +++ b/servers/audio/effects/audio_effect_pitch_shift.cpp @@ -305,9 +305,9 @@ Ref<AudioEffectInstance> AudioEffectPitchShift::instance() { return ins; } -void AudioEffectPitchShift::set_pitch_scale(float p_adjust) { - - pitch_scale = p_adjust; +void AudioEffectPitchShift::set_pitch_scale(float p_pitch_scale) { + ERR_FAIL_COND(p_pitch_scale <= 0.0); + pitch_scale = p_pitch_scale; } float AudioEffectPitchShift::get_pitch_scale() const { diff --git a/servers/audio/effects/audio_effect_pitch_shift.h b/servers/audio/effects/audio_effect_pitch_shift.h index f1c78d752f..78f92a0261 100644 --- a/servers/audio/effects/audio_effect_pitch_shift.h +++ b/servers/audio/effects/audio_effect_pitch_shift.h @@ -100,7 +100,7 @@ protected: public: Ref<AudioEffectInstance> instance(); - void set_pitch_scale(float p_adjust); + void set_pitch_scale(float p_pitch_scale); float get_pitch_scale() const; AudioEffectPitchShift(); |