Dopesheet: Mirroring GPencil keyframes now works again

This commit is contained in:
Joshua Leung
2015-12-14 02:36:02 +13:00
parent a27477b9e8
commit ab0b0efe82
3 changed files with 19 additions and 20 deletions

View File

@@ -535,7 +535,6 @@ void ED_gplayer_snap_frames(bGPDlayer *gpl, Scene *scene, short mode)
}
}
#if 0 /* XXX disabled until grease pencil code stabilises again */
/* -------------------------------------- */
/* Mirror Tools */
@@ -545,7 +544,7 @@ static short mirror_gpf_cframe(bGPDframe *gpf, Scene *scene)
if (gpf->flag & GP_FRAME_SELECT) {
diff = CFRA - gpf->framenum;
gpf->framenum = CFRA;
gpf->framenum = CFRA + diff;
}
return 0;
@@ -567,6 +566,7 @@ static short mirror_gpf_xaxis(bGPDframe *gpf, Scene *scene)
{
int diff;
/* NOTE: since we can't really do this, we just do the same as for yaxis... */
if (gpf->flag & GP_FRAME_SELECT) {
diff = -gpf->framenum;
gpf->framenum = diff;
@@ -617,19 +617,20 @@ static short mirror_gpf_marker(bGPDframe *gpf, Scene *scene)
/* mirror selected gp-frames on... */
void mirror_gplayer_frames(bGPDlayer *gpl, Scene *scene, short mode)
// TODO: mirror over a specific time
void ED_gplayer_mirror_frames(bGPDlayer *gpl, Scene *scene, short mode)
{
switch (mode) {
case 1: /* mirror over current frame */
case MIRROR_KEYS_CURFRAME: /* mirror over current frame */
ED_gplayer_frames_looper(gpl, scene, mirror_gpf_cframe);
break;
case 2: /* mirror over frame 0 */
case MIRROR_KEYS_YAXIS: /* mirror over frame 0 */
ED_gplayer_frames_looper(gpl, scene, mirror_gpf_yaxis);
break;
case 3: /* mirror over value 0 */
case MIRROR_KEYS_XAXIS: /* mirror over value 0 */
ED_gplayer_frames_looper(gpl, scene, mirror_gpf_xaxis);
break;
case 4: /* mirror over marker */
case MIRROR_KEYS_MARKER: /* mirror over marker */
mirror_gpf_marker(NULL, NULL);
ED_gplayer_frames_looper(gpl, scene, mirror_gpf_marker);
mirror_gpf_marker(NULL, NULL);
@@ -641,4 +642,3 @@ void mirror_gplayer_frames(bGPDlayer *gpl, Scene *scene, short mode)
}
/* ***************************************** */
#endif // XXX disabled until Grease Pencil code stabilises again...

View File

@@ -125,14 +125,12 @@ void ED_gplayer_frames_duplicate(struct bGPDlayer *gpl);
void ED_gplayer_frames_keytype_set(struct bGPDlayer *gpl, short type);
void ED_gplayer_snap_frames(struct bGPDlayer *gpl, struct Scene *scene, short mode);
void ED_gplayer_mirror_frames(struct bGPDlayer *gpl, struct Scene *scene, short mode);
void ED_gpencil_anim_copybuf_free(void);
bool ED_gpencil_anim_copybuf_copy(struct bAnimContext *ac);
bool ED_gpencil_anim_copybuf_paste(struct bAnimContext *ac, const short copy_mode);
#if 0
void mirror_gplayer_frames(struct bGPDlayer *gpl, short mode);
#endif
/* ------------ Grease-Pencil Undo System ------------------ */
int ED_gpencil_session_active(void);

View File

@@ -1693,16 +1693,21 @@ static void mirror_action_keys(bAnimContext *ac, short mode)
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
if (adt) {
if (ale->type == ANIMTYPE_GPLAYER) {
ED_gplayer_mirror_frames(ale->data, ac->scene, mode);
}
else if (ale->type == ANIMTYPE_MASKLAYER) {
/* TODO */
}
else if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
//else if (ale->type == ACTTYPE_GPLAYER)
// snap_gplayer_frames(ale->data, mode);
else
else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
}
ale->update |= ANIM_UPDATE_DEFAULT;
}
@@ -1721,10 +1726,6 @@ static int actkeys_mirror_exec(bContext *C, wmOperator *op)
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
/* XXX... */
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
return OPERATOR_PASS_THROUGH;
/* get mirroring mode */
mode = RNA_enum_get(op->ptr, "type");