[Bf-blender-cvs] [0c3283654ed] usd-importer-T81257: USD transform cache import bug fix.
makowalski
noreply at git.blender.org
Sun Dec 27 22:18:13 CET 2020
Commit: 0c3283654ed0d5abd6663e8d142d2281a59002c6
Author: makowalski
Date: Tue Dec 8 22:28:20 2020 -0500
Branches: usd-importer-T81257
https://developer.blender.org/rB0c3283654ed0d5abd6663e8d142d2281a59002c6
USD transform cache import bug fix.
Fixed USD_get_transform() to work for parented objects.
===================================================================
M source/blender/io/usd/intern/usd_capi.cc
===================================================================
diff --git a/source/blender/io/usd/intern/usd_capi.cc b/source/blender/io/usd/intern/usd_capi.cc
index 74b281807b5..931b08433ef 100644
--- a/source/blender/io/usd/intern/usd_capi.cc
+++ b/source/blender/io/usd/intern/usd_capi.cc
@@ -69,6 +69,7 @@
#include "DNA_meshdata_types.h"
#include "BLI_fileops.h"
+#include "BLI_math_matrix.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
@@ -731,7 +732,10 @@ void USD_free_handle(CacheArchiveHandle *handle)
delete archive;
}
-void USD_get_transform(struct CacheReader *reader, float r_mat[4][4], float time, float scale)
+void USD_get_transform(struct CacheReader *reader,
+ float r_mat_world[4][4],
+ float time,
+ float scale)
{
if (!reader) {
return;
@@ -741,5 +745,23 @@ void USD_get_transform(struct CacheReader *reader, float r_mat[4][4], float time
reinterpret_cast<blender::io::usd::USDXformableReader *>(reader);
bool is_constant = false;
- usd_reader->read_matrix(r_mat, time, scale, is_constant);
+
+ /* Convert from the local matrix we obtain from USD to world coordinates
+ * for Blender. This conversion is done here rather than by Blender due to
+ * work around the non-standard interpretation of CONSTRAINT_SPACE_LOCAL in
+ * BKE_constraint_mat_convertspace(). */
+ Object *object = usd_reader->object();
+ if (object->parent == nullptr) {
+ /* No parent, so local space is the same as world space. */
+ usd_reader->read_matrix(r_mat_world, time, scale, is_constant);
+ return;
+ }
+
+ float mat_parent[4][4];
+ BKE_object_get_parent_matrix(object, object->parent, mat_parent);
+
+ float mat_local[4][4];
+ usd_reader->read_matrix(mat_local, time, scale, is_constant);
+ mul_m4_m4m4(r_mat_world, mat_parent, object->parentinv);
+ mul_m4_m4m4(r_mat_world, r_mat_world, mat_local);
}
More information about the Bf-blender-cvs
mailing list