use min_ max_ functions in more places.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 23 Oct 2012 16:21:55 +0000 (16:21 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 23 Oct 2012 16:21:55 +0000 (16:21 +0000)
also fix minor error in MOD decimate when the modifier did nothing the reported face count would be wrong.

29 files changed:
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/mask_evaluate.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenlib/intern/BLI_kdopbvh.c
source/blender/compositor/intern/COM_ExecutionGroup.cpp
source/blender/compositor/intern/COM_NodeOperation.cpp
source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
source/blender/compositor/operations/COM_CropOperation.cpp
source/blender/compositor/operations/COM_DilateErodeOperation.cpp
source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
source/blender/compositor/operations/COM_KeyingOperation.cpp
source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
source/blender/editors/mask/mask_select.c
source/blender/editors/mesh/editmesh_loopcut.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/render/render_preview.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/space_console/console_ops.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/uvedit/uvedit_parametrizer.c
source/blender/modifiers/intern/MOD_decimate.c
source/blender/python/mathutils/mathutils_Matrix.c
source/blender/render/intern/raytrace/rayobject_rtbuild.cpp

index aee7714538fe2f7f7783f679bc4aea819e29bb37..e95451252d0c0ad22aa69aa5540a434c9decf596 100644 (file)
@@ -906,8 +906,8 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
                                calc_fcurve_range(fcu, &nmin, &nmax, FALSE, TRUE);
                                
                                /* compare to the running tally */
-                               min = MIN2(min, nmin);
-                               max = MAX2(max, nmax);
+                               min = min_ff(min, nmin);
+                               max = max_ff(max, nmax);
                                
                                foundvert = 1;
                        }
@@ -925,10 +925,10 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
                                                FMod_Limits *fmd = (FMod_Limits *)fcm->data;
                                                
                                                if (fmd->flag & FCM_LIMIT_XMIN) {
-                                                       min = MIN2(min, fmd->rect.xmin);
+                                                       min = min_ff(min, fmd->rect.xmin);
                                                }
                                                if (fmd->flag & FCM_LIMIT_XMAX) {
-                                                       max = MAX2(max, fmd->rect.xmax);
+                                                       max = max_ff(max, fmd->rect.xmax);
                                                }
                                        }
                                        break;
