[Bf-blender-cvs] [a753d2625bc] usd-importer-T81257: Invoking copy_zup_from_yup() function.

Michael A. Kowalski noreply at git.blender.org
Sun Oct 4 21:54:19 CEST 2020


Commit: a753d2625bc9ddfb4977a01290ea7ad60bf5f1b4
Author: Michael A. Kowalski
Date:   Sat Oct 3 17:04:46 2020 -0400
Branches: usd-importer-T81257
https://developer.blender.org/rBa753d2625bc9ddfb4977a01290ea7ad60bf5f1b4

Invoking copy_zup_from_yup() function.

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

M	source/blender/io/usd/intern/usd_reader_mesh.cc
M	source/blender/io/usd/intern/usd_util.h

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

diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc
index f4650fcc6d3..5cf30d8b79a 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.cc
+++ b/source/blender/io/usd/intern/usd_reader_mesh.cc
@@ -90,10 +90,7 @@ static void read_mverts(MVert *mverts, const MeshSampleData &mesh_data)
     pxr::GfVec3f pt = mesh_data.points[i];
 
     if (mesh_data.y_up) {
-      // Convert from y-up to z-up.
-      mvert.co[0] = pt[0];
-      mvert.co[1] = -pt[2];
-      mvert.co[2] = pt[1];
+      blender::io::usd::copy_zup_from_yup(mvert.co, pt.GetArray());
     }
     else {
       mvert.co[0] = pt[0];
diff --git a/source/blender/io/usd/intern/usd_util.h b/source/blender/io/usd/intern/usd_util.h
index ee324061297..4e67733c8bf 100644
--- a/source/blender/io/usd/intern/usd_util.h
+++ b/source/blender/io/usd/intern/usd_util.h
@@ -18,6 +18,8 @@
  */
 #pragma once
 
+#include "BLI_compiler_compat.h"
+
 #include "pxr/usd/usd/common.h"
 
 #include <vector>
@@ -30,9 +32,9 @@ class UsdObjectReader;
 
 void debug_traverse_stage(const pxr::UsdStageRefPtr &usd_stage);
 
-/* TODO(makowalski):  copy_m44_axis_swap and create_swapped_rotation_matrix
- * below are duplicates of the declarations in abc_axis_conversion.h.
- * Should move this to a shared location. */
+/* TODO(makowalski):  copy_m44_axis_swap, create_swapped_rotation_matrix
+ * and copy_zup_from_yup below are duplicates of the declarations in
+ * abc_axis_conversion.h, and should be moved to a shared location. */
 typedef enum {
   USD_ZUP_FROM_YUP = 1,
   USD_YUP_FROM_ZUP = 2,
@@ -48,6 +50,14 @@ void create_swapped_rotation_matrix(float rot_x_mat[3][3],
 
 void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], UsdAxisSwapMode mode);
 
+BLI_INLINE void copy_zup_from_yup(float zup[3], const float yup[3])
+{
+  const float old_yup1 = yup[1]; /* in case zup == yup */
+  zup[0] = yup[0];
+  zup[1] = -yup[2];
+  zup[2] = old_yup1;
+}
+
 void create_readers(const pxr::UsdStageRefPtr &usd_stage,
                     const USDImporterContext &context,
                     std::vector<UsdObjectReader *> &r_readers);



More information about the Bf-blender-cvs mailing list