Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2018-05-18 18:07:41 +0300
committerJoshua Leung <aligorith@gmail.com>2018-05-18 18:07:46 +0300
commit29595334f06107c484e928358715b55dac3e840d (patch)
treea54fc917b739751390fd3bdf25659796ffbde3d3 /source/blender/editors/armature/pose_transform.c
parent2d6bfb5b63cdb92422e6b6d8e2ff58f844b7ed94 (diff)
COW Fix: POSE_OT_armature_apply (Apply Pose as Rest Pose) now works with COW
Diffstat (limited to 'source/blender/editors/armature/pose_transform.c')
-rw-r--r--source/blender/editors/armature/pose_transform.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c
index 1da8e24bd00..af9d94c0bac 100644
--- a/source/blender/editors/armature/pose_transform.c
+++ b/source/blender/editors/armature/pose_transform.c
@@ -100,6 +100,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object
+ const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
bArmature *arm = BKE_armature_from_object(ob);
bPose *pose;
bPoseChannel *pchan;
@@ -127,11 +128,12 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
pose = ob->pose;
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
+ const bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name);
curbone = ED_armature_ebone_find_name(arm->edbo, pchan->name);
/* simply copy the head/tail values from pchan over to curbone */
- copy_v3_v3(curbone->head, pchan->pose_head);
- copy_v3_v3(curbone->tail, pchan->pose_tail);
+ copy_v3_v3(curbone->head, pchan_eval->pose_head);
+ copy_v3_v3(curbone->tail, pchan_eval->pose_tail);
/* fix roll:
* 1. find auto-calculated roll value for this bone now
@@ -147,7 +149,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
invert_m3_m3(imat, premat);
/* get pchan 'visual' matrix */
- copy_m3_m4(pmat, pchan->pose_mat);
+ copy_m3_m4(pmat, pchan_eval->pose_mat);
/* remove auto from visual and get euler rotation */
mul_m3_m3m3(tmat, imat, pmat);
@@ -161,17 +163,19 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
* then clear the pchan values (so we don't get a double-up)
*/
if (pchan->bone->segments > 1) {
- curbone->curveInX += pchan->curveInX;
- curbone->curveInY += pchan->curveInY;
- curbone->curveOutX += pchan->curveOutX;
- curbone->curveOutY += pchan->curveOutY;
- curbone->roll1 += pchan->roll1;
- curbone->roll2 += pchan->roll2;
- curbone->ease1 += pchan->ease1;
- curbone->ease2 += pchan->ease2;
- curbone->scaleIn += pchan->scaleIn;
- curbone->scaleOut += pchan->scaleOut;
+ /* combine rest/pose values */
+ curbone->curveInX += pchan_eval->curveInX;
+ curbone->curveInY += pchan_eval->curveInY;
+ curbone->curveOutX += pchan_eval->curveOutX;
+ curbone->curveOutY += pchan_eval->curveOutY;
+ curbone->roll1 += pchan_eval->roll1;
+ curbone->roll2 += pchan_eval->roll2;
+ curbone->ease1 += pchan_eval->ease1;
+ curbone->ease2 += pchan_eval->ease2;
+ curbone->scaleIn += pchan_eval->scaleIn;
+ curbone->scaleOut += pchan_eval->scaleOut;
+ /* reset pose values */
pchan->curveInX = pchan->curveOutX = 0.0f;
pchan->curveInY = pchan->curveOutY = 0.0f;
pchan->roll1 = pchan->roll2 = 0.0f;
@@ -202,6 +206,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
+ DEG_id_tag_update(&ob->id, DEG_TAG_COPY_ON_WRITE);
return OPERATOR_FINISHED;
}