diff options
author | makowalski <makowalski@nvidia.com> | 2021-03-09 00:46:35 +0300 |
---|---|---|
committer | makowalski <makowalski@nvidia.com> | 2021-03-09 00:46:35 +0300 |
commit | 7c1ebabbe12faec94818d13f4185d11bb38c9123 (patch) | |
tree | 0183e95a326fb9d227da5daec364369fd6a2e128 | |
parent | 7be1708487603c8ec96b44de69f0cb37a0b0f9b7 (diff) |
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.
-rw-r--r-- | source/blender/io/usd/intern/usd_reader_xform.cc | 31 |
1 files changed, 7 insertions, 24 deletions
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. */ |