[Bf-blender-cvs] [da766dd71c0] universal-scene-description: USD IO format fixes.

Michael Kowalski noreply at git.blender.org
Wed Nov 10 15:27:41 CET 2021


Commit: da766dd71c022fa9681d52666ae1b59462eeaba2
Author: Michael Kowalski
Date:   Tue Nov 9 18:42:05 2021 -0500
Branches: universal-scene-description
https://developer.blender.org/rBda766dd71c022fa9681d52666ae1b59462eeaba2

USD IO format fixes.

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

M	source/blender/editors/io/io_usd.c
M	source/blender/io/usd/intern/usd_capi_export.cc
M	source/blender/io/usd/intern/usd_reader_material.cc
M	source/blender/io/usd/intern/usd_reader_prim.cc
M	source/blender/io/usd/intern/usd_reader_prim.h
M	source/blender/io/usd/intern/usd_reader_xform.cc
M	source/blender/io/usd/intern/usd_umm.cc
M	source/blender/io/usd/intern/usd_umm.h
M	source/blender/io/usd/intern/usd_writer_abstract.cc
M	source/blender/io/usd/intern/usd_writer_skel_root.cc
M	source/blender/io/usd/intern/usd_writer_skinned_mesh.cc

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

diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c
index 7a07c5f403d..bd64cb0775c 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -151,11 +151,7 @@ const EnumPropertyItem rna_enum_usd_mtl_name_collision_mode_items[] = {
 };
 
 const EnumPropertyItem rna_enum_usd_attr_import_mode_items[] = {
-    {USD_ATTR_IMPORT_NONE,
-     "NONE",
-     0,
-     "None",
-     "Do not import attributes"},
+    {USD_ATTR_IMPORT_NONE, "NONE", 0, "None", "Do not import attributes"},
     {USD_ATTR_IMPORT_USER,
      "USER",
      0,
@@ -756,11 +752,12 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
                   true,
                   "Export Custom Properties",
                   "When checked, custom properties will be exported as USD User Properties");
-  RNA_def_boolean(ot->srna,
-                  "add_properties_namespace",
-                  true,
-                  "Add Properties Namespace",
-                  "Add exported custom properties to the 'userProperties' USD attribute namespace");
+  RNA_def_boolean(
+      ot->srna,
+      "add_properties_namespace",
+      true,
+      "Add Properties Namespace",
+      "Add exported custom properties to the 'userProperties' USD attribute namespace");
   RNA_def_boolean(ot->srna,
                   "export_identity_transforms",
                   false,
@@ -971,8 +968,7 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
   const eUSDMtlNameCollisionMode mtl_name_collision_mode = RNA_enum_get(op->ptr,
                                                                         "mtl_name_collision_mode");
 
-  const eUSDAttrImportMode attr_import_mode = RNA_enum_get(op->ptr,
-                                                           "attr_import_mode");
+  const eUSDAttrImportMode attr_import_mode = RNA_enum_get(op->ptr, "attr_import_mode");
 
   /* TODO(makowalski): Add support for sequences. */
   const bool is_sequence = false;
@@ -1249,13 +1245,12 @@ void WM_OT_usd_import(struct wmOperatorType *ot)
       "Material Name Collision",
       "Behavior when the name of an imported material conflicts with an existing material");
 
-  RNA_def_enum(
-    ot->srna,
-    "attr_import_mode",
-    rna_enum_usd_attr_import_mode_items,
-    USD_ATTR_IMPORT_NONE,
-    "Import Attributes",
-    "Behavior when importing USD attributes as Blender custom properties");
+  RNA_def_enum(ot->srna,
+               "attr_import_mode",
+               rna_enum_usd_attr_import_mode_items,
+               USD_ATTR_IMPORT_NONE,
+               "Import Attributes",
+               "Behavior when importing USD attributes as Blender custom properties");
 }
 
 #endif /* WITH_USD */
