[Bf-blender-cvs] [10428ca4728] master: Cleanup: reduce indentation

Campbell Barton noreply at git.blender.org
Tue Jul 13 14:15:55 CEST 2021


Commit: 10428ca4728265649b7666a79c49518723398f73
Author: Campbell Barton
Date:   Tue Jul 13 22:11:57 2021 +1000
Branches: master
https://developer.blender.org/rB10428ca4728265649b7666a79c49518723398f73

Cleanup: reduce indentation

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

M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/object/object_transform.c
M	source/blender/editors/space_view3d/view3d_snap.c

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

diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 5d3e9e42f29..0e45970a165 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -803,93 +803,95 @@ static bool ui_afterfunc_check(const uiBlock *block, const uiBut *but)
           (block->handle && block->handle->popup_op));
 }
 
+/**
+ * These functions are postponed and only executed after all other
+ * handling is done, i.e. menus are closed, in order to avoid conflicts
+ * with these functions removing the buttons we are working with.
+ */
 static void ui_apply_but_func(bContext *C, uiBut *but)
 {
   uiBlock *block = but->block;
+  if (!ui_afterfunc_check(block, but)) {
+    return;
+  }
 
-  /* these functions are postponed and only executed after all other
-   * handling is done, i.e. menus are closed, in order to avoid conflicts
-   * with these functions removing the buttons we are working with */
-
-  if (ui_afterfunc_check(block, but)) {
-    uiAfterFunc *after = ui_afterfunc_new();
-
-    if (but->func && ELEM(but, but->func_arg1, but->func_arg2)) {
-      /* exception, this will crash due to removed button otherwise */
-      but->func(C, but->func_arg1, but->func_arg2);
-    }
-    else {
-      after->func = but->func;
-    }
+  uiAfterFunc *after = ui_afterfunc_new();
 
-    after->func_arg1 = but->func_arg1;
-    after->func_arg2 = but->func_arg2;
+  if (but->func && ELEM(but, but->func_arg1, but->func_arg2)) {
+    /* exception, this will crash due to removed button otherwise */
+    but->func(C, but->func_arg1, but->func_arg2);
+  }
+  else {
+    after->func = but->func;
+  }
 
-    after->funcN = but->funcN;
-    after->func_argN = (but->func_argN) ? MEM_dupallocN(but->func_argN) : NULL;
+  after->func_arg1 = but->func_arg1;
+  after->func_arg2 = but->func_arg2;
 
-    after->rename_func = but->rename_func;
-    after->rename_arg1 = but->rename_arg1;
-    after->rename_orig = but->rename_orig; /* needs free! */
+  after->funcN = but->funcN;
+  after->func_argN = (but->func_argN) ? MEM_dupallocN(but->func_argN) : NULL;
 
-    after->handle_func = block->handle_func;
-    after->handle_func_arg = block->handle_func_arg;
-    after->retval = but->retval;
+  after->rename_func = but->rename_func;
+  after->rename_arg1 = but->rename_arg1;
+  after->rename_orig = but->rename_orig; /* needs free! */
 
-    if (but->type == UI_BTYPE_BUT_MENU) {
-      after->butm_func = block->butm_func;
-      after->butm_func_arg = block->butm_func_arg;
-      after->a2 = but->a2;
-    }
+  after->handle_func = block->handle_func;
+  after->handle_func_arg = block->handle_func_arg;
+  after->retval = but->retval;
 
-    if (block->handle) {
-      after->popup_op = block->handle->popup_op;
-    }
+  if (but->type == UI_BTYPE_BUT_MENU) {
+    after->butm_func = block->butm_func;
+    after->butm_func_arg = block->butm_func_arg;
+    after->a2 = but->a2;
+  }
 
-    after->optype = but->optype;
-    after->opcontext = but->opcontext;
-    after->opptr = but->opptr;
+  if (block->handle) {
+    after->popup_op = block->handle->popup_op;
+  }
 
-    after->rnapoin = but->rnapoin;
-    after->rnaprop = but->rnaprop;
+  after->optype = but->optype;
+  after->opcontext = but->opcontext;
+  after->opptr = but->opptr;
 
-    if (but->type == UI_BTYPE_SEARCH_MENU) {
-      uiButSearch *search_but = (uiButSearch *)but;
-      after->search_arg_free_fn = search_but->arg_free_fn;
-      after->search_arg = search_but->arg;
-      search_but->arg_free_fn = NULL;
-      search_but->arg = NULL;
-    }
+  after->rnapoin = but->rnapoin;
+  after->rnaprop = but->rnaprop;
 
-    if (but->active != NULL) {
-      uiHandleButtonData *data = but->active;
-      if (data->custom_interaction_handle != NULL) {
-        after->custom_interaction_callbacks = block->custom_interaction_callbacks;
-        after->custom_interaction_handle = data->custom_interaction_handle;
+  if (but->type == UI_BTYPE_SEARCH_MENU) {
+    uiButSearch *search_but = (uiButSearch *)but;
+    after->search_arg_free_fn = search_but->arg_free_fn;
+    after->search_arg = search_but->arg;
+    search_but->arg_free_fn = NULL;
+    search_but->arg = NULL;
+  }
 
-        /* Ensure this callback runs once and last. */
-        uiAfterFunc *after_prev = after->prev;
-        if (after_prev &&
-            (after_prev->custom_interaction_handle == data->custom_interaction_handle)) {
-          after_prev->custom_interaction_handle = NULL;
-          memset(&after_prev->custom_interaction_callbacks,
-                 0x0,
-                 sizeof(after_prev->custom_interaction_callbacks));
-        }
-        else {
-          after->custom_interaction_handle->user_count++;
-        }
+  if (but->active != NULL) {
+    uiHandleButtonData *data = but->active;
+    if (data->custom_interaction_handle != NULL) {
+      after->custom_interaction_callbacks = block->custom_interaction_callbacks;
+      after->custom_interaction_handle = data->custom_interaction_handle;
+
+      /* Ensure this callback runs once and last. */
+      uiAfterFunc *after_prev = after->prev;
+      if (after_prev &&
+          (after_prev->custom_interaction_handle == data->custom_interaction_handle)) {
+        after_prev->custom_interaction_handle = NULL;
+        memset(&after_prev->custom_interaction_callbacks,
+               0x0,
+               sizeof(after_prev->custom_interaction_callbacks));
+      }
+      else {
+        after->custom_interaction_handle->user_count++;
       }
     }
+  }
 
-    if (but->context) {
-      after->context = CTX_store_copy(but->context);
-    }
-
-    but->optype = NULL;
-    but->opcontext = 0;
-    but->opptr = NULL;
+  if (but->context) {
+    after->context = CTX_store_copy(but->context);
   }
+
+  but->optype = NULL;
+  but->opcontext = 0;
+  but->opptr = NULL;
 }
 
 /* typically call ui_apply_but_undo(), ui_apply_but_autokey() */
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 86871a02a72..4c4727f51ee 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -1152,336 +1152,337 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
 
   for (int object_index = 0; object_index < num_objects; object_index++) {
     Object *ob = objects[object_index];
+    if (ob->flag & OB_DONE) {
+      continue;
+    }
 
-    if ((ob->flag & OB_DONE) == 0) {
-      bool do_inverse_offset = false;
-      ob->flag |= OB_DONE;
-
-      if (centermode == ORIGIN_TO_CURSOR) {
-        copy_v3_v3(cent, cursor);
-        invert_m4_m4(ob->imat, ob->obmat);
-        mul_m4_v3(ob->imat, cent);
-      }
+    bool do_inverse_offset = false;
+    ob->flag |= OB_DONE;
 
-      if (ob->data == NULL) {
-        /* special support for dupligroups */
-        if ((ob->transflag & OB_DUPLICOLLECTION) && ob->instance_collection &&
-            (ob->instance_collection->id.tag & LIB_TAG_DOIT) == 0) {
-          if (ID_IS_LINKED(ob->instance_collection)) {
-            tot_lib_error++;
-          }
-          else {
-            if (centermode == ORIGIN_TO_CURSOR) {
-              /* done */
-            }
-            else {
-              float min[3], max[3];
-              /* only bounds support */
-              INIT_MINMAX(min, max);
-              BKE_object_minmax_dupli(depsgraph, scene, ob, min, max, true);
-              mid_v3_v3v3(cent, min, max);
-              invert_m4_m4(ob->imat, ob->obmat);
-              mul_m4_v3(ob->imat, cent);
-            }
-
-            add_v3_v3(ob->instance_collection->instance_offset, cent);
+    if (centermode == ORIGIN_TO_CURSOR) {
+      copy_v3_v3(cent, cursor);
+      invert_m4_m4(ob->imat, ob->obmat);
+      mul_m4_v3(ob->imat, cent);
+    }
 
-            tot_change++;
-            ob->instance_collection->id.tag |= LIB_TAG_DOIT;
-            do_inverse_offset = true;
-          }
+    if (ob->data == NULL) {
+      /* special support for dupligroups */
+      if ((ob->transflag & OB_DUPLICOLLECTION) && ob->instance_collection &&
+          (ob->instance_collection->id.tag & LIB_TAG_DOIT) == 0) {
+        if (ID_IS_LINKED(ob->instance_collection)) {
+          tot_lib_error++;
         }
-      }
-      else if (ID_IS_LINKED(ob->data)) {
-        tot_lib_error++;
-      }
-      else if (ob->type == OB_MESH) {
-        if (obedit == NULL) {
-          Mesh *me = ob->data;
-
+        else {
           if (centermode == ORIGIN_TO_CURSOR) {
             /* done */
           }
-          else if (centermode == ORIGIN_TO_CENTER_OF_MASS_SURFACE) {
-            BKE_mesh_center_of_surface(me, cent);
-          }
-          else if (centermode == ORIGIN_TO_CENTER_OF_MASS_VOLUME) {
-            BKE_mesh_center_of_volume(me, cent);
-          }
-          else if (around == V3D_AROUND_CENTER_BOUNDS) {
-            BKE_mesh_center_bounds(me, cent);
-          }
-          else { /* #V3D_AROUND_CENTER_MEDIAN. */
-            BKE_mesh_center_median(me, cent);
+          else {
+            float min[3], max[3];
+            /* only bounds support */
+            INIT_MINMAX(min, max);
+            BKE_object_minmax_dupli(depsgraph, scene, ob, min, max, true);
+            mid_v3_v3v3(cent, min, max);
+            invert_m4_m4(ob->imat, ob->obmat);
+            mul_m4_v3(ob->imat, cent);
           }
 
-          negate_v3_v3(cent_neg, cent);
-          BKE_mesh_translate(me, cent_neg, 1);
+          add_v3_v3(ob->instance_collection->instance_offset, cent);
 
           tot_change++;
-          me->id.tag |= LIB_TAG_DOIT;
+          ob->instance_collection->id.tag |= LIB_TAG_DOIT;
           do_inverse_offset = true;
         }
       }
-      else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
-        Curve *cu = ob->data;
+    }
+    else if (ID_IS_LINKED(ob->data)) {
+      tot_lib_error++;
+    }
+    else if (ob->type == OB_MESH) {
+      if (obedit == NULL) {
+        Mesh *me = ob->data;
 
         if (centermode == ORIGIN_TO_CURSOR) {
           /* done */
         }
+        else if (centermode == ORIGIN_TO_CENTER_OF_MASS_SURFACE) {
+        

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list