diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-11-20 19:44:47 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-11-20 19:44:47 +0300 |
commit | 4bf40bb6462c29816b2de4b2221f882e7af63fec (patch) | |
tree | 2635be88ed8674f6a015df2464a197802350fbc5 /source | |
parent | 2f43befed93ed50faaeb800e3790c31a21fb5632 (diff) |
Fix T42660 snapping not working nicely on graph editor.
Basically, get the grid increments and reuse them when snapping. System
is slightly crappy here, we should calculate those factors only once,
but leaving as todo for later.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/transform/transform.c | 5 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 9547f0bc77f..ca971281420 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4061,6 +4061,11 @@ static void initTranslation(TransInfo *t) t->snap[1] = ED_node_grid_size() * NODE_GRID_STEPS; t->snap[2] = ED_node_grid_size(); } + else if (t->spacetype == SPACE_IPO) { + t->snap[0] = 0.0f; + t->snap[1] = 1.0; + t->snap[2] = 0.1f; + } else { t->snap[0] = 0.0f; t->snap[1] = t->snap[2] = 1.0f; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index cd636591212..92c9c55ac64 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -2457,6 +2457,19 @@ static void applyGridIncrement(TransInfo *t, float *val, int max_index, const fl ED_space_image_get_uv_aspect(t->sa->spacedata.first, asp, asp + 1); } } + else if ((t->spacetype == SPACE_IPO) && (t->mode == TFM_TRANSLATION)) { + View2D *v2d = &t->ar->v2d; + View2DGrid *grid; + SpaceIpo *sipo = t->sa->spacedata.first; + int unity = V2D_UNIT_VALUES; + int unitx = (sipo->flag & SIPO_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMESCALE; + + /* grid */ + grid = UI_view2d_grid_calc(t->scene, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, t->ar->winx, t->ar->winy); + + UI_view2d_grid_size(grid, &asp[0], &asp[1]); + UI_view2d_grid_free(grid); + } for (i = 0; i <= max_index; i++) { val[i] = fac[action] * asp[i] * floorf(val[i] / (fac[action] * asp[i]) + 0.5f); |