diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c index 580fd23a427..9494740f810 100644 --- a/source/blender/editors/io/io_usd.c +++ b/source/blender/editors/io/io_usd.c @@ -422,6 +422,10 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op) const bool validate_meshes = false; const bool use_instancing = false; + if (import_materials) { + mesh_read_flag |= MOD_MESHSEQ_READ_MAT_FACE_SETS; + } + const eUSDTexImportMode import_textures_mode = RNA_enum_get(op->ptr, "import_textures_mode"); char import_textures_dir[FILE_MAXDIR]; diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc index fd4b80b9137..072b537ce68 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.cc +++ b/source/blender/io/usd/intern/usd_reader_mesh.cc @@ -857,7 +857,7 @@ Mesh *USDMeshReader::read_mesh(Mesh *existing_mesh, * the material slots that were created when the object was loaded from * USD are still valid now. */ MutableSpan polys = active_mesh->polys_for_write(); - if (!polys.is_empty() && import_params_.import_materials) { + if (!polys.is_empty() && read_flag & MOD_MESHSEQ_READ_MAT_FACE_SETS) { std::map mat_map; bke::MutableAttributeAccessor attributes = active_mesh->attributes_for_write(); bke::SpanAttributeWriter material_indices = diff --git a/source/blender/makesdna/DNA_modifier_defaults.h b/source/blender/makesdna/DNA_modifier_defaults.h index 44644d7eb78..2ce17429b90 100644 --- a/source/blender/makesdna/DNA_modifier_defaults.h +++ b/source/blender/makesdna/DNA_modifier_defaults.h @@ -401,7 +401,8 @@ .cache_file = NULL, \ .object_path = "", \ .read_flag = MOD_MESHSEQ_READ_VERT | MOD_MESHSEQ_READ_POLY | MOD_MESHSEQ_READ_UV | \ - MOD_MESHSEQ_READ_COLOR | MOD_MESHSEQ_INTERPOLATE_VERTICES, \ + MOD_MESHSEQ_READ_COLOR | MOD_MESHSEQ_INTERPOLATE_VERTICES | \ + MOD_MESHSEQ_READ_MAT_FACE_SETS, \ .velocity_scale = 1.0f, \ .reader = NULL, \ .reader_object_path = "", \ diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 7af83f8f888..0582abf47ca 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -2215,6 +2215,10 @@ enum { * the mesh topology changes, but this heuristic sometimes fails. In these cases, users can * disable interpolation with this flag. */ MOD_MESHSEQ_INTERPOLATE_VERTICES = (1 << 4), + + /* Whether or not to read material face sets. This flag currently applies when loading USD + * files only, since the Alembic mesh importer always reads material face sets by default. */ + MOD_MESHSEQ_READ_MAT_FACE_SETS = (1 << 5), }; typedef struct SDefBind { diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index b86e202a791..c9fc2286e57 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -6179,6 +6179,13 @@ static void rna_def_modifier_meshseqcache(BlenderRNA *brna) prop, "Vertex Interpolation", "Allow interpolation of vertex positions"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "read_mat_face_sets", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "read_flag", MOD_MESHSEQ_READ_MAT_FACE_SETS); + RNA_def_property_ui_text(prop, + "Read Material Face Sets", + "Allow reading of material face sets (applies to USD files only)"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "velocity_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "velocity_scale"); RNA_def_property_range(prop, 0.0f, FLT_MAX);