mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Improve resource load cache
-Added a new method in Resource: reset_state , used for reloading the same resource from disk -Added a new cache mode "replace" in ResourceLoader, which reuses existing loaded sub-resources but resets their data from disk (or replaces them if they chaged type) -Because the correct sub-resource paths are always loaded now, this fixes bugs with subresource folding or subresource ordering when saving.
This commit is contained in:
parent
e5bb89cdd5
commit
f8d03b98e7
83 changed files with 395 additions and 183 deletions
|
@ -1003,7 +1003,7 @@ Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_d
|
|||
dependency_errors.clear();
|
||||
|
||||
Error err;
|
||||
RES res = ResourceLoader::load(p_resource, "", false, &err);
|
||||
RES res = ResourceLoader::load(p_resource, "", ResourceFormatLoader::CACHE_MODE_REUSE, &err);
|
||||
ERR_FAIL_COND_V(!res.is_valid(), ERR_CANT_OPEN);
|
||||
|
||||
if (!p_ignore_broken_deps && dependency_errors.has(p_resource)) {
|
||||
|
@ -3452,7 +3452,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
|
|||
dependency_errors.clear();
|
||||
|
||||
Error err;
|
||||
Ref<PackedScene> sdata = ResourceLoader::load(lpath, "", true, &err);
|
||||
Ref<PackedScene> sdata = ResourceLoader::load(lpath, "", ResourceFormatLoader::CACHE_MODE_REPLACE, &err);
|
||||
if (!sdata.is_valid()) {
|
||||
_dialog_display_load_error(lpath, err);
|
||||
opening_prev = false;
|
||||
|
@ -5274,6 +5274,8 @@ void EditorNode::_file_access_close_error_notify(const String &p_str) {
|
|||
}
|
||||
|
||||
void EditorNode::reload_scene(const String &p_path) {
|
||||
/*
|
||||
* No longer necesary since scenes now reset and reload their internal resource if needed.
|
||||
//first of all, reload internal textures, materials, meshes, etc. as they might have changed on disk
|
||||
|
||||
List<Ref<Resource>> cached;
|
||||
|
@ -5291,6 +5293,8 @@ void EditorNode::reload_scene(const String &p_path) {
|
|||
to_clear.pop_front();
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
int scene_idx = -1;
|
||||
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
|
||||
if (editor_data.get_scene_path(i) == p_path) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue