use min_ii/max_ii over MIN2 MAX2
authorCampbell Barton <ideasman42@gmail.com>
Wed, 24 Oct 2012 05:06:40 +0000 (05:06 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 24 Oct 2012 05:06:40 +0000 (05:06 +0000)
source/blender/blenlib/intern/BLI_kdopbvh.c
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/screen/area.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/space_info/textview.c
source/blender/editors/transform/transform_constraints.c
source/blender/windowmanager/intern/wm_operators.c

index dd4b1e524ecf751694c3782e79dceeb11076e639..a44b694bdf461fa6f91c8ce53cb671b6604ebf31 100644 (file)
@@ -724,7 +724,7 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array,
        /* Loop tree levels (log N) loops */
        for (i = 1, depth = 1; i <= num_branches; i = i * tree_type + tree_offset, depth++) {
                const int first_of_next_level = i * tree_type + tree_offset;
-               const int end_j = MIN2(first_of_next_level, num_branches + 1);  /* index of last branch on this level */
+               const int end_j = min_ii(first_of_next_level, num_branches + 1);  /* index of last branch on this level */
                int j;
 
                /* Loop all branches on this level */
@@ -1080,7 +1080,9 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int
                return NULL;
        
        /* fast check root nodes for collision before doing big splitting + traversal */
-       if (!tree_overlap(tree1->nodes[tree1->totleaf], tree2->nodes[tree2->totleaf], MIN2(tree1->start_axis, tree2->start_axis), MIN2(tree1->stop_axis, tree2->stop_axis)))
+       if (!tree_overlap(tree1->nodes[tree1->totleaf], tree2->nodes[tree2->totleaf],
+                         min_ii(tree1->start_axis, tree2->start_axis),
+                         min_ii(tree1->stop_axis, tree2->stop_axis)))
                return NULL;
 
        data = MEM_callocN(sizeof(BVHOverlapData *) * tree1->tree_type, "BVHOverlapData_star");
@@ -1094,8 +1096,8 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int
                data[j]->tree2 = tree2;
                data[j]->max_overlap = MAX2(tree1->totleaf, tree2->totleaf);
                data[j]->i = 0;
-               data[j]->start_axis = MIN2(tree1->start_axis, tree2->start_axis);
-               data[j]->stop_axis  = MIN2(tree1->stop_axis,  tree2->stop_axis);
+               data[j]->start_axis = min_ii(tree1->start_axis, tree2->start_axis);
+               data[j]->stop_axis  = min_ii(tree1->stop_axis,  tree2->stop_axis);
        }
 
 #pragma omp parallel for private(j) schedule(static)
index 6374314e4bb4654340581f1fed0b0c6172541b2d..1b88a60b741c464b4c4ed8665b4410f9aa3ae728 100644 (file)
@@ -1303,7 +1303,7 @@ void ui_get_but_vectorf(uiBut *but, float vec[3])
 
                if (RNA_property_type(prop) == PROP_FLOAT) {
                        tot = RNA_property_array_length(&but->rnapoin, prop);
-                       tot = MIN2(tot, 3);
+                       tot = min_ii(tot, 3);
 
                        for (a = 0; a < tot; a++)
                                vec[a] = RNA_property_float_get_index(&but->rnapoin, prop, a);
@@ -1348,7 +1348,7 @@ void ui_set_but_vectorf(uiBut *but, const float vec[3])
                        int a;
 
                        tot = RNA_property_array_length(&but->rnapoin, prop);
-                       tot = MIN2(tot, 3);
+                       tot = min_ii(tot, 3);
 
                        for (a = 0; a < tot; a++) {
                                RNA_property_float_set_index(&but->rnapoin, prop, a, vec[a]);
index 9fac19031de6e17d84b1dbec3529b4cbc216d8e6..96e089ee151c89e70bc458f95691d933b95ef7db 100644 (file)
@@ -41,6 +41,7 @@
 #include "BLI_string.h"
 #include "BLI_rect.h"
 #include "BLI_utildefines.h"
+#include "BLI_math.h"
 
 #include "BLF_translation.h"
 
@@ -1932,8 +1933,8 @@ static void ui_litem_estimate_column_flow(uiLayout *litem)
                        return;
                }
 
-               flow->totcol = MAX2(litem->root->emw / maxw, 1);
-               flow->totcol = MIN2(flow->totcol, totitem);
+               flow->totcol = max_ii(litem->root->emw / maxw, 1);
+               flow->totcol = min_ii(flow->totcol, totitem);
        }
        else
                flow->totcol = flow->number;
@@ -2007,7 +2008,7 @@ static void ui_litem_layout_column_flow(uiLayout *litem)
                emy -= itemh;
                ui_item_position(item, x + offset, y, itemw, itemh);
                y -= style->buttonspacey;
-               miny = MIN2(miny, y);
+               miny = min_ii(miny, y);
 
                /* decide to go to next one */
                if (col < flow->totcol - 1 && emy <= -emh) {
@@ -2038,8 +2039,8 @@ static void ui_litem_estimate_absolute(uiLayout *litem)
                ui_item_offset(item, &itemx, &itemy);
                ui_item_size(item, &itemw, &itemh);
 
-               minx = MIN2(minx, itemx);
-               miny = MIN2(miny, itemy);
+               minx = min_ii(minx, itemx);
+               miny = min_ii(miny, itemy);
 
                litem->w = MAX2(litem->w, itemx + itemw);
                litem->h = MAX2(litem->h, itemy + itemh);
@@ -2064,11 +2065,11 @@ static void ui_litem_layout_absolute(uiLayout *litem)
                ui_item_offset(item, &itemx, &itemy);
                ui_item_size(item, &itemw, &itemh);
 
-               minx = MIN2(minx, itemx);
-               miny = MIN2(miny, itemy);
+               minx = min_ii(minx, itemx);
+               miny = min_ii(miny, itemy);
 
-               totw = MAX2(totw, itemx + itemw);
-               toth = MAX2(toth, itemy + itemh);
+               totw = max_ii(totw, itemx + itemw);
+               toth = max_ii(toth, itemy + itemh);
        }
 
        totw -= minx;
index a09504fa4b7618999cc65d5ca75e27467ebad329..2b170ea546b81dc5ffd85ccab84efb18e6d1b5fc 100644 (file)
@@ -814,8 +814,8 @@ static void ui_panels_size(ScrArea *sa, ARegion *ar, int *x, int *y)
                                pa_sizey = pa->ofsy + get_panel_size_y(pa);
                        }
 
-                       sizex = MAX2(sizex, pa_sizex);
-                       sizey = MIN2(sizey, pa_sizey);
+                       sizex = max_ii(sizex, pa_sizex);
+                       sizey = min_ii(sizey, pa_sizey);
                }
        }
 
index 1cdeeb174f6bb9810851ea8cd46e0dc400116826..eb08ba7d92ed739b519d9a9430aca559f3e26c0d 100644 (file)
@@ -533,10 +533,7 @@ void ED_region_tag_redraw_partial(ARegion *ar, rcti *rct)
                }
                else if (ar->drawrct.xmin != ar->drawrct.xmax) {
                        /* partial redraw already set, expand region */
-                       ar->drawrct.xmin = MIN2(ar->drawrct.xmin, rct->xmin);
-                       ar->drawrct.ymin = MIN2(ar->drawrct.ymin, rct->ymin);
-                       ar->drawrct.xmax = MAX2(ar->drawrct.xmax, rct->xmax);
-                       ar->drawrct.ymax = MAX2(ar->drawrct.ymax, rct->ymax);
+                       BLI_rcti_union(&ar->drawrct, rct);
                }
        }
 }
index 711928251edcb4e35ea50270e0379a092c6371d5..cd8a7978fb6f953d7254ee41573880a6373f90f3 100644 (file)
@@ -969,18 +969,18 @@ static void area_move_set_limits(bScreen *sc, int dir, int *bigger, int *smaller
                        
                        /* if top or down edge selected, test height */
                        if (sa->v1->flag && sa->v4->flag)
-                               *bigger = MIN2(*bigger, y1);
+                               *bigger = min_ii(*bigger, y1);
                        else if (sa->v2->flag && sa->v3->flag)
-                               *smaller = MIN2(*smaller, y1);
+                               *smaller = min_ii(*smaller, y1);
                }
                else {
                        int x1 = sa->v4->vec.x - sa->v1->vec.x - AREAMINX;
                        
                        /* if left or right edge selected, test width */
                        if (sa->v1->flag && sa->v2->flag)
-                               *bigger = MIN2(*bigger, x1);
+                               *bigger = min_ii(*bigger, x1);
                        else if (sa->v3->flag && sa->v4->flag)
-                               *smaller = MIN2(*smaller, x1);
+                               *smaller = min_ii(*smaller, x1);
                }
        }
 }
