EditBone.matrix calculation

Hi,

I have the following piece of code from the blender BVH importer:

    # create new editbone
    bone = bvh_node.temp = arm_data.edit_bones.new(bvh_node.name)

    bone.head = bvh_node.rest_head_world
    bone.tail = bvh_node.rest_tail_world 

    logging.debug ("bone info: {0} {1} {2}".format (bone.head , bone.tail , bone.matrix))

and I’m trying to find in blender’s code the code which calculates the bone.matrix from the head and tail. I’ve tried to search in in blender’s source, but I’m not very used to it (actually first time I’ve had a look), nor used to python

Could somebody please point me to the piece of code which calculates bone.matrix ?

Algorithmically it is clear that the matrix’s Y vector is bone.tail-bone.head normalized, but I’m having trouble to reproduce the other values because with a single vector I have infinite matrices to pick from and I’d like to have the same matrix to compare side by side with an app I’m writing.

Thanks!

The code is in ED_armature_ebone_to_mat4:
https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/armature/armature_utils.c;658a9c6cf5228efafd9e7b8d5282f09019f4c4f2$219

1 Like