diff options
author | Saracen <SaracenOne@gmail.com> | 2024-09-04 00:57:51 +0100 |
---|---|---|
committer | K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com> | 2024-11-24 10:23:56 -0800 |
commit | 74611a74d1ae8af26fd889a6f2c83ba42198c6aa (patch) | |
tree | 88175262c4977c575bc9ee7f176cf056682e556b /editor/editor_resource_preview.cpp | |
parent | f952bfe9985ad8f507cc29b2c7601bbba18b8039 (diff) | |
download | redot-engine-74611a74d1ae8af26fd889a6f2c83ba42198c6aa.tar.gz |
Generate editor thumbnails on imported scenes.
Diffstat (limited to 'editor/editor_resource_preview.cpp')
-rw-r--r-- | editor/editor_resource_preview.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 4dca3b33af..32c44133e0 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -147,6 +147,10 @@ void EditorResourcePreview::_preview_ready(const String &p_path, int p_hash, con if (!p_path.begins_with("ID:")) { modified_time = FileAccess::get_modified_time(p_path); + String import_path = p_path + ".import"; + if (FileAccess::exists(import_path)) { + modified_time = MAX(modified_time, FileAccess::get_modified_time(import_path)); + } } Item item; @@ -237,7 +241,14 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref< } Ref<FileAccess> f = FileAccess::open(cache_base + ".txt", FileAccess::WRITE); ERR_FAIL_COND_MSG(f.is_null(), "Cannot create file '" + cache_base + ".txt'. Check user write permissions."); - _write_preview_cache(f, thumbnail_size, has_small_texture, FileAccess::get_modified_time(p_item.path), FileAccess::get_md5(p_item.path), p_metadata); + + uint64_t modtime = FileAccess::get_modified_time(p_item.path); + String import_path = p_item.path + ".import"; + if (FileAccess::exists(import_path)) { + modtime = MAX(modtime, FileAccess::get_modified_time(import_path)); + } + + _write_preview_cache(f, thumbnail_size, has_small_texture, modtime, FileAccess::get_md5(p_item.path), p_metadata); } } @@ -298,6 +309,11 @@ void EditorResourcePreview::_iterate() { _generate_preview(texture, small_texture, item, cache_base, preview_metadata); } else { uint64_t modtime = FileAccess::get_modified_time(item.path); + String import_path = item.path + ".import"; + if (FileAccess::exists(import_path)) { + modtime = MAX(modtime, FileAccess::get_modified_time(import_path)); + } + int tsize; bool has_small_texture; uint64_t last_modtime; @@ -513,6 +529,11 @@ void EditorResourcePreview::check_for_invalidation(const String &p_path) { if (cache.has(p_path)) { uint64_t modified_time = FileAccess::get_modified_time(p_path); + String import_path = p_path + ".import"; + if (FileAccess::exists(import_path)) { + modified_time = MAX(modified_time, FileAccess::get_modified_time(import_path)); + } + if (modified_time != cache[p_path].modified_time) { cache.erase(p_path); call_invalidated = true; |