Fix T43989: Sequencer - Ctrl snapping a sequencer strip does not work if you specify the x axis.
New 'strip' snapping was simply not computed in case of constrained transform, hence init '0' value was used as frame offset in this case. This commit reorganizes a bit that snapping, to keep it more 'confined' into `snapSequenceBounds()` dedicated function. It still needs a minor hack (setting snapping mode to something else than defualt `SCE_SNAP_MODE_INCREMENT`, to avoid this snapping to be called by contraint code). Thanks to Antony for review and enhancements. This fix should be backported to 2.74.
This commit is contained in:
parent
ea12b87afd
commit
05e3c261a4
Notes:
blender-bot
2023-02-14 11:08:33 +01:00
Referenced by issue #43989, Sequencer - Ctrl snapping a sequencer strip does not work if you specify the x axis
|
@ -7311,40 +7311,28 @@ static void headerSeqSlide(TransInfo *t, const float val[2], char str[MAX_INFO_L
|
|||
WM_bool_as_string((t->flag & T_ALT_TRANSFORM) != 0));
|
||||
}
|
||||
|
||||
static void applySeqSlideValue(TransInfo *t, const float val[2], int frame)
|
||||
static void applySeqSlideValue(TransInfo *t, const float val[2])
|
||||
{
|
||||
TransData *td = t->data;
|
||||
int i;
|
||||
TransSeq *ts = t->customData;
|
||||
|
||||
for (i = 0; i < t->total; i++, td++) {
|
||||
float tvec[2];
|
||||
|
||||
if (td->flag & TD_NOACTION)
|
||||
break;
|
||||
|
||||
if (td->flag & TD_SKIP)
|
||||
continue;
|
||||
|
||||
copy_v2_v2(tvec, val);
|
||||
|
||||
mul_v2_fl(tvec, td->factor);
|
||||
|
||||
if (t->modifiers & MOD_SNAP_INVERT) {
|
||||
td->loc[0] = frame + td->factor * (td->iloc[0] - ts->min);
|
||||
}
|
||||
else {
|
||||
td->loc[0] = td->iloc[0] + tvec[0];
|
||||
}
|
||||
|
||||
td->loc[1] = td->iloc[1] + tvec[1];
|
||||
madd_v2_v2v2fl(td->loc, td->iloc, val, td->factor);
|
||||
}
|
||||
}
|
||||
|
||||
static void applySeqSlide(TransInfo *t, const int mval[2])
|
||||
{
|
||||
char str[MAX_INFO_LEN];
|
||||
int snap_frame = 0;
|
||||
|
||||
snapSequenceBounds(t, mval);
|
||||
|
||||
if (t->con.mode & CON_APPLY) {
|
||||
float pvec[3] = {0.0f, 0.0f, 0.0f};
|
||||
float tvec[3];
|
||||
|
@ -7352,7 +7340,6 @@ static void applySeqSlide(TransInfo *t, const int mval[2])
|
|||
copy_v3_v3(t->values, tvec);
|
||||
}
|
||||
else {
|
||||
snap_frame = snapSequenceBounds(t, mval);
|
||||
// snapGridIncrement(t, t->values);
|
||||
applyNumInput(&t->num, t->values);
|
||||
}
|
||||
|
@ -7361,7 +7348,7 @@ static void applySeqSlide(TransInfo *t, const int mval[2])
|
|||
t->values[1] = floor(t->values[1] + 0.5f);
|
||||
|
||||
headerSeqSlide(t, t->values, str);
|
||||
applySeqSlideValue(t, t->values, snap_frame);
|
||||
applySeqSlideValue(t, t->values);
|
||||
|
||||
recalcData(t);
|
||||
|
||||
|
|
|
@ -626,7 +626,7 @@ typedef enum {
|
|||
void snapGridIncrement(TransInfo *t, float *val);
|
||||
void snapGridIncrementAction(TransInfo *t, float *val, GearsType action);
|
||||
|
||||
int snapSequenceBounds(TransInfo *t, const int mval[2]);
|
||||
void snapSequenceBounds(TransInfo *t, const int mval[2]);
|
||||
|
||||
bool activeSnap(TransInfo *t);
|
||||
bool validSnap(TransInfo *t);
|
||||
|
|
|
@ -577,6 +577,10 @@ static void initSnappingMode(TransInfo *t)
|
|||
t->tsnap.mode = SCE_SNAP_MODE_INCREMENT;
|
||||
}
|
||||
}
|
||||
else if (t->spacetype == SPACE_SEQ) {
|
||||
/* We do our own snapping currently, so nothing here */
|
||||
t->tsnap.mode = SCE_SNAP_MODE_GRID; /* Dummy, should we rather add a NOP mode? */
|
||||
}
|
||||
else {
|
||||
/* Always grid outside of 3D view */
|
||||
t->tsnap.mode = SCE_SNAP_MODE_INCREMENT;
|
||||
|
@ -2431,15 +2435,16 @@ void snapGridIncrement(TransInfo *t, float *val)
|
|||
snapGridIncrementAction(t, val, action);
|
||||
}
|
||||
|
||||
int snapSequenceBounds(TransInfo *t, const int mval[2])
|
||||
void snapSequenceBounds(TransInfo *t, const int mval[2])
|
||||
{
|
||||
float xmouse, ymouse;
|
||||
int frame;
|
||||
int mframe;
|
||||
TransData *td = t->data;
|
||||
TransSeq *ts = t->customData;
|
||||
/* reuse increment, strictly speaking could be another snap mode, but leave as is */
|
||||
if (!(t->modifiers & MOD_SNAP_INVERT))
|
||||
return 0;
|
||||
return;
|
||||
|
||||
/* convert to frame range */
|
||||
UI_view2d_region_to_view(&t->ar->v2d, mval[0], mval[1], &xmouse, &ymouse);
|
||||
|
@ -2450,7 +2455,7 @@ int snapSequenceBounds(TransInfo *t, const int mval[2])
|
|||
if (!ts->snap_left)
|
||||
frame = frame - (ts->max - ts->min);
|
||||
|
||||
return frame;
|
||||
t->values[0] = frame - ts->min;
|
||||
}
|
||||
|
||||
static void applyGridIncrement(TransInfo *t, float *val, int max_index, const float fac[3], GearsType action)
|
||||
|
|
Loading…
Reference in New Issue