Pasting poses now updates motion paths

This commit is contained in:
Joshua Leung
2017-11-20 00:31:07 +13:00
parent cda05639df
commit c01ffefb68

View File

@@ -484,12 +484,15 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
bPoseChannel *chan; bPoseChannel *chan;
const bool flip = RNA_boolean_get(op->ptr, "flipped"); const bool flip = RNA_boolean_get(op->ptr, "flipped");
bool selOnly = RNA_boolean_get(op->ptr, "selected_mask"); bool selOnly = RNA_boolean_get(op->ptr, "selected_mask");
/* Get KeyingSet to use. */ /* Get KeyingSet to use. */
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID); KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID);
/* Sanity checks. */ /* Sanity checks. */
if (ELEM(NULL, ob, ob->pose)) { if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
/* Read copy buffer .blend file. */ /* Read copy buffer .blend file. */
char str[FILE_MAX]; char str[FILE_MAX];
Main *tmp_bmain = BKE_main_new(); Main *tmp_bmain = BKE_main_new();
@@ -505,6 +508,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
BKE_main_free(tmp_bmain); BKE_main_free(tmp_bmain);
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
Object *object_from = tmp_bmain->object.first; Object *object_from = tmp_bmain->object.first;
bPose *pose_from = object_from->pose; bPose *pose_from = object_from->pose;
if (pose_from == NULL) { if (pose_from == NULL) {
@@ -512,6 +516,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
BKE_main_free(tmp_bmain); BKE_main_free(tmp_bmain);
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
/* If selOnly option is enabled, if user hasn't selected any bones, /* If selOnly option is enabled, if user hasn't selected any bones,
* just go back to default behavior to be more in line with other * just go back to default behavior to be more in line with other
* pose tools. * pose tools.
@@ -521,6 +526,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
selOnly = false; selOnly = false;
} }
} }
/* Safely merge all of the channels in the buffer pose into any /* Safely merge all of the channels in the buffer pose into any
* existing pose. * existing pose.
*/ */
@@ -535,8 +541,15 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
} }
} }
BKE_main_free(tmp_bmain); BKE_main_free(tmp_bmain);
/* Update event for pose and deformation children. */ /* Update event for pose and deformation children. */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA); DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* Recalculate paths if any of the bones have paths... */
if ((ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) {
ED_pose_recalculate_paths(scene, ob);
}
/* Notifiers for updates, */ /* Notifiers for updates, */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);