Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/transform/transform.c')
-rw-r--r--source/blender/editors/transform/transform.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 28b0d9711cc..34314e7ff3d 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2038,6 +2038,35 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
}
+static void initSnappingAspect(TransInfo *t)
+{
+ if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION)) {
+ if (t->options & CTX_MASK) {
+ ED_space_image_get_aspect(t->sa->spacedata.first, t->snap_aspect, t->snap_aspect + 1);
+ }
+ else if (t->options & CTX_PAINT_CURVE) {
+ t->snap_aspect[0] = t->snap_aspect[1] = 1.0;
+ }
+ else {
+ ED_space_image_get_uv_aspect(t->sa->spacedata.first, t->snap_aspect, t->snap_aspect + 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, t->snap_aspect, t->snap_aspect + 1);
+ UI_view2d_grid_free(grid);
+ }
+}
+
+
/* note: caller needs to free 't' on a 0 return */
bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event, int mode)
{
@@ -2123,6 +2152,11 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
else
unit_m3(t->spacemtx);
+ /* initialize snapping factors */
+ t->snap_aspect[0] = t->snap_aspect[1] = t->snap_aspect[2] = 1.0f;
+
+ initSnappingAspect(t);
+
createTransData(C, t); // make TransData structs from selection
if (t->total == 0) {