Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_convert_action.c
| Show All 32 Lines | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_nla.h" | #include "BKE_nla.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "ED_anim_api.h" | #include "ED_anim_api.h" | ||||
| #include "transform.h" | #include "transform.h" | ||||
| #include "transform_convert.h" | #include "transform_convert.h" | ||||
| #include "transform_data.h" | |||||
| /* helper struct for gp-frame transforms */ | /* helper struct for gp-frame transforms */ | ||||
| typedef struct tGPFtransdata { | typedef struct tGPFtransdata { | ||||
| float val; /* where transdata writes transform */ | float val; /* where transdata writes transform */ | ||||
| int *sdata; /* pointer to gpf->framenum */ | int *sdata; /* pointer to gpf->framenum */ | ||||
| } tGPFtransdata; | } tGPFtransdata; | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| ▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | if (is_prop_edit && count > 0) { | ||||
| return count_all; | return count_all; | ||||
| } | } | ||||
| else { | else { | ||||
| return count; | return count; | ||||
| } | } | ||||
| } | } | ||||
| /* This function assigns the information to transdata */ | /* This function assigns the information to transdata */ | ||||
| static void TimeToTransData(TransData *td, float *time, AnimData *adt, float ypos) | static void TimeToTransData(TransData *td, const int tdi, float *time, AnimData *adt, float ypos) | ||||
| { | { | ||||
| /* memory is calloc'ed, so that should zero everything nicely for us */ | /* memory is calloc'ed, so that should zero everything nicely for us */ | ||||
| td->val = time; | td->special[tdi].val = time; | ||||
| td->ival = *(time); | td->special[tdi].ival = *(time); | ||||
| td->center[0] = td->ival; | td->center[tdi][0] = *(time); | ||||
| td->center[1] = ypos; | td->center[tdi][1] = ypos; | ||||
| /* store the AnimData where this keyframe exists as a keyframe of the | /* store the AnimData where this keyframe exists as a keyframe of the | ||||
| * active action as td->extra. | * active action as td->basic[tdi].extra. | ||||
| */ | */ | ||||
| td->extra = adt; | td->basic[tdi].extra = adt; | ||||
| } | } | ||||
| /* This function advances the address to which td points to, so it must return | /* This function advances the address to which td points to, so it must return | ||||
| * the new address so that the next time new transform data is added, it doesn't | * the new address so that the next time new transform data is added, it doesn't | ||||
| * overwrite the existing ones... i.e. td = IcuToTransData(td, icu, ob, side, cfra); | * overwrite the existing ones... i.e. td = IcuToTransData(td, icu, ob, side, cfra); | ||||
| * | * | ||||
| * The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data | * The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data | ||||
| * on the named side are used. | * on the named side are used. | ||||
| */ | */ | ||||
| static TransData *ActionFCurveToTransData(TransData *td, | static int ActionFCurveToTransData(TransData *td, | ||||
| int tdi, | |||||
| TransData2D **td2dv, | TransData2D **td2dv, | ||||
| FCurve *fcu, | FCurve *fcu, | ||||
| AnimData *adt, | AnimData *adt, | ||||
| char side, | char side, | ||||
| float cfra, | float cfra, | ||||
| bool is_prop_edit, | bool is_prop_edit, | ||||
| float ypos) | float ypos) | ||||
| { | { | ||||
| BezTriple *bezt; | BezTriple *bezt; | ||||
| TransData2D *td2d = *td2dv; | TransData2D *td2d = *td2dv; | ||||
| int i; | int i; | ||||
| if (ELEM(NULL, fcu, fcu->bezt)) { | if (ELEM(NULL, fcu, fcu->bezt)) { | ||||
| return td; | return tdi; | ||||
| } | } | ||||
| for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { | for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { | ||||
| /* only add selected keyframes (for now, proportional edit is not enabled) */ | /* only add selected keyframes (for now, proportional edit is not enabled) */ | ||||
| if (is_prop_edit || (bezt->f2 & SELECT)) { /* note this MUST match count_fcurve_keys(), | if (is_prop_edit || (bezt->f2 & SELECT)) { /* note this MUST match count_fcurve_keys(), | ||||
| * so can't use BEZT_ISSEL_ANY() macro */ | * so can't use BEZT_ISSEL_ANY() macro */ | ||||
| /* only add if on the right 'side' of the current frame */ | /* only add if on the right 'side' of the current frame */ | ||||
| if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) { | if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) { | ||||
| TimeToTransData(td, bezt->vec[1], adt, ypos); | TimeToTransData(td, tdi, bezt->vec[1], adt, ypos); | ||||
| if (bezt->f2 & SELECT) { | if (bezt->f2 & SELECT) { | ||||
| td->flag |= TD_SELECTED; | td->basic[tdi].flag |= TD_SELECTED; | ||||
| } | } | ||||
| /*set flags to move handles as necessary*/ | /*set flags to move handles as necessary*/ | ||||
| td->flag |= TD_MOVEHANDLE1 | TD_MOVEHANDLE2; | td->basic[tdi].flag |= TD_MOVEHANDLE1 | TD_MOVEHANDLE2; | ||||
| td2d->h1 = bezt->vec[0]; | td2d->h1 = bezt->vec[0]; | ||||
| td2d->h2 = bezt->vec[2]; | td2d->h2 = bezt->vec[2]; | ||||
| copy_v2_v2(td2d->ih1, td2d->h1); | copy_v2_v2(td2d->ih1, td2d->h1); | ||||
| copy_v2_v2(td2d->ih2, td2d->h2); | copy_v2_v2(td2d->ih2, td2d->h2); | ||||
| td++; | tdi++; | ||||
| td2d++; | td2d++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| *td2dv = td2d; | *td2dv = td2d; | ||||
| return td; | return tdi; | ||||
| } | } | ||||
| /* This function advances the address to which td points to, so it must return | /* This function advances the address to which td points to, so it must return | ||||
| * the new address so that the next time new transform data is added, it doesn't | * the new address so that the next time new transform data is added, it doesn't | ||||
| * overwrite the existing ones... i.e. td = GPLayerToTransData(td, ipo, ob, side, cfra); | * overwrite the existing ones... i.e. td = GPLayerToTransData(td, ipo, ob, side, cfra); | ||||
| * | * | ||||
| * The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data | * The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data | ||||
| * on the named side are used. | * on the named side are used. | ||||
| */ | */ | ||||
| static int GPLayerToTransData(TransData *td, | static int GPLayerToTransData(TransData *td, | ||||
| int tdi, | |||||
| tGPFtransdata *tfd, | tGPFtransdata *tfd, | ||||
| bGPDlayer *gpl, | bGPDlayer *gpl, | ||||
| char side, | char side, | ||||
| float cfra, | float cfra, | ||||
| bool is_prop_edit, | bool is_prop_edit, | ||||
| float ypos) | float ypos) | ||||
| { | { | ||||
| bGPDframe *gpf; | bGPDframe *gpf; | ||||
| int count = 0; | int count = 0; | ||||
| /* check for select frames on right side of current frame */ | /* check for select frames on right side of current frame */ | ||||
| for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { | for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { | ||||
| if (is_prop_edit || (gpf->flag & GP_FRAME_SELECT)) { | if (is_prop_edit || (gpf->flag & GP_FRAME_SELECT)) { | ||||
| if (FrameOnMouseSide(side, (float)gpf->framenum, cfra)) { | if (FrameOnMouseSide(side, (float)gpf->framenum, cfra)) { | ||||
| /* memory is calloc'ed, so that should zero everything nicely for us */ | /* memory is calloc'ed, so that should zero everything nicely for us */ | ||||
| td->val = &tfd->val; | td->special[tdi].val = &tfd->val; | ||||
| td->ival = (float)gpf->framenum; | td->special[tdi].ival = (float)gpf->framenum; | ||||
| td->center[0] = td->ival; | td->center[tdi][0] = (float)gpf->framenum; | ||||
| td->center[1] = ypos; | td->center[tdi][1] = ypos; | ||||
| tfd->val = (float)gpf->framenum; | tfd->val = (float)gpf->framenum; | ||||
| tfd->sdata = &gpf->framenum; | tfd->sdata = &gpf->framenum; | ||||
| /* advance td now */ | /* advance tdi now */ | ||||
| td++; | tdi++; | ||||
| tfd++; | tfd++; | ||||
| count++; | count++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return count; | return count; | ||||
| } | } | ||||
| /* refer to comment above #GPLayerToTransData, this is the same but for masks */ | /* refer to comment above #GPLayerToTransData, this is the same but for masks */ | ||||
| static int MaskLayerToTransData(TransData *td, | static int MaskLayerToTransData(TransData *td, | ||||
| int tdi, | |||||
| tGPFtransdata *tfd, | tGPFtransdata *tfd, | ||||
| MaskLayer *masklay, | MaskLayer *masklay, | ||||
| char side, | char side, | ||||
| float cfra, | float cfra, | ||||
| bool is_prop_edit, | bool is_prop_edit, | ||||
| float ypos) | float ypos) | ||||
| { | { | ||||
| MaskLayerShape *masklay_shape; | MaskLayerShape *masklay_shape; | ||||
| int count = 0; | int count = 0; | ||||
| /* check for select frames on right side of current frame */ | /* check for select frames on right side of current frame */ | ||||
| for (masklay_shape = masklay->splines_shapes.first; masklay_shape; | for (masklay_shape = masklay->splines_shapes.first; masklay_shape; | ||||
| masklay_shape = masklay_shape->next) { | masklay_shape = masklay_shape->next) { | ||||
| if (is_prop_edit || (masklay_shape->flag & MASK_SHAPE_SELECT)) { | if (is_prop_edit || (masklay_shape->flag & MASK_SHAPE_SELECT)) { | ||||
| if (FrameOnMouseSide(side, (float)masklay_shape->frame, cfra)) { | if (FrameOnMouseSide(side, (float)masklay_shape->frame, cfra)) { | ||||
| /* memory is calloc'ed, so that should zero everything nicely for us */ | /* memory is calloc'ed, so that should zero everything nicely for us */ | ||||
| td->val = &tfd->val; | td->special[tdi].val = &tfd->val; | ||||
| td->ival = (float)masklay_shape->frame; | td->special[tdi].ival = (float)masklay_shape->frame; | ||||
| td->center[0] = td->ival; | td->center[tdi][0] = (float)masklay_shape->frame; | ||||
| td->center[1] = ypos; | td->center[tdi][1] = ypos; | ||||
| tfd->val = (float)masklay_shape->frame; | tfd->val = (float)masklay_shape->frame; | ||||
| tfd->sdata = &masklay_shape->frame; | tfd->sdata = &masklay_shape->frame; | ||||
| /* advance td now */ | /* advance tdi now */ | ||||
| td++; | tdi++; | ||||
| tfd++; | tfd++; | ||||
| count++; | count++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return count; | return count; | ||||
| } | } | ||||
| void createTransActionData(bContext *C, TransInfo *t) | void createTransActionData(bContext *C, TransInfo *t) | ||||
| { | { | ||||
| Scene *scene = t->scene; | Scene *scene = t->scene; | ||||
| TransData *td = NULL; | |||||
| TransData2D *td2d = NULL; | TransData2D *td2d = NULL; | ||||
| tGPFtransdata *tfd = NULL; | tGPFtransdata *tfd = NULL; | ||||
| rcti *mask = &t->region->v2d.mask; | rcti *mask = &t->region->v2d.mask; | ||||
| rctf *datamask = &t->region->v2d.cur; | rctf *datamask = &t->region->v2d.cur; | ||||
| float xsize = BLI_rctf_size_x(datamask); | float xsize = BLI_rctf_size_x(datamask); | ||||
| float ysize = BLI_rctf_size_y(datamask); | float ysize = BLI_rctf_size_y(datamask); | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | if (count == 0) { | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| return; | return; | ||||
| } | } | ||||
| TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); | TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); | ||||
| /* allocate memory for data */ | /* allocate memory for data */ | ||||
| tc->data_len = count; | tc->data_len = count; | ||||
| TransData *td = tc->data = transform_data_alloc(tc->data_len, TD_BASIC_COMP); | |||||
| tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransData(Action Editor)"); | tc->data_2d = MEM_callocN(td->elem_len * sizeof(TransData2D), "transdata2d"); | ||||
| tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "transdata2d"); | |||||
| td = tc->data; | |||||
| td2d = tc->data_2d; | td2d = tc->data_2d; | ||||
| if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { | if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { | ||||
| tc->custom.type.data = tfd = MEM_callocN(sizeof(tGPFtransdata) * count, "tGPFtransdata"); | tc->custom.type.data = tfd = MEM_callocN(sizeof(tGPFtransdata) * count, "tGPFtransdata"); | ||||
| tc->custom.type.use_free = true; | tc->custom.type.use_free = true; | ||||
| } | } | ||||
| /* loop 2: build transdata array */ | /* loop 2: build transdata array */ | ||||
| int tdi = 0; | |||||
| for (ale = anim_data.first; ale; ale = ale->next) { | for (ale = anim_data.first; ale; ale = ale->next) { | ||||
| if (is_prop_edit && !ale->tag) { | if (is_prop_edit && !ale->tag) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| cfra = (float)CFRA; | cfra = (float)CFRA; | ||||
| { | { | ||||
| AnimData *adt; | AnimData *adt; | ||||
| adt = ANIM_nla_mapping_get(&ac, ale); | adt = ANIM_nla_mapping_get(&ac, ale); | ||||
| if (adt) { | if (adt) { | ||||
| cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); | cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); | ||||
| } | } | ||||
| } | } | ||||
| if (ale->type == ANIMTYPE_GPLAYER) { | if (ale->type == ANIMTYPE_GPLAYER) { | ||||
| bGPDlayer *gpl = (bGPDlayer *)ale->data; | bGPDlayer *gpl = (bGPDlayer *)ale->data; | ||||
| int i; | int i; | ||||
| i = GPLayerToTransData(td, tfd, gpl, t->frame_side, cfra, is_prop_edit, ypos); | i = GPLayerToTransData(td, tdi, tfd, gpl, t->frame_side, cfra, is_prop_edit, ypos); | ||||
| td += i; | tdi += i; | ||||
| tfd += i; | tfd += i; | ||||
| } | } | ||||
| else if (ale->type == ANIMTYPE_MASKLAYER) { | else if (ale->type == ANIMTYPE_MASKLAYER) { | ||||
| MaskLayer *masklay = (MaskLayer *)ale->data; | MaskLayer *masklay = (MaskLayer *)ale->data; | ||||
| int i; | int i; | ||||
| i = MaskLayerToTransData(td, tfd, masklay, t->frame_side, cfra, is_prop_edit, ypos); | i = MaskLayerToTransData(td, tdi, tfd, masklay, t->frame_side, cfra, is_prop_edit, ypos); | ||||
| td += i; | tdi += i; | ||||
| tfd += i; | tfd += i; | ||||
| } | } | ||||
| else { | else { | ||||
| AnimData *adt = ANIM_nla_mapping_get(&ac, ale); | AnimData *adt = ANIM_nla_mapping_get(&ac, ale); | ||||
| FCurve *fcu = (FCurve *)ale->key_data; | FCurve *fcu = (FCurve *)ale->key_data; | ||||
| td = ActionFCurveToTransData(td, &td2d, fcu, adt, t->frame_side, cfra, is_prop_edit, ypos); | tdi = ActionFCurveToTransData( | ||||
| td, tdi, &td2d, fcu, adt, t->frame_side, cfra, is_prop_edit, ypos); | |||||
| } | } | ||||
| } | } | ||||
| /* calculate distances for proportional editing */ | /* calculate distances for proportional editing */ | ||||
| if (is_prop_edit) { | if (is_prop_edit) { | ||||
| td = tc->data; | tdi = 0; | ||||
| for (ale = anim_data.first; ale; ale = ale->next) { | for (ale = anim_data.first; ale; ale = ale->next) { | ||||
| AnimData *adt; | AnimData *adt; | ||||
| /* F-Curve may not have any keyframes */ | /* F-Curve may not have any keyframes */ | ||||
| if (!ale->tag) { | if (!ale->tag) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| adt = ANIM_nla_mapping_get(&ac, ale); | adt = ANIM_nla_mapping_get(&ac, ale); | ||||
| if (adt) { | if (adt) { | ||||
| cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); | cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); | ||||
| } | } | ||||
| else { | else { | ||||
| cfra = (float)CFRA; | cfra = (float)CFRA; | ||||
| } | } | ||||
| if (ale->type == ANIMTYPE_GPLAYER) { | if (ale->type == ANIMTYPE_GPLAYER) { | ||||
| bGPDlayer *gpl = (bGPDlayer *)ale->data; | bGPDlayer *gpl = (bGPDlayer *)ale->data; | ||||
| bGPDframe *gpf; | bGPDframe *gpf; | ||||
| for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { | for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { | ||||
| if (gpf->flag & GP_FRAME_SELECT) { | if (gpf->flag & GP_FRAME_SELECT) { | ||||
| td->dist = td->rdist = 0.0f; | td->prop[tdi].dist = td->prop[tdi].rdist = 0.0f; | ||||
| } | } | ||||
| else { | else { | ||||
| bGPDframe *gpf_iter; | bGPDframe *gpf_iter; | ||||
| int min = INT_MAX; | int min = INT_MAX; | ||||
| for (gpf_iter = gpl->frames.first; gpf_iter; gpf_iter = gpf_iter->next) { | for (gpf_iter = gpl->frames.first; gpf_iter; gpf_iter = gpf_iter->next) { | ||||
| if (gpf_iter->flag & GP_FRAME_SELECT) { | if (gpf_iter->flag & GP_FRAME_SELECT) { | ||||
| if (FrameOnMouseSide(t->frame_side, (float)gpf_iter->framenum, cfra)) { | if (FrameOnMouseSide(t->frame_side, (float)gpf_iter->framenum, cfra)) { | ||||
| int val = abs(gpf->framenum - gpf_iter->framenum); | int val = abs(gpf->framenum - gpf_iter->framenum); | ||||
| if (val < min) { | if (val < min) { | ||||
| min = val; | min = val; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| td->dist = td->rdist = min; | td->prop[tdi].dist = td->prop[tdi].rdist = min; | ||||
| } | } | ||||
| td++; | tdi++; | ||||
| } | } | ||||
| } | } | ||||
| else if (ale->type == ANIMTYPE_MASKLAYER) { | else if (ale->type == ANIMTYPE_MASKLAYER) { | ||||
| MaskLayer *masklay = (MaskLayer *)ale->data; | MaskLayer *masklay = (MaskLayer *)ale->data; | ||||
| MaskLayerShape *masklay_shape; | MaskLayerShape *masklay_shape; | ||||
| for (masklay_shape = masklay->splines_shapes.first; masklay_shape; | for (masklay_shape = masklay->splines_shapes.first; masklay_shape; | ||||
| masklay_shape = masklay_shape->next) { | masklay_shape = masklay_shape->next) { | ||||
| if (FrameOnMouseSide(t->frame_side, (float)masklay_shape->frame, cfra)) { | if (FrameOnMouseSide(t->frame_side, (float)masklay_shape->frame, cfra)) { | ||||
| if (masklay_shape->flag & MASK_SHAPE_SELECT) { | if (masklay_shape->flag & MASK_SHAPE_SELECT) { | ||||
| td->dist = td->rdist = 0.0f; | td->prop[tdi].dist = td->prop[tdi].rdist = 0.0f; | ||||
| } | } | ||||
| else { | else { | ||||
| MaskLayerShape *masklay_iter; | MaskLayerShape *masklay_iter; | ||||
| int min = INT_MAX; | int min = INT_MAX; | ||||
| for (masklay_iter = masklay->splines_shapes.first; masklay_iter; | for (masklay_iter = masklay->splines_shapes.first; masklay_iter; | ||||
| masklay_iter = masklay_iter->next) { | masklay_iter = masklay_iter->next) { | ||||
| if (masklay_iter->flag & MASK_SHAPE_SELECT) { | if (masklay_iter->flag & MASK_SHAPE_SELECT) { | ||||
| if (FrameOnMouseSide(t->frame_side, (float)masklay_iter->frame, cfra)) { | if (FrameOnMouseSide(t->frame_side, (float)masklay_iter->frame, cfra)) { | ||||
| int val = abs(masklay_shape->frame - masklay_iter->frame); | int val = abs(masklay_shape->frame - masklay_iter->frame); | ||||
| if (val < min) { | if (val < min) { | ||||
| min = val; | min = val; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| td->dist = td->rdist = min; | td->prop[tdi].dist = td->prop[tdi].rdist = min; | ||||
| } | } | ||||
| td++; | tdi++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| FCurve *fcu = (FCurve *)ale->key_data; | FCurve *fcu = (FCurve *)ale->key_data; | ||||
| BezTriple *bezt; | BezTriple *bezt; | ||||
| int i; | int i; | ||||
| for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { | for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { | ||||
| if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) { | if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) { | ||||
| if (bezt->f2 & SELECT) { | if (bezt->f2 & SELECT) { | ||||
| td->dist = td->rdist = 0.0f; | td->prop[tdi].dist = td->prop[tdi].rdist = 0.0f; | ||||
| } | } | ||||
| else { | else { | ||||
| BezTriple *bezt_iter; | BezTriple *bezt_iter; | ||||
| int j; | int j; | ||||
| float min = FLT_MAX; | float min = FLT_MAX; | ||||
| for (j = 0, bezt_iter = fcu->bezt; j < fcu->totvert; j++, bezt_iter++) { | for (j = 0, bezt_iter = fcu->bezt; j < fcu->totvert; j++, bezt_iter++) { | ||||
| if (bezt_iter->f2 & SELECT) { | if (bezt_iter->f2 & SELECT) { | ||||
| if (FrameOnMouseSide(t->frame_side, (float)bezt_iter->vec[1][0], cfra)) { | if (FrameOnMouseSide(t->frame_side, (float)bezt_iter->vec[1][0], cfra)) { | ||||
| float val = fabs(bezt->vec[1][0] - bezt_iter->vec[1][0]); | float val = fabs(bezt->vec[1][0] - bezt_iter->vec[1][0]); | ||||
| if (val < min) { | if (val < min) { | ||||
| min = val; | min = val; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| td->dist = td->rdist = min; | td->prop[tdi].dist = td->prop[tdi].rdist = min; | ||||
| } | } | ||||
| td++; | tdi++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* cleanup temp list */ | /* cleanup temp list */ | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Action Transform Flush | /** \name Action Transform Flush | ||||
| * | * | ||||
| * \{ */ | * \{ */ | ||||
| /* This function helps flush transdata written to tempdata into the gp-frames */ | /* This function helps flush transdata written to tempdata into the gp-frames */ | ||||
| void flushTransIntFrameActionData(TransInfo *t) | void flushTransIntFrameActionData(TransInfo *t) | ||||
| { | { | ||||
| TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); | TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); | ||||
| tGPFtransdata *tfd = tc->custom.type.data; | tGPFtransdata *tfd = tc->custom.type.data; | ||||
| /* flush data! */ | /* flush data! */ | ||||
| for (int i = 0; i < tc->data_len; i++, tfd++) { | for (int i = 0; i < tc->data->elem_len; i++, tfd++) { | ||||
| *(tfd->sdata) = round_fl_to_int(tfd->val); | *(tfd->sdata) = round_fl_to_int(tfd->val); | ||||
| } | } | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||