[Bf-blender-cvs] [b748ad7488d] temp-usd-prev-export2: USD material export: reorder code.

Michael Kowalski noreply at git.blender.org
Tue Dec 28 06:13:53 CET 2021


Commit: b748ad7488d8e004a409de91111de0b91a480c39
Author: Michael Kowalski
Date:   Mon Dec 27 14:13:41 2021 -0500
Branches: temp-usd-prev-export2
https://developer.blender.org/rBb748ad7488d8e004a409de91111de0b91a480c39

USD material export: reorder code.

Moved related get_node_tex_image_filepath() functions closer
togther, per suggestion by Sybren in his review.

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

M	source/blender/io/usd/intern/usd_writer_material.cc

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

diff --git a/source/blender/io/usd/intern/usd_writer_material.cc b/source/blender/io/usd/intern/usd_writer_material.cc
index 30eab8534d5..a80a6bbe99f 100644
--- a/source/blender/io/usd/intern/usd_writer_material.cc
+++ b/source/blender/io/usd/intern/usd_writer_material.cc
@@ -546,38 +546,6 @@ static void copy_single_file(Image *ima, const std::string &dest_dir, const bool
   }
 }
 
-/* Gets a NodeTexImage's filepath */
-static std::string get_node_tex_image_filepath(bNode *node)
-{
-  NodeTexImage *tex_original = (NodeTexImage *)node->storage;
-
-  Image *ima = (Image *)node->id;
-  if (!ima) {
-    return "";
-  }
-
-  if (strlen(ima->filepath) == 0) {
-    return "";
-  }
-
-  char filepath[1024];
-  strncpy(filepath, ima->filepath, sizeof(ima->filepath));
-
-  BKE_image_user_file_path(&tex_original->iuser, ima, filepath);
-
-  BLI_str_replace_char(filepath, '\\', '/');
-
-  if (ima->source == IMA_SRC_TILED) {
-    char head[FILE_MAX], tail[FILE_MAX];
-    unsigned short numlen;
-
-    BLI_path_sequence_decode(filepath, head, tail, &numlen);
-    return (std::string(head) + "<UDIM>" + std::string(tail));
-  }
-
-  return std::string(filepath);
-}
-
 static pxr::TfToken get_node_tex_image_color_space(bNode *node)
 {
   if (node->type != SH_NODE_TEX_IMAGE) {
@@ -703,6 +671,38 @@ static pxr::UsdShadeShader create_usd_preview_shader(const USDExporterContext &u
   return shader;
 }
 
+/* Gets a NodeTexImage's filepath */
+static std::string get_node_tex_image_filepath(bNode *node)
+{
+  NodeTexImage *tex_original = (NodeTexImage *)node->storage;
+
+  Image *ima = (Image *)node->id;
+  if (!ima) {
+    return "";
+  }
+
+  if (strlen(ima->filepath) == 0) {
+    return "";
+  }
+
+  char filepath[1024];
+  strncpy(filepath, ima->filepath, sizeof(ima->filepath));
+
+  BKE_image_user_file_path(&tex_original->iuser, ima, filepath);
+
+  BLI_str_replace_char(filepath, '\\', '/');
+
+  if (ima->source == IMA_SRC_TILED) {
+    char head[FILE_MAX], tail[FILE_MAX];
+    unsigned short numlen;
+
+    BLI_path_sequence_decode(filepath, head, tail, &numlen);
+    return (std::string(head) + "<UDIM>" + std::string(tail));
+  }
+
+  return std::string(filepath);
+}
+
 /* Gets a NodeTexImage's filepath, returning a path in the texture export directory or a relative
  * path, if the export parameters require it. */
 static std::string get_node_tex_image_filepath(bNode *node,



More information about the Bf-blender-cvs mailing list