fix [#34303] Rotation fcurves don't work with transforming with individual centers

This commit is contained in:
Campbell Barton
2013-02-18 16:35:13 +00:00
parent 4cd487d731
commit 9ab3d4ff1e
6 changed files with 40 additions and 12 deletions

View File

@@ -399,20 +399,23 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short rest
static short bezt_unit_mapping_apply(KeyframeEditData *ked, BezTriple *bezt)
{
/* mapping factor is stored in f1, flags are stored in i1 */
short only_keys = (ked->i1 & ANIM_UNITCONV_ONLYKEYS);
short sel_vs = (ked->i1 & ANIM_UNITCONV_SELVERTS);
const bool only_keys = (ked->i1 & ANIM_UNITCONV_ONLYKEYS);
const bool sel_vs = (ked->i1 & ANIM_UNITCONV_SELVERTS);
const bool skip_knot = (ked->i1 & ANIM_UNITCONV_SKIPKNOTS);
float fac = ked->f1;
/* adjust BezTriple handles only if allowed to */
if (only_keys == 0) {
if ((sel_vs == 0) || (bezt->f1 & SELECT))
if (only_keys == false) {
if ((sel_vs == false) || (bezt->f1 & SELECT))
bezt->vec[0][1] *= fac;
if ((sel_vs == 0) || (bezt->f3 & SELECT))
if ((sel_vs == false) || (bezt->f3 & SELECT))
bezt->vec[2][1] *= fac;
}
if ((sel_vs == 0) || (bezt->f2 & SELECT))
bezt->vec[1][1] *= fac;
if (skip_knot == false) {
if ((sel_vs == false) || (bezt->f2 & SELECT))
bezt->vec[1][1] *= fac;
}
return 0;
}

View File

@@ -552,7 +552,8 @@ typedef enum eAnimUnitConv_Flags {
/* only touch selected BezTriples */
ANIM_UNITCONV_ONLYSEL = (1 << 2),
/* only touch selected vertices */
ANIM_UNITCONV_SELVERTS = (1 << 3)
ANIM_UNITCONV_SELVERTS = (1 << 3),
ANIM_UNITCONV_SKIPKNOTS = (1 << 4),
} eAnimUnitConv_Flags;
/* Get unit conversion factor for given ID + F-Curve */

View File

@@ -7388,3 +7388,10 @@ void BIF_TransformSetUndo(const char *UNUSED(str))
// TRANSFORM_FIX_ME
//Trans.undostr = str;
}
/* TODO, move to: transform_queries.c */
bool checkUseLocalCenter_GraphEdit(TransInfo *t)
{
return ((t->around == V3D_LOCAL) && !ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE));
}

View File

@@ -745,4 +745,8 @@ void projectEdgeSlideData(TransInfo *t, bool is_final);
void freeVertSlideVerts(TransInfo *t);
/* TODO. transform_queries.c */
bool checkUseLocalCenter_GraphEdit(TransInfo *t);
#endif

View File

@@ -123,6 +123,7 @@
#include "BLO_sys_types.h" // for intptr_t support
/* local function prototype - for Object/Bone Constraints */
static short constraints_list_needinv(TransInfo *t, ListBase *list);
@@ -3530,7 +3531,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
int count = 0, i;
float cfra;
float mtx[3][3], smtx[3][3];
const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
const bool use_handle = !(sipo->flag & SIPO_NOHANDLES);
const bool use_local_center = checkUseLocalCenter_GraphEdit(t);
const short anim_map_flag = ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS;
/* determine what type of data we are operating on */
if (ANIM_animdata_get_context(C, &ac) == 0)
@@ -3662,7 +3665,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (fcu->bezt == NULL)
continue;
ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS);
ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, anim_map_flag);
/* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse (if applicable) */
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
@@ -3697,7 +3700,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
}
/* only include main vert if selected */
if (sel2 && (sipo->around != V3D_LOCAL || ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE))) {
if (sel2 && (use_local_center == false)) {
/* move handles relative to center */
if (ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE)) {
@@ -3733,6 +3736,13 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
/* Sets handles based on the selection */
testhandles_fcurve(fcu, use_handle);
/* even though transform values are written back right after during transform,
* using individual center's with rotation means the center point wont
* be touched again see: [#34303] */
if (use_local_center) {
ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, anim_map_flag | ANIM_UNITCONV_RESTORE);
}
}
/* cleanup temp list */

View File

@@ -130,6 +130,7 @@ void getViewVector(TransInfo *t, float coord[3], float vec[3])
/* ************************** GENERICS **************************** */
static void clipMirrorModifier(TransInfo *t, Object *ob)
{
ModifierData *md = ob->modifiers.first;
@@ -407,7 +408,9 @@ static void recalcData_graphedit(TransInfo *t)
continue;
// fixme: only do this for selected verts...
ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS | ANIM_UNITCONV_RESTORE);
ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data,
ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS | ANIM_UNITCONV_RESTORE |
(checkUseLocalCenter_GraphEdit(t) ? ANIM_UNITCONV_SKIPKNOTS : 0));
/* watch it: if the time is wrong: do not correct handles yet */