[Bf-blender-cvs] [c6b4bd407ef] master: Cleanup: deduplicate conditions in transform code

Germano Cavalcante noreply at git.blender.org
Tue Jan 10 13:36:10 CET 2023


Commit: c6b4bd407ef1068ba201c49d971213e5d6785e59
Author: Germano Cavalcante
Date:   Tue Jan 10 09:35:59 2023 -0300
Branches: master
https://developer.blender.org/rBc6b4bd407ef1068ba201c49d971213e5d6785e59

Cleanup: deduplicate conditions in transform code

The `t->spacetype` check is already done in `setSnappingCallback`.

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

M	source/blender/editors/transform/transform_snap.cc

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

diff --git a/source/blender/editors/transform/transform_snap.cc b/source/blender/editors/transform/transform_snap.cc
index 0eebe05fa0c..00ccf1ed632 100644
--- a/source/blender/editors/transform/transform_snap.cc
+++ b/source/blender/editors/transform/transform_snap.cc
@@ -741,12 +741,7 @@ static void initSnappingMode(TransInfo *t)
     t->tsnap.project = false;
   }
 
-  if (ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE, SPACE_SEQ)) {
-    /* Not with camera selected in camera view. */
-    if (!(t->options & CTX_CAMERA)) {
-      setSnappingCallback(t);
-    }
-  }
+  setSnappingCallback(t);
 
   if (t->spacetype == SPACE_VIEW3D) {
     if (t->tsnap.object_context == nullptr) {
@@ -903,6 +898,10 @@ void freeSnapping(TransInfo *t)
 static void setSnappingCallback(TransInfo *t)
 {
   if (t->spacetype == SPACE_VIEW3D) {
+    if (t->options & CTX_CAMERA) {
+      /* Not with camera selected in camera view. */
+      return;
+    }
     t->tsnap.calcSnap = snap_calc_view3d_fn;
   }
   else if (t->spacetype == SPACE_IMAGE) {
@@ -924,6 +923,9 @@ static void setSnappingCallback(TransInfo *t)
     /* The target is calculated along with the snap point. */
     return;
   }
+  else {
+    return;
+  }
 
   switch (t->tsnap.source_select) {
     case SCE_SNAP_SOURCE_CLOSEST:



More information about the Bf-blender-cvs mailing list