diff options
-rw-r--r-- | core/object.cpp | 5 | ||||
-rw-r--r-- | core/resource.cpp | 17 | ||||
-rw-r--r-- | doc/classes/Dictionary.xml | 1 | ||||
-rw-r--r-- | doc/classes/File.xml | 35 | ||||
-rw-r--r-- | doc/classes/FileDialog.xml | 6 | ||||
-rw-r--r-- | doc/classes/RigidBody2D.xml | 7 | ||||
-rw-r--r-- | doc/classes/RigidBody3D.xml | 7 | ||||
-rw-r--r-- | editor/editor_node.cpp | 4 | ||||
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 6 | ||||
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.h | 4 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 1 | ||||
-rw-r--r-- | editor/scene_tree_dock.cpp | 4 | ||||
-rw-r--r-- | scene/gui/file_dialog.cpp | 5 | ||||
-rw-r--r-- | scene/resources/default_theme/default_theme.cpp | 2 | ||||
-rw-r--r-- | scene/resources/default_theme/icon_file.png | bin | 0 -> 183 bytes | |||
-rw-r--r-- | scene/resources/default_theme/theme_data.h | 4 | ||||
-rw-r--r-- | servers/physics_2d/broad_phase_2d_basic.cpp | 4 | ||||
-rw-r--r-- | servers/physics_2d/broad_phase_2d_hash_grid.cpp | 5 | ||||
-rw-r--r-- | servers/physics_2d/space_2d_sw.cpp | 8 | ||||
-rw-r--r-- | servers/physics_3d/broad_phase_3d_basic.cpp | 4 | ||||
-rw-r--r-- | servers/physics_3d/space_3d_sw.cpp | 8 |
21 files changed, 102 insertions, 35 deletions
diff --git a/core/object.cpp b/core/object.cpp index f3c5a13809..3ea3e27d41 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -2038,7 +2038,7 @@ void ObjectDB::cleanup() { if (slot_count > 0) { spin_lock.lock(); - WARN_PRINT("ObjectDB Instances still exist!"); + WARN_PRINT("ObjectDB instances leaked at exit (run with --verbose for details)."); if (OS::get_singleton()->is_stdout_verbose()) { for (uint32_t i = 0; i < slot_count; i++) { uint32_t slot = object_slots[i].next_free; @@ -2049,12 +2049,13 @@ void ObjectDB::cleanup() { node_name = " - Node name: " + String(obj->call("get_name")); } if (obj->is_class("Resource")) { - node_name = " - Resource name: " + String(obj->call("get_name")) + " Path: " + String(obj->call("get_path")); + node_name = " - Resource path: " + String(obj->call("get_path")); } uint64_t id = uint64_t(slot) | (uint64_t(object_slots[slot].validator) << OBJECTDB_VALIDATOR_BITS) | (object_slots[slot].is_reference ? OBJECTDB_REFERENCE_BIT : 0); print_line("Leaked instance: " + String(obj->get_class()) + ":" + itos(id) + node_name); } + print_line("Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not freed (with `free()` or `queue_free()`)."); } spin_lock.unlock(); } diff --git a/core/resource.cpp b/core/resource.cpp index 0af8c9c2b3..3b589793ef 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -33,6 +33,7 @@ #include "core/core_string_names.h" #include "core/io/resource_loader.h" #include "core/os/file_access.h" +#include "core/os/os.h" #include "core/script_language.h" #include "scene/main/node.h" //only so casting works @@ -431,7 +432,14 @@ void ResourceCache::setup() { void ResourceCache::clear() { if (resources.size()) { - ERR_PRINT("Resources Still in use at Exit!"); + ERR_PRINT("Resources still in use at exit (run with --verbose for details)."); + if (OS::get_singleton()->is_stdout_verbose()) { + const String *K = nullptr; + while ((K = resources.next(K))) { + Resource *r = resources[*K]; + print_line(vformat("Resource still in use: %s (%s)", *K, r->get_class())); + } + } } resources.clear(); @@ -442,12 +450,6 @@ void ResourceCache::clear() { } void ResourceCache::reload_externals() { - /* - const String *K=nullptr; - while ((K=resources.next(K))) { - resources[*K]->reload_external_data(); - } - */ } bool ResourceCache::has(const String &p_path) { @@ -530,6 +532,5 @@ void ResourceCache::dump(const char *p_file, bool p_short) { } lock->read_unlock(); - #endif } diff --git a/doc/classes/Dictionary.xml b/doc/classes/Dictionary.xml index 385f4b7e59..4538e5ea4e 100644 --- a/doc/classes/Dictionary.xml +++ b/doc/classes/Dictionary.xml @@ -148,6 +148,7 @@ # The line below prints `true`, whereas it would have printed `false` if both variables were compared directly. print(dict1.hash() == dict2.hash()) [/codeblock] + [b]Note:[/b] Dictionaries with the same keys/values but in a different order will have a different hash. </description> </method> <method name="keys"> diff --git a/doc/classes/File.xml b/doc/classes/File.xml index 17c65731ff..b90039e496 100644 --- a/doc/classes/File.xml +++ b/doc/classes/File.xml @@ -54,28 +54,28 @@ <return type="int"> </return> <description> - Returns the next 16 bits from the file as an integer. + Returns the next 16 bits from the file as an integer. See [method store_16] for details on what values can be stored and retrieved this way. </description> </method> <method name="get_32" qualifiers="const"> <return type="int"> </return> <description> - Returns the next 32 bits from the file as an integer. + Returns the next 32 bits from the file as an integer. See [method store_32] for details on what values can be stored and retrieved this way. </description> </method> <method name="get_64" qualifiers="const"> <return type="int"> </return> <description> - Returns the next 64 bits from the file as an integer. + Returns the next 64 bits from the file as an integer. See [method store_64] for details on what values can be stored and retrieved this way. </description> </method> <method name="get_8" qualifiers="const"> <return type="int"> </return> <description> - Returns the next 8 bits from the file as an integer. + Returns the next 8 bits from the file as an integer. See [method store_8] for details on what values can be stored and retrieved this way. </description> </method> <method name="get_as_text" qualifiers="const"> @@ -297,7 +297,26 @@ </argument> <description> Stores an integer as 16 bits in the file. - [b]Note:[/b] The [code]value[/code] should lie in the interval [code][0, 2^16 - 1][/code]. + [b]Note:[/b] The [code]value[/code] should lie in the interval [code][0, 2^16 - 1][/code]. Any other value will overflow and wrap around. + To store a signed integer, use [method store_64] or store a signed integer from the interval [code][-2^15, 2^15 - 1][/code] (i.e. keeping one bit for the signedness) and compute its sign manually when reading. For example: + [codeblock] + const MAX_15B = 1 << 15 + const MAX_16B = 1 << 16 + + func unsigned16_to_signed(unsigned): + return (unsigned + MAX_15B) % MAX_16B - MAX_15B + + func _ready(): + var f = File.new() + f.open("user://file.dat", File.WRITE_READ) + f.store_16(-42) # This wraps around and stores 65494 (2^16 - 42). + f.store_16(121) # In bounds, will store 121. + f.seek(0) # Go back to start to read the stored value. + var read1 = f.get_16() # 65494 + var read2 = f.get_16() # 121 + var converted1 = unsigned16_to_signed(read1) # -42 + var converted2 = unsigned16_to_signed(read2) # 121 + [/codeblock] </description> </method> <method name="store_32"> @@ -307,7 +326,8 @@ </argument> <description> Stores an integer as 32 bits in the file. - [b]Note:[/b] The [code]value[/code] should lie in the interval [code][0, 2^32 - 1][/code]. + [b]Note:[/b] The [code]value[/code] should lie in the interval [code][0, 2^32 - 1][/code]. Any other value will overflow and wrap around. + To store a signed integer, use [method store_64], or convert it manually (see [method store_16] for an example). </description> </method> <method name="store_64"> @@ -327,7 +347,8 @@ </argument> <description> Stores an integer as 8 bits in the file. - [b]Note:[/b] The [code]value[/code] should lie in the interval [code][0, 255][/code]. + [b]Note:[/b] The [code]value[/code] should lie in the interval [code][0, 255][/code]. Any other value will overflow and wrap around. + To store a signed integer, use [method store_64], or convert it manually (see [method store_16] for an example). </description> </method> <method name="store_buffer"> diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml index 99563ee367..f4868df6a4 100644 --- a/doc/classes/FileDialog.xml +++ b/doc/classes/FileDialog.xml @@ -132,6 +132,12 @@ </constant> </constants> <theme_items> + <theme_item name="file" type="Texture2D"> + Custom icon for files. + </theme_item> + <theme_item name="file_icon_modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + The color modulation applied to the file icon. + </theme_item> <theme_item name="files_disabled" type="Color" default="Color( 0, 0, 0, 0.7 )"> The color tint for disabled files (when the [FileDialog] is used in open folder mode). </theme_item> diff --git a/doc/classes/RigidBody2D.xml b/doc/classes/RigidBody2D.xml index 8379fc5b58..a3fd2e81fd 100644 --- a/doc/classes/RigidBody2D.xml +++ b/doc/classes/RigidBody2D.xml @@ -127,7 +127,7 @@ The body's total applied torque. </member> <member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep" default="true"> - If [code]true[/code], the body will not calculate forces and will act as a static body if there is no movement. The body will wake up when other forces are applied via collisions or by using [method apply_impulse] or [method add_force]. + If [code]true[/code], the body can enter sleep mode when there is no movement. See [member sleeping]. </member> <member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled" default="false"> If [code]true[/code], the body will emit signals when it collides with another RigidBody2D. See also [member contacts_reported]. @@ -165,7 +165,7 @@ If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one. </member> <member name="sleeping" type="bool" setter="set_sleeping" getter="is_sleeping" default="false"> - If [code]true[/code], the body is sleeping and will not calculate forces until woken up by a collision or by using [method apply_impulse] or [method add_force]. + If [code]true[/code], the body will not move and will not calculate forces until woken up by another body through, for example, a collision, or by using the [method apply_impulse] or [method add_force] methods. </member> <member name="weight" type="float" setter="set_weight" getter="get_weight" default="9.8"> The body's weight based on its mass and the [b]Default Gravity[/b] value in [b]Project > Project Settings > Physics > 2d[/b]. @@ -214,7 +214,8 @@ </signal> <signal name="sleeping_state_changed"> <description> - Emitted when [member sleeping] changes. + Emitted when the physics engine changes the body's sleeping state. + [b]Note:[/b] Changing the value [member sleeping] will not trigger this signal. It is only emitted if the sleeping state is changed by the physics engine or [code]emit_signal("sleeping_state_changed")[/code] is used. </description> </signal> </signals> diff --git a/doc/classes/RigidBody3D.xml b/doc/classes/RigidBody3D.xml index 1db818d6af..063cc3ca59 100644 --- a/doc/classes/RigidBody3D.xml +++ b/doc/classes/RigidBody3D.xml @@ -147,7 +147,7 @@ Lock the body's movement in the Z axis. </member> <member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep" default="true"> - If [code]true[/code], the body is deactivated when there is no movement, so it will not take part in the simulation until it is awaken by an external force. + If [code]true[/code], the body can enter sleep mode when there is no movement. See [member sleeping]. </member> <member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled" default="false"> If [code]true[/code], the RigidBody3D will emit signals when it collides with another RigidBody3D. @@ -182,7 +182,7 @@ If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one. </member> <member name="sleeping" type="bool" setter="set_sleeping" getter="is_sleeping" default="false"> - If [code]true[/code], the body is sleeping and will not calculate forces until woken up by a collision or the [code]apply_impulse[/code] method. + If [code]true[/code], the body will not move and will not calculate forces until woken up by another body through, for example, a collision, or by using the [method apply_impulse] or [method add_force] methods. </member> <member name="weight" type="float" setter="set_weight" getter="get_weight" default="9.8"> The body's weight based on its mass and the global 3D gravity. Global values are set in [b]Project > Project Settings > Physics > 3d[/b]. @@ -233,7 +233,8 @@ </signal> <signal name="sleeping_state_changed"> <description> - Emitted when the body changes its sleeping state. Either by sleeping or waking up. + Emitted when the physics engine changes the body's sleeping state. + [b]Note:[/b] Changing the value [member sleeping] will not trigger this signal. It is only emitted if the sleeping state is changed by the physics engine or [code]emit_signal("sleeping_state_changed")[/code] is used. </description> </signal> </signals> diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 86af5b742f..9a9a1bfdeb 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -619,7 +619,9 @@ void EditorNode::_fs_changed() { preset.unref(); } if (preset.is_null()) { - export_error = vformat("Invalid export preset name: %s.", preset_name); + export_error = vformat( + "Invalid export preset name: %s. Make sure `export_presets.cfg` is present in the current directory.", + preset_name); } else { Ref<EditorExportPlatform> platform = preset->get_platform(); if (platform.is_null()) { diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index b8209fe50d..796dd3f8b2 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -3419,11 +3419,7 @@ void Node3DEditorViewport::reset() { last_message = ""; name = ""; - cursor.x_rot = 0.5; - cursor.y_rot = 0.5; - cursor.distance = 4; - cursor.region_select = false; - cursor.pos = Vector3(); + cursor = Cursor(); _update_name(); } diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index 32b087c372..83173b5ad2 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -391,7 +391,9 @@ private: Point2 region_begin, region_end; Cursor() { - x_rot = y_rot = 0.5; + // These rotations place the camera in +X +Y +Z, aka south east, facing north west. + x_rot = 0.5; + y_rot = -0.5; distance = 4; region_select = false; } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 8d6dac3907..48a9febcf9 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -837,7 +837,6 @@ void ScriptEditor::_file_dialog_action(String p_file) { Error err; FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err); if (err) { - memdelete(file); editor->show_warning(TTR("Error writing TextFile:") + "\n" + p_file, TTR("Error!")); break; } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index c37d32b26b..5795d85e66 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2658,7 +2658,9 @@ void SceneTreeDock::_remote_tree_selected() { } void SceneTreeDock::_local_tree_selected() { - scene_tree->show(); + if (!bool(EDITOR_GET("interface/editors/show_scene_tree_root_selection")) || get_tree()->get_edited_scene_root() != nullptr) { + scene_tree->show(); + } if (remote_tree) { remote_tree->hide(); } diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index be6b542ae1..630f3c8ff6 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -402,7 +402,9 @@ void FileDialog::update_file_list() { TreeItem *root = tree->create_item(); Ref<Texture2D> folder = vbox->get_theme_icon("folder", "FileDialog"); + Ref<Texture2D> file_icon = vbox->get_theme_icon("file", "FileDialog"); const Color folder_color = vbox->get_theme_color("folder_icon_modulate", "FileDialog"); + const Color file_color = vbox->get_theme_color("file_icon_modulate", "FileDialog"); List<String> files; List<String> dirs; @@ -491,7 +493,10 @@ void FileDialog::update_file_list() { if (get_icon_func) { Ref<Texture2D> icon = get_icon_func(base_dir.plus_file(files.front()->get())); ti->set_icon(0, icon); + } else { + ti->set_icon(0, file_icon); } + ti->set_icon_modulate(0, file_color); if (mode == FILE_MODE_OPEN_DIR) { ti->set_custom_color(0, vbox->get_theme_color("files_disabled", "FileDialog")); diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index de39fac627..fd5c861eb5 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -726,7 +726,9 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const // FileDialog theme->set_icon("folder", "FileDialog", make_icon(icon_folder_png)); + theme->set_icon("file", "FileDialog", make_icon(icon_file_png)); theme->set_color("folder_icon_modulate", "FileDialog", Color(1, 1, 1)); + theme->set_color("file_icon_modulate", "FileDialog", Color(1, 1, 1)); theme->set_color("files_disabled", "FileDialog", Color(0, 0, 0, 0.7)); // ColorPicker diff --git a/scene/resources/default_theme/icon_file.png b/scene/resources/default_theme/icon_file.png Binary files differnew file mode 100644 index 0000000000..bb4c361a8d --- /dev/null +++ b/scene/resources/default_theme/icon_file.png diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h index 0a4e557451..edcdb90db9 100644 --- a/scene/resources/default_theme/theme_data.h +++ b/scene/resources/default_theme/theme_data.h @@ -150,6 +150,10 @@ static const unsigned char icon_color_pick_png[] = { 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0xaa, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0x9d, 0x8e, 0x35, 0x82, 0x2, 0x41, 0x10, 0x45, 0x3b, 0xda, 0x3d, 0xca, 0xba, 0x44, 0x2b, 0x70, 0x9, 0xdc, 0xe1, 0x20, 0xe8, 0x91, 0x90, 0x78, 0x6e, 0x40, 0x4c, 0x82, 0x74, 0xff, 0xc2, 0x9d, 0x18, 0xa7, 0x6, 0x77, 0x7b, 0x23, 0x2d, 0xaf, 0x4c, 0xdc, 0xc, 0xbd, 0x65, 0x1e, 0x84, 0x80, 0x19, 0x55, 0x34, 0x60, 0x3e, 0xd0, 0xea, 0x17, 0x3d, 0x4a, 0xc8, 0x80, 0x1a, 0x60, 0xc2, 0x4f, 0xfd, 0x30, 0xe0, 0x1b, 0x2d, 0x16, 0xab, 0xa7, 0x2c, 0xe, 0x41, 0x68, 0xa5, 0xb9, 0xca, 0x91, 0x16, 0x2e, 0x54, 0xe0, 0x59, 0x54, 0x91, 0xfe, 0xa3, 0x3a, 0xff, 0xce, 0xab, 0x5b, 0xf, 0xa0, 0x4, 0x8f, 0x7b, 0x4c, 0xd3, 0x1b, 0xca, 0x32, 0xcc, 0x55, 0x7a, 0xf4, 0x76, 0x42, 0x2b, 0x97, 0x3e, 0xae, 0xfa, 0xdd, 0xd2, 0xd2, 0x8e, 0x72, 0xe1, 0x83, 0xaf, 0x9f, 0xa9, 0x28, 0x7d, 0x5b, 0xe2, 0x2a, 0xd, 0xc3, 0xa2, 0x78, 0xfe, 0x7d, 0x51, 0xfc, 0x0, 0x8a, 0x41, 0xcb, 0x3d, 0xb2, 0xae, 0x1c, 0xd3, 0xc, 0xa5, 0x30, 0x81, 0xc6, 0xda, 0x29, 0x8e, 0x83, 0x34, 0x25, 0x29, 0x4a, 0x46, 0x71, 0x1f, 0x33, 0xbe, 0x51, 0x89, 0xaf, 0x78, 0xe3, 0x97, 0x7e, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 }; +static const unsigned char icon_file_png[] = { + 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x2, 0x3, 0x0, 0x0, 0x0, 0x62, 0x9d, 0x17, 0xf2, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xe, 0xc3, 0x0, 0x0, 0xe, 0xc3, 0x1, 0xc7, 0x6f, 0xa8, 0x64, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x0, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63, 0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x0, 0x0, 0x0, 0x9, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0xdf, 0xdf, 0xdf, 0xe0, 0xe0, 0xe0, 0x42, 0xf, 0xc7, 0x49, 0x0, 0x0, 0x0, 0x2, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x88, 0x95, 0xf0, 0xc6, 0x2a, 0x0, 0x0, 0x0, 0x21, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x0, 0x1, 0xae, 0x55, 0x2d, 0x20, 0xa2, 0x13, 0x44, 0x74, 0x39, 0x80, 0x88, 0x9, 0x40, 0xa2, 0x1, 0xc4, 0x5d, 0xb5, 0x80, 0x68, 0x2, 0x4, 0x0, 0x95, 0x34, 0x18, 0xe4, 0x5e, 0x46, 0xf7, 0x27, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 +}; + static const unsigned char icon_folder_png[] = { 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x2e, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0x63, 0xa0, 0x6, 0x78, 0x70, 0xf4, 0xc1, 0x7f, 0x24, 0x78, 0x18, 0x53, 0xc1, 0x7f, 0x54, 0x48, 0x50, 0xc1, 0x43, 0x1b, 0xbc, 0xa, 0x50, 0xad, 0x23, 0xa4, 0xe0, 0xff, 0x70, 0x52, 0x70, 0x18, 0x97, 0xf4, 0xfd, 0x43, 0xd4, 0x88, 0x4a, 0x0, 0x5a, 0xcb, 0x18, 0xab, 0x5e, 0xd9, 0x1a, 0x53, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 }; diff --git a/servers/physics_2d/broad_phase_2d_basic.cpp b/servers/physics_2d/broad_phase_2d_basic.cpp index 8c7e715a09..3bdfc1a973 100644 --- a/servers/physics_2d/broad_phase_2d_basic.cpp +++ b/servers/physics_2d/broad_phase_2d_basic.cpp @@ -152,8 +152,10 @@ void BroadPhase2DBasic::update() { void *data = nullptr; if (pair_callback) { data = pair_callback(elem_A->owner, elem_A->subindex, elem_B->owner, elem_B->subindex, unpair_userdata); + if (data) { + pair_map.insert(key, data); + } } - pair_map.insert(key, data); } } } diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.cpp b/servers/physics_2d/broad_phase_2d_hash_grid.cpp index ae549ed2e4..cfd02cef2c 100644 --- a/servers/physics_2d/broad_phase_2d_hash_grid.cpp +++ b/servers/physics_2d/broad_phase_2d_hash_grid.cpp @@ -75,7 +75,10 @@ void BroadPhase2DHashGrid::_check_motion(Element *p_elem) { if (pairing != E->get()->colliding) { if (pairing) { if (pair_callback) { - E->get()->ud = pair_callback(p_elem->owner, p_elem->subindex, E->key()->owner, E->key()->subindex, pair_userdata); + void *ud = pair_callback(p_elem->owner, p_elem->subindex, E->key()->owner, E->key()->subindex, pair_userdata); + if (ud) { + E->get()->ud = ud; + } } } else { if (unpair_callback) { diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index f4a21da254..966dcbd651 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -1111,6 +1111,10 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co } void *Space2DSW::_broadphase_pair(CollisionObject2DSW *A, int p_subindex_A, CollisionObject2DSW *B, int p_subindex_B, void *p_self) { + if (!A->test_collision_mask(B)) { + return nullptr; + } + CollisionObject2DSW::Type type_A = A->get_type(); CollisionObject2DSW::Type type_B = B->get_type(); if (type_A > type_B) { @@ -1143,6 +1147,10 @@ void *Space2DSW::_broadphase_pair(CollisionObject2DSW *A, int p_subindex_A, Coll } void Space2DSW::_broadphase_unpair(CollisionObject2DSW *A, int p_subindex_A, CollisionObject2DSW *B, int p_subindex_B, void *p_data, void *p_self) { + if (!p_data) { + return; + } + Space2DSW *self = (Space2DSW *)p_self; self->collision_pairs--; Constraint2DSW *c = (Constraint2DSW *)p_data; diff --git a/servers/physics_3d/broad_phase_3d_basic.cpp b/servers/physics_3d/broad_phase_3d_basic.cpp index 0f271b33af..f5ea1897a9 100644 --- a/servers/physics_3d/broad_phase_3d_basic.cpp +++ b/servers/physics_3d/broad_phase_3d_basic.cpp @@ -190,8 +190,10 @@ void BroadPhase3DBasic::update() { void *data = nullptr; if (pair_callback) { data = pair_callback(elem_A->owner, elem_A->subindex, elem_B->owner, elem_B->subindex, unpair_userdata); + if (data) { + pair_map.insert(key, data); + } } - pair_map.insert(key, data); } } } diff --git a/servers/physics_3d/space_3d_sw.cpp b/servers/physics_3d/space_3d_sw.cpp index 4d272bdabd..48f250ba35 100644 --- a/servers/physics_3d/space_3d_sw.cpp +++ b/servers/physics_3d/space_3d_sw.cpp @@ -987,6 +987,10 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, cons } void *Space3DSW::_broadphase_pair(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_self) { + if (!A->test_collision_mask(B)) { + return nullptr; + } + CollisionObject3DSW::Type type_A = A->get_type(); CollisionObject3DSW::Type type_B = B->get_type(); if (type_A > type_B) { @@ -1019,6 +1023,10 @@ void *Space3DSW::_broadphase_pair(CollisionObject3DSW *A, int p_subindex_A, Coll } void Space3DSW::_broadphase_unpair(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_data, void *p_self) { + if (!p_data) { + return; + } + Space3DSW *self = (Space3DSW *)p_self; self->collision_pairs--; Constraint3DSW *c = (Constraint3DSW *)p_data; |