diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-06-12 16:03:59 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-06-12 17:37:02 +0300 |
commit | dc80fe5a3fef758b2dda924f93a39df5874cfed3 (patch) | |
tree | 08f316c09bef8e99ddc7d06fb3088fc098e1067a | |
parent | 7e43bbb790d534eb0f7885e7cc793b12e7681d3f (diff) |
USD: Use new material binding API
The material binding API that we used was removed in the Universal Scene
Description library version 20.02. Using this new API, the code is
compatible with both USD 19.11 and 20.02.
-rw-r--r-- | source/blender/io/usd/intern/usd_writer_mesh.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc b/source/blender/io/usd/intern/usd_writer_mesh.cc index 841501bcf42..61337beff20 100644 --- a/source/blender/io/usd/intern/usd_writer_mesh.cc +++ b/source/blender/io/usd/intern/usd_writer_mesh.cc @@ -335,6 +335,7 @@ void USDGenericMeshWriter::assign_materials(const HierarchyContext &context, * which is why we always bind the first material to the entire mesh. See * https://github.com/PixarAnimationStudios/USD/issues/542 for more info. */ bool mesh_material_bound = false; + pxr::UsdShadeMaterialBindingAPI material_binding_api(usd_mesh.GetPrim()); for (short mat_num = 0; mat_num < context.object->totcol; mat_num++) { Material *material = BKE_object_material_get(context.object, mat_num + 1); if (material == nullptr) { @@ -342,7 +343,7 @@ void USDGenericMeshWriter::assign_materials(const HierarchyContext &context, } pxr::UsdShadeMaterial usd_material = ensure_usd_material(material); - usd_material.Bind(usd_mesh.GetPrim()); + material_binding_api.Bind(usd_material); /* USD seems to support neither per-material nor per-face-group double-sidedness, so we just * use the flag from the first non-empty material slot. */ @@ -378,9 +379,9 @@ void USDGenericMeshWriter::assign_materials(const HierarchyContext &context, pxr::UsdShadeMaterial usd_material = ensure_usd_material(material); pxr::TfToken material_name = usd_material.GetPath().GetNameToken(); - pxr::UsdShadeMaterialBindingAPI api = pxr::UsdShadeMaterialBindingAPI(usd_mesh); - pxr::UsdGeomSubset usd_face_subset = api.CreateMaterialBindSubset(material_name, face_indices); - usd_material.Bind(usd_face_subset.GetPrim()); + pxr::UsdGeomSubset usd_face_subset = material_binding_api.CreateMaterialBindSubset( + material_name, face_indices); + pxr::UsdShadeMaterialBindingAPI(usd_face_subset.GetPrim()).Bind(usd_material); } } |