diff --git a/source/blender/io/usd/intern/usd_capi_export.cc b/source/blender/io/usd/intern/usd_capi_export.cc
index 2dda4b2ddec..738c6c0931a 100644
--- a/source/blender/io/usd/intern/usd_capi_export.cc
+++ b/source/blender/io/usd/intern/usd_capi_export.cc
@@ -84,19 +84,23 @@ static bool validate_params(const USDExportParams &params)
 
   if (params.export_materials && !pxr::SdfPath::IsValidPathString(params.material_prim_path)) {
     WM_reportf(RPT_ERROR,
-      "USD Export: invalid material prim path parameter '%s'", params.material_prim_path);
+               "USD Export: invalid material prim path parameter '%s'",
+               params.material_prim_path);
     valid = false;
   }
 
-  if (strlen(params.root_prim_path) != 0 && !pxr::SdfPath::IsValidPathString(params.root_prim_path)) {
-    WM_reportf(RPT_ERROR,
-      "USD Export: invalid root prim path parameter '%s'", params.root_prim_path);
+  if (strlen(params.root_prim_path) != 0 &&
+      !pxr::SdfPath::IsValidPathString(params.root_prim_path)) {
+    WM_reportf(
+        RPT_ERROR, "USD Export: invalid root prim path parameter '%s'", params.root_prim_path);
     valid = false;
   }
 
-  if (strlen(params.default_prim_path) != 0 && !pxr::SdfPath::IsValidPathString(params.default_prim_path)) {
+  if (strlen(params.default_prim_path) != 0 &&
+      !pxr::SdfPath::IsValidPathString(params.default_prim_path)) {
     WM_reportf(RPT_ERROR,
-      "USD Export: invalid default prim path parameter '%s'", params.default_prim_path);
+               "USD Export: invalid default prim path parameter '%s'",
+               params.default_prim_path);
     valid = false;
   }
 
@@ -219,7 +223,7 @@ static void export_startjob(void *customdata,
     pxr::SdfPath mtl_prim_path(data->params.material_prim_path);
 
     blender::io::usd::usd_define_or_over<pxr::UsdGeomScope>(
-      usd_stage, mtl_prim_path, data->params.export_as_overs);
+        usd_stage, mtl_prim_path, data->params.export_as_overs);
   }
 
   pxr::VtValue upAxis = pxr::VtValue(pxr::UsdGeomTokens->z);
diff --git a/source/blender/io/usd/intern/usd_reader_material.cc b/source/blender/io/usd/intern/usd_reader_material.cc
index fb5c8a8368d..863b8021ad2 100644
--- a/source/blender/io/usd/intern/usd_reader_material.cc
+++ b/source/blender/io/usd/intern/usd_reader_material.cc
@@ -354,8 +354,7 @@ Material *USDMaterialReader::add_material(const pxr::UsdShadeMaterial &usd_mater
     set_viewport_material_props(mtl, usd_preview);
   }
 
