Commit Graph

72 Commits

Author SHA1 Message Date
e281a9ace2 Merge pull request #102650 from bruvzg/emit_changed_spam
Prevent `changed` signal spam on resource reload.
2025-03-14 00:07:59 +01:00
bebe037abf Add ConstIterator to Dictionary. 2025-03-13 01:28:46 +08:00
da767ebfa2 Prevent changed signal spam on resource reload. 2025-02-11 15:22:49 +02:00
3c304ab7cc Merge pull request #96076 from AThousandShips/improve_null_check_core_drivers
[Core,Drivers] Improve use of `Ref.is_null/valid`
2024-12-23 11:14:58 -06:00
be86ce3103 Apply iwyu suggestion in core. 2024-12-19 00:43:47 +08:00
ec650a2f09 [Core,Drivers] Improve use of Ref.is_null/valid
Use `is_null` over `!is_valid` and vice versa.
2024-11-01 16:50:11 +01:00
38f9769bc6 [Core] Improve error messages with vformat 2024-10-30 15:55:51 +01:00
abf9d24520 Make internal unique scene resource ID deterministic
Changes the Resource::generate_scene_unique_id() to be deterministic and
seedable.

Fixes #97110
2024-09-23 15:07:00 +02:00
bc3dcf3d40 Expose several resource/resource-saver functions 2024-09-22 15:27:13 -04:00
74b9c38d58 ResourceLoader: Add thread-aware resource changed mechanism 2024-09-06 08:57:09 +02:00
e33fdb4296 Use MutexLock in more places 2024-08-29 14:12:59 +02:00
0d1c388991 Fix some legacy code 2024-08-01 12:08:14 +02:00
62d9ce6445 Re-add resource thread-safety measures
These deferring measures were added to aid threaded resource loading in being safe.

They were removed as seemingly unneeded, but it seems they are needed so resources involved in threaded loading interact with others only after "sync points".
2024-07-15 12:15:22 +02:00
b6994a414d Remove no longer needed thread safety measures
This is basically a revertion of commit 84b85d894c.
2024-06-12 18:10:11 +02:00
944b95e1a5 Merge pull request #91897 from RandomShaper/res_unreg_if_true
Add an identity check to resource unregistration from cache
2024-05-16 09:32:03 +02:00
413c11357d Use Core/Scene stringnames consistently 2024-05-13 23:41:07 +02:00
b70afac286 Add an identity check to resource unregistration from cache
This is needed because resources loaded with CACHE_MODE_IGNORE still have path_cache set.
2024-05-13 11:55:50 +02:00
a262d2d881 Add shorthand for using singleton string names 2024-05-11 18:53:08 +02:00
f9b488508c Add PackedVector4Array Variant type
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2024-05-03 00:58:27 +02:00
c2be2dfbde Fix Resource::get_rid override not working in GDExtension 2024-04-06 01:27:16 +09:00
d5f944ff10 Merge pull request #89261 from paulloz/core/fix-script-reloading-outside-script-editor
Fix how scripts reload outside of ScriptEditor
2024-03-24 01:15:23 +01:00
63674648fb Fix how scripts reload outside of ScriptEditor 2024-03-18 10:29:06 +01:00
1c8ef9e252 Merge pull request #89251 from KoBeWi/fastpector
Speed up inspector updates for TileMap
2024-03-09 00:52:09 +01:00
7319b612f3 Speed up inspector updates for TileMap 2024-03-07 18:01:30 +01:00
42ce14043e Expose scene unique id functionality in Resource 2024-03-07 14:53:58 +01:00
84b85d894c Improve thread safety of resource loading 2024-02-28 15:19:22 +01:00
608b5d2e07 Fix recursive resource local to scene
Any resource that contains other local to scene resources inside of
arrays or dictionaries will now be duplicated and configured.

The case where a scene's node has an exported array/dictionary
property containing local to scene resources is NOT handled here.
2024-01-11 20:02:14 +01:00
f8f8fe0615 Improve message about resources in use at exit 2023-11-28 14:01:08 +01:00
a3627b6e37 Assign temporary path to preloaded resources 2023-11-10 00:43:30 +01:00
79ce0c6e80 Reimplement Resource._local_to_scene_setup & remove workaround
Reimplements the virtual method _setup_local_to_scene, lost in #51970

