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 *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 *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; + double d_obmat[4][4]; + float f_obmat[4][4]; - 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); - } - } - - 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; } }