-  if (params_.import_shaders_mode == USD_IMPORT_USD_PREVIEW_SURFACE
-    && usd_preview) {
+  if (params_.import_shaders_mode == USD_IMPORT_USD_PREVIEW_SURFACE && usd_preview) {
     /* Create shader nodes to represent a UsdPreviewSurface. */
     import_usd_preview(mtl, usd_preview);
   }
@@ -367,8 +366,8 @@ Material *USDMaterialReader::add_material(const pxr::UsdShadeMaterial &usd_mater
 #endif
     if (!imported_mdl && usd_preview) {
       /* We failed to import an MDL, so fall back on importing UsdPreviewSuface. */
-      std::string message = "Couldn't import MDL shaders for material "
-        + mtl_name + ", importing USD Preview Surface shaders instead";
+      std::string message = "Couldn't import MDL shaders for material " + mtl_name +
+                            ", importing USD Preview Surface shaders instead";
       WM_reportf(RPT_INFO, message.c_str());
       import_usd_preview(mtl, usd_preview);
     }
diff --git a/source/blender/io/usd/intern/usd_reader_prim.cc b/source/blender/io/usd/intern/usd_reader_prim.cc
index f2ab4bbe203..510a3a062a4 100644
--- a/source/blender/io/usd/intern/usd_reader_prim.cc
+++ b/source/blender/io/usd/intern/usd_reader_prim.cc
@@ -46,7 +46,7 @@ void set_array_prop(IDProperty *idgroup,
     return;
   }
 
-  IDPropertyTemplate val = { 0 };
+  IDPropertyTemplate val = {0};
   val.array.len = static_cast<int>(vec.dimension);
 
   if (val.array.len <= 0) {
@@ -76,7 +76,8 @@ void set_array_prop(IDProperty *idgroup,
     return;
   }
 
-  typename VECT::ScalarType *prop_data = static_cast<typename VECT::ScalarType *>(prop->data.pointer);
+  typename VECT::ScalarType *prop_data = static_cast<typename VECT::ScalarType *>(
+      prop->data.pointer);
 
   for (int i = 0; i < val.array.len; ++i) {
     prop_data[i] = vec[i];
@@ -85,24 +86,22 @@ void set_array_prop(IDProperty *idgroup,
   IDP_AddToGroup(idgroup, prop);
 }
 
-} // anonymous namespace
+}  // anonymous namespace
 
 namespace blender::io::usd {
 
 /* TfToken objects are not cheap to construct, so we do it once. */
 namespace usdtokens {
-  static const pxr::TfToken userProperties("userProperties", pxr::TfToken::Immortal);
+static const pxr::TfToken userProperties("userProperties", pxr::TfToken::Immortal);
 }  // namespace usdtokens
 
-static void set_string_prop(IDProperty *idgroup,
-                            const char *prop_name,
-                            const char *str_val)
+static void set_string_prop(IDProperty *idgroup, const char *prop_name, const char *str_val)
 {
   if (!idgroup) {
     return;
   }
 
-  IDPropertyTemplate val = { 0 };
+  IDPropertyTemplate val = {0};
   val.string.str = str_val;
   /* Note length includes null terminator. */
   val.string.len = strlen(str_val) + 1;
@@ -113,45 +112,39 @@ static void set_string_prop(IDProperty *idgroup,
   IDP_AddToGroup(idgroup, prop);
 }
 
-static void set_int_prop(IDProperty *idgroup,
-                         const char *prop_name,
-                         const int ival)
+static void set_int_prop(IDProperty *idgroup, const char *prop_name, const int ival)
 {
   if (!idgroup) {
     return;
   }
 
-  IDPropertyTemplate val = { 0 };
+  IDPropertyTemplate val = {0};
   val.i = ival;
   IDProperty *prop = IDP_New(IDP_INT, &val, prop_name);
 
   IDP_AddToGroup(idgroup, prop);
 }
 
-static void set_float_prop(IDProperty *idgroup,
-                           const char *prop_name,
-                           const float fval)
+static void set_float_prop(IDProperty *idgroup, const char *prop_name, const float fval)
 {
   if (!idgroup) {
     return;
   }
 
-  IDPropertyTemplate val = { 0 };
+  IDPropertyTemplate val = {0};
   val.f = fval;
   IDProperty *prop = IDP_New(IDP_FLOAT, &val, prop_name);
 
   IDP_AddToGroup(idgroup, prop);
 }
 
-static void set_double_prop(IDProperty *idgroup,
-                            const char *prop_name,
-                            const double dval)
+static void set_double_prop(IDProperty *idgroup, const char *prop_name, const double dval)
 {
   if (!idgroup) {
     return;
   }
 
-  IDPropertyTemplate val = { 0 };
+  IDPropertyTemplate val = {0};
   val.d = dval;
   IDProperty *prop = IDP_New(IDP_DOUBLE, &val, prop_name);
 
@@ -195,7 +188,8 @@ void USDPrimReader::set_props(ID *id, const pxr::UsdPrim &prim, const double mot
     }
 
     /* When importing user properties, strip the namespace. */
-    pxr::TfToken attr_name = (attr_import_mode == USD_ATTR_IMPORT_USER) ? attr.GetBaseName() : attr.GetName();
+    pxr::TfToken attr_name = (attr_import_mode == USD_ATTR_IMPORT_USER) ? attr.GetBaseName() :
+                                                                          attr.GetName();
 
     pxr::SdfValueTypeName type_name = attr.GetTypeName();
 
@@ -259,7 +253,6 @@ void USDPrimReader::set_props(ID *id, const pxr::UsdPrim &prim, const double mot
   }
 }
 
-
 USDPrimReader::USDPrimReader(const pxr::UsdPrim &prim,
                              const USDImportParams &import_params,
                              const ImportSettings &sett

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list