From 7319b612f3512b5077279c51230b48b56622c564 Mon Sep 17 00:00:00 2001 From: kobewi Date: Thu, 7 Mar 2024 17:45:13 +0100 Subject: [PATCH] Speed up inspector updates for TileMap --- core/io/resource.cpp | 4 ++-- core/io/resource.h | 2 +- editor/editor_inspector.cpp | 4 ++++ editor/editor_resource_preview.cpp | 4 ++-- scene/resources/2d/tile_set.h | 4 ++++ 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/core/io/resource.cpp b/core/io/resource.cpp index 7e8d0b43cd2..c90a7523487 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -425,7 +425,7 @@ RID Resource::get_rid() const { #ifdef TOOLS_ENABLED -uint32_t Resource::hash_edited_version() const { +uint32_t Resource::hash_edited_version_for_preview() const { uint32_t hash = hash_murmur3_one_32(get_edited_version()); List plist; @@ -435,7 +435,7 @@ uint32_t Resource::hash_edited_version() const { if (E.usage & PROPERTY_USAGE_STORAGE && E.type == Variant::OBJECT && E.hint == PROPERTY_HINT_RESOURCE_TYPE) { Ref res = get(E.name); if (res.is_valid()) { - hash = hash_murmur3_one_32(res->hash_edited_version(), hash); + hash = hash_murmur3_one_32(res->hash_edited_version_for_preview(), hash); } } } diff --git a/core/io/resource.h b/core/io/resource.h index f0f686af57f..cc8a0d4387d 100644 --- a/core/io/resource.h +++ b/core/io/resource.h @@ -125,7 +125,7 @@ public: #ifdef TOOLS_ENABLED - uint32_t hash_edited_version() const; + virtual uint32_t hash_edited_version_for_preview() const; virtual void set_last_modified_time(uint64_t p_time) { last_modified_time = p_time; } uint64_t get_last_modified_time() const { return last_modified_time; } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 83a7e115c99..a14c6e84623 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -2009,6 +2009,10 @@ Array EditorInspectorArray::_extract_properties_as_array(const Listhash_edited_version(), texture, small_texture, item.id, item.function, item.userdata, preview_metadata); + _preview_ready(item.path, item.resource->hash_edited_version_for_preview(), texture, small_texture, item.id, item.function, item.userdata, preview_metadata); return; } @@ -407,7 +407,7 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref &p String path_id = "ID:" + itos(p_res->get_instance_id()); - if (cache.has(path_id) && cache[path_id].last_hash == p_res->hash_edited_version()) { + if (cache.has(path_id) && cache[path_id].last_hash == p_res->hash_edited_version_for_preview()) { cache[path_id].order = order++; p_receiver->call(p_receiver_func, path_id, cache[path_id].preview, cache[path_id].small_preview, p_userdata); return; diff --git a/scene/resources/2d/tile_set.h b/scene/resources/2d/tile_set.h index b55afd2de59..c17241a436e 100644 --- a/scene/resources/2d/tile_set.h +++ b/scene/resources/2d/tile_set.h @@ -299,6 +299,10 @@ protected: void _get_property_list(List *p_list) const; void _validate_property(PropertyInfo &p_property) const; +#ifdef TOOLS_ENABLED + virtual uint32_t hash_edited_version_for_preview() const override { return 0; } // Not using preview, so disable it for performance. +#endif + private: // --- TileSet data --- // Basic shape and layout.