diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-06-26 09:57:03 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-06-26 09:57:03 +0300 |
commit | c1fe58244646c7ecc58fba1bdbf7c511750b14c9 (patch) | |
tree | 1af2cab3aadecb153b5943f9f6400a9c03215bc0 /source/blender/editors | |
parent | a287c8d3c160ba448424905a201c75fd97f9182a (diff) |
Cleanup: move snap with projection check into a function
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 29 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.h | 2 |
2 files changed, 22 insertions, 9 deletions
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index bebef049718..4ecb9594325 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -61,6 +61,8 @@ #include "transform_convert.h" #include "transform_snap.h" +static bool doForceIncrementSnap(const TransInfo *t); + /* this should be passed as an arg for use in snap functions */ #undef BASACT @@ -133,6 +135,23 @@ bool activeSnap(const TransInfo *t) ((t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT); } +bool activeSnap_with_project(const TransInfo *t) +{ + if (!t->tsnap.project) { + return false; + } + + if (!activeSnap(t) || (t->flag & T_NO_PROJECT)) { + return false; + } + + if (doForceIncrementSnap(t)) { + return false; + } + + return true; +} + bool transformModeUseSnap(const TransInfo *t) { ToolSettings *ts = t->settings; @@ -299,15 +318,7 @@ eRedrawFlag handleSnapping(TransInfo *t, const wmEvent *event) void applyProject(TransInfo *t) { - if (!t->tsnap.project) { - return; - } - - if (!activeSnap(t) || (t->flag & T_NO_PROJECT)) { - return; - } - - if (doForceIncrementSnap(t)) { + if (!activeSnap_with_project(t)) { return; } diff --git a/source/blender/editors/transform/transform_snap.h b/source/blender/editors/transform/transform_snap.h index c557368ed17..1632b49fbbf 100644 --- a/source/blender/editors/transform/transform_snap.h +++ b/source/blender/editors/transform/transform_snap.h @@ -61,6 +61,8 @@ bool transform_snap_grid(TransInfo *t, float *val); void snapSequenceBounds(TransInfo *t, const int mval[2]); bool activeSnap(const TransInfo *t); +bool activeSnap_with_project(const TransInfo *t); + bool validSnap(const TransInfo *t); void initSnapping(struct TransInfo *t, struct wmOperator *op); |