collada: Simplify reading Node Matrix
This commit is contained in:
parent
1729dd9998
commit
339d0170d1
|
@ -132,18 +132,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBon
|
|||
|
||||
// create a bone even if there's no joint data for it (i.e. it has no influence)
|
||||
if (!bone_is_skinned) {
|
||||
float obmat[4][4];
|
||||
// bone-space
|
||||
get_node_mat(obmat, node, NULL, NULL);
|
||||
|
||||
// get world-space
|
||||
if (parent) {
|
||||
mul_m4_m4m4(mat, parent_mat, obmat);
|
||||
}
|
||||
else {
|
||||
copy_m4_m4(mat, obmat);
|
||||
}
|
||||
|
||||
get_node_mat(mat, node, NULL, NULL, parent_mat);
|
||||
}
|
||||
|
||||
if (parent) bone->parent = parent;
|
||||
|
|
|
@ -34,7 +34,21 @@ TransformReader::TransformReader(UnitConverter *conv) : unit_converter(conv)
|
|||
/* pass */
|
||||
}
|
||||
|
||||
void TransformReader::get_node_mat(float mat[4][4], COLLADAFW::Node *node, std::map<COLLADAFW::UniqueId, Animation> *animation_map, Object *ob)
|
||||
void TransformReader::get_node_mat(
|
||||
float mat[4][4],
|
||||
COLLADAFW::Node *node,
|
||||
std::map<COLLADAFW::UniqueId, Animation> *animation_map,
|
||||
Object *ob)
|
||||
{
|
||||
get_node_mat(mat, node, animation_map, ob, NULL);
|
||||
}
|
||||
|
||||
void TransformReader::get_node_mat(
|
||||
float mat[4][4],
|
||||
COLLADAFW::Node *node,
|
||||
std::map<COLLADAFW::UniqueId, Animation> *animation_map,
|
||||
Object *ob,
|
||||
float parent_mat[4][4])
|
||||
{
|
||||
float cur[4][4];
|
||||
float copy[4][4];
|
||||
|
@ -52,6 +66,9 @@ void TransformReader::get_node_mat(float mat[4][4], COLLADAFW::Node *node, std::
|
|||
// then this is considered as redundant information.
|
||||
// So if we find a Matrix we use that and return.
|
||||
dae_matrix_to_mat4(tm, mat);
|
||||
if (parent_mat) {
|
||||
mul_m4_m4m4(mat, parent_mat, mat);
|
||||
}
|
||||
return;
|
||||
case COLLADAFW::Transformation::TRANSLATE:
|
||||
dae_translate_to_mat4(tm, cur);
|
||||
|
@ -80,6 +97,10 @@ void TransformReader::get_node_mat(float mat[4][4], COLLADAFW::Node *node, std::
|
|||
(*animation_map)[anim_list_id] = anim;
|
||||
}
|
||||
}
|
||||
|
||||
if (parent_mat) {
|
||||
mul_m4_m4m4(mat, parent_mat, mat);
|
||||
}
|
||||
}
|
||||
|
||||
void TransformReader::dae_rotate_to_mat4(COLLADAFW::Transformation *tm, float m[4][4])
|
||||
|
|
|
@ -59,7 +59,8 @@ public:
|
|||
TransformReader(UnitConverter *conv);
|
||||
|
||||
void get_node_mat(float mat[4][4], COLLADAFW::Node *node, std::map<COLLADAFW::UniqueId, Animation> *animation_map, Object *ob);
|
||||
|
||||
void get_node_mat(float mat[4][4], COLLADAFW::Node *node, std::map<COLLADAFW::UniqueId, Animation> *animation_map, Object *ob, float parent_mat[4][4]);
|
||||
|
||||
void dae_rotate_to_mat4(COLLADAFW::Transformation *tm, float m[4][4]);
|
||||
void dae_translate_to_mat4(COLLADAFW::Transformation *tm, float m[4][4]);
|
||||
void dae_scale_to_mat4(COLLADAFW::Transformation *tm, float m[4][4]);
|
||||
|
|
Loading…
Reference in New Issue