diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-04 04:50:12 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-04 05:04:23 +0300 |
commit | a4530f59d2151ee56c58fdab8e1e202b612fe42e (patch) | |
tree | 11c3ae568fa7d7de82a64598596c6d6752e4d554 /source | |
parent | e30f32b5a3409f689a3f1ece73f87741ad73ddf8 (diff) |
Transform: support for 2D cursor editing
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 1676260d231..571608ac21d 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -345,7 +345,40 @@ static void createTransTexspace(TransInfo *t) copy_v3_v3(td->ext->isize, td->ext->size); } -static void createTransCursor3D(TransInfo *t) +/* -------------------------------------------------------------------- */ +/** \name Cursor Transform Creation + * + * Instead of transforming the selection, move the 2D/3D cursor. + * + * \{ */ + +static void createTransCursor_image(TransInfo *t) +{ + TransData *td; + SpaceImage *sima = t->sa->spacedata.first; + float *cursor_location = sima->cursor; + + { + BLI_assert(t->data_container_len == 1); + TransDataContainer *tc = t->data_container; + tc->data_len = 1; + td = tc->data = MEM_callocN(sizeof(TransData), "TransTexspace"); + td->ext = tc->data_ext = MEM_callocN(sizeof(TransDataExtension), "TransTexspace"); + } + + td->flag = TD_SELECTED; + copy_v3_v3(td->center, cursor_location); + td->ob = NULL; + + unit_m3(td->mtx); + unit_m3(td->axismtx); + pseudoinverse_m3_m3(td->smtx, td->mtx, PSEUDOINVERSE_EPSILON); + + td->loc = cursor_location; + copy_v3_v3(td->iloc, cursor_location); +} + +static void createTransCursor_view3d(TransInfo *t) { TransData *td; @@ -382,6 +415,8 @@ static void createTransCursor3D(TransInfo *t) copy_qt_qt(td->ext->iquat, cursor->rotation); } +/** \} */ + /* ********************* edge (for crease) ***** */ static void createTransEdge(TransInfo *t) @@ -8418,7 +8453,12 @@ void createTransData(bContext *C, TransInfo *t) t->flag |= T_CURSOR; t->obedit_type = -1; - createTransCursor3D(t); + if (t->spacetype == SPACE_IMAGE) { + createTransCursor_image(t); + } + else { + createTransCursor_view3d(t); + } countAndCleanTransDataContainer(t); } else if (t->options & CTX_TEXTURE) { |