Commit: df4feb33c7aeecab9898182e4ebdfc4880f14bab
Author: Sybren A. Stüvel
Date:   Thu Feb 23 16:00:06 2017 +0100
Branches: temp-sybren-alembic
https://developer.blender.org/rBdf4feb33c7aeecab9898182e4ebdfc4880f14bab

Alembic import: fixed bug where local matrix from Alembic was used as object 
matrix

Also renamed AbcObjectReader::readObjectMatrix to
setupObjectTransform, as it does more than just reading the object
matrix; it also sets up an object constraint if the Alembic Xform is
animated.

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

M       source/blender/alembic/intern/abc_object.cc
M       source/blender/alembic/intern/abc_object.h
M       source/blender/alembic/intern/alembic_capi.cc

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

diff --git a/source/blender/alembic/intern/abc_object.cc 
b/source/blender/alembic/intern/abc_object.cc
index 7250ebb4c0..b8152dec7f 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -214,7 +214,7 @@ Imath::M44d get_matrix(const IXformSchema &schema, const 
float time)
        return s0.getMatrix();
 }
 
-void AbcObjectReader::readObjectMatrix(const float time)
+void AbcObjectReader::setupObjectTransform(const float time)
 {
        bool is_constant = false;
 
@@ -296,6 +296,16 @@ void AbcObjectReader::read_matrix(float mat[4][4], const 
float time, const float
        const Imath::M44d matrix = get_matrix(schema, time);
        convert_matrix(matrix, m_object, mat, scale, has_alembic_parent);
 
+       if (has_alembic_parent) {
+               /* In this case, the matrix in Alembic is in local coordinates, 
so
+                * convert to world matrix. To prevent us from reading and 
accumulating
+                * all parent matrices in the Alembic file, we assume that the 
Blender
+                * parent object is already updated for the current timekey, 
and use its
+                * world matrix. */
+               BLI_assert(m_object->parent);
+               mul_m4_m4m4(mat, m_object->parent->obmat, mat);
+       }
+
        is_constant = schema.isConstant();
 }
 
diff --git a/source/blender/alembic/intern/abc_object.h 
b/source/blender/alembic/intern/abc_object.h
index 6d97c0359b..5b7663943c 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -183,7 +183,8 @@ public:
                return dm;
        }
 
-       void readObjectMatrix(const float time);
+       /** Reads the object matrix and sets up an object transform if 
animated. */
+       void setupObjectTransform(const float time);
 
        void addCacheModifier();
 
diff --git a/source/blender/alembic/intern/alembic_capi.cc 
b/source/blender/alembic/intern/alembic_capi.cc
index f773b4a770..1e34de0500 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -655,7 +655,6 @@ static void import_startjob(void *user_data, short *stop, 
short *do_update, floa
 
                if (reader->valid()) {
                        reader->readObjectData(data->bmain, 0.0f);
-                       reader->readObjectMatrix(0.0f);
 
                        min_time = std::min(min_time, reader->minTime());
                        max_time = std::max(max_time, reader->maxTime());
@@ -728,6 +727,12 @@ static void import_startjob(void *user_data, short *stop, 
short *do_update, floa
                        return;
                }
        }
+
+       /* Setup transformations and constraints. */
+       for (iter = data->readers.begin(); iter != data->readers.end(); ++iter) 
{
+               AbcObjectReader *reader = *iter;
+               reader->setupObjectTransform(0.0f);
+       }
 }
 
 static void import_endjob(void *user_data)

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to