index 4e236c6c225e86ea7b20dfc81989b6b9efa6ca5a..5f05c7f8df822590737b888db398e6f9e5918313 100644 (file)
@@ -4032,11 +4032,11 @@ static void *do_projectpaint_thread(void *ph_v)
                                                        /* end copy */
 
                                                        last_partial_redraw_cell = last_projIma->partRedrawRect + projPixel->bb_cell_index;
-                                                       last_partial_redraw_cell->x1 = MIN2(last_partial_redraw_cell->x1, projPixel->x_px);
-                                                       last_partial_redraw_cell->y1 = MIN2(last_partial_redraw_cell->y1, projPixel->y_px);
+                                                       last_partial_redraw_cell->x1 = min_ii(last_partial_redraw_cell->x1, (int)projPixel->x_px);
+                                                       last_partial_redraw_cell->y1 = min_ii(last_partial_redraw_cell->y1, (int)projPixel->y_px);
 
-                                                       last_partial_redraw_cell->x2 = MAX2(last_partial_redraw_cell->x2, projPixel->x_px + 1);
-                                                       last_partial_redraw_cell->y2 = MAX2(last_partial_redraw_cell->y2, projPixel->y_px + 1);
+                                                       last_partial_redraw_cell->x2 = max_ii(last_partial_redraw_cell->x2, (int)projPixel->x_px + 1);
+                                                       last_partial_redraw_cell->y2 = max_ii(last_partial_redraw_cell->y2, (int)projPixel->y_px + 1);
 
                                                        
                                                        switch (tool) {
index cfab254275615baa3b5c3af145733605cb58bf7d..f454b1dbe7d6a0e88a7f7437c3bde64fb8dad263 100644 (file)
@@ -36,8 +36,6 @@
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
 
-
-
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 
@@ -66,8 +64,8 @@ typedef struct ConsoleDrawContext {
 static void console_draw_sel(int sel[2], int xy[2], int str_len_draw, int cwidth, int lheight)
 {
        if (sel[0] <= str_len_draw && sel[1] >= 0) {
-               int sta = MAX2(sel[0], 0);
-               int end = MIN2(sel[1], str_len_draw);
+               int sta = max_ii(sel[0], 0);
+               int end = min_ii(sel[1], str_len_draw);
 
                glEnable(GL_POLYGON_STIPPLE);
                glPolygonStipple(stipple_halftone);
index 0aa46a36afe812ef352771eeaaa564734c83742a..311cb5ee94d762224302ba67ef72810c26d48e1b 100644 (file)
@@ -782,7 +782,7 @@ void startConstraint(TransInfo *t)
 {
        t->con.mode |= CON_APPLY;
        *t->con.text = ' ';
-       t->num.idx_max = MIN2(getConstraintSpaceDimension(t) - 1, t->idx_max);
+       t->num.idx_max = min_ii(getConstraintSpaceDimension(t) - 1, t->idx_max);
 }
 
 void stopConstraint(TransInfo *t)
index 995fa15aef3399bf8ee8ec34aa52916b419fa209..b2e9af2f1434ad4258717c1f73764c8884f05d80 100644 (file)
@@ -2282,10 +2282,10 @@ static int border_apply_rect(wmOperator *op)
 
        
        /* operator arguments and storage. */
-       RNA_int_set(op->ptr, "xmin", MIN2(rect->xmin, rect->xmax));
-       RNA_int_set(op->ptr, "ymin", MIN2(rect->ymin, rect->ymax));
-       RNA_int_set(op->ptr, "xmax", MAX2(rect->xmin, rect->xmax));
-       RNA_int_set(op->ptr, "ymax", MAX2(rect->ymin, rect->ymax));
+       RNA_int_set(op->ptr, "xmin", min_ii(rect->xmin, rect->xmax));
+       RNA_int_set(op->ptr, "ymin", min_ii(rect->ymin, rect->ymax));
+       RNA_int_set(op->ptr, "xmax", max_ii(rect->xmin, rect->xmax));
+       RNA_int_set(op->ptr, "ymax", max_ii(rect->ymin, rect->ymax));
 
        return 1;
 }