瀏覽代碼

Merge pull request #54732 from zedutch/fix-threaded-load-request-cachemode

Rémi Verschelde 3 年之前
父節點
當前提交
787bb0f269
共有 3 個文件被更改,包括 6 次插入4 次删除
  1. 3 3
      core/core_bind.cpp
  2. 1 1
      core/core_bind.h
  3. 2 0
      doc/classes/ResourceLoader.xml

+ 3 - 3
core/core_bind.cpp

@@ -46,8 +46,8 @@ namespace core_bind {
 
 
 ResourceLoader *ResourceLoader::singleton = nullptr;
 ResourceLoader *ResourceLoader::singleton = nullptr;
 
 
-Error ResourceLoader::load_threaded_request(const String &p_path, const String &p_type_hint, bool p_use_sub_threads) {
-	return ::ResourceLoader::load_threaded_request(p_path, p_type_hint, p_use_sub_threads);
+Error ResourceLoader::load_threaded_request(const String &p_path, const String &p_type_hint, bool p_use_sub_threads, CacheMode p_cache_mode) {
+	return ::ResourceLoader::load_threaded_request(p_path, p_type_hint, p_use_sub_threads, ResourceFormatLoader::CacheMode(p_cache_mode));
 }
 }
 
 
 ResourceLoader::ThreadLoadStatus ResourceLoader::load_threaded_get_status(const String &p_path, Array r_progress) {
 ResourceLoader::ThreadLoadStatus ResourceLoader::load_threaded_get_status(const String &p_path, Array r_progress) {
@@ -121,7 +121,7 @@ ResourceUID::ID ResourceLoader::get_resource_uid(const String &p_path) {
 }
 }
 
 
 void ResourceLoader::_bind_methods() {
 void ResourceLoader::_bind_methods() {
-	ClassDB::bind_method(D_METHOD("load_threaded_request", "path", "type_hint", "use_sub_threads"), &ResourceLoader::load_threaded_request, DEFVAL(""), DEFVAL(false));
+	ClassDB::bind_method(D_METHOD("load_threaded_request", "path", "type_hint", "use_sub_threads", "cache_mode"), &ResourceLoader::load_threaded_request, DEFVAL(""), DEFVAL(false), DEFVAL(CACHE_MODE_REUSE));
 	ClassDB::bind_method(D_METHOD("load_threaded_get_status", "path", "progress"), &ResourceLoader::load_threaded_get_status, DEFVAL(Array()));
 	ClassDB::bind_method(D_METHOD("load_threaded_get_status", "path", "progress"), &ResourceLoader::load_threaded_get_status, DEFVAL(Array()));
 	ClassDB::bind_method(D_METHOD("load_threaded_get", "path"), &ResourceLoader::load_threaded_get);
 	ClassDB::bind_method(D_METHOD("load_threaded_get", "path"), &ResourceLoader::load_threaded_get);
 
 

+ 1 - 1
core/core_bind.h

@@ -71,7 +71,7 @@ public:
 
 
 	static ResourceLoader *get_singleton() { return singleton; }
 	static ResourceLoader *get_singleton() { return singleton; }
 
 
-	Error load_threaded_request(const String &p_path, const String &p_type_hint = "", bool p_use_sub_threads = false);
+	Error load_threaded_request(const String &p_path, const String &p_type_hint = "", bool p_use_sub_threads = false, CacheMode p_cache_mode = CACHE_MODE_REUSE);
 	ThreadLoadStatus load_threaded_get_status(const String &p_path, Array r_progress = Array());
 	ThreadLoadStatus load_threaded_get_status(const String &p_path, Array r_progress = Array());
 	Ref<Resource> load_threaded_get(const String &p_path);
 	Ref<Resource> load_threaded_get(const String &p_path);
 
 

+ 2 - 0
doc/classes/ResourceLoader.xml

@@ -95,8 +95,10 @@
 			<argument index="0" name="path" type="String" />
 			<argument index="0" name="path" type="String" />
 			<argument index="1" name="type_hint" type="String" default="&quot;&quot;" />
 			<argument index="1" name="type_hint" type="String" default="&quot;&quot;" />
 			<argument index="2" name="use_sub_threads" type="bool" default="false" />
 			<argument index="2" name="use_sub_threads" type="bool" default="false" />
+			<argument index="3" name="cache_mode" type="int" enum="ResourceLoader.CacheMode" default="1" />
 			<description>
 			<description>
 				Loads the resource using threads. If [code]use_sub_threads[/code] is [code]true[/code], multiple threads will be used to load the resource, which makes loading faster, but may affect the main thread (and thus cause game slowdowns).
 				Loads the resource using threads. If [code]use_sub_threads[/code] is [code]true[/code], multiple threads will be used to load the resource, which makes loading faster, but may affect the main thread (and thus cause game slowdowns).
+				The [code]cache_mode[/code] property defines whether and how the cache should be used or updated when loading the resource. See [enum CacheMode] for details.
 			</description>
 			</description>
 		</method>
 		</method>
 		<method name="remove_resource_format_loader">
 		<method name="remove_resource_format_loader">