diff options
Diffstat (limited to 'source/blender/editors/transform/transform.c')
-rw-r--r-- | source/blender/editors/transform/transform.c | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 6e9820ba57c..ccd57db5959 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -105,6 +105,7 @@ static void len_v3_ensure(float v[3], const float length); static void postInputRotation(TransInfo *t, float values[3]); static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short around); +static void initSnapSpatial(TransInfo *t, float r_snap[3]); /* Transform Callbacks */ @@ -2130,6 +2131,8 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve initSnapping(t, op); // Initialize snapping data AFTER mode flags + initSnapSpatial(t, t->snap_spatial); + /* EVIL! posemode code can switch translation to rotate when 1 bone is selected. will be removed (ton) */ /* EVIL2: we gave as argument also texture space context bit... was cleared */ /* EVIL3: extend mode for animation editors also switches modes... but is best way to avoid duplicate code */ @@ -4080,6 +4083,38 @@ static void applyTrackball(TransInfo *t, const int UNUSED(mval[2])) /* -------------------------------------------------------------------- */ /* Transform (Translation) */ +static void initSnapSpatial(TransInfo *t, float r_snap[3]) +{ + if (t->spacetype == SPACE_VIEW3D) { + RegionView3D *rv3d = t->ar->regiondata; + + if (rv3d) { + r_snap[0] = 0.0f; + r_snap[1] = rv3d->gridview * 1.0f; + r_snap[2] = r_snap[1] * 0.1f; + } + } + else if (ELEM(t->spacetype, SPACE_IMAGE, SPACE_CLIP)) { + r_snap[0] = 0.0f; + r_snap[1] = 0.125f; + r_snap[2] = 0.0625f; + } + else if (t->spacetype == SPACE_NODE) { + r_snap[0] = 0.0f; + r_snap[1] = ED_node_grid_size(); + r_snap[2] = ED_node_grid_size(); + } + else if (t->spacetype == SPACE_IPO) { + r_snap[0] = 0.0f; + r_snap[1] = 1.0; + r_snap[2] = 0.1f; + } + else { + r_snap[0] = 0.0f; + r_snap[1] = r_snap[2] = 1.0f; + } +} + /** \name Transform Translation * \{ */ @@ -4102,34 +4137,7 @@ static void initTranslation(TransInfo *t) t->num.flag = 0; t->num.idx_max = t->idx_max; - if (t->spacetype == SPACE_VIEW3D) { - RegionView3D *rv3d = t->ar->regiondata; - - if (rv3d) { - t->snap[0] = 0.0f; - t->snap[1] = rv3d->gridview * 1.0f; - t->snap[2] = t->snap[1] * 0.1f; - } - } - else if (ELEM(t->spacetype, SPACE_IMAGE, SPACE_CLIP)) { - t->snap[0] = 0.0f; - t->snap[1] = 0.125f; - t->snap[2] = 0.0625f; - } - else if (t->spacetype == SPACE_NODE) { - t->snap[0] = 0.0f; - t->snap[1] = ED_node_grid_size(); - 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; - } + copy_v3_v3(t->snap, t->snap_spatial); copy_v3_fl(t->num.val_inc, t->snap[1]); t->num.unit_sys = t->scene->unit.system; |