diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-13 07:56:51 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-13 07:56:51 +0300 |
commit | 59c6487e9314dd43003af1a018fc092b041e7e10 (patch) | |
tree | de8cc7dd06b875d174cb79cad7558874c8bffa5e /source/blender/editors/transform/transform_conversions.c | |
parent | 7a56d31af3523081e33a67d7aea11314c37c7104 (diff) | |
parent | b99d064e9142b2e9d790731f4c4c6c107ca43696 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/editors/transform/transform_conversions.c')
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 550 |
1 files changed, 275 insertions, 275 deletions
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index bdcb42e74ef..7c5f7dba045 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -495,9 +495,9 @@ static short apply_targetless_ik(Object *ob) /* apply and decompose, doesn't work for constraints or non-uniform scale well */ { float rmat3[3][3], qrmat[3][3], imat3[3][3], smat[3][3]; - + copy_m3_m4(rmat3, rmat); - + /* rotation */ /* [#22409] is partially caused by this, as slight numeric error introduced during * the solving process leads to locked-axis values changing. However, we cannot modify @@ -510,7 +510,7 @@ static short apply_targetless_ik(Object *ob) mat3_to_axis_angle(parchan->rotAxis, &parchan->rotAngle, rmat3); else mat3_to_quat(parchan->quat, rmat3); - + /* for size, remove rotation */ /* causes problems with some constraints (so apply only if needed) */ if (data->flag & CONSTRAINT_IK_STRETCH) { @@ -520,12 +520,12 @@ static short apply_targetless_ik(Object *ob) axis_angle_to_mat3(qrmat, parchan->rotAxis, parchan->rotAngle); else quat_to_mat3(qrmat, parchan->quat); - + invert_m3_m3(imat3, qrmat); mul_m3_m3m3(smat, rmat3, imat3); mat3_to_size(parchan->size, smat); } - + /* causes problems with some constraints (e.g. childof), so disable this */ /* as it is IK shouldn't affect location directly */ /* copy_v3_v3(parchan->loc, rmat[3]); */ @@ -575,7 +575,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr td->ext->rotAxis = NULL; td->ext->rotAngle = NULL; td->ext->quat = NULL; - + copy_v3_v3(td->ext->irot, pchan->eul); } else if (pchan->rotmode == ROT_MODE_AXISANGLE) { @@ -583,7 +583,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr td->ext->rotAxis = pchan->rotAxis; td->ext->rotAngle = &pchan->rotAngle; td->ext->quat = NULL; - + td->ext->irotAngle = pchan->rotAngle; copy_v3_v3(td->ext->irotAxis, pchan->rotAxis); } @@ -592,7 +592,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr td->ext->rotAxis = NULL; td->ext->rotAngle = NULL; td->ext->quat = pchan->quat; - + copy_qt_qt(td->ext->iquat, pchan->quat); } td->ext->rotOrder = pchan->rotmode; @@ -645,7 +645,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr td->flag |= TD_PBONE_LOCAL_MTX_P; } } - + /* for axismat we use bone's own transform */ copy_m3_m4(pmat, pchan->pose_mat); mul_m3_m3m3(td->axismtx, omat, pmat); @@ -730,7 +730,7 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob) bone->flag |= BONE_TRANSFORM; else bone->flag &= ~BONE_TRANSFORM; - + bone->flag &= ~BONE_HINGE_CHILD_TRANSFORM; bone->flag &= ~BONE_TRANSFORM_CHILD; } @@ -754,7 +754,7 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob) bone = pchan->bone; if (bone->flag & BONE_TRANSFORM) { total++; - + if (mode == TFM_TRANSLATION) { if (has_targetless_ik(pchan) == NULL) { if (pchan->parent && (pchan->bone->flag & BONE_CONNECTED)) { @@ -878,9 +878,9 @@ static void pose_grab_with_ik_clear(Object *ob) for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { /* clear all temporary lock flags */ pchan->ikflag &= ~(BONE_IK_NO_XDOF_TEMP | BONE_IK_NO_YDOF_TEMP | BONE_IK_NO_ZDOF_TEMP); - + pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_TARGET); - + /* remove all temporary IK-constraints added */ for (con = pchan->constraints.first; con; con = next) { next = con->next; @@ -925,15 +925,15 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) for (con = pchan->constraints.first; con; con = con->next) { if (con->type == CONSTRAINT_TYPE_KINEMATIC) { data = con->data; - + if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == '\0')) { /* make reference to constraint to base things off later (if it's the last targetless constraint encountered) */ targetless = (bKinematicConstraint *)con->data; - + /* but, if this is a targetless IK, we make it auto anyway (for the children loop) */ if (con->enforce != 0.0f) { data->flag |= CONSTRAINT_IK_AUTO; - + /* if no chain length has been specified, just make things obey standard rotation locks too */ if (data->rootbone == 0) { for (; pchan; pchan = pchan->parent) { @@ -944,11 +944,11 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) if (pchan->protectflag & OB_LOCK_ROTZ) pchan->ikflag |= BONE_IK_NO_ZDOF_TEMP; } } - - return 0; + + return 0; } } - + if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f)) return 0; } @@ -966,7 +966,7 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) data->flag |= CONSTRAINT_IK_TEMP | CONSTRAINT_IK_AUTO | CONSTRAINT_IK_POS; copy_v3_v3(data->grabtarget, pchan->pose_tail); data->rootbone = 0; /* watch-it! has to be 0 here, since we're still on the same bone for the first time through the loop [#25885] */ - + /* we only include bones that are part of a continual connected chain */ do { /* here, we set ik-settings for bone from pchan->protectflag */ @@ -974,10 +974,10 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) if (pchan->protectflag & OB_LOCK_ROTX) pchan->ikflag |= BONE_IK_NO_XDOF_TEMP; if (pchan->protectflag & OB_LOCK_ROTY) pchan->ikflag |= BONE_IK_NO_YDOF_TEMP; if (pchan->protectflag & OB_LOCK_ROTZ) pchan->ikflag |= BONE_IK_NO_ZDOF_TEMP; - + /* now we count this pchan as being included */ data->rootbone++; - + /* continue to parent, but only if we're connected to it */ if (pchan->bone->flag & BONE_CONNECTED) pchan = pchan->parent; @@ -1167,7 +1167,7 @@ void restoreBones(TransDataContainer *tc) while (bid->bone) { ebo = bid->bone; - + ebo->dist = bid->dist; ebo->rad_tail = bid->rad_tail; ebo->roll = bid->roll; @@ -1175,7 +1175,7 @@ void restoreBones(TransDataContainer *tc) ebo->zwidth = bid->zwidth; copy_v3_v3(ebo->head, bid->head); copy_v3_v3(ebo->tail, bid->tail); - + if (arm->flag & ARM_MIRROR_EDIT) { EditBone *ebo_child; @@ -1194,7 +1194,7 @@ void restoreBones(TransDataContainer *tc) parent->rad_tail = ebo->rad_head; } } - + bid++; } } @@ -3303,12 +3303,12 @@ static void createTransNlaData(bContext *C, TransInfo *t) SpaceNla *snla = NULL; TransData *td = NULL; TransDataNla *tdn = NULL; - + bAnimContext ac; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + int count = 0; TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); @@ -3317,16 +3317,16 @@ static void createTransNlaData(bContext *C, TransInfo *t) if (ANIM_animdata_get_context(C, &ac) == 0) return; snla = (SpaceNla *)ac.sl; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* which side of the current frame should be allowed */ if (t->mode == TFM_TIME_EXTEND) { /* only side on which mouse is gets transformed */ float xmouse, ymouse; - + UI_view2d_region_to_view(&ac.ar->v2d, t->mouse.imval[0], t->mouse.imval[1], &xmouse, &ymouse); t->frame_side = (xmouse > CFRA) ? 'R' : 'L'; } @@ -3334,15 +3334,15 @@ static void createTransNlaData(bContext *C, TransInfo *t) /* normal transform - both sides of current frame are considered */ t->frame_side = 'B'; } - + /* loop 1: count how many strips are selected (consider each strip as 2 points) */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + /* make some meta-strips for chains of selected strips */ BKE_nlastrips_make_metas(&nlt->strips, 1); - + /* only consider selected strips */ for (strip = nlt->strips.first; strip; strip = strip->next) { // TODO: we can make strips have handles later on... @@ -3355,30 +3355,30 @@ static void createTransNlaData(bContext *C, TransInfo *t) } } } - + /* stop if trying to build list if nothing selected */ if (count == 0) { - /* clear temp metas that may have been created but aren't needed now + /* clear temp metas that may have been created but aren't needed now * because they fell on the wrong side of CFRA */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; BKE_nlastrips_clear_metas(&nlt->strips, 0, 1); } - + /* cleanup temp list */ ANIM_animdata_freelist(&anim_data); return; } - + /* allocate memory for data */ tc->data_len = count; - + tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransData(NLA Editor)"); td = tc->data; tc->custom.type.data = tdn = MEM_callocN(tc->data_len * sizeof(TransDataNla), "TransDataNla (NLA Editor)"); tc->custom.type.use_free = true; - + /* loop 2: build transdata array */ for (ale = anim_data.first; ale; ale = ale->next) { /* only if a real NLA-track */ @@ -3386,7 +3386,7 @@ static void createTransNlaData(bContext *C, TransInfo *t) AnimData *adt = ale->adt; NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + /* only consider selected strips */ for (strip = nlt->strips.first; strip; strip = strip->next) { // TODO: we can make strips have handles later on... @@ -3403,44 +3403,44 @@ static void createTransNlaData(bContext *C, TransInfo *t) * cases, there will need to be 1 of these tdn elements in the array skipped... */ float center[3], yval; - + /* firstly, init tdn settings */ tdn->id = ale->id; tdn->oldTrack = tdn->nlt = nlt; tdn->strip = strip; tdn->trackIndex = BLI_findindex(&adt->nla_tracks, nlt); - + yval = (float)(tdn->trackIndex * NLACHANNEL_STEP(snla)); - + tdn->h1[0] = strip->start; tdn->h1[1] = yval; tdn->h2[0] = strip->end; tdn->h2[1] = yval; - + center[0] = (float)CFRA; center[1] = yval; center[2] = 0.0f; - + /* set td's based on which handles are applicable */ if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA)) { /* just set tdn to assume that it only has one handle for now */ tdn->handle = -1; - + /* now, link the transform data up to this data */ if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) { td->loc = tdn->h1; copy_v3_v3(td->iloc, tdn->h1); - + /* store all the other gunk that is required by transform */ copy_v3_v3(td->center, center); memset(td->axismtx, 0, sizeof(td->axismtx)); td->axismtx[2][2] = 1.0f; - + td->ext = NULL; td->val = NULL; - + td->flag |= TD_SELECTED; td->dist = 0.0f; - + unit_m3(td->mtx); unit_m3(td->smtx); } @@ -3449,29 +3449,29 @@ static void createTransNlaData(bContext *C, TransInfo *t) td->val = &tdn->h1[0]; td->ival = tdn->h1[0]; } - + td->extra = tdn; td++; } if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA)) { /* if tdn is already holding the start handle, then we're doing both, otherwise, only end */ tdn->handle = (tdn->handle) ? 2 : 1; - + /* now, link the transform data up to this data */ if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) { td->loc = tdn->h2; copy_v3_v3(td->iloc, tdn->h2); - + /* store all the other gunk that is required by transform */ copy_v3_v3(td->center, center); memset(td->axismtx, 0, sizeof(td->axismtx)); td->axismtx[2][2] = 1.0f; - + td->ext = NULL; td->val = NULL; - + td->flag |= TD_SELECTED; td->dist = 0.0f; - + unit_m3(td->mtx); unit_m3(td->smtx); } @@ -3480,11 +3480,11 @@ static void createTransNlaData(bContext *C, TransInfo *t) td->val = &tdn->h2[0]; td->ival = tdn->h2[0]; } - + td->extra = tdn; td++; } - + /* if both handles were used, skip the next tdn (i.e. leave it blank) since the counting code is dumb... * otherwise, just advance to the next one... */ @@ -3497,7 +3497,7 @@ static void createTransNlaData(bContext *C, TransInfo *t) } } } - + /* cleanup temp list */ ANIM_animdata_freelist(&anim_data); } @@ -3546,7 +3546,7 @@ static int masklay_shape_cmp_frame(void *thunk, const void *a, const void *b) static void posttrans_gpd_clean(bGPdata *gpd) { bGPDlayer *gpl; - + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { bGPDframe *gpf, *gpfn; bool is_double = false; @@ -3602,7 +3602,7 @@ typedef struct tRetainedKeyframe { struct tRetainedKeyframe *next, *prev; float frame; /* frame to cluster around */ float val; /* average value */ - + size_t tot_count; /* number of keyframes that have been averaged */ size_t del_count; /* number of keyframes of this sort that have been deleted so far */ } tRetainedKeyframe; @@ -3615,27 +3615,27 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle) /* NOTE: We assume that all keys are sorted */ ListBase retained_keys = {NULL, NULL}; const bool can_average_points = ((fcu->flag & (FCURVE_INT_VALUES | FCURVE_DISCRETE_VALUES)) == 0); - + /* sanity checks */ if ((fcu->totvert == 0) || (fcu->bezt == NULL)) return; - + /* 1) Identify selected keyframes, and average the values on those * in case there are collisions due to multiple keys getting scaled * to all end up on the same frame */ for (int i = 0; i < fcu->totvert; i++) { BezTriple *bezt = &fcu->bezt[i]; - + if (BEZT_ISSEL_ANY(bezt)) { bool found = false; - + /* If there's another selected frame here, merge it */ for (tRetainedKeyframe *rk = retained_keys.last; rk; rk = rk->prev) { if (IS_EQT(rk->frame, bezt->vec[1][0], BEZT_BINARYSEARCH_THRESH)) { rk->val += bezt->vec[1][1]; rk->tot_count++; - + found = true; break; } @@ -3644,20 +3644,20 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle) break; } } - + /* If nothing found yet, create a new one */ if (found == false) { tRetainedKeyframe *rk = MEM_callocN(sizeof(tRetainedKeyframe), "tRetainedKeyframe"); - + rk->frame = bezt->vec[1][0]; rk->val = bezt->vec[1][1]; rk->tot_count = 1; - + BLI_addtail(&retained_keys, rk); } } } - + if (BLI_listbase_is_empty(&retained_keys)) { /* This may happen if none of the points were selected... */ if (G.debug & G_DEBUG) { @@ -3671,15 +3671,15 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle) rk->val = rk->val / (float)rk->tot_count; } } - + /* 2) Delete all keyframes duplicating the "retained keys" found above * - Most of these will be unselected keyframes * - Some will be selected keyframes though. For those, we only keep the last one - * (or else everything is gone), and replace its value with the averaged value. + * (or else everything is gone), and replace its value with the averaged value. */ for (int i = fcu->totvert - 1; i >= 0; i--) { BezTriple *bezt = &fcu->bezt[i]; - + /* Is this keyframe a candidate for deletion? */ /* TODO: Replace loop with an O(1) lookup instead */ for (tRetainedKeyframe *rk = retained_keys.last; rk; rk = rk->prev) { @@ -3702,7 +3702,7 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle) /* Delete Keyframe */ delete_fcurve_key(fcu, i, 0); } - + /* Update count of how many we've deleted * - It should only matter that we're doing this for all but the last one */ @@ -3712,16 +3712,16 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle) /* Always delete - Unselected keys don't matter */ delete_fcurve_key(fcu, i, 0); } - + /* Stop the RK search... we've found our match now */ break; } } } - + /* 3) Recalculate handles */ testhandles_fcurve(fcu, use_handle); - + /* cleanup */ BLI_freelistN(&retained_keys); } @@ -3746,7 +3746,7 @@ static void posttrans_action_clean(bAnimContext *ac, bAction *act) */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); posttrans_fcurve_clean(ale->key_data, false); /* only use handles in graph editor */ @@ -3793,10 +3793,10 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra, bool is_p { bGPDframe *gpf; int count = 0, count_all = 0; - + if (gpl == NULL) return count; - + /* only include points that occur on the right side of cfra */ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if (FrameOnMouseSide(side, (float)gpf->framenum, cfra)) { @@ -3805,7 +3805,7 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra, bool is_p count_all++; } } - + if (is_prop_edit && count > 0) return count_all; else @@ -3875,7 +3875,7 @@ static TransData *ActionFCurveToTransData(TransData *td, TransData2D **td2dv, FC /* only add if on the right 'side' of the current frame */ if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) { TimeToTransData(td, bezt->vec[1], adt, ypos); - + if (bezt->f2 & SELECT) td->flag |= TD_SELECTED; @@ -3883,18 +3883,18 @@ static TransData *ActionFCurveToTransData(TransData *td, TransData2D **td2dv, FC td->flag |= TD_MOVEHANDLE1 | TD_MOVEHANDLE2; td2d->h1 = bezt->vec[0]; td2d->h2 = bezt->vec[2]; - + copy_v2_v2(td2d->ih1, td2d->h1); copy_v2_v2(td2d->ih2, td2d->h2); - + td++; td2d++; } } } - + *td2dv = td2d; - + return td; } @@ -3927,7 +3927,7 @@ static int GPLayerToTransData(TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl, { bGPDframe *gpf; int count = 0; - + /* check for select frames on right side of current frame */ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if (is_prop_edit || (gpf->flag & GP_FRAME_SELECT)) { @@ -3935,13 +3935,13 @@ static int GPLayerToTransData(TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl, /* memory is calloc'ed, so that should zero everything nicely for us */ td->val = &tfd->val; td->ival = (float)gpf->framenum; - + td->center[0] = td->ival; td->center[1] = ypos; tfd->val = (float)gpf->framenum; tfd->sdata = &gpf->framenum; - + /* advance td now */ td++; tfd++; @@ -3949,7 +3949,7 @@ static int GPLayerToTransData(TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl, } } } - + return count; } @@ -4013,19 +4013,19 @@ static void createTransActionData(bContext *C, TransInfo *t) /* determine what type of data we are operating on */ if (ANIM_animdata_get_context(C, &ac) == 0) return; - + /* filter data */ if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* which side of the current frame should be allowed */ if (t->mode == TFM_TIME_EXTEND) { /* only side on which mouse is gets transformed */ float xmouse, ymouse; - + UI_view2d_region_to_view(&ac.ar->v2d, t->mouse.imval[0], t->mouse.imval[1], &xmouse, &ymouse); t->frame_side = (xmouse > CFRA) ? 'R' : 'L'; // XXX use t->frame_side } @@ -4033,7 +4033,7 @@ static void createTransActionData(bContext *C, TransInfo *t) /* normal transform - both sides of current frame are considered */ t->frame_side = 'B'; } - + /* loop 1: fully select ipo-keys and count how many BezTriples are selected */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); @@ -4045,7 +4045,7 @@ static void createTransActionData(bContext *C, TransInfo *t) cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); else cfra = (float)CFRA; - + if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) adt_count = count_fcurve_keys(ale->key_data, t->frame_side, cfra, is_prop_edit); else if (ale->type == ANIMTYPE_GPLAYER) @@ -4060,7 +4060,7 @@ static void createTransActionData(bContext *C, TransInfo *t) ale->tag = true; } } - + /* stop if trying to build list if nothing selected */ if (count == 0) { /* cleanup temp list */ @@ -4072,17 +4072,17 @@ static void createTransActionData(bContext *C, TransInfo *t) /* allocate memory for data */ tc->data_len = count; - + tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransData(Action Editor)"); tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "transdata2d"); td = tc->data; td2d = tc->data_2d; - + if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { tc->custom.type.data = tfd = MEM_callocN(sizeof(tGPFtransdata) * count, "tGPFtransdata"); tc->custom.type.use_free = true; } - + /* loop 2: build transdata array */ for (ale = anim_data.first; ale; ale = ale->next) { @@ -4102,7 +4102,7 @@ static void createTransActionData(bContext *C, TransInfo *t) if (ale->type == ANIMTYPE_GPLAYER) { bGPDlayer *gpl = (bGPDlayer *)ale->data; int i; - + i = GPLayerToTransData(td, tfd, gpl, t->frame_side, cfra, is_prop_edit, ypos); td += i; tfd += i; @@ -4118,7 +4118,7 @@ static void createTransActionData(bContext *C, TransInfo *t) else { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); FCurve *fcu = (FCurve *)ale->key_data; - + td = ActionFCurveToTransData(td, &td2d, fcu, adt, t->frame_side, cfra, is_prop_edit, ypos); } } @@ -4254,18 +4254,18 @@ static void bezt_to_transdata(TransData *td, TransData2D *td2d, TransDataGraph * * Due to NLA mapping, we apply NLA mapping to some of the verts here, * and then that mapping will be undone after transform is done. */ - + if (adt) { td2d->loc[0] = BKE_nla_tweakedit_remap(adt, loc[0], NLATIME_CONVERT_MAP); td2d->loc[1] = (loc[1] + offset) * unit_scale; td2d->loc[2] = 0.0f; td2d->loc2d = loc; - + td->loc = td2d->loc; td->center[0] = BKE_nla_tweakedit_remap(adt, cent[0], NLATIME_CONVERT_MAP); td->center[1] = (cent[1] + offset) * unit_scale; td->center[2] = 0.0f; - + copy_v3_v3(td->iloc, td->loc); } else { @@ -4273,7 +4273,7 @@ static void bezt_to_transdata(TransData *td, TransData2D *td2d, TransDataGraph * td2d->loc[1] = (loc[1] + offset) * unit_scale; td2d->loc[2] = 0.0f; td2d->loc2d = loc; - + td->loc = td2d->loc; copy_v3_v3(td->center, cent); td->center[1] = (td->center[1] + offset) * unit_scale; @@ -4293,19 +4293,19 @@ static void bezt_to_transdata(TransData *td, TransData2D *td2d, TransDataGraph * memset(td->axismtx, 0, sizeof(td->axismtx)); td->axismtx[2][2] = 1.0f; - + td->ext = NULL; td->val = NULL; - + /* store AnimData info in td->extra, for applying mapping when flushing */ td->extra = adt; - + if (selected) { td->flag |= TD_SELECTED; td->dist = 0.0f; } else td->dist = FLT_MAX; - + if (ishandle) td->flag |= TD_NOTIMESNAP; if (intvals) @@ -4359,16 +4359,16 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) Scene *scene = t->scene; ARegion *ar = t->ar; View2D *v2d = &ar->v2d; - + TransData *td = NULL; TransData2D *td2d = NULL; TransDataGraph *tdg = NULL; - + bAnimContext ac; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + BezTriple *bezt; int count = 0, i; float mtx[3][3], smtx[3][3]; @@ -4377,7 +4377,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) const bool use_local_center = graph_edit_use_local_center(t); const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0; 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) return; @@ -4387,13 +4387,13 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* which side of the current frame should be allowed */ // XXX we still want this mode, but how to get this using standard transform too? if (t->mode == TFM_TIME_EXTEND) { /* only side on which mouse is gets transformed */ float xmouse, ymouse; - + UI_view2d_region_to_view(v2d, t->mouse.imval[0], t->mouse.imval[1], &xmouse, &ymouse); t->frame_side = (xmouse > CFRA) ? 'R' : 'L'; // XXX use t->frame_side } @@ -4401,7 +4401,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) /* normal transform - both sides of current frame are considered */ t->frame_side = 'B'; } - + /* loop 1: count how many BezTriples (specifically their verts) are selected (or should be edited) */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); @@ -4460,7 +4460,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) } } } - + /* stop if trying to build list if nothing selected */ if (count == 0) { /* cleanup temp list */ @@ -4472,36 +4472,36 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) /* allocate memory for data */ tc->data_len = count; - + tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransData (Graph Editor)"); /* for each 2d vert a 3d vector is allocated, so that they can be treated just as if they were 3d verts */ tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransData2D (Graph Editor)"); tc->custom.type.data = MEM_callocN(tc->data_len * sizeof(TransDataGraph), "TransDataGraph"); tc->custom.type.use_free = true; - + td = tc->data; td2d = tc->data_2d; tdg = tc->custom.type.data; - + /* precompute space-conversion matrices for dealing with non-uniform scaling of Graph Editor */ unit_m3(mtx); unit_m3(smtx); - + if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE)) { float xscale, yscale; - + /* apply scale factors to x and y axes of space-conversion matrices */ UI_view2d_scale_get(v2d, &xscale, &yscale); - + /* mtx is data to global (i.e. view) conversion */ mul_v3_fl(mtx[0], xscale); mul_v3_fl(mtx[1], yscale); - + /* smtx is global (i.e. view) to data conversion */ if (IS_EQF(xscale, 0.0f) == 0) mul_v3_fl(smtx[0], 1.0f / xscale); if (IS_EQF(yscale, 0.0f) == 0) mul_v3_fl(smtx[1], 1.0f / yscale); } - + /* loop 2: build transdata arrays */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); @@ -4533,7 +4533,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) TransDataCurveHandleFlags *hdata = NULL; /* short h1=1, h2=1; */ /* UNUSED */ - + if (is_prop_edit) { bool is_sel = (sel2 || sel1 || sel3); /* we always select all handles for proportional editing if central handle is selected */ @@ -4601,7 +4601,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) } } } - + /* Sets handles based on the selection */ testhandles_fcurve(fcu, use_handle); } @@ -4689,19 +4689,19 @@ static BeztMap *bezt_to_beztmaps(BezTriple *bezts, int totvert, const short UNUS BezTriple *prevbezt = NULL; BeztMap *bezm, *bezms; int i; - + /* allocate memory for this array */ if (totvert == 0 || bezts == NULL) return NULL; bezm = bezms = MEM_callocN(sizeof(BeztMap) * totvert, "BeztMaps"); - + /* assign beztriples to beztmaps */ for (i = 0; i < totvert; i++, bezm++, prevbezt = bezt, bezt++) { bezm->bezt = bezt; - + bezm->oldIndex = i; bezm->newIndex = i; - + bezm->pipo = (prevbezt) ? prevbezt->ipo : bezt->ipo; bezm->cipo = bezt->ipo; } @@ -4714,11 +4714,11 @@ static void sort_time_beztmaps(BeztMap *bezms, int totvert, const short UNUSED(u { BeztMap *bezm; int i, ok = 1; - + /* keep repeating the process until nothing is out of place anymore */ while (ok) { ok = 0; - + bezm = bezms; i = totvert; while (i--) { @@ -4727,13 +4727,13 @@ static void sort_time_beztmaps(BeztMap *bezms, int totvert, const short UNUSED(u if (bezm->bezt->vec[1][0] > (bezm + 1)->bezt->vec[1][0]) { bezm->newIndex++; (bezm + 1)->newIndex--; - + SWAP(BeztMap, *bezm, *(bezm + 1)); - + ok = 1; } } - + /* do we need to check if the handles need to be swapped? * optimization: this only needs to be performed in the first loop */ @@ -4749,7 +4749,7 @@ static void sort_time_beztmaps(BeztMap *bezms, int totvert, const short UNUSED(u bezm->swapHs = -1; } } - + bezm++; } } @@ -4772,7 +4772,7 @@ static void beztmap_to_data(TransInfo *t, FCurve *fcu, BeztMap *bezms, int totve * already done */ adjusted = MEM_callocN(tc->data_len, "beztmap_adjusted_map"); - + /* for each beztmap item, find if it is used anywhere */ bezm = bezms; for (i = 0; i < totvert; i++, bezm++) { @@ -4784,7 +4784,7 @@ static void beztmap_to_data(TransInfo *t, FCurve *fcu, BeztMap *bezms, int totve for (j = 0; j < tc->data_len; j++, td2d++, td++) { /* skip item if already marked */ if (adjusted[j] != 0) continue; - + /* update all transdata pointers, no need to check for selections etc, * since only points that are really needed were created as transdata */ @@ -4804,13 +4804,13 @@ static void beztmap_to_data(TransInfo *t, FCurve *fcu, BeztMap *bezms, int totve } else if (td2d->loc2d == bezm->bezt->vec[1]) { td2d->loc2d = (bezts + bezm->newIndex)->vec[1]; - + /* if only control point is selected, the handle pointers need to be updated as well */ if (td2d->h1) td2d->h1 = (bezts + bezm->newIndex)->vec[0]; if (td2d->h2) td2d->h2 = (bezts + bezm->newIndex)->vec[2]; - + adjusted[j] = 1; } @@ -4826,9 +4826,9 @@ static void beztmap_to_data(TransInfo *t, FCurve *fcu, BeztMap *bezms, int totve } } } - + } - + /* free temp memory used for 'adjusted' array */ MEM_freeN(adjusted); } @@ -4845,26 +4845,26 @@ void remake_graph_transdata(TransInfo *t, ListBase *anim_data) SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first; bAnimListElem *ale; const bool use_handle = (sipo->flag & SIPO_NOHANDLES) == 0; - + /* sort and reassign verts */ for (ale = anim_data->first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; - + if (fcu->bezt) { BeztMap *bezm; - + /* adjust transform-data pointers */ /* note, none of these functions use 'use_handle', it could be removed */ bezm = bezt_to_beztmaps(fcu->bezt, fcu->totvert, use_handle); sort_time_beztmaps(bezm, fcu->totvert, use_handle); beztmap_to_data(t, fcu, bezm, fcu->totvert, use_handle); - + /* free mapping stuff */ MEM_freeN(bezm); - + /* re-sort actual beztriples (perhaps this could be done using the beztmaps to save time?) */ sort_time_fcurve(fcu); - + /* make sure handles are all set correctly */ testhandles_fcurve(fcu, use_handle); } @@ -4904,11 +4904,11 @@ void flushTransGraphData(TransInfo *t) case SACTSNAP_FRAME: /* snap to nearest frame */ td2d->loc[0] = floor((double)td2d->loc[0] + 0.5); break; - + case SACTSNAP_SECOND: /* snap to nearest second */ td2d->loc[0] = floor(((double)td2d->loc[0] / secf) + 0.5) * secf; break; - + case SACTSNAP_MARKER: /* snap to nearest marker */ td2d->loc[0] = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, td2d->loc[0]); break; @@ -4920,7 +4920,7 @@ void flushTransGraphData(TransInfo *t) td2d->loc2d[0] = BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP); else td2d->loc2d[0] = td2d->loc[0]; - + /* Time-stepping auto-snapping modes don't get applied for Graph Editor transforms, * as these use the generic transform modes which don't account for this sort of thing. * These ones aren't affected by NLA mapping, so we do this after the conversion... @@ -4929,15 +4929,15 @@ void flushTransGraphData(TransInfo *t) * to, otherwise we get "swimming handles" * NOTE: We don't do this when canceling transforms, or else these changes don't go away */ - if ((t->state != TRANS_CANCEL) && (td->flag & TD_NOTIMESNAP) == 0 && - ELEM(sipo->autosnap, SACTSNAP_STEP, SACTSNAP_TSTEP)) + if ((t->state != TRANS_CANCEL) && (td->flag & TD_NOTIMESNAP) == 0 && + ELEM(sipo->autosnap, SACTSNAP_STEP, SACTSNAP_TSTEP)) { switch (sipo->autosnap) { case SACTSNAP_STEP: /* frame step */ td2d->loc2d[0] = floor((double)td2d->loc[0] + 0.5); td->loc[0] = floor((double)td->loc[0] + 0.5); break; - + case SACTSNAP_TSTEP: /* second step */ /* XXX: the handle behaviour in this case is still not quite right... */ td2d->loc[0] = floor(((double)td2d->loc[0] / secf) + 0.5) * secf; @@ -4945,18 +4945,18 @@ void flushTransGraphData(TransInfo *t) break; } } - + /* if int-values only, truncate to integers */ if (td->flag & TD_INTVALUES) td2d->loc2d[1] = floorf(td2d->loc[1] * inv_unit_scale - tdg->offset + 0.5f); else td2d->loc2d[1] = td2d->loc[1] * inv_unit_scale - tdg->offset; - + if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) { td2d->h1[0] = td2d->ih1[0] + td->loc[0] - td->iloc[0]; td2d->h1[1] = td2d->ih1[1] + (td->loc[1] - td->iloc[1]) * inv_unit_scale; } - + if ((td->flag & TD_MOVEHANDLE2) && td2d->h2) { td2d->h2[0] = td2d->ih2[0] + td->loc[0] - td->iloc[0]; td2d->h2[1] = td2d->ih2[1] + (td->loc[1] - td->iloc[1]) * inv_unit_scale; @@ -5505,7 +5505,7 @@ static void createTransSeqData(bContext *C, TransInfo *t) /* loop 2: build transdata array */ SeqToTransData_Recursive(t, ed->seqbasep, td, td2d, tdsq); SeqTransDataBounds(t, ed->seqbasep, ts); - + /* set the snap mode based on how close the mouse is at the end/start points */ if (abs(xmouse - ts->max) > abs(xmouse - ts->min)) ts->snap_left = true; @@ -5543,19 +5543,19 @@ static bool constraints_list_needinv(TransInfo *t, ListBase *list) { return true; } - + /* constraints that require this only under special conditions */ if (con->type == CONSTRAINT_TYPE_CHILDOF) { /* ChildOf constraint only works when using all location components, see T42256. */ bChildOfConstraint *data = (bChildOfConstraint *)con->data; - + if ((data->flag & CHILDOF_LOCX) && (data->flag & CHILDOF_LOCY) && (data->flag & CHILDOF_LOCZ)) return true; } else if (con->type == CONSTRAINT_TYPE_ROTLIKE) { /* CopyRot constraint only does this when rotating, and offset is on */ bRotateLikeConstraint *data = (bRotateLikeConstraint *)con->data; - + if ((data->flag & ROTLIKE_OFFSET) && (t->mode == TFM_ROTATION)) return true; } @@ -5563,7 +5563,7 @@ static bool constraints_list_needinv(TransInfo *t, ListBase *list) /* Transform constraint needs it for rotation at least (r.57309), * but doing so when translating may also mess things up [#36203] */ - + if (t->mode == TFM_ROTATION) return true; /* ??? (t->mode == TFM_SCALE) ? */ @@ -5639,13 +5639,13 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) td->loc = ob->loc; copy_v3_v3(td->iloc, td->loc); - + if (ob->rotmode > 0) { td->ext->rot = ob->rot; td->ext->rotAxis = NULL; td->ext->rotAngle = NULL; td->ext->quat = NULL; - + copy_v3_v3(td->ext->irot, ob->rot); copy_v3_v3(td->ext->drot, ob->drot); } @@ -5654,7 +5654,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) td->ext->rotAxis = ob->rotAxis; td->ext->rotAngle = &ob->rotAngle; td->ext->quat = NULL; - + td->ext->irotAngle = ob->rotAngle; copy_v3_v3(td->ext->irotAxis, ob->rotAxis); // td->ext->drotAngle = ob->drotAngle; // XXX, not implemented @@ -5665,7 +5665,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) td->ext->rotAxis = NULL; td->ext->rotAngle = NULL; td->ext->quat = ob->quat; - + copy_qt_qt(td->ext->iquat, ob->quat); copy_qt_qt(td->ext->dquat, ob->dquat); } @@ -5804,7 +5804,7 @@ static bool mark_children(Object *ob) return true; } } - + return false; } @@ -5885,7 +5885,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, ViewLayer *view_layer, O { ID *id = &ob->id; FCurve *fcu; - + // TODO: this should probably be done per channel instead... if (autokeyframe_cfra_can_key(scene, id)) { ReportList *reports = CTX_wm_reports(C); @@ -5894,36 +5894,36 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, ViewLayer *view_layer, O ListBase dsources = {NULL, NULL}; float cfra = (float)CFRA; // xxx this will do for now short flag = 0; - + /* get flags used for inserting keyframes */ flag = ANIM_get_keyframing_flags(scene, 1); - + /* add datasource override for the object */ - ANIM_relative_keyingset_add_source(&dsources, id, NULL, NULL); - + ANIM_relative_keyingset_add_source(&dsources, id, NULL, NULL); + if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (active_ks)) { - /* only insert into active keyingset + /* only insert into active keyingset * NOTE: we assume here that the active Keying Set does not need to have its iterator overridden */ ANIM_apply_keyingset(C, &dsources, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra); } else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL)) { AnimData *adt = ob->adt; - + /* only key on available channels */ if (adt && adt->action) { for (fcu = adt->action->curves.first; fcu; fcu = fcu->next) { fcu->flag &= ~FCURVE_SELECTED; insert_keyframe(reports, id, adt->action, (fcu->grp ? fcu->grp->name : NULL), - fcu->rna_path, fcu->array_index, cfra, + fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag); } } } else if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED)) { bool do_loc = false, do_rot = false, do_scale = false; - + /* filter the conditions when this happens (assume that curarea->spacetype==SPACE_VIE3D) */ if (tmode == TFM_TRANSLATION) { do_loc = true; @@ -5936,7 +5936,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, ViewLayer *view_layer, O else if (scene->toolsettings->transform_pivot_point == V3D_AROUND_CURSOR) { do_loc = true; } - + if ((scene->toolsettings->transform_flag & SCE_XFORM_AXIS_ALIGN) == 0) { do_rot = true; } @@ -5974,23 +5974,23 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, ViewLayer *view_layer, O KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID); ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); } - + /* only calculate paths if there are paths to be recalculated, * assuming that since we've autokeyed the transforms this is * now safe to apply... - * + * * NOTE: only do this when there's context info */ if (C && (ob->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) { //ED_objects_clear_paths(C); // XXX for now, don't need to clear ED_objects_recalculate_paths(C, scene); - - /* XXX: there's potential here for problems with unkeyed rotations/scale, + + /* XXX: there's potential here for problems with unkeyed rotations/scale, * but for now (until proper data-locality for baking operations), * this should be a better fix for T24451 and T37755 */ } - + /* free temp info */ BLI_freelistN(&dsources); } @@ -6009,7 +6009,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, Object *ob, int tmode, bPose *pose = ob->pose; bPoseChannel *pchan; FCurve *fcu; - + // TODO: this should probably be done per channel instead... if (autokeyframe_cfra_can_key(scene, id)) { ReportList *reports = CTX_wm_reports(C); @@ -6017,27 +6017,27 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, Object *ob, int tmode, KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene); float cfra = (float)CFRA; short flag = 0; - + /* flag is initialized from UserPref keyframing settings * - special exception for targetless IK - INSERTKEY_MATRIX keyframes should get * visual keyframes even if flag not set, as it's not that useful otherwise * (for quick animation recording) */ flag = ANIM_get_keyframing_flags(scene, 1); - - if (targetless_ik) + + if (targetless_ik) flag |= INSERTKEY_MATRIX; - + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->bone->flag & BONE_TRANSFORM) { ListBase dsources = {NULL, NULL}; - + /* clear any 'unkeyed' flag it may have */ pchan->bone->flag &= ~BONE_UNKEYED; - + /* add datasource override for the camera object */ - ANIM_relative_keyingset_add_source(&dsources, id, &RNA_PoseBone, pchan); - + ANIM_relative_keyingset_add_source(&dsources, id, &RNA_PoseBone, pchan); + /* only insert into active keyingset? */ if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (active_ks)) { /* run the active Keying Set on the current datasource */ @@ -6050,17 +6050,17 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, Object *ob, int tmode, /* only insert keyframes for this F-Curve if it affects the current bone */ if (strstr(fcu->rna_path, "bones")) { char *pchanName = BLI_str_quoted_substrN(fcu->rna_path, "bones["); - - /* only if bone name matches too... + + /* only if bone name matches too... * NOTE: this will do constraints too, but those are ok to do here too? */ if (pchanName && STREQ(pchanName, pchan->name)) { - insert_keyframe(reports, id, act, + insert_keyframe(reports, id, act, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag); } - + if (pchanName) MEM_freeN(pchanName); } } @@ -6069,7 +6069,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, Object *ob, int tmode, /* only insert keyframe if needed? */ else if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED)) { bool do_loc = false, do_rot = false, do_scale = false; - + /* filter the conditions when this happens (assume that curarea->spacetype==SPACE_VIE3D) */ if (tmode == TFM_TRANSLATION) { if (targetless_ik) @@ -6114,13 +6114,13 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, Object *ob, int tmode, KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID); ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); } - + /* free temp info */ BLI_freelistN(&dsources); } } - - /* do the bone paths + + /* do the bone paths * - only do this when there is context info, since we need that to resolve * how to do the updates and so on... * - do not calculate unless there are paths already to update... @@ -6218,7 +6218,7 @@ static void special_aftertrans_update__mask(bContext *C, TransInfo *t) static void special_aftertrans_update__node(bContext *UNUSED(C), TransInfo *t) { const bool canceled = (t->state == TRANS_CANCEL); - + if (canceled && t->remove_on_cancel) { /* remove selected nodes on cancel */ SpaceNode *snode = (SpaceNode *)t->sa->spacedata.first; @@ -6279,7 +6279,7 @@ static void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t) } /* inserting keys, pointcache, redraw events... */ -/* +/* * note: sequencer freeing has its own function now because of a conflict with transform's order of freeing (campbell) * Order changed, the sequencer stuff should go back in here * */ @@ -6379,10 +6379,10 @@ void special_aftertrans_update(bContext *C, TransInfo *t) special_aftertrans_update__node(C, t); if (canceled == 0) { ED_node_post_apply_transform(C, snode->edittree); - + ED_node_link_insert(t->sa); } - + /* clear link line */ ED_node_link_intersect_test(t->sa, 0); } @@ -6397,26 +6397,26 @@ void special_aftertrans_update(bContext *C, TransInfo *t) else if (t->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; bAnimContext ac; - + /* initialize relevant anim-context 'context' data */ if (ANIM_animdata_get_context(C, &ac) == 0) return; - + ob = ac.obact; - + if (ELEM(ac.datatype, ANIMCONT_DOPESHEET, ANIMCONT_SHAPEKEY)) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; short filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/); - + /* get channels to work on */ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* these should all be F-Curves */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); FCurve *fcu = (FCurve *)ale->key_data; - + /* 3 cases here for curve cleanups: * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done * 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed @@ -6434,7 +6434,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) posttrans_fcurve_clean(fcu, false); /* only use handles in graph editor */ } } - + /* free temp memory */ ANIM_animdata_freelist(&anim_data); } @@ -6447,7 +6447,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) else DEG_id_tag_update(&ob->id, OB_RECALC_OB); } - + /* 3 cases here for curve cleanups: * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done * 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed @@ -6470,7 +6470,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) ((canceled == 0) || (duplicate))) { bGPdata *gpd; - + // XXX: BAD! this get gpencil datablocks directly from main db... // but that's how this currently works :/ for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) { @@ -6499,9 +6499,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } } } - + /* marker transform, not especially nice but we may want to move markers - * at the same time as keyframes in the dope sheet. + * at the same time as keyframes in the dope sheet. */ if ((saction->flag & SACTION_MARKERS_MOVE) && (canceled == 0)) { if (t->mode == TFM_TIME_TRANSLATE) { @@ -6520,11 +6520,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t) ED_markers_post_apply_transform(ED_context_get_markers(C), t->scene, t->mode, t->values[0], t->frame_side); } } - + /* make sure all F-Curves are set correctly */ if (!ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) ANIM_editkeyframes_refresh(&ac); - + /* clear flag that was set for time-slide drawing */ saction->flag &= ~SACTION_MOVING; } @@ -6532,23 +6532,23 @@ void special_aftertrans_update(bContext *C, TransInfo *t) SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first; bAnimContext ac; const bool use_handle = (sipo->flag & SIPO_NOHANDLES) == 0; - + /* initialize relevant anim-context 'context' data */ if (ANIM_animdata_get_context(C, &ac) == 0) return; - + if (ac.datatype) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; short filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE); - + /* get channels to work on */ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); FCurve *fcu = (FCurve *)ale->key_data; - + /* 3 cases here for curve cleanups: * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done * 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed @@ -6566,11 +6566,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t) posttrans_fcurve_clean(fcu, use_handle); } } - + /* free temp memory */ ANIM_animdata_freelist(&anim_data); } - + /* Make sure all F-Curves are set correctly, but not if transform was * canceled, since then curves were already restored to initial state. * Note: if the refresh is really needed after cancel then some way @@ -6581,32 +6581,32 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } else if (t->spacetype == SPACE_NLA) { bAnimContext ac; - + /* initialize relevant anim-context 'context' data */ if (ANIM_animdata_get_context(C, &ac) == 0) return; - + if (ac.datatype) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; short filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT); - + /* get channels to work on */ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; - + /* make sure strips are in order again */ BKE_nlatrack_sort_strips(nlt); - + /* remove the temp metas */ BKE_nlastrips_clear_metas(&nlt->strips, 0, 1); } - + /* free temp memory */ ANIM_animdata_freelist(&anim_data); - + /* perform after-transfrom validation */ ED_nla_postop_refresh(&ac); } @@ -6702,7 +6702,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) if (td->flag & TD_NOACTION) break; - + if (td->flag & TD_SKIP) continue; @@ -6728,7 +6728,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) if (!canceled) { autokeyframe_ob_cb_func(C, t->scene, t->view_layer, ob, t->mode); } - + /* restore rigid body transform */ if (ob->rigidbody_object && canceled) { float ctime = BKE_scene_frame_get(t->scene); @@ -6771,13 +6771,13 @@ static void createTransObject(bContext *C, TransInfo *t) /* count */ tc->data_len = CTX_DATA_COUNT(C, selected_objects); - + if (!tc->data_len) { /* clear here, main transform function escapes too */ clear_trans_object_base_flags(t); return; } - + if (is_prop_edit) { tc->data_len += count_proportional_objects(t); } @@ -6788,29 +6788,29 @@ static void createTransObject(bContext *C, TransInfo *t) CTX_DATA_BEGIN(C, Base *, base, selected_bases) { Object *ob = base->object; - + td->flag = TD_SELECTED; td->protectflag = ob->protectflag; td->ext = tx; td->ext->rotOrder = ob->rotmode; - + if (base->flag & BA_TRANSFORM_CHILD) { td->flag |= TD_NOCENTER; td->flag |= TD_NO_LOC; } - + /* select linked objects, but skip them later */ if (ID_IS_LINKED(ob)) { td->flag |= TD_SKIP; } - + ObjectToTransData(t, td, ob); td->val = NULL; td++; tx++; } CTX_DATA_END; - + if (is_prop_edit) { ViewLayer *view_layer = t->view_layer; Base *base; @@ -6826,7 +6826,7 @@ static void createTransObject(bContext *C, TransInfo *t) td->protectflag = ob->protectflag; td->ext = tx; td->ext->rotOrder = ob->rotmode; - + ObjectToTransData(t, td, ob); td->val = NULL; td++; @@ -6840,7 +6840,7 @@ static void createTransObject(bContext *C, TransInfo *t) static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node, const float dpi_fac) { float locx, locy; - + /* account for parents (nested nodes) */ if (node->parent) { nodeToView(node->parent, node->locx, node->locy, &locx, &locy); @@ -6849,7 +6849,7 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node, const locx = node->locx; locy = node->locy; } - + /* use top-left corner as the transform origin for nodes */ /* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */ #ifdef USE_NODE_CENTER @@ -8043,10 +8043,10 @@ static void createTransGPencil(bContext *C, TransInfo *t) bGPDlayer *gpl; TransData *td = NULL; float mtx[3][3], smtx[3][3]; - + const Scene *scene = CTX_data_scene(C); const int cfra_scene = CFRA; - + const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0; const bool is_prop_edit_connected = (t->flag & T_PROP_CONNECTED) != 0; @@ -8059,11 +8059,11 @@ static void createTransGPencil(bContext *C, TransInfo *t) * strokes. This may cause issues in future though. */ tc->data_len = 0; - + if (gpd == NULL) return; - - /* First Pass: Count the number of datapoints required for the strokes, + + /* First Pass: Count the number of datapoints required for the strokes, * (and additional info about the configuration - e.g. 2D/3D?) */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { @@ -8099,30 +8099,30 @@ static void createTransGPencil(bContext *C, TransInfo *t) if (gps->flag & GP_STROKE_SELECT) { bGPDspoint *pt; int i; - + // TODO: 2D vs 3D? for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { if (pt->flag & GP_SPOINT_SELECT) tc->data_len++; } } - } + } } } } - + /* Stop trying if nothing selected */ if (tc->data_len == 0) { return; } - + /* Allocate memory for data */ tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransData(GPencil)"); td = tc->data; - + unit_m3(smtx); unit_m3(mtx); - + /* Second Pass: Build transdata array */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { /* only editable and visible layers are considered */ @@ -8139,7 +8139,7 @@ static void createTransGPencil(bContext *C, TransInfo *t) /* undo matrix */ invert_m4_m4(inverse_diff_mat, diff_mat); } - + /* Make a new frame to work on if the layer's frame and the current scene frame don't match up * - This is useful when animating as it saves that "uh-oh" moment when you realize you've * spent too much time editing the wrong frame... @@ -8151,13 +8151,13 @@ static void createTransGPencil(bContext *C, TransInfo *t) continue; } } - + /* Loop over strokes, adding TransData for points as needed... */ for (gps = gpf->strokes.first; gps; gps = gps->next) { TransData *head = td; TransData *tail = td; bool stroke_ok; - + /* skip strokes that are invalid for current view */ if (ED_gpencil_stroke_can_use(C, gps) == false) { continue; @@ -8181,26 +8181,26 @@ static void createTransGPencil(bContext *C, TransInfo *t) /* C) Only selected points in selected strokes */ stroke_ok = (gps->flag & GP_STROKE_SELECT) != 0; } - + /* Do stroke... */ if (stroke_ok && gps->totpoints) { bGPDspoint *pt; int i; - + #if 0 /* XXX: this isn't needed anymore; cannot calculate center this way or is_prop_edit breaks */ const float ninv = 1.0f / gps->totpoints; float center[3] = {0.0f}; - + /* compute midpoint of stroke */ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { madd_v3_v3v3fl(center, center, &pt->x, ninv); } #endif - + /* add all necessary points... */ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { bool point_ok; - + /* include point? */ if (is_prop_edit) { /* Always all points in strokes that get included */ @@ -8210,30 +8210,30 @@ static void createTransGPencil(bContext *C, TransInfo *t) /* Only selected points in selected strokes */ point_ok = (pt->flag & GP_SPOINT_SELECT) != 0; } - + /* do point... */ if (point_ok) { copy_v3_v3(td->iloc, &pt->x); copy_v3_v3(td->center, &pt->x); // XXX: what about t->around == local? - + td->loc = &pt->x; - + td->flag = 0; - + if (pt->flag & GP_SPOINT_SELECT) td->flag |= TD_SELECTED; - + /* for other transform modes (e.g. shrink-fatten), need to additional data */ if (t->mode == TFM_GPENCIL_SHRINKFATTEN) { td->val = &pt->pressure; td->ival = pt->pressure; } - + /* screenspace needs special matrices... */ if ((gps->flag & (GP_STROKE_3DSPACE | GP_STROKE_2DSPACE | GP_STROKE_2DIMAGE)) == 0) { /* screenspace */ td->protectflag = OB_LOCK_LOCZ | OB_LOCK_ROTZ | OB_LOCK_SCALEZ; - + /* apply parent transformations */ if (gpl->parent == NULL) { copy_m3_m4(td->smtx, t->persmat); @@ -8253,7 +8253,7 @@ static void createTransGPencil(bContext *C, TransInfo *t) td->protectflag = OB_LOCK_LOCZ | OB_LOCK_ROTZ | OB_LOCK_SCALEZ; // XXX: matrices may need to be different? } - + /* apply parent transformations */ if (gpl->parent == NULL) { copy_m3_m3(td->smtx, smtx); @@ -8274,7 +8274,7 @@ static void createTransGPencil(bContext *C, TransInfo *t) tail++; } } - + /* March over these points, and calculate the proportional editing distances */ if (is_prop_edit && (head != tail)) { /* XXX: for now, we are similar enough that this works... */ @@ -8348,7 +8348,7 @@ void createTransData(bContext *C, TransInfo *t) createTransGPencil(C, t); countAndCleanTransDataContainer(t); - + if (t->data_len_all && (t->flag & T_PROP_EDIT)) { sort_trans_data(t); // makes selected become first in array set_prop_dist(t, 1); @@ -8380,7 +8380,7 @@ void createTransData(bContext *C, TransInfo *t) initTransDataContainers_FromObjectData(t); createTransUVs(C, t); countAndCleanTransDataContainer(t); - + t->flag |= T_EDIT; if (t->data_len_all && (t->flag & T_PROP_EDIT)) { @@ -8538,7 +8538,7 @@ void createTransData(bContext *C, TransInfo *t) countAndCleanTransDataContainer(t); } } - + } } else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_start_edit(PE_get_current(scene, ob))) { |