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:
Diffstat (limited to 'source/blender/editors/armature/poseobject.c')
-rw-r--r--source/blender/editors/armature/poseobject.c239
1 files changed, 41 insertions, 198 deletions
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c
index 7d7f54309a8..d4b7aa149df 100644
--- a/source/blender/editors/armature/poseobject.c
+++ b/source/blender/editors/armature/poseobject.c
@@ -798,6 +798,8 @@ void pose_copy_menu(Scene *scene)
VECCOPY(pchan->limitmax, pchanact->limitmax);
VECCOPY(pchan->stiffness, pchanact->stiffness);
pchan->ikstretch= pchanact->ikstretch;
+ pchan->ikrotweight= pchanact->ikrotweight;
+ pchan->iklinweight= pchanact->iklinweight;
}
break;
case 8: /* Custom Bone Shape */
@@ -812,14 +814,14 @@ void pose_copy_menu(Scene *scene)
armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat);
- if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
+ if (pchan->rotmode == ROT_MODE_AXISANGLE) {
float tmp_quat[4];
/* need to convert to quat first (in temp var)... */
Mat4ToQuat(delta_mat, tmp_quat);
QuatToAxisAngle(tmp_quat, &pchan->quat[1], &pchan->quat[0]);
}
- else if (pchan->rotmode == PCHAN_ROT_QUAT)
+ else if (pchan->rotmode == ROT_MODE_QUAT)
Mat4ToQuat(delta_mat, pchan->quat);
else
Mat4ToEulO(delta_mat, pchan->eul, pchan->rotmode);
@@ -961,6 +963,11 @@ void POSE_OT_copy (wmOperatorType *ot)
/* ---- */
+/* Pointers to the builtin KeyingSets that we want to use */
+static KeyingSet *posePaste_ks_locrotscale = NULL; /* the only keyingset we'll need */
+
+/* ---- */
+
static int pose_paste_exec (bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
@@ -969,6 +976,13 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
char name[32];
int flip= RNA_boolean_get(op->ptr, "flipped");
+ bCommonKeySrc cks;
+ ListBase dsources = {&cks, &cks};
+
+ /* init common-key-source for use by KeyingSets */
+ memset(&cks, 0, sizeof(bCommonKeySrc));
+ cks.id= &ob->id;
+
/* sanity checks */
if ELEM(NULL, ob, ob->pose)
return OPERATOR_CANCELLED;
@@ -1009,12 +1023,12 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
}
else if (pchan->rotmode > 0) {
/* quat/axis-angle to euler */
- if (chan->rotmode == PCHAN_ROT_AXISANGLE)
+ if (chan->rotmode == ROT_MODE_AXISANGLE)
AxisAngleToEulO(&chan->quat[1], chan->quat[0], pchan->eul, pchan->rotmode);
else
QuatToEulO(chan->quat, pchan->eul, pchan->rotmode);
}
- else if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
+ else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
/* quat/euler to axis angle */
if (chan->rotmode > 0)
EulOToAxisAngle(chan->eul, chan->rotmode, &pchan->quat[1], &pchan->quat[0]);
@@ -1038,13 +1052,20 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
pchan->eul[1] *= -1;
pchan->eul[2] *= -1;
}
- else if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
+ else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
float eul[3];
AxisAngleToEulO(&pchan->quat[1], pchan->quat[0], eul, EULER_ORDER_DEFAULT);
eul[1]*= -1;
eul[2]*= -1;
EulOToAxisAngle(eul, EULER_ORDER_DEFAULT, &pchan->quat[1], &pchan->quat[0]);
+
+ // experimental method (uncomment to test):
+#if 0
+ /* experimental method: just flip the orientation of the axis on x/y axes */
+ pchan->quat[1] *= -1;
+ pchan->quat[2] *= -1;
+#endif
}
else {
float eul[3];
@@ -1056,28 +1077,19 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
}
}
-#if 0 // XXX old animation system
- if (autokeyframe_cfra_can_key(ob)) {
- ID *id= &ob->id;
+ if (autokeyframe_cfra_can_key(scene, &ob->id)) {
+ /* Set keys on pose
+ * - KeyingSet to use depends on rotation mode
+ * (but that's handled by the templates code)
+ */
+ // TODO: for getting the KeyingSet used, we should really check which channels were affected
+ if (posePaste_ks_locrotscale == NULL)
+ posePaste_ks_locrotscale= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
- /* Set keys on pose */
- // TODO: make these use keyingsets....
- if (chan->flag & POSE_ROT) {
- insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_X, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Y, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Z, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_W, 0);
- }
- if (chan->flag & POSE_SIZE) {
- insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_X, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_Y, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_Z, 0);
- }
- if (chan->flag & POSE_LOC) {
- insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_X, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_Y, 0);
- insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_Z, 0);
- }
+ /* init cks for this PoseChannel, then use the relative KeyingSets to keyframe it */
+ cks.pchan= pchan;
+
+ modify_keyframes(C, &dsources, NULL, posePaste_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)CFRA);
/* clear any unkeyed tags */
if (chan->bone)
@@ -1088,7 +1100,6 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
if (chan->bone)
chan->bone->flag |= BONE_UNKEYED;
}
-#endif // XXX old animation system
}
}
}
@@ -1933,7 +1944,7 @@ static int armature_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev
/* Set the visible layers for the active armature (edit and pose modes) */
static int armature_bone_layers_exec (bContext *C, wmOperator *op)
{
- Object *ob= CTX_data_active_object(C);
+ Object *ob= CTX_data_edit_object(C);
bArmature *arm= (ob)? ob->data : NULL;
PointerRNA ptr;
int layers[16]; /* hardcoded for now - we can only have 16 armature layers, so this should be fine... */
@@ -1946,7 +1957,7 @@ static int armature_bone_layers_exec (bContext *C, wmOperator *op)
{
/* get pointer for pchan, and write flags this way */
RNA_pointer_create((ID *)arm, &RNA_EditBone, ebone, &ptr);
- RNA_boolean_set_array(&ptr, "layers", layers);
+ RNA_boolean_set_array(&ptr, "layer", layers);
}
CTX_DATA_END;
@@ -1975,175 +1986,7 @@ void ARMATURE_OT_bone_layers (wmOperatorType *ot)
RNA_def_boolean_array(ot->srna, "layers", 16, NULL, "Layers", "Armature layers that bone belongs to.");
}
-
-#if 0
-// XXX old sys
-/* for use with pose_relax only */
-static int pose_relax_icu(struct IpoCurve *icu, float framef, float *val, float *frame_prev, float *frame_next)
-{
- if (!icu) {
- return 0;
- }
- else {
- BezTriple *bezt = icu->bezt;
-
- BezTriple *bezt_prev=NULL, *bezt_next=NULL;
- float w1, w2, wtot;
- int i;
-
- for (i=0; i < icu->totvert; i++, bezt++) {
- if (bezt->vec[1][0] < framef - 0.5) {
- bezt_prev = bezt;
- } else {
- break;
- }
- }
-
- if (bezt_prev==NULL) return 0;
-
- /* advance to the next, dont need to advance i */
- bezt = bezt_prev+1;
-
- for (; i < icu->totvert; i++, bezt++) {
- if (bezt->vec[1][0] > framef + 0.5) {
- bezt_next = bezt;
- break;
- }
- }
-
- if (bezt_next==NULL) return 0;
-
- if (val) {
- w1 = framef - bezt_prev->vec[1][0];
- w2 = bezt_next->vec[1][0] - framef;
- wtot = w1 + w2;
- w1=w1/wtot;
- w2=w2/wtot;
-#if 0
- val = (bezt_prev->vec[1][1] * w2) + (bezt_next->vec[1][1] * w1);
-#else
- /* apply the value with a hard coded 6th */
- *val = (((bezt_prev->vec[1][1] * w2) + (bezt_next->vec[1][1] * w1)) + (*val * 5.0f)) / 6.0f;
-#endif
- }
-
- if (frame_prev) *frame_prev = bezt_prev->vec[1][0];
- if (frame_next) *frame_next = bezt_next->vec[1][0];
-
- return 1;
- }
-}
-#endif
-
-void pose_relax(Scene *scene)
-{
- Object *ob = OBACT;
- bPose *pose;
- bAction *act;
- bArmature *arm;
-
-// IpoCurve *icu_w, *icu_x, *icu_y, *icu_z;
-
- bPoseChannel *pchan;
-// bActionChannel *achan;
-// float framef = F_CFRA;
-// float frame_prev, frame_next;
-// float quat_prev[4], quat_next[4], quat_interp[4], quat_orig[4];
-
- int do_scale = 0;
- int do_loc = 0;
- int do_quat = 0;
- int flag = 0;
-// int do_x, do_y, do_z;
-
- if (!ob) return;
-
- pose = ob->pose;
- act = ob->action;
- arm = (bArmature *)ob->data;
-
- if (!pose || !act || !arm) return;
-
- for (pchan=pose->chanbase.first; pchan; pchan= pchan->next) {
-
- pchan->bone->flag &= ~BONE_TRANSFORM;
-
- if (pchan->bone->layer & arm->layer) {
- if (pchan->bone->flag & BONE_SELECTED) {
- /* do we have an ipo curve? */
-#if 0 // XXX old animation system
- achan= get_action_channel(act, pchan->name);
-
- if (achan && achan->ipo) {
- /*calc_ipo(achan->ipo, ctime);*/
-
- do_x = pose_relax_icu(find_ipocurve(achan->ipo, AC_LOC_X), framef, &pchan->loc[0], NULL, NULL);
- do_y = pose_relax_icu(find_ipocurve(achan->ipo, AC_LOC_Y), framef, &pchan->loc[1], NULL, NULL);
- do_z = pose_relax_icu(find_ipocurve(achan->ipo, AC_LOC_Z), framef, &pchan->loc[2], NULL, NULL);
- do_loc += do_x + do_y + do_z;
-
- do_x = pose_relax_icu(find_ipocurve(achan->ipo, AC_SIZE_X), framef, &pchan->size[0], NULL, NULL);
- do_y = pose_relax_icu(find_ipocurve(achan->ipo, AC_SIZE_Y), framef, &pchan->size[1], NULL, NULL);
- do_z = pose_relax_icu(find_ipocurve(achan->ipo, AC_SIZE_Z), framef, &pchan->size[2], NULL, NULL);
- do_scale += do_x + do_y + do_z;
-
- if( ((icu_w = find_ipocurve(achan->ipo, AC_QUAT_W))) &&
- ((icu_x = find_ipocurve(achan->ipo, AC_QUAT_X))) &&
- ((icu_y = find_ipocurve(achan->ipo, AC_QUAT_Y))) &&
- ((icu_z = find_ipocurve(achan->ipo, AC_QUAT_Z))) )
- {
- /* use the quatw keyframe as a basis for others */
- if (pose_relax_icu(icu_w, framef, NULL, &frame_prev, &frame_next)) {
- /* get 2 quats */
- quat_prev[0] = eval_icu(icu_w, frame_prev);
- quat_prev[1] = eval_icu(icu_x, frame_prev);
- quat_prev[2] = eval_icu(icu_y, frame_prev);
- quat_prev[3] = eval_icu(icu_z, frame_prev);
-
- quat_next[0] = eval_icu(icu_w, frame_next);
- quat_next[1] = eval_icu(icu_x, frame_next);
- quat_next[2] = eval_icu(icu_y, frame_next);
- quat_next[3] = eval_icu(icu_z, frame_next);
-
-#if 0
- /* apply the setting, completely smooth */
- QuatInterpol(pchan->quat, quat_prev, quat_next, (framef-frame_prev) / (frame_next-frame_prev) );
-#else
- /* tricky interpolation */
- QuatInterpol(quat_interp, quat_prev, quat_next, (framef-frame_prev) / (frame_next-frame_prev) );
- QUATCOPY(quat_orig, pchan->quat);
- QuatInterpol(pchan->quat, quat_orig, quat_interp, 1.0f/6.0f);
- /* done */
-#endif
- do_quat++;
- }
- }
-
- /* apply BONE_TRANSFORM tag so that autokeying will pick it up */
- pchan->bone->flag |= BONE_TRANSFORM;
- }
-
-#endif // XXX old animation system
- }
- }
- }
-
- ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK);
-
- /* do auto-keying */
- if (do_loc) flag |= TFM_TRANSLATION;
- if (do_scale) flag |= TFM_RESIZE;
- if (do_quat) flag |= TFM_ROTATION;
- autokeyframe_pose_cb_func(ob, flag, 0);
-
- /* clear BONE_TRANSFORM flags */
- for (pchan=pose->chanbase.first; pchan; pchan= pchan->next)
- pchan->bone->flag &= ~ BONE_TRANSFORM;
-
- /* do depsgraph flush */
- DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
- BIF_undo_push("Relax Pose");
-}
+/* ********************************************** */
/* for use in insertkey, ensure rotation goes other way around */
void pose_flipquats(Scene *scene)