[Bf-blender-cvs] [756a0c6dc38] usd-importer-T81257: USD importer: use built-in matrix conversion.

Michael A. Kowalski noreply at git.blender.org
Fri Nov 6 01:31:00 CET 2020


Commit: 756a0c6dc38c898cb23538db1a80e59736a8ff11
Author: Michael A. Kowalski
Date:   Thu Nov 5 16:16:15 2020 -0500
Branches: usd-importer-T81257
https://developer.blender.org/rB756a0c6dc38c898cb23538db1a80e59736a8ff11

USD importer: use built-in matrix conversion.

Use the standard conversion of a pxr::GfMatrix4d to float.

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

M	source/blender/io/usd/import/usd_reader_prim.h
M	source/blender/io/usd/import/usd_reader_xformable.cc

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

diff --git a/source/blender/io/usd/import/usd_reader_prim.h b/source/blender/io/usd/import/usd_reader_prim.h
index 6265fcdecdf..a1fa1a9057d 100644
--- a/source/blender/io/usd/import/usd_reader_prim.h
+++ b/source/blender/io/usd/import/usd_reader_prim.h
@@ -52,8 +52,8 @@ class USDPrimReader {
   virtual ~USDPrimReader();
 
   // Disallow assignment and copying.
-  USDPrimReader(const USDPrimReader&) = delete;
-  USDPrimReader& operator=(const USDPrimReader&) = delete;
+  USDPrimReader(const USDPrimReader &) = delete;
+  USDPrimReader &operator=(const USDPrimReader &) = delete;
 
   const pxr::UsdPrim &prim() const;
 
diff --git a/source/blender/io/usd/import/usd_reader_xformable.cc b/source/blender/io/usd/import/usd_reader_xformable.cc
index aecefb55a4e..af5cb3558e3 100644
--- a/source/blender/io/usd/import/usd_reader_xformable.cc
+++ b/source/blender/io/usd/import/usd_reader_xformable.cc
@@ -30,6 +30,7 @@
 #include "BLI_utildefines.h"
 
 #include <pxr/base/gf/matrix4d.h>
+#include <pxr/base/gf/matrix4f.h>
 #include <pxr/usd/usdGeom/xformable.h>
 
 #include <iostream>
@@ -99,14 +100,9 @@ void USDXformableReader::read_matrix(float r_mat[4][4] /* local matrix */,
     }
   }
 
-  double double_mat[4][4];
-  usd_local_xf.Get(double_mat);
-
-  for (int i = 0; i < 4; ++i) {
-    for (int j = 0; j < 4; ++j) {
-      r_mat[i][j] = static_cast<float>(double_mat[i][j]);
-    }
-  }
+  // Convert the result to a float matrix.
+  pxr::GfMatrix4f mat4f = pxr::GfMatrix4f(usd_local_xf);
+  mat4f.Get(r_mat);
 
   if (this->context_.stage_up_axis == pxr::UsdGeomTokens->y) {
     /* Swap the matrix from y-up to z-up. */



More information about the Bf-blender-cvs mailing list