[Bf-blender-cvs] [62bf0731519] tmp_lib_update_32: USD: bring back building with older USD

Ray Molenkamp noreply at git.blender.org
Tue Feb 22 19:30:12 CET 2022


Commit: 62bf0731519f5ffa6246fb13fdfa8c6856162a76
Author: Ray Molenkamp
Date:   Tue Feb 22 11:30:03 2022 -0700
Branches: tmp_lib_update_32
https://developer.blender.org/rB62bf0731519f5ffa6246fb13fdfa8c6856162a76

USD: bring back building with older USD

Since we can't schedule the landing of the
new libraries that precisely support both
building with USD 21.11+ and older versions

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

M	source/blender/io/usd/CMakeLists.txt
M	source/blender/io/usd/intern/usd_reader_light.cc
M	source/blender/io/usd/intern/usd_reader_stage.cc
M	source/blender/io/usd/intern/usd_writer_light.cc

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

diff --git a/source/blender/io/usd/CMakeLists.txt b/source/blender/io/usd/CMakeLists.txt
index 8365620860f..282df68daa7 100644
--- a/source/blender/io/usd/CMakeLists.txt
+++ b/source/blender/io/usd/CMakeLists.txt
@@ -10,6 +10,13 @@ if(UNIX AND NOT APPLE)
 endif()
 if(WIN32)
   add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
+  # The existance of this header really doesn't influence wither USD is
+  # a static or dynamic lib, however, when this header got introduced
+  # we switched from static -> dynamic. To ease the trasition period
+  # deal with both options.
+  if (NOT EXISTS "${USD_INCLUDE_DIRS}/pxr/usd/usdLux/boundableLightBase.h")
+    add_definitions(-DPXR_STATIC)
+  endif()
 else()
   add_definitions(-DPXR_STATIC)
 endif()
diff --git a/source/blender/io/usd/intern/usd_reader_light.cc b/source/blender/io/usd/intern/usd_reader_light.cc
index e820ebab371..8365d9ac88f 100644
--- a/source/blender/io/usd/intern/usd_reader_light.cc
+++ b/source/blender/io/usd/intern/usd_reader_light.cc
@@ -39,7 +39,11 @@ void USDLightReader::read_object_data(Main *bmain, const double motionSampleTime
     return;
   }
 
+#if PXR_VERSION >= 2111
   pxr::UsdLuxBoundableLightBase light_prim(prim_);
+#else
+  pxr::UsdLuxLight light_prim(prim_);
+#endif
 
   if (!light_prim) {
     return;
diff --git a/source/blender/io/usd/intern/usd_reader_stage.cc b/source/blender/io/usd/intern/usd_reader_stage.cc
index b7ba535d222..76194e443ec 100644
--- a/source/blender/io/usd/intern/usd_reader_stage.cc
+++ b/source/blender/io/usd/intern/usd_reader_stage.cc
@@ -18,7 +18,12 @@
 #include <pxr/usd/usdGeom/nurbsCurves.h>
 #include <pxr/usd/usdGeom/scope.h>
 #include <pxr/usd/usdGeom/xform.h>
-#include <pxr/usd/usdLux/boundableLightBase.h>
+
+#if PXR_VERSION >= 2111
+#  include <pxr/usd/usdLux/boundableLightBase.h>
+#else
+#  include <pxr/usd/usdLux/light.h>
+#endif
 
 #include <iostream>
 
@@ -55,9 +60,15 @@ USDPrimReader *USDStageReader::create_reader_if_allowed(const pxr::UsdPrim &prim
   if (params_.import_meshes && prim.IsA<pxr::UsdGeomMesh>()) {
     return new USDMeshReader(prim, params_, settings_);
   }
+#if PXR_VERSION >= 2111
   if (params_.import_lights && prim.IsA<pxr::UsdLuxBoundableLightBase>()) {
     return new USDLightReader(prim, params_, settings_);
   }
+#else
+  if (params_.import_lights && prim.IsA<pxr::UsdLuxLight>()) {
+    return new USDLightReader(prim, params_, settings_);
+  }
+#endif
   if (params_.import_volumes && prim.IsA<pxr::UsdVolVolume>()) {
     return new USDVolumeReader(prim, params_, settings_);
   }
diff --git a/source/blender/io/usd/intern/usd_writer_light.cc b/source/blender/io/usd/intern/usd_writer_light.cc
index fbe2e918a57..54d71027662 100644
--- a/source/blender/io/usd/intern/usd_writer_light.cc
+++ b/source/blender/io/usd/intern/usd_writer_light.cc
@@ -33,7 +33,12 @@ void USDLightWriter::do_write(HierarchyContext &context)
   pxr::UsdTimeCode timecode = get_export_time_code();
 
   Light *light = static_cast<Light *>(context.object->data);
+
+#if PXR_VERSION >= 2111
   pxr::UsdLuxBoundableLightBase usd_light;
+#else
+  pxr::UsdLuxLight usd_light;
+#endif
 
   switch (light->type) {
     case LA_AREA:
@@ -68,8 +73,12 @@ void USDLightWriter::do_write(HierarchyContext &context)
       break;
     }
     case LA_SUN:
+
+#if PXR_VERSION >= 2111
       // TODO: RAY TOTALLY BROKE THIS SINCE SEARCH AND REPLACE DIDNT WORK HERE
-      //usd_light = pxr::UsdLuxDistantLight::Define(stage, usd_path);
+#else
+      usd_light = pxr::UsdLuxDistantLight::Define(stage, usd_path);
+#endif
       break;
     default:
       BLI_assert_msg(0, "is_supported() returned true for unsupported light type");



More information about the Bf-blender-cvs mailing list