Commit: 03c6ec2400603c16d6f552b221c735df3b262913
Author: makowalski
Date:   Fri Mar 12 02:31:27 2021 -0500
Branches: usd-importer-T81257-merge
https://developer.blender.org/rB03c6ec2400603c16d6f552b221c735df3b262913

USD Import: check bound materials on all subsets.

Changed material import logic to check bound materials
on all subsets, not just on the 'materialBind' subsets,
as this is necessary for geometry currently exported
from Houdini.

===================================================================

M       source/blender/io/usd/intern/usd_reader_mesh.cc

===================================================================

diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc 
b/source/blender/io/usd/intern/usd_reader_mesh.cc
index 3d902126b74..d2d2651afd4 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.cc
+++ b/source/blender/io/usd/intern/usd_reader_mesh.cc
@@ -671,11 +671,19 @@ void USDMeshReader::assign_facesets_to_mpoly(double 
motionSampleTime,
                                              std::map<pxr::SdfPath, int> 
&r_mat_map)
 {
   pxr::UsdShadeMaterialBindingAPI api = pxr::UsdShadeMaterialBindingAPI(prim_);
-  std::vector<pxr::UsdGeomSubset> subsets = api.GetMaterialBindSubsets();
+
+  /* Find the geom subsets that have bound materials.
+   * We don't call pxr::UsdShadeMaterialBindingAPI::GetMaterialBindSubsets()
+   * because this function returns only those subsets that are in the 
'materialBind'
+   * family, but, in practice, applications (like Houdini) might export subsets
+   * in different families that are bound to materials.
+   * TODO(makowalski): Reassess if the above is the best approach. */
+  const std::vector<pxr::UsdGeomSubset> subsets = 
pxr::UsdGeomSubset::GetAllGeomSubsets(
+      mesh_prim_);
 
   int current_mat = 0;
   if (subsets.size() > 0) {
-    for (pxr::UsdGeomSubset &subset : subsets) {
+    for (const pxr::UsdGeomSubset &subset : subsets) {
       pxr::UsdShadeMaterialBindingAPI subsetAPI = 
pxr::UsdShadeMaterialBindingAPI(
           subset.GetPrim());

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to