[Bf-blender-cvs] [4bf40bb] master: Fix T42660 snapping not working nicely on graph editor.

Antony Riakiotakis noreply at git.blender.org
Thu Nov 20 17:45:01 CET 2014


Commit: 4bf40bb6462c29816b2de4b2221f882e7af63fec
Author: Antony Riakiotakis
Date:   Thu Nov 20 17:44:47 2014 +0100
Branches: master
https://developer.blender.org/rB4bf40bb6462c29816b2de4b2221f882e7af63fec

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.

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

M	source/blender/editors/transform/transform.c
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 9547f0b..ca97128 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 cd63659..92c9c55 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);




More information about the Bf-blender-cvs mailing list