[Bf-blender-cvs] [c1fe5824464] master: Cleanup: move snap with projection check into a function

Campbell Barton noreply at git.blender.org
Sat Jun 26 09:08:12 CEST 2021


Commit: c1fe58244646c7ecc58fba1bdbf7c511750b14c9
Author: Campbell Barton
Date:   Sat Jun 26 16:57:03 2021 +1000
Branches: master
https://developer.blender.org/rBc1fe58244646c7ecc58fba1bdbf7c511750b14c9

Cleanup: move snap with projection check into a function

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

M	source/blender/editors/transform/transform_snap.c
M	source/blender/editors/transform/transform_snap.h

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

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);



More information about the Bf-blender-cvs mailing list