USD mesh sequence cache modifier doesn't update material indices #104683

Open
Michael Kowalski wants to merge 1 commits from makowalski/blender:usd-mesh-sequence-mtl-update into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
5 changed files with 18 additions and 2 deletions

View File

@ -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];

View File

@ -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<MPoly> 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<pxr::SdfPath, int> mat_map;
bke::MutableAttributeAccessor attributes = active_mesh->attributes_for_write();
bke::SpanAttributeWriter<int> material_indices =

View File

@ -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 = "", \

View File

@ -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 {

View File

@ -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);