forked from bartvdbraak/blender
fix: #34823 Collada: nodes exporting world matrices
This commit is contained in:
parent
33b65832d2
commit
f5033303e1
@ -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
|
anim_importer.read_node_transform(node, ob); // overwrites location set earlier
|
||||||
|
|
||||||
if (!is_joint) {
|
if (!is_joint) {
|
||||||
// if par was given make this object child of the previous
|
if (par && ob) {
|
||||||
if (par && ob)
|
ob->parent = par;
|
||||||
bc_set_parent(ob, par, mContext);
|
ob->partype = PAROBJECT;
|
||||||
|
ob->parsubstr[0] = 0;
|
||||||
|
|
||||||
|
//bc_set_parent(ob, par, mContext, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if node has child nodes write them
|
// if node has child nodes write them
|
||||||
COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes();
|
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.
|
/** 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)
|
bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScene)
|
||||||
{
|
{
|
||||||
if (mImportStage != General)
|
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);
|
add_transform(node, loc, rot, scale);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
UnitConverter converter;
|
UnitConverter converter;
|
||||||
|
double d_obmat[4][4];
|
||||||
/* Using parentinv should allow use of existing curves */
|
float f_obmat[4][4];
|
||||||
if (ob->parent) {
|
|
||||||
// If parentinv is identity don't add it.
|
|
||||||
bool add_parinv = false;
|
|
||||||
|
|
||||||
for (int i = 0; i < 16; ++i) {
|
/* Export the local Matrix (relative to the object parent) */
|
||||||
float f = (i % 4 == i / 4) ? 1.0f : 0.0f;
|
BKE_object_matrix_local_get(ob, f_obmat);
|
||||||
add_parinv |= (ob->parentinv[i % 4][i / 4] != f);
|
converter.mat4_to_dae_double(d_obmat, f_obmat);
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
switch (transformation_type) {
|
switch (transformation_type) {
|
||||||
case BC_TRANSFORMATION_TYPE_MATRIX : {
|
case BC_TRANSFORMATION_TYPE_MATRIX : {
|
||||||
node.addMatrix("transform",d_obmat);
|
node.addMatrix("transform",d_obmat);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BC_TRANSFORMATION_TYPE_TRANSROTLOC: {
|
|
||||||
add_transform(node, ob->loc, ob->rot, ob->size);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case BC_TRANSFORMATION_TYPE_BOTH : {
|
case BC_TRANSFORMATION_TYPE_BOTH : {
|
||||||
node.addMatrix("transform",d_obmat);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user