Also deprecates the redundant `setup_local_to_scene_requested` signal.
2023-09-09 13:51:12 +02:00
4795c3cdfa Clear the previously set state when configuring for a new scene root node
Saving a subscene causes the main scene to be re-instantiated. And the resource
instance in the main scene will be reused when the main scene is re-instantiated.
So for resources with `resource_local_to_scene` enabled, resetting state may be
necessary (at least for `ViewportTexture`).
2023-08-08 23:49:53 +08:00
de4a3fa151 Unify and streamline connecting to Resource changes 2023-07-17 19:35:57 +02:00
c586835541 Make ResourceCache::get_cached_resources thread-safe 2023-02-20 01:02:08 -08:00
bfffb8f254 Fix Resource::duplicate() missing packed arrays 2023-01-28 23:06:44 -05:00
2a65f6812b Add PROPERTY_USAGE_NEVER_DUPLICATE flag and use for script
Co-authored-by: Yakov Borevich <j.borevich@gmail.com>
2023-01-24 16:37:50 -06:00
2bc0bcbd26 PropertyUsage: Rename "DO_NOT_SHARE_ON_DUPLICATE" to "ALWAYS_DUPLICATE" 2023-01-24 16:05:07 -06:00
c0083e431b Cleanup unused engine code v2 2023-01-19 13:02:18 +01:00
d95794ec8a One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
2c576eb281 [Core] Fix Resource.resource_name type.
The methods returns a String, but the Variant was bound as a StringName.

We could alternatively change the method return type but that's a
breaking change which will requires code changes in other parts of the
engine.
2022-11-29 15:43:08 +01:00
474cee7daf Rename and expose RefCounted::get_reference_count() 2022-09-21 21:18:54 +01:00
0aecfc9254 Fixes #65377: get_datetime_* functions can return wrong values 2022-09-10 07:58:38 +08:00
eb56d1d1eb Drop obsolete resource usage debug methods from OS class
These methods exist since the dawn of (open source) Godot and have hardly
been updated over time, so they barely work and I'm fairly sure nobody is
using them. (See #46505 for details.)

While some of the functionality they aimed to provide might be useful for
optimization work and introspection, this should likely be redesigned from
scratch with a cleaner and more modern interface (e.g. exposed via the
Performance singleton, or ResourceLoader, and a better API overall).
2022-08-29 12:57:37 +02:00
e772b65d92 Remake resource thread safety and API
* Ensures thread safety when resources are destroyed.
* Simplified API by always forcing `ResourceCache::get_ref`, which needs less hacks and is fully thread safe.
* Removed RWLock for resources because its not possible to use for the new logic. Should not be a problem.

Supersedes #57533
2022-06-22 13:46:46 +02:00
141c375581 Clean up Hash Functions
Clean up and do fixes to hash functions and newly introduced murmur3 hashes in #61934
* Clean up usage of murmur3
* Fixed usages of binary murmur3 on floats (this is invalid)
* Changed DJB2 to use xor (which seems to be better)
2022-06-20 12:54:19 +02:00
900c676b02 Use range iterators for RBSet in most cases 2022-05-19 12:09:16 +02:00
746dddc067 Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
  (order matters) but use is discouraged.

There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
2022-05-16 10:37:48 +02:00
8b7c7f5a75 Add a new HashMap implementation
Adds a new, cleaned up, HashMap implementation.

* Uses Robin Hood Hashing (https://en.wikipedia.org/wiki/Hash_table#Robin_Hood_hashing).
* Keeps elements in a double linked list for simpler, ordered, iteration.
* Allows keeping iterators for later use in removal (Unlike Map<>, it does not do much
  for performance vs keeping the key, but helps replace old code).
* Uses a more modern C++ iterator API, deprecates the old one.
* Supports custom allocator (in case there is a wish to use a paged one).

This class aims to unify all the associative template usage and replace it by this one:
* Map<> (whereas key order does not matter, which is 99% of cases)
* HashMap<>
* OrderedHashMap<>
* OAHashMap<>
2022-05-12 11:21:29 +02:00
180e5d3028 Remove RES and REF typedefs in favor of spelled out Ref<>
These typedefs don't save much typing compared to the full `Ref<Resource>`
and `Ref<RefCounted>`, yet they sometimes introduce confusion among
new contributors.
2022-05-03 01:43:50 +02:00
de4c97758a Fix more issues found by cppcheck. 2022-04-20 10:34:00 +03:00
9381acb6a4 Make FileAccess and DirAccess classes reference counted. 2022-04-11 13:28:51 +03:00