Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAras Pranckevicius <aras@nesnausk.org>2022-06-17 22:28:22 +0300
committerAras Pranckevicius <aras@nesnausk.org>2022-06-17 22:28:22 +0300
commit5b5811c97b59fd187a7aafd874535c749054d5db (patch)
tree0302a5af3f62cd1d449a75377f0a3c8d17f0c55c /source/blender/io/usd/intern/usd_reader_prim.h
parent230f72347a9931b0f2e39ffeff63db43db3787a1 (diff)
USD: speed up large USD imports by not rebuilding material name map for each object
Previous code was rebuilding "name to material" map for each object being imported. Which means O(N*M) complexity (N=object count, M=material count). There was already a TODO comment suggesting that a single map that's maintained for the whole import would be enough. This commit does exactly that. While importing Moana USD scene (260k objects, 18k materials) this saves about 6 minutes of import time. Reviewed By: Bastien Montagne Differential Revision: https://developer.blender.org/D15222
Diffstat (limited to 'source/blender/io/usd/intern/usd_reader_prim.h')
-rw-r--r--source/blender/io/usd/intern/usd_reader_prim.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/io/usd/intern/usd_reader_prim.h b/source/blender/io/usd/intern/usd_reader_prim.h
index f2df00accf6..c44c4a14ad7 100644
--- a/source/blender/io/usd/intern/usd_reader_prim.h
+++ b/source/blender/io/usd/intern/usd_reader_prim.h
@@ -11,6 +11,7 @@
#include <string>
struct Main;
+struct Material;
struct Object;
namespace blender::io::usd {
@@ -42,6 +43,10 @@ struct ImportSettings {
* of what the importer is doing. This is necessary even
* when all the other import settings are to remain const. */
mutable std::map<std::string, std::string> usd_path_to_mat_name;
+ /* Map a material name to Blender material.
+ * This map is updated by readers during stage traversal,
+ * and is mutable similar to the map above. */
+ mutable std::map<std::string, Material *> mat_name_to_mat;
ImportSettings()
: do_convert_mat(false),