Commit Graph

11086 Commits

Author SHA1 Message Date
Pedro J. Estébanez 342266cfd9 Overhaul Variant::duplicate() for resources
This in the scope of a duplication triggered via any type in the `Variant` realm. that is, the following: `Variant` itself, `Array` and `Dictionary`. That includes invoking `duplicate()` from scripts.

A `duplicate_deep(deep_subresources_mode)` method is added to `Variant`, `Array` and `Dictionary` (for compatibility reasons, simply adding an extra parameter was not possible). The default value for it is `RESOURCE_DEEP_DUPLICATE_NONE`, which is like calling `duplicate(true)`.

Remarks:
- The results of copying resources via those `Variant` types are exactly the same as if the copy were initiated from the `Resource` type at C++.
- In order to keep some separation between `Variant` and the higher-level animal which is `Resource`, `Variant` still contains the original code for that, so it's self-sufficient unless there's a `Resource` involved. Once the deep copy finds a `Resource` that has to be copied according to the duplication parameters, the algorithm invokes the `Resource` duplication machinery. When the stack is unwind back to a nesting level `Variant` can handle, `Variant` duplication logic keeps functioning.

While that is good from a responsibility separation standpoint, that would have a caveat: `Variant` would not be aware of the mapping between original and duplicate subresources and so wouldn't be able to keep preventing multiple duplicates.

To avoid that, this commit also introduces a wormwhole, a sharing mechanism by which `Variant` and `Resource` can collaborate in managing the lifetime of the original-to-duplicates map. The user-visible benefit is that the overduplicate prevention works as broadly as the whole `Variant` entity being copied, including all nesting levels, regardless how disconnected the data members containing resources may be across al the nesting levels. In other words, despite the aforementioned division of duties between `Variant` and `Resource` duplication logic, the duplicates map is shared among them. It's created when first finding a `Resource` and, however how deep the copy was working at that point, the map kept alive unitl the stack is unwind to the root user call, until the first step of the recursion.

Thanks to that common map of duplicates, this commit is able to fix the issue that `Resource::duplicate_for_local_scene()` used to ignore overridden duplicate logic.
2025-05-26 10:06:40 +02:00
Pedro J. Estébanez 2a03b459b9 Overhaul Resource::duplicate()
Thanks to a refactor, `Resource::duplicate_for_local_scene()` and `Resource::duplicate()` are now both users of the same, parametrized, implementation.

`Resource::duplicate()` now honors deepness in a more consistent and predictable fashion. `Resource::duplicate_deep()` is added (instead of just adding a parameter to the former, for compatibility needs).

The behavior after this change is as follows:
  - Deep (`deep=true`, formerly `subresources=true`):
    - Previously, only resources found as direct property values of the one to copy would be, recursively, duplicated.
    - Now, in addition, arrays and dictionaries are walked so the copy is truly deep, and only local subresources found across are copied.
    - Previously, subresources would be duplicated as many times as being referenced throughout the main resource.
    - Now, each subresource is only duplicated once and from that point, a referenced to that single copy is used. That's the enhanced behavior that `duplicate_for_local_scene()` already featured.
    - The behavior with respect to packed arrays is still duplication.
    - Formerly, arrays and dictionaries were recursive duplicated, with resources ignored.
    - Now, arrays and dictionaries are recursive duplicated, with resources duplicated.
    - When doing it through `duplicate_deep()`, there's a` deep_subresources_mode` parameter, with various possibilites to control if no resources are duplicated (so arrays, etc. are, but keeping referencing the originals), if only the internal ones are (resources with no non-local path, the default), or if all of them are. The default is to copy every subresource, just like `duplicate(true)`.
  - Not deep (`deep=false`, formerly `subresources=false`): <a name="resource-shallow"></a>
    - Previously, the first level of resources found as direct property values would be duplicated unconditionally. Packed arrays, arrays and dictionaries were non-recursively duplicated.
    - Now, no subresource found at any level in any form will be duplicated, but the original reference kept instead. Packed arrays, arrays and dictionaries are referenced, not duplicated at all.
    - Now, resources found as values of always-duplicate properties are duplicated, recursively or not matching what was requested for the root call.

