Skip to content

Commit

Permalink
Merge pull request #89251 from KoBeWi/fastpector
Browse files Browse the repository at this point in the history
Speed up inspector updates for TileMap
  • Loading branch information
akien-mga committed Mar 8, 2024
2 parents d78fafa + 7319b61 commit 1c8ef9e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions core/io/resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,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<PropertyInfo> plist;
Expand All @@ -445,7 +445,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<Resource> 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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/io/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class Resource : public RefCounted {

#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; }
Expand Down
4 changes: 4 additions & 0 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,10 @@ Array EditorInspectorArray::_extract_properties_as_array(const List<PropertyInfo
Array output;

for (const PropertyInfo &pi : p_list) {
if (!(pi.usage & PROPERTY_USAGE_EDITOR)) {
continue;
}

if (pi.name.begins_with(array_element_prefix)) {
String str = pi.name.trim_prefix(array_element_prefix);

Expand Down
4 changes: 2 additions & 2 deletions editor/editor_resource_preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void EditorResourcePreview::_iterate() {
if (item.resource.is_valid()) {
Dictionary preview_metadata;
_generate_preview(texture, small_texture, item, String(), preview_metadata);
_preview_ready(item.path, item.resource->hash_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;
}

Expand Down Expand Up @@ -407,7 +407,7 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &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;
Expand Down
4 changes: 4 additions & 0 deletions scene/resources/2d/tile_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ class TileSet : public Resource {
void _get_property_list(List<PropertyInfo> *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.
Expand Down

0 comments on commit 1c8ef9e

Please sign in to comment.