diff options
author | Joshua Leung <aligorith@gmail.com> | 2018-05-15 19:39:13 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2018-05-15 19:39:24 +0300 |
commit | 747326ed25266fcd1775a80430583f0beef46f80 (patch) | |
tree | d2b2944505c14a39e8514163e230f1993f0e1861 /source | |
parent | c3282cb746b36f05564ea6e3c24bb462d00f6bc9 (diff) |
Fix: POSE_OT_visual_transform_apply now works with Copy on Write
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/armature/pose_transform.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index e4ffa614420..1da8e24bd00 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -53,6 +53,7 @@ #include "BKE_report.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" #include "RNA_access.h" #include "RNA_define.h" @@ -225,15 +226,18 @@ void POSE_OT_armature_apply(wmOperatorType *ot) static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) { ViewLayer *view_layer = CTX_data_view_layer(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); - FOREACH_OBJECT_IN_MODE_BEGIN(view_layer, OB_MODE_POSE, ob_iter) + FOREACH_OBJECT_IN_MODE_BEGIN(view_layer, OB_MODE_POSE, ob) { /* loop over all selected pchans * * TODO, loop over children before parents if multiple bones * at once are to be predictable*/ - FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob_iter, pchan) + FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob, pchan) { + const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); + bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name); float delta_mat[4][4]; /* chan_mat already contains the delta transform from rest pose to pose-mode pose @@ -244,16 +248,16 @@ static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) /* XXX For some reason, we can't use pchan->chan_mat here, gives odd rotation/offset (see T38251). * Using pchan->pose_mat and bringing it back in bone space seems to work as expected! */ - BKE_armature_mat_pose_to_bone(pchan, pchan->pose_mat, delta_mat); + BKE_armature_mat_pose_to_bone(pchan_eval, pchan_eval->pose_mat, delta_mat); BKE_pchan_apply_mat4(pchan, delta_mat, true); } FOREACH_PCHAN_SELECTED_IN_OBJECT_END; - DEG_id_tag_update(&ob_iter->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob_iter); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); } FOREACH_OBJECT_IN_MODE_END; |