This commit also changes what's the virtual method to override to customize the duplication (now it's the protected `_duplicate()` instead of the public `duplicate()`).
2025-05-26 10:05:25 +02:00
Thaddeus Crews 13aaf5e228 Merge pull request #103462 from GlitchedCode922/master
Fix InputEventMouseMotion reference
2025-05-16 10:29:01 -05:00
Thaddeus Crews 1e50e05235 Merge pull request #105723 from KoBeWi/sortatron
Add file sort to FileDialog
2025-05-16 07:43:13 -05:00
Omar Qurashi a6ca9088e0 Fix typo in Node.get_child documentation 2025-05-15 22:18:30 +02:00
Thaddeus Crews f3e0005266 Merge pull request #105547 from KoBeWi/default_ok_ok
Improve default OK text in AcceptDialog
2025-05-15 10:22:23 -05:00
Thaddeus Crews a7a61cc284 Merge pull request #106439 from timothyqiu/import-out-params
Document output parameters of `EditorImportPlugin.import`
2025-05-15 10:22:22 -05:00
Thaddeus Crews e625565853 Merge pull request #106396 from chocola-mint/canvas-item-add-triangle-array-count
Implement the `count` parameter in `RenderingServer.canvas_item_add_triangle_array`
2025-05-15 10:22:16 -05:00
Haoyu Qiu c31746fdcf Document output parameters of EditorImportPlugin.import 2025-05-15 19:46:15 +08:00
kobewi 33dcd7a6d9 Add file sort to FileDialog 2025-05-15 13:23:38 +02:00
kobewi 076608c979 Improve default OK text in AcceptDialog 2025-05-14 23:08:22 +02:00
Thaddeus Crews 8b4dd7a34e Merge pull request #105724 from dugramen/recovery/split-commit
Add inline color pickers to script editor
2025-05-14 09:44:16 -05:00
Thaddeus Crews 006b986fbb Merge pull request #106121 from KoBeWi/you_can_undo_but_you_can't_save
Allow undoredo actions to not make history unsaved
2025-05-14 09:44:11 -05:00
Thaddeus Crews d0693d6867 Merge pull request #89988 from LunaCapra/specular-occlusion
Add support for bent normal maps for specular occlusion and indirect lighting
2025-05-14 09:44:06 -05:00
chocola-mint 101dc9868f Implement the count parameter in RenderingServer.canvas_item_add_triangle_array() 2025-05-14 22:52:30 +09:00
dugramen b9f59ae6ca Add color pickers to script editor 2025-05-13 18:03:21 -04:00
Thaddeus Crews 3d20e906b9 Merge pull request #99318 from HolonProduction/editor-script-palette
Editor: Add named `EditorScript`s to the command palette
2025-05-13 16:22:31 -05:00
Thaddeus Crews 1c4b660312 Merge pull request #96611 from Dynamic-Pistol/master
Add `PROPERTY_HINT_INPUT_NAME` for use with `@export_custom` to allow using input actions
2025-05-13 16:22:25 -05:00
Thaddeus Crews 93140c0f76 Merge pull request #99676 from BlueCube3310/tex-import-vram-specified
Add Channel Remap settings to ResourceImporterTexture
2025-05-13 16:22:22 -05:00
Thaddeus Crews b59d6bea4f Merge pull request #67777 from aaronfranke/virtually-annotated
Add a keyword for abstract classes in GDScript
2025-05-13 16:22:16 -05:00
GlitchedCode efb72ef0f6 Fix InputEventMouseMotion reference 2025-05-13 11:06:11 +00:00
kobewi e7e48cd58c Allow undoredo actions to not make history unsaved 2025-05-13 02:40:31 +02:00
Capry 9828c365c3 Add support for bent normals for indirect lighting and specular occlusion 2025-05-12 12:52:04 +02:00
Thaddeus Crews d68e2710a2 Merge pull request #106205 from RedMser/limit-length-discoverability
Doc: Add search keywords for `Vector2/3.limit_length` method
2025-05-09 11:29:24 -05:00
Thaddeus Crews ee89536cbd Merge pull request #106195 from timothyqiu/action-type
Fix type error in `InputEventAction.action` description
2025-05-09 11:29:22 -05:00
Thaddeus Crews 941a979c38 Merge pull request #106179 from Aioshiro/editorProperty_description_swap
Fix description of `EditorProperty`'s `draw_background` and `draw_label`
2025-05-09 11:29:19 -05:00
Thaddeus Crews dda0562f2f Merge pull request #103934 from LiveTrower/dfg-lut
Forward+: Replace the current BRDF approximation with a DFG LUT and add multiscattering energy compensation
2025-05-09 11:29:16 -05:00
Thaddeus Crews 821170f054 Merge pull request #106145 from lander-vr/ambient-light-specular-occlusion
Add specular occlusion from ambient light
2025-05-09 11:29:14 -05:00
RedMser 542639de3c Add aliases for Vector2/3.limit_length method 2025-05-09 14:42:47 +02:00
Haoyu Qiu 664b2f7c71 Fix type error in InputEventAction.action description 2025-05-09 17:01:36 +08:00
landervr 56730d0cb2 Add specular occlusion from ambient light
Co-authored-by: guerro323 <kaltobattle@gmail.com>
2025-05-08 23:52:01 +02:00
Aioshiro 964f51c69a Fix description of EditorProperty.draw_background and EditorProperty.draw_label 2025-05-08 19:55:55 +02:00
LiveTrower 44408eabaa Replace BRDF approximation with a DFG LUT 2025-05-08 10:23:35 -06:00
Thaddeus Crews 2d3b25e61d Merge pull request #106162 from timothyqiu/store-half
Add missing description of `FileAccess.store_half` behavior on error
2025-05-08 07:19:37 -05:00
Thaddeus Crews 16aaa0a213 Merge pull request #103944 from KoBeWi/more_red_info
Improve error messages for `add_property_info()`
2025-05-08 07:19:33 -05:00
Thaddeus Crews 288822e330 Merge pull request #105570 from kroketio/texture-extension-mipmaps
RenderingDevice: Pass mipmap count to `texture_create_from_extension()`
2025-05-08 07:19:16 -05:00
Haoyu Qiu c24bfb0491 Add missing description of FileAccess.store_half behavior on error 2025-05-08 12:53:52 +08:00
Thaddeus Crews 051712dfb8 Merge pull request #103264 from mhilbrunner/docs-path-join
Rename "file" param for str.path_join() to "path"
2025-05-07 12:48:29 -05:00
Thaddeus Crews c714743bb1 Merge pull request #105944 from syntaxerror247/main-menu
Add editor setting to collapse main menu into a `MenuButton`
2025-05-07 12:48:29 -05:00
RedMser 4acdc7a657 Remove redundant line_spacing editor setting 2025-05-07 16:53:05 +02:00
Sander 6ae50cad17 RenderingDevice: introduce parameter 'mipmaps' for texture_create_from_extension() 2025-05-07 15:15:55 +03:00
Anish Mishra e03942a6ef Add editor setting to collapse main menu 2025-05-07 08:39:21 +05:30
Thaddeus Crews fd1168620f Merge pull request #105718 from aaronfranke/nav-const-caps
Capitalize global navigation constants
2025-05-06 08:38:07 -05:00
Thaddeus Crews 4cb030d6bf Merge pull request #106089 from mihe/rogue-newlines
Fix empty lines being added for errors with no script backtrace
2025-05-06 08:38:04 -05:00
Thaddeus Crews ee599f0850 Merge pull request #97148 from Calinou/editor-default-auto-reload-scripts-external-change
Enable Auto Reload Scripts on External Change by default in the editor settings
2025-05-06 08:38:02 -05:00
Thaddeus Crews c4de8ef825 Merge pull request #105765 from smix8/navlink_iteration_id
Add function to get navigation link iteration id from NavigationServer
2025-05-06 08:38:00 -05:00
Thaddeus Crews cc5857728d Merge pull request #106114 from m4gr3d/disable_auto_keyboard_popup
Add property to control showing the virtual keyboard on focus events
2025-05-06 08:37:40 -05:00
Fredia Huya-Kouadio f29feac7a5 Add a LineEdit / TextEdit property to control whether the virtual keyboard should show on focus 2025-05-05 22:01:34 -04:00
Aaron Franke 783728fcb4 Capitalize global navigation constants 2025-05-05 12:08:15 -07:00
Thaddeus Crews 5bc01f2994 Merge pull request #105080 from beicause/basisu-ktx2-settings
BasisU: Use KTX2 format and add import options to configure encoder
2025-05-05 11:24:20 -05:00