index 50be5b8a112681ce424ae619b50ed3131f0b63a4..e67df9c6419b19e45b30218886f02ececfd65d95 100644 (file)
@@ -131,7 +131,7 @@ unsigned int BKE_mask_spline_feather_resolution(MaskSpline *spline, int width, i
                        if (u_diff > FLT_EPSILON) {
                                float jump = fabsf(w_diff / u_diff);
 
-                               max_jump = MAX2(max_jump, jump);
+                               max_jump = max_ff(max_jump, jump);
                        }
 
                        prev_u = point->uw[j].u;
index e52fa3498a9f943dfc7aaee6170b10148f0bfd76..cf8569ec3d858999da35efc8c6ddfe1ed3849b29 100644 (file)
@@ -2826,7 +2826,7 @@ ImBuf *BKE_sequencer_give_ibuf(SeqRenderData context, float cfra, int chanshown)
 
        count = BLI_countlist(&ed->metastack);
        if ((chanshown < 0) && (count > 0)) {
-               count = MAX2(count + chanshown, 0);
+               count = max_ii(count + chanshown, 0);
                seqbasep = ((MetaStack *)BLI_findlink(&ed->metastack, count))->oldbasep;
        }
        else {
@@ -3458,7 +3458,7 @@ int BKE_sequence_base_shuffle(ListBase *seqbasep, Sequence *test, Scene *evil_sc
 
                for (seq = seqbasep->first; seq; seq = seq->next) {
                        if (seq->machine == orig_machine)
-                               new_frame = MAX2(new_frame, seq->enddisp);
+                               new_frame = max_ii(new_frame, seq->enddisp);
                }
 
                test->machine = orig_machine;
@@ -3483,10 +3483,10 @@ static int shuffle_seq_time_offset_test(ListBase *seqbasep, char dir)
                        for (seq_other = seqbasep->first; seq_other; seq_other = seq_other->next) {
                                if (!seq_other->tmp && seq_overlap(seq, seq_other)) {
                                        if (dir == 'L') {
-                                               offset = MIN2(offset, seq_other->startdisp - seq->enddisp);
+                                               offset = min_ii(offset, seq_other->startdisp - seq->enddisp);
                                        }
                                        else {
-                                               offset = MAX2(offset, seq_other->enddisp - seq->startdisp);
+                                               offset = max_ii(offset, seq_other->enddisp - seq->startdisp);
                                        }
                                }
                        }
index 4fcaed66f6b639d6143008091d77a414d3f028cd..e6904a23d51054d7d1005172835908532da32b0b 100644 (file)
@@ -221,7 +221,7 @@ void BKE_tracking_get_projection_matrix(MovieTracking *tracking, MovieTrackingOb
        float viewfac, pixsize, left, right, bottom, top, clipsta, clipend;
        float winmat[4][4];
        float ycor =  1.0f / tracking->camera.pixel_aspect;
-       float shiftx, shifty, winside = MAX2(winx, winy);
+       float shiftx, shifty, winside = (float)min_ii(winx, winy);
 
        BKE_tracking_camera_shift_get(tracking, winx, winy, &shiftx, &shifty);
 
@@ -2848,10 +2848,10 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieTracking *
                }
 
                if (first < track->markersnr - 1)
-                       sfra = MIN2(sfra, first_marker->framenr);
+                       sfra = min_ii(sfra, first_marker->framenr);
 
                if (last >= 0)
-                       efra = MAX2(efra, last_marker->framenr);
+                       efra = max_ii(efra, last_marker->framenr);
 
                tracks_map_insert(context->tracks_map, track, NULL);
 
@@ -3198,8 +3198,8 @@ static float stabilization_calculate_autoscale_factor(MovieTracking *tracking, i
                        if (track->flag & TRACK_USE_2D_STAB ||
                            ((stab->flag & TRACKING_STABILIZE_ROTATION) && track == stab->rot_track))
                        {
-                               sfra = MIN2(sfra, track->markers[0].framenr);
-                               efra = MAX2(efra, track->markers[track->markersnr - 1].framenr);
+                               sfra = min_ii(sfra, track->markers[0].framenr);
+                               efra = max_ii(efra, track->markers[track->markersnr - 1].framenr);
                        }
 
                        track = track->next;
@@ -3643,7 +3643,7 @@ static void channels_segments_calc(MovieTrackingDopesheetChannel *channel)
                        channel->segments[2 * segment] = start_marker->framenr;
                        channel->segments[2 * segment + 1] = start_marker->framenr + len;
 
-                       channel->max_segment =  MAX2(channel->max_segment, len);
+                       channel->max_segment = max_ii(channel->max_segment, len);
                        segment++;
                }
 
index 4dea802208364d4eefd22cf93fe9dd365576c701..dd4b1e524ecf751694c3782e79dceeb11076e639 100644 (file)
@@ -810,7 +810,7 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
        /* tree epsilon must be >= FLT_EPSILON
         * so that tangent rays can still hit a bounding volume..
         * this bug would show up when casting a ray aligned with a kdop-axis and with an edge of 2 faces */
-       epsilon = MAX2(FLT_EPSILON, epsilon);
+       epsilon = max_ff(FLT_EPSILON, epsilon);
 
        if (tree) {
                tree->epsilon = epsilon;
@@ -1089,7 +1089,7 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int
                data[j] = (BVHOverlapData *)MEM_callocN(sizeof(BVHOverlapData), "BVHOverlapData");
                
                /* init BVHOverlapData */
-               data[j]->overlap = (BVHTreeOverlap *)malloc(sizeof(BVHTreeOverlap) * MAX2(tree1->totleaf, tree2->totleaf));
+               data[j]->overlap = (BVHTreeOverlap *)malloc(sizeof(BVHTreeOverlap) * max_ii(tree1->totleaf, tree2->totleaf));
                data[j]->tree1 = tree1;
                data[j]->tree2 = tree2;
                data[j]->max_overlap = MAX2(tree1->totleaf, tree2->totleaf);
index 011d1865957565c4e9bdca77db5730afc88bcea4..265fab97cc57d8f78e3fbbd8da5e0503d46d2c64 100644 (file)
@@ -475,10 +475,10 @@ bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area
        int maxxchunk = ceil((area->xmax - 1) / chunkSizef);
        int minychunk = floor(area->ymin / chunkSizef);
        int maxychunk = ceil((area->ymax - 1) / chunkSizef);
-       minxchunk = MAX2(minxchunk, 0);
-       minychunk = MAX2(minychunk, 0);
-       maxxchunk = MIN2(maxxchunk, this->m_numberOfXChunks);
-       maxychunk = MIN2(maxychunk, this->m_numberOfYChunks);
+       minxchunk = max(minxchunk, 0);
+       minychunk = max(minychunk, 0);
+       maxxchunk = min(maxxchunk, this->m_numberOfXChunks);
+       maxychunk = min(maxychunk, this->m_numberOfYChunks);
 
        bool result = true;
        for (indexx = minxchunk; indexx < maxxchunk; indexx++) {
index 7b52c52154d3ce92f3b548342ca666921a1f92b2..a05c37e1b09a36e669a9e8155ac7a07b9b5a3811 100644 (file)
@@ -137,10 +137,10 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOper
                                        first = false;
                                }
                                else {
-                                       output->xmin = MIN2(output->xmin, tempOutput.xmin);
-                                       output->ymin = MIN2(output->ymin, tempOutput.ymin);
-                                       output->xmax = MAX2(output->xmax, tempOutput.xmax);
-                                       output->ymax = MAX2(output->ymax, tempOutput.ymax);
+                                       output->xmin = min(output->xmin, tempOutput.xmin);
+                                       output->ymin = min(output->ymin, tempOutput.ymin);
+                                       output->xmax = max(output->xmax, tempOutput.xmax);
+                                       output->ymax = max(output->ymax, tempOutput.ymax);
                                }
                        }
                }
index f6b23f6afd26336532e8466b11a82457baee15c1..f39a28b87a80a19f2760482fbc6af24a6f1a7cd8 100644 (file)
@@ -65,7 +65,7 @@ void ConvertDepthToRadiusOperation::initExecution()
        this->m_aspect = (this->getWidth() > this->getHeight()) ? (this->getHeight() / (float)this->getWidth()) : (this->getWidth() / (float)this->getHeight());
        this->m_aperture = 0.5f * (this->m_cam_lens / (this->m_aspect * cam_sensor)) / this->m_fStop;
        const float minsz = min(getWidth(), getHeight());
-       this->m_dof_sp = minsz / ((cam_sensor / 2.0f) / this->m_cam_lens);    // <- == aspect * MIN2(img->x, img->y) / tan(0.5f * fov);
+       this->m_dof_sp = minsz / ((cam_sensor / 2.0f) / this->m_cam_lens);    // <- == aspect * min(img->x, img->y) / tan(0.5f * fov);
 
        if (this->m_blurPostOperation) {
                m_blurPostOperation->setSigma(min(m_aperture * 128.0f, this->m_maxRadius));
index 24f28b2c98f8645559f544c376bd2af490f1d5b1..925374c79ed2e7e82fe729a028ebac7e9f17480e 100644 (file)
@@ -54,10 +54,10 @@ void CropBaseOperation::updateArea()
                if (height <= this->m_settings->y2 + 1)
                        this->m_settings->y2 = height - 1;
                
-               this->m_xmax = MAX2(this->m_settings->x1, this->m_settings->x2) + 1;
-               this->m_xmin = MIN2(this->m_settings->x1, this->m_settings->x2);
-               this->m_ymax = MAX2(this->m_settings->y1, this->m_settings->y2) + 1;
-               this->m_ymin = MIN2(this->m_settings->y1, this->m_settings->y2);
+               this->m_xmax = max(this->m_settings->x1, this->m_settings->x2) + 1;
+               this->m_xmin = min(this->m_settings->x1, this->m_settings->x2);
+               this->m_ymax = max(this->m_settings->y1, this->m_settings->y2) + 1;
+               this->m_ymin = min(this->m_settings->y1, this->m_settings->y2);
        }
 }
 
index 9c09c9bf034378188e0af4f4e76dc9040166a591..f0fffa770f80c4e81657147e1eb5fc807af63c8d 100644 (file)
@@ -344,28 +344,28 @@ void *DilateStepOperation::initializeTileData(rcti *rect)
                        for (y = 0; y < bheight; y++) {
                                for (x = 0; x < bwidth - 1; x++) {
                                        p = rectf + (bwidth * y + x);
-                                       *p = MAX2(*p, *(p + 1));
+                                       *p = max(*p, *(p + 1));
                                }
                        }
                
                        for (y = 0; y < bheight; y++) {
                                for (x = bwidth - 1; x >= 1; x--) {
                                        p = rectf + (bwidth * y + x);
-                                       *p = MAX2(*p, *(p - 1));
+                                       *p = max(*p, *(p - 1));
                                }
                        }
                
                        for (x = 0; x < bwidth; x++) {
                                for (y = 0; y < bheight - 1; y++) {
                                        p = rectf + (bwidth * y + x);
-                                       *p = MAX2(*p, *(p + bwidth));
+                                       *p = max(*p, *(p + bwidth));
                                }
                        }
                
                        for (x = 0; x < bwidth; x++) {
                                for (y = bheight - 1; y >= 1; y--) {
                                        p = rectf + (bwidth * y + x);
-                                       *p = MAX2(*p, *(p - bwidth));
+                                       *p = max(*p, *(p - bwidth));
                                }
                        }
                }
