We need to leave tweak mode before trying to modifiy the action as doing
so will leave Blender in a semi-corrupted state.
Reviewers: #animation
Reviewed by: aligorith
Maniphest Tasks: T48397
Differential Revision: https://developer.blender.org/D2119
Caused by own rBfb7ff31315a1c9 - not surprising code using Object.matrix_local
in other contexts than mere Object parenting fails, since it was using a broken
implementation before...
Note that whole NLA_OT_Bake op would need some love, it is quite brittle in many aspects.
there are cases where you want to use visual-keying but not remove constraints, also it wasnt obvious that clearing constraints used a different method of keyframing.
So split these into 2 options.
bake_action tries to make kind of a 'visual keying'... On one side, this is rather stupid when you keep constraints (in this case, keying actual loc/rot/scale transforms, i.e. matrix_basis, is enough, doing more would lead to unexpected behavior with some constraints). On the other one, making a good visual keying of bones is *really* tricky, so now using the new object's convert_space() func to compute that (when the user chooses to remove the constraints).
Incidentally, this greatly simplifies the code of bake_action!