Commit: 638368a9307b8702b22bd1e778096f00b5b90d4b
Author: Bastien Montagne
Date:   Thu Mar 19 20:47:38 2015 +0100
Branches: blender-v2.74-release
https://developer.blender.org/rB638368a9307b8702b22bd1e778096f00b5b90d4b

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.

===================================================================

M       source/blender/editors/transform/transform.c
M       source/blender/editors/transform/transform.h
M       source/blender/editors/transform/transform_snap.c

===================================================================

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index 061d004..a014be4 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -7307,40 +7307,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];
@@ -7348,7 +7336,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);
        }
@@ -7357,7 +7344,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);
 
diff --git a/source/blender/editors/transform/transform.h 
b/source/blender/editors/transform/transform.h
index 8d6c693..97cc6dd 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -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);
diff --git a/source/blender/editors/transform/transform_snap.c 
b/source/blender/editors/transform/transform_snap.c
index 4a2927a..1f2a06a 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -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)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to