index 262252f7d8ce7b648e6aca63a4244f17397e0435..4bdb2591cb7479680b0391f6f99bce9a7ba767c5 100644 (file)
@@ -190,7 +190,7 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsign
 } (void)0
        
        // intermediate buffers
-       sz = MAX2(src_width, src_height);
+       sz = max(src_width, src_height);
        X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf");
        Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf");
        W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf");
index a9bcb2dd75209a39eddda081ae10e6cf61f1b1fe..44bce6308e82332bba2ac810cffcde4e33d15357 100644 (file)
@@ -257,7 +257,7 @@ void GaussianBlurReferenceOperation::initExecution()
 void GaussianBlurReferenceOperation::updateGauss()
 {
        int i;
-       int x = MAX2(m_radx, m_rady);
+       int x = max(m_radx, m_rady);
        this->m_maintabs = (float **)MEM_mallocN(x * sizeof(float *), "gauss array");
        for (i = 0; i < x; i++) {
                m_maintabs[i] = make_gausstab(i + 1);
@@ -327,11 +327,11 @@ void GaussianBlurReferenceOperation::executePixel(float output[4], int x, int y,
 void GaussianBlurReferenceOperation::deinitExecution()
 {
        int x, i;
-       x = MAX2(m_radx, m_rady);
+       x = max(this->m_radx, this->m_rady);
        for (i = 0; i < x; i++) {
-               MEM_freeN(m_maintabs[i]);
+               MEM_freeN(this->m_maintabs[i]);
        }
-       MEM_freeN(m_maintabs);
+       MEM_freeN(this->m_maintabs);
        BlurBaseOperation::deinitExecution();
 }
 
index 4426666f100b847284072fadc979e4f6fc6b36b9..f9f43025d29173cd514544a0e3ee77dd2bcd35fb 100644 (file)
@@ -28,9 +28,9 @@
 #include "BLI_listbase.h"
 #include "BLI_math.h"
 
-static int get_pixel_primary_channel(float *pixel)
+static int get_pixel_primary_channel(float pixel[3])
 {
-       float max_value = MAX3(pixel[0], pixel[1], pixel[2]);
+       float max_value = max(max(pixel[0], pixel[1]), pixel[2]);
 
        if (max_value == pixel[0])
                return 0;
@@ -77,8 +77,8 @@ void KeyingDespillOperation::executePixel(float output[4], float x, float y, Pix
        int other_1 = (screen_primary_channel + 1) % 3;
        int other_2 = (screen_primary_channel + 2) % 3;
 
-       int min_channel = MIN2(other_1, other_2);
-       int max_channel = MAX2(other_1, other_2);
+       int min_channel = min(other_1, other_2);
+       int max_channel = max(other_1, other_2);
 
        float average_value, amount;
 
index 35138cf0b92a5913d092ac3b0b2cd2c93b8212a6..bc2d14d42b84c508f5b0b66b6ecece121eb528aa 100644 (file)
 #include "BLI_listbase.h"
 #include "BLI_math.h"
 
-static int get_pixel_primary_channel(float pixelColor[4])
+static int get_pixel_primary_channel(float pixel[3])
 {
-       float max_value = MAX3(pixelColor[0], pixelColor[1], pixelColor[2]);
+       float max_value = max(max(pixel[0], pixel[1]), pixel[2]);
 
-       if (max_value == pixelColor[0])
+       if (max_value == pixel[0])
                return 0;
-       else if (max_value == pixelColor[1])
+       else if (max_value == pixel[1])
                return 1;
 
        return 2;
@@ -45,8 +45,8 @@ static float get_pixel_saturation(float pixelColor[4], float screen_balance, int
        int other_1 = (primary_channel + 1) % 3;
        int other_2 = (primary_channel + 2) % 3;
 
-       int min_channel = MIN2(other_1, other_2);
-       int max_channel = MAX2(other_1, other_2);
+       int min_channel = min(other_1, other_2);
+       int max_channel = max(other_1, other_2);
 
        float val = screen_balance * pixelColor[min_channel] + (1.0f - screen_balance) * pixelColor[max_channel];
 
index b8e15934c305f3ca087a251e30fce77704b5bbf1..52a9e2a4d8c460a42a844dd7d6938ad9973eddcf 100644 (file)
@@ -198,7 +198,7 @@ void VariableSizeBokehBlurOperation::executeOpenCL(OpenCLDevice *device,
        cl_float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
 
        maxBlur = (cl_int)sizeMemoryBuffer->getMaximumValue() * scalar;
-       maxBlur = MIN2(maxBlur, this->m_maxBlur);
+       maxBlur = min(maxBlur, this->m_maxBlur);
 
        device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
        device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 1,  -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBokehProgram);
index dc204909577c30c6d1c0306eca0b87609572db05..cd1a47754f830066a869dbb9adbca14677b91cc9 100644 (file)
@@ -34,6 +34,7 @@
 #include "BLI_utildefines.h"
 #include "BLI_rect.h"
 #include "BLI_lasso.h"
+#include "BLI_math.h"
 
 #include "BKE_context.h"
 #include "BKE_mask.h"
@@ -622,7 +623,7 @@ static int circle_select_exec(bContext *C, wmOperator *op)
        /* compute ellipse and position in unified coordinates */
        ED_mask_get_size(sa, &width, &height);
        ED_mask_zoom(sa, ar, &zoomx, &zoomy);
-       width = height = MAX2(width, height);
+       width = height = max_ii(width, height);
 
        ellipse[0] = width * zoomx / radius;
        ellipse[1] = height * zoomy / radius;
index fa1b04df05f6ab4b7a9adabba9bec30ac3711fa4..262f81abacb22833b7fae5ccb733ec1924c3c4a1 100644 (file)
@@ -505,7 +505,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event)
                        if (event->val == KM_RELEASE)
                                break;
 
-                       cuts = MAX2(cuts - 1, 0);
+                       cuts = max_ii(cuts - 1, 0);
                        RNA_int_set(op->ptr, "number_cuts", cuts);
                        ringsel_find_edge(lcd, cuts);
                        show_cuts = TRUE;
index 740f769b5bc9111c2d5a86c3b4fba744ed744a01..9dbf9049bfce956d8b4ea1ab83d801a11ff95a62 100644 (file)
@@ -1062,7 +1062,7 @@ static void vgroup_normalize(Object *ob)
 
                        dw = defvert_find_index(dv, def_nr);
                        if (dw) {
-                               weight_max = MAX2(dw->weight, weight_max);
+                               weight_max = max_ff(dw->weight, weight_max);
                        }
                }
 
index 5cfe7179f5a895b908f568bdd9b7709ed7f45613..a2f31b35246e1de97677de961cc33428d0bc66d9 100644 (file)
@@ -368,7 +368,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
                                        if (OB_TYPE_SUPPORT_MATERIAL(base->object->type)) {
                                                /* don't use assign_material, it changed mat->id.us, which shows in the UI */
                                                Material ***matar = give_matarar(base->object);
-                                               int actcol = MAX2(base->object->actcol - 1, 0);
+                                               int actcol = max_ii(base->object->actcol - 1, 0);
 
                                                if (matar && actcol < base->object->totcol)
                                                        (*matar)[actcol] = mat;
@@ -518,8 +518,8 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int
                
                if (ABS(rres.rectx - newx) < 2 && ABS(rres.recty - newy) < 2) {
 
-                       newrect->xmax = MAX2(newrect->xmax, rect->xmin + rres.rectx + offx);
-                       newrect->ymax = MAX2(newrect->ymax, rect->ymin + rres.recty);
+                       newrect->xmax = max_ii(newrect->xmax, rect->xmin + rres.rectx + offx);
+                       newrect->ymax = max_ii(newrect->ymax, rect->ymin + rres.recty);
 
                        if (rres.rectx && rres.recty) {
                                /* temporary conversion to byte for drawing */
index b24681fdb05d15b306be02deccdb05ba84ac165d..4e236c6c225e86ea7b20dfc81989b6b9efa6ca5a 100644 (file)
@@ -173,7 +173,7 @@ typedef struct ImagePaintState {
 } ImagePaintState;
 
 typedef struct ImagePaintPartialRedraw {
-       int x1, y1, x2, y2;
+       int x1, y1, x2, y2;  /* XXX, could use 'rcti' */
        int enabled;
 } ImagePaintPartialRedraw;
 
@@ -3583,11 +3583,11 @@ static int partial_redraw_array_merge(ImagePaintPartialRedraw *pr, ImagePaintPar
 {
        int touch = 0;
        while (tot--) {
-               pr->x1 = MIN2(pr->x1, pr_other->x1);
-               pr->y1 = MIN2(pr->y1, pr_other->y1);
+               pr->x1 = min_ii(pr->x1, pr_other->x1);
+               pr->y1 = min_ii(pr->y1, pr_other->y1);
                
-               pr->x2 = MAX2(pr->x2, pr_other->x2);
-               pr->y2 = MAX2(pr->y2, pr_other->y2);
+               pr->x2 = max_ii(pr->x2, pr_other->x2);
+               pr->y2 = max_ii(pr->y2, pr_other->y2);
                
                if (pr->x2 != -1)
                        touch = 1;
@@ -4222,10 +4222,10 @@ static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w,
                imapaintpartial.enabled = 1;
        }
        else {
-               imapaintpartial.x1 = MIN2(imapaintpartial.x1, x);
-               imapaintpartial.y1 = MIN2(imapaintpartial.y1, y);
-               imapaintpartial.x2 = MAX2(imapaintpartial.x2, x + w);
-               imapaintpartial.y2 = MAX2(imapaintpartial.y2, y + h);
+               imapaintpartial.x1 = min_ii(imapaintpartial.x1, x);
+               imapaintpartial.y1 = min_ii(imapaintpartial.y1, y);
+               imapaintpartial.x2 = max_ii(imapaintpartial.x2, x + w);
+               imapaintpartial.y2 = max_ii(imapaintpartial.y2, y + h);
        }
 
        w = ((x + w - 1) >> IMAPAINT_TILE_BITS);
index 68de184f0085816b74240e3477d3d8699858e940..ccdbc38936c274f5e11a2a27c8fb72395d2a643e 100644 (file)
@@ -39,6 +39,7 @@
 #include "BLI_string.h"
 #include "BLI_dynstr.h"
 #include "BLI_utildefines.h"
+#include "BLI_math.h"
 
 #include "BKE_context.h"
 #include "BKE_text.h" /* only for character utility funcs */
@@ -904,8 +905,8 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op))
 
        for (cl = sc->scrollback.first; cl; cl = cl->next) {
                if (sel[0] <= cl->len && sel[1] >= 0) {
-                       int sta = MAX2(sel[0], 0);
-                       int end = MIN2(sel[1], cl->len);
+                       int sta = max_ii(sel[0], 0);
+                       int end = min_ii(sel[1], cl->len);
 
                        if (BLI_dynstr_get_len(buf_dyn))
                                BLI_dynstr_append(buf_dyn, "\n");
index 636d2f2fc013d7f3a1d56f6a0112824382b7852e..c4b468317141c0091c6781bb43bd6fd1b44644e5 100644 (file)
@@ -1240,8 +1240,8 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
                        /* boundbox and selection tests for NOT drawing the strip... */
                        if ((seq->flag & SELECT) != sel) continue;
                        else if (seq == last_seq) continue;
-                       else if (MIN2(seq->startdisp, seq->start) > v2d->cur.xmax) continue;
-                       else if (MAX2(seq->enddisp, seq->start + seq->len) < v2d->cur.xmin) continue;
+                       else if (min_ii(seq->startdisp, seq->start) > v2d->cur.xmax) continue;
+                       else if (max_ii(seq->enddisp, seq->start + seq->len) < v2d->cur.xmin) continue;
                        else if (seq->machine + 1.0f < v2d->cur.ymin) continue;
                        else if (seq->machine > v2d->cur.ymax) continue;
                        
index c09e0ffaa33e4e640820a009c1d92dcb4139e933..6b71fbe301e87da199036bbfca5050a3c35fe9d0 100644 (file)
@@ -1952,7 +1952,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
        while (seq) {
                next = seq->next;
                if (seq != seqm && (seq->flag & SELECT)) {
-                       channel_max = MAX2(seq->machine, channel_max);
+                       channel_max = max_ii(seq->machine, channel_max);
                        BLI_remlink(ed->seqbasep, seq);
                        BLI_addtail(&seqm->seqbase, seq);
                }
@@ -2255,11 +2255,11 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
 
        for (seq = ed->seqbasep->first; seq; seq = seq->next) {
                if (seq->flag & SELECT) {
-                       xmin = MIN2(xmin, seq->startdisp);
-                       xmax = MAX2(xmax, seq->enddisp);
+                       xmin = min_ii(xmin, seq->startdisp);
+                       xmax = max_ii(xmax, seq->enddisp);
 
-                       ymin = MIN2(ymin, seq->machine);
-                       ymax = MAX2(ymax, seq->machine);
+                       ymin = min_ii(ymin, seq->machine);
+                       ymax = max_ii(ymax, seq->machine);
                }
        }
 
index 9755c7d1b7ce216d7c4b0fa1906cdb911ba90fcb..f1be0978c061c66e45f84a94c810dae793e4b4c2 100644 (file)
@@ -1223,7 +1223,7 @@ static void view3d_panel_object(const bContext *C, Panel *pa)
        if (ob == NULL)
                return;
 
-       lim = 10000.0f * MAX2(1.0f, v3d->grid);
+       lim = 10000.0f * max_ff(1.0f, v3d->grid);
 
        block = uiLayoutGetBlock(pa->layout);
        uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL);
index f7ae082787b192b27a54373d5d25de3a5fec12c1..b7cde89bf4d365cf70b891e5aaf59653f8dd944a 100644 (file)
@@ -2868,8 +2868,8 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
                /* clamp small tile sizes to prevent inefficient threading utilization
                 * the same happens for final renders as well
                 */
-               engine->tile_x = MAX2(engine->tile_x, 64);
-               engine->tile_y = MAX2(engine->tile_x, 64);
+               engine->tile_x = max_ii(engine->tile_x, 64);
+               engine->tile_y = max_ii(engine->tile_x, 64);
 
                type->view_update(engine, C);
 
index 8d34108011a8c67996aadc0223c617eb75dacb6f..5b6125b558b2bf312a036605691828a945453d1c 100644 (file)
@@ -3988,7 +3988,7 @@ static void p_smooth(PChart *chart)
                                        diff[1] = p[1] - oldp[1];
 
                                        length = sqrt(diff[0] * diff[0] + diff[1] * diff[1]);
-                                       d = MAX2(d, length);
+                                       d = max_ff(d, length);
                                        moved += length;
                                }
                        }
index 75bea93910736df9417b40bc0ef12453aee0a217..8ac303f7bd5e8e54df5ab3bf74827207304e07f8 100644 (file)
@@ -106,6 +106,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
        TIMEIT_START(decim);
 #endif
 
+       /* set up front so we dont show invalid info in the UI */
+       dmd->face_count = dm->getNumPolys(dm);
+
        switch (dmd->mode) {
                case MOD_DECIM_MODE_COLLAPSE:
                        if (dmd->percent == 1.0f) {
@@ -124,7 +127,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
                        break;
        }
 
-       if (dm->getNumPolys(dm) <= 3) {
+       if (dmd->face_count <= 3) {
                modifier_setError(md, "%s", TIP_("Modifier requires more than 3 input faces"));
                return dm;
        }
index e9f58526113b950c0b01c858a757e73d17d40798..13153605b03d2e02054592b0c7d00cfac905f2e4 100644 (file)
@@ -1579,7 +1579,7 @@ static PyObject *Matrix_str(MatrixObject *self)
                maxsize[col] = 0;
                for (row = 0; row < self->num_row; row++) {
                        int size = BLI_snprintf(dummy_buf, sizeof(dummy_buf), "%.4f", MATRIX_ITEM(self, row, col));
-                       maxsize[col] = MAX2(maxsize[col], size);
+                       maxsize[col] = max_ii(maxsize[col], size);
                }
        }
 
index 3ca21e14e4e54f61a51582bc1b7efc052cbbe6d7..a08edd3fdb7035d1cb4e927ad17cd455158700e4 100644 (file)
@@ -348,12 +348,12 @@ int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds)
                                        sweep[i].cost = obj[i]->cost;
                                }
                                else {
-                                       sweep[i].bb[0] = MIN2(obj[i]->bb[0], sweep[i + 1].bb[0]);
-                                       sweep[i].bb[1] = MIN2(obj[i]->bb[1], sweep[i + 1].bb[1]);
-                                       sweep[i].bb[2] = MIN2(obj[i]->bb[2], sweep[i + 1].bb[2]);
-                                       sweep[i].bb[3] = MAX2(obj[i]->bb[3], sweep[i + 1].bb[3]);
-                                       sweep[i].bb[4] = MAX2(obj[i]->bb[4], sweep[i + 1].bb[4]);
-                                       sweep[i].bb[5] = MAX2(obj[i]->bb[5], sweep[i + 1].bb[5]);
+                                       sweep[i].bb[0] = min_ff(obj[i]->bb[0], sweep[i + 1].bb[0]);
+                                       sweep[i].bb[1] = min_ff(obj[i]->bb[1], sweep[i + 1].bb[1]);
+                                       sweep[i].bb[2] = min_ff(obj[i]->bb[2], sweep[i + 1].bb[2]);
+                                       sweep[i].bb[3] = max_ff(obj[i]->bb[3], sweep[i + 1].bb[3]);
+                                       sweep[i].bb[4] = max_ff(obj[i]->bb[4], sweep[i + 1].bb[4]);
+                                       sweep[i].bb[5] = max_ff(obj[i]->bb[5], sweep[i + 1].bb[5]);
                                        sweep[i].cost  = obj[i]->cost + sweep[i + 1].cost;
                                }
 //                             right_cost += obj[i]->cost;