[Bf-blender-cvs] [18bf798dc60] temp-usd-prev-export2: USD material export code cleanup.

Michael Kowalski noreply at git.blender.org
Fri Jan 7 01:45:37 CET 2022


Commit: 18bf798dc6032f67c247f0b64e246e94a88f3f5f
Author: Michael Kowalski
Date:   Tue Dec 28 06:45:08 2021 -0500
Branches: temp-usd-prev-export2
https://developer.blender.org/rB18bf798dc6032f67c247f0b64e246e94a88f3f5f

USD material export code cleanup.

Added const where needed.

Updated conditional in get_tex_image_asset_path() to avoid
recomputing relative path when exporting textures.

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

M	source/blender/blenkernel/intern/customdata.c
M	source/blender/io/usd/intern/usd_writer_material.cc

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

diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index bf2760d3db3..1170f59bee3 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -2405,10 +2405,10 @@ int CustomData_get_stencil_layer(const CustomData *data, int type)
   return (layer_index != -1) ? data->layers[layer_index].active_mask : -1;
 }
 
-const char *CustomData_get_active_layer_name(const struct CustomData *data, int type)
+const char *CustomData_get_active_layer_name(const struct CustomData *data, const int type)
 {
   /* Get the layer index of the active layer of this type. */
-  int layer_index = CustomData_get_active_layer_index(data, type);
+  const int layer_index = CustomData_get_active_layer_index(data, type);
   return layer_index < 0 ? NULL : data->layers[layer_index].name;
 }
 
diff --git a/source/blender/io/usd/intern/usd_writer_material.cc b/source/blender/io/usd/intern/usd_writer_material.cc
index 99a05ab67c6..b0bc95b93f5 100644
--- a/source/blender/io/usd/intern/usd_writer_material.cc
+++ b/source/blender/io/usd/intern/usd_writer_material.cc
@@ -550,7 +550,7 @@ static pxr::TfToken get_node_tex_image_color_space(bNode *node)
 
 /* Search the upstream nodes connected to the given socket and return the first occurrance
  * of the node of the given type. Return null if no node of this type was found. */
-static bNode *traverse_channel(bNodeSocket *input, short target_type)
+static bNode *traverse_channel(bNodeSocket *input, const short target_type)
 {
   if (!input->link) {
     return nullptr;
@@ -589,7 +589,7 @@ static bNode *find_bsdf_node(Material *material)
 static pxr::UsdShadeShader create_usd_preview_shader(const USDExporterContext &usd_export_context,
                                                      pxr::UsdShadeMaterial &material,
                                                      const char *name,
-                                                     int type)
+                                                     const int type)
 {
   pxr::SdfPath shader_path = material.GetPath()
                                  .AppendChild(usdtokens::preview)
@@ -725,8 +725,7 @@ static std::string get_tex_image_asset_path(bNode *node,
     }
     return exp_path;
   }
-
-  if (export_params.relative_texture_paths) {
+  else if (export_params.relative_texture_paths) {
     /* Get the path relative to the USD. */
     pxr::SdfLayerHandle layer = stage->GetRootLayer();
     std::string stage_path = layer->GetRealPath();



More information about the Bf-blender-cvs mailing list