Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up inspector updates for TileMap #89251

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/io/resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PropertyInfo> plist;
Expand All @@ -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<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
Loading