diff options
author | Gaia Clary <gaia.clary@machinimatrix.org> | 2013-07-14 04:34:21 +0400 |
---|---|---|
committer | Gaia Clary <gaia.clary@machinimatrix.org> | 2013-07-14 04:34:21 +0400 |
commit | f5033303e18192e1b66e9eb96bff1968ce874eb8 (patch) | |
tree | d24d7db28d9f06ac04722bc56795f319ade2bd26 /source | |
parent | 33b65832d2002979c27b39a1fbe1d59f77a24565 (diff) |
fix: #34823 Collada: nodes exporting world matrices
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/collada/DocumentImporter.cpp | 13 | ||||
-rw-r--r-- | source/blender/collada/TransformWriter.cpp | 35 |
2 files changed, 20 insertions, 28 deletions
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 0abf413788f..167ee7f40e4 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -601,11 +601,16 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA anim_importer.read_node_transform(node, ob); // overwrites location set earlier if (!is_joint) { - // if par was given make this object child of the previous - if (par && ob) - bc_set_parent(ob, par, mContext); + if (par && ob) { + ob->parent = par; + ob->partype = PAROBJECT; + ob->parsubstr[0] = 0; + + //bc_set_parent(ob, par, mContext, false); + } } } + // if node has child nodes write them COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes(); @@ -624,7 +629,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA } /** When this method is called, the writer must write the entire visual scene. - * \return The writer should return true, if writing succeeded, false otherwise.*/ + * Return The writer should return true, if writing succeeded, false otherwise. */ bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScene) { if (mImportStage != General) diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp index d4db42da35b..5ed67e00aa9 100644 --- a/source/blender/collada/TransformWriter.cpp +++ b/source/blender/collada/TransformWriter.cpp @@ -97,40 +97,27 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob, B add_transform(node, loc, rot, scale); #endif - UnitConverter converter; - - /* Using parentinv should allow use of existing curves */ - if (ob->parent) { - // If parentinv is identity don't add it. - bool add_parinv = false; - - for (int i = 0; i < 16; ++i) { - float f = (i % 4 == i / 4) ? 1.0f : 0.0f; - add_parinv |= (ob->parentinv[i % 4][i / 4] != f); - } - if (add_parinv) { - double dmat[4][4]; - converter.mat4_to_dae_double(dmat, ob->parentinv); - node.addMatrix("parentinverse", dmat); - } - } + UnitConverter converter; + double d_obmat[4][4]; + float f_obmat[4][4]; - double d_obmat[4][4]; - converter.mat4_to_dae_double(d_obmat, ob->obmat); + /* Export the local Matrix (relative to the object parent) */ + BKE_object_matrix_local_get(ob, f_obmat); + converter.mat4_to_dae_double(d_obmat, f_obmat); switch (transformation_type) { case BC_TRANSFORMATION_TYPE_MATRIX : { node.addMatrix("transform",d_obmat); break; } - case BC_TRANSFORMATION_TYPE_TRANSROTLOC: { - add_transform(node, ob->loc, ob->rot, ob->size); - break; - } case BC_TRANSFORMATION_TYPE_BOTH : { node.addMatrix("transform",d_obmat); - add_transform(node, ob->loc, ob->rot, ob->size); + } + case BC_TRANSFORMATION_TYPE_TRANSROTLOC: { + float loc[3], rot[3], scale[3]; + TransformBase::decompose(f_obmat, loc, rot, NULL, scale); + add_transform(node, loc, rot, scale); break; } } |