fix: #34823 Collada: nodes exporting world matrices

This commit is contained in:
Gaia Clary 2013-07-14 00:34:21 +00:00
parent 33b65832d2
commit f5033303e1
2 changed files with 20 additions and 28 deletions

@ -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)

@ -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;
}
}