[3a186491f18] temp-usd-library-update-20.02: USD: Library upgrade 19.11 → 20.02

Sybren A. Stüvel noreply at git.blender.org
Fri Jun 12 14:39:59 CEST 2020


Commit: 3a186491f183de5277344cec900de9fdb3123cae
Author: Sybren A. Stüvel
Date:   Fri Jun 5 11:33:23 2020 +0200
Branches: temp-usd-library-update-20.02
https://developer.blender.org/rB3a186491f183de5277344cec900de9fdb3123cae

USD: Library upgrade 19.11 → 20.02

This requires a few changes:
- Some parts of our patch are no longer necessary, as the USD library
  now includes those changes.
- The rest of the patch needed adjustment as the `pxr/base/lib/*`
  directories in USD's source code have moved to `pxr/base/*`.
- The new Material Binding API is used when exporting meshes.

Note that this does not enable the USD Python API for inclusion in
Blender. It just aims at being an as-simple-as-possible version upgrade
of the USD library.

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

M	build_files/build_environment/cmake/versions.cmake
M	build_files/build_environment/patches/usd.diff
M	source/blender/io/usd/intern/usd_writer_mesh.cc

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

diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake
index c1dcf98318c..a140a26b023 100644
--- a/build_files/build_environment/cmake/versions.cmake
+++ b/build_files/build_environment/cmake/versions.cmake
@@ -297,9 +297,9 @@ set(EMBREE_VERSION 3.10.0)
 set(EMBREE_URI https://github.com/embree/embree/archive/v${EMBREE_VERSION}.zip)
 set(EMBREE_HASH 4bbe29e7eaa46417efc75fc5f1e8eb87)
 
-set(USD_VERSION 19.11)
+set(USD_VERSION 20.02)
 set(USD_URI https://github.com/PixarAnimationStudios/USD/archive/v${USD_VERSION}.tar.gz)
-set(USD_HASH 79ff176167b3fe85f4953abd6cc5e0cc)
+set(USD_HASH 8901815f01469a7f4496bd60315a9d10)
 
 set(OIDN_VERSION 1.0.0)
 set(OIDN_URI https://github.com/OpenImageDenoise/oidn/releases/download/v${OIDN_VERSION}/oidn-${OIDN_VERSION}.src.zip)
diff --git a/build_files/build_environment/patches/usd.diff b/build_files/build_environment/patches/usd.diff
index 6302f13796b..adee3d2e458 100644
--- a/build_files/build_environment/patches/usd.diff
+++ b/build_files/build_environment/patches/usd.diff
@@ -1,14 +1,3 @@
-diff -x .git -ur usd.orig/cmake/defaults/Options.cmake external_usd/cmake/defaults/Options.cmake
---- usd.orig/cmake/defaults/Options.cmake	2019-10-24 22:39:53.000000000 +0200
-+++ external_usd/cmake/defaults/Options.cmake	2019-11-28 13:00:33.197957712 +0100
-@@ -25,6 +25,7 @@
- option(PXR_VALIDATE_GENERATED_CODE "Validate script generated code" OFF)
- option(PXR_HEADLESS_TEST_MODE "Disallow GUI based tests, useful for running under headless CI systems." OFF)
- option(PXR_BUILD_TESTS "Build tests" ON)
-+option(PXR_BUILD_USD_TOOLS "Build commandline tools" ON)
- option(PXR_BUILD_IMAGING "Build imaging components" ON)
- option(PXR_BUILD_EMBREE_PLUGIN "Build embree imaging plugin" OFF)
- option(PXR_BUILD_OPENIMAGEIO_PLUGIN "Build OpenImageIO plugin" OFF)
 diff -x .git -ur usd.orig/cmake/defaults/Packages.cmake external_usd/cmake/defaults/Packages.cmake
 --- usd.orig/cmake/defaults/Packages.cmake	2019-10-24 22:39:53.000000000 +0200
 +++ external_usd/cmake/defaults/Packages.cmake	2019-11-28 13:00:33.185957483 +0100
@@ -21,9 +10,9 @@ diff -x .git -ur usd.orig/cmake/defaults/Packages.cmake external_usd/cmake/defau
  add_definitions(${TBB_DEFINITIONS})
  
  # --math
-diff -x .git -ur usd.orig/pxr/base/lib/plug/initConfig.cpp external_usd/pxr/base/lib/plug/initConfig.cpp
---- usd.orig/pxr/base/lib/plug/initConfig.cpp	2019-10-24 22:39:53.000000000 +0200
-+++ external_usd/pxr/base/lib/plug/initConfig.cpp	2019-12-11 11:00:37.643323127 +0100
+diff -x .git -ur usd.orig/pxr/base/plug/initConfig.cpp external_usd/pxr/base/plug/initConfig.cpp
+--- usd.orig/pxr/base/plug/initConfig.cpp	2019-10-24 22:39:53.000000000 +0200
++++ external_usd/pxr/base/plug/initConfig.cpp	2019-12-11 11:00:37.643323127 +0100
 @@ -69,8 +69,38 @@
  
  ARCH_CONSTRUCTOR(Plug_InitConfig, 2, void)
@@ -90,28 +79,9 @@ diff -x .git -ur usd.orig/pxr/base/lib/plug/initConfig.cpp external_usd/pxr/base
 +    PXR_NS::usd_initialise_plugin_path(datafiles_usd_path);
 +}
 +}
-diff -x .git -ur usd.orig/pxr/usd/CMakeLists.txt external_usd/pxr/usd/CMakeLists.txt
---- usd.orig/pxr/usd/CMakeLists.txt	2019-10-24 22:39:53.000000000 +0200
-+++ external_usd/pxr/usd/CMakeLists.txt	2019-11-28 13:00:33.197957712 +0100
-@@ -1,6 +1,5 @@
- set(DIRS
-     lib
--    bin
-     plugin
- )
- 
-@@ -8,3 +7,8 @@
-     add_subdirectory(${d})
- endforeach()
- 
-+if (PXR_BUILD_USD_TOOLS)
-+    add_subdirectory(bin)
-+else()
-+    message(STATUS "Skipping commandline tools because PXR_BUILD_USD_TOOLS=OFF")
-+endif()
-diff -Naur external_usd_orig/pxr/base/lib/tf/preprocessorUtils.h external_usd/pxr/base/lib/tf/preprocessorUtils.h
---- external_usd_orig/pxr/base/lib/tf/preprocessorUtils.h	2019-10-24 14:39:53 -0600
-+++ external_usd/pxr/base/lib/tf/preprocessorUtils.h	2020-01-14 09:30:18 -0700
+diff -Naur external_usd_orig/pxr/base/tf/preprocessorUtils.h external_usd/pxr/base/tf/preprocessorUtils.h
+--- external_usd_orig/pxr/base/tf/preprocessorUtils.h	2019-10-24 14:39:53 -0600
++++ external_usd/pxr/base/tf/preprocessorUtils.h	2020-01-14 09:30:18 -0700
 @@ -189,7 +189,7 @@
  /// Exapnds to 1 if the argument is a tuple, and 0 otherwise.
  /// \ingroup group_tf_Preprocessor
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);
   }
 }



More information about the Bf-blender-cvs mailing list