[Bf-blender-cvs] [7c1ebabbe12] usd-importer-T81257-merge: USD Import: simplify xform matrix computation.

makowalski noreply at git.blender.org
Mon Mar 8 22:53:18 CET 2021


Commit: 7c1ebabbe12faec94818d13f4185d11bb38c9123
Author: makowalski
Date:   Mon Mar 8 16:46:35 2021 -0500
Branches: usd-importer-T81257-merge
https://developer.blender.org/rB7c1ebabbe12faec94818d13f4185d11bb38c9123

USD Import: simplify xform matrix computation.

Updated the USDXformReader matrix computation function to use the
standard UsdGeomXformable API for querying the prim's local
transform and to determine whether the matrix is time-varying,
rather than explicitly iterating over the UsdGeomXformOps.

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

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

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

diff --git a/source/blender/io/usd/intern/usd_reader_xform.cc b/source/blender/io/usd/intern/usd_reader_xform.cc
index d167cf1a052..1104ddb126d 100644
--- a/source/blender/io/usd/intern/usd_reader_xform.cc
+++ b/source/blender/io/usd/intern/usd_reader_xform.cc
@@ -95,32 +95,15 @@ void USDXformReader::read_matrix(float r_mat[4][4] /* local matrix */,
     return;
   }
 
-  bool resetsXformStack = false;
-  std::vector<pxr::UsdGeomXformOp> orderedXformOps = xformable.GetOrderedXformOps(
-      &resetsXformStack);
+  is_constant = !xformable.TransformMightBeTimeVarying();
 
-  for (std::vector<pxr::UsdGeomXformOp>::iterator I = orderedXformOps.begin();
-       I != orderedXformOps.end();
-       ++I) {
+  pxr::GfMatrix4d usd_local_xf;
+  bool reset_xform_stack;
+  xformable.GetLocalTransformation(&usd_local_xf, &reset_xform_stack, time);
 
-    pxr::UsdGeomXformOp &xformOp = (*I);
-
-    if (xformOp.MightBeTimeVarying()) {
-      is_constant = false;
-    }
-
-    // Note, we don't apply the scale here because the XformOps may
-    // be empty, in which case this code won't be reached.
-    pxr::GfMatrix4d mat = xformOp.GetOpTransform(time);
-
-    // Convert the result to a float matrix.
-    pxr::GfMatrix4f mat4f(mat);
-
-    float t_mat[4][4];
-    mat4f.Get(t_mat);
-
-    mul_m4_m4m4(r_mat, r_mat, t_mat);
-  }
+  // Convert the result to a float matrix.
+  pxr::GfMatrix4f mat4f = pxr::GfMatrix4f(usd_local_xf);
+  mat4f.Get(r_mat);
 
   /* Apply global scaling and rotation only to root objects, parenting
    * will propagate it. */



More information about the Bf-blender-cvs mailing list