Commit: 119d53263f0d0dc5474cb36e888dbdd48a64f9c6 Author: Germano Cavalcante Date: Thu Aug 19 10:23:35 2021 -0300 Branches: master https://developer.blender.org/rB119d53263f0d0dc5474cb36e888dbdd48a64f9c6
Transform Convert Action: conventionalize TransData creation `td2d->loc`, `td2d->loc2d`, `td->loc` and `td->iloc` were not being initialized as is done with the other conversion types. This avoids problems with transform modes becoming incompatible. This avoids problems with incompatible transform modes that could result in a crash. =================================================================== M source/blender/editors/transform/transform_convert_action.c =================================================================== diff --git a/source/blender/editors/transform/transform_convert_action.c b/source/blender/editors/transform/transform_convert_action.c index cfa14e21d0d..30cb9fa20e5 100644 --- a/source/blender/editors/transform/transform_convert_action.c +++ b/source/blender/editors/transform/transform_convert_action.c @@ -140,19 +140,37 @@ static int count_masklayer_frames(MaskLayer *masklay, char side, float cfra, boo } /* This function assigns the information to transdata */ -static void TimeToTransData(TransData *td, float *time, AnimData *adt, float ypos) +static void TimeToTransData( + TransData *td, TransData2D *td2d, BezTriple *bezt, AnimData *adt, float ypos) { - /* memory is calloc'ed, so that should zero everything nicely for us */ + float *time = bezt->vec[1]; + + /* Setup #TransData2D. */ + td2d->loc[0] = *time; + td2d->loc2d = time; + td2d->h1 = bezt->vec[0]; + td2d->h2 = bezt->vec[2]; + copy_v2_v2(td2d->ih1, td2d->h1); + copy_v2_v2(td2d->ih2, td2d->h2); + + /* Setup #TransData. */ + td->loc = time; /* Usually #td2d->loc is used here. But this is for when the original location is + not float[3]. */ td->val = time; - td->ival = *(time); - + td->ival = td->iloc[0] = *(time); td->center[0] = td->ival; td->center[1] = ypos; - /* store the AnimData where this keyframe exists as a keyframe of the - * active action as td->extra. - */ + /* Store the AnimData where this keyframe exists as a keyframe of the + * active action as #td->extra. */ td->extra = adt; + + if (bezt->f2 & SELECT) { + td->flag |= TD_SELECTED; + } + + /* Set flags to move handles as necessary. */ + td->flag |= TD_MOVEHANDLE1 | TD_MOVEHANDLE2; } /* This function advances the address to which td points to, so it must return @@ -185,19 +203,7 @@ static TransData *ActionFCurveToTransData(TransData *td, * so can't use BEZT_ISSEL_ANY() macro */ /* 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; - } - - /* Set flags to move handles as necessary. */ - 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); + TimeToTransData(td, td2d, bezt, adt, ypos); td++; td2d++; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs