code cleanup: use rect size macros
authorCampbell Barton <ideasman42@gmail.com>
Tue, 21 Aug 2012 20:34:05 +0000 (20:34 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 21 Aug 2012 20:34:05 +0000 (20:34 +0000)
32 files changed:
source/blender/blenfont/intern/blf_font.c
source/blender/blenkernel/intern/colortools.c
source/blender/blenlib/intern/rct.c
source/blender/editors/gpencil/gpencil_paint.c
source/blender/editors/interface/interface_draw.c
source/blender/editors/interface/view2d.c
source/blender/editors/interface/view2d_ops.c
source/blender/editors/screen/area.c
source/blender/editors/screen/glutil.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/screen/screendump.c
source/blender/editors/sculpt_paint/paint_cursor.c
source/blender/editors/space_buttons/buttons_header.c
source/blender/editors/space_graph/graph_edit.c
source/blender/editors/space_image/image_buttons.c
source/blender/editors/space_image/image_edit.c
source/blender/editors/space_node/node_draw.c
source/blender/editors/space_node/node_view.c
source/blender/editors/space_outliner/outliner_edit.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_text/text_draw.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/transform/transform_snap.c
source/blender/nodes/composite/node_composite_util.c
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/imagetexture.c
source/blender/render/intern/source/initrender.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/rendercore.c
source/blender/render/intern/source/shadbuf.c
source/blender/windowmanager/intern/wm_subwindow.c

index d47fa5383d44daa298e0f68413ba44d76e4489d6..ab43804db8e6be039000c7c5431971c520a02ef3 100644 (file)
@@ -456,7 +456,7 @@ float blf_font_height(FontBLF *font, const char *str)
                ya = 1.0f;
 
        blf_font_boundbox(font, str, &box);
-       return (box.ymax - box.ymin) * ya;
+       return BLI_RCT_SIZE_Y(&box) * ya;
 }
 
 float blf_font_fixed_width(FontBLF *font)
index 85d28f680347ae871431126aca61624e3c5ad430..7c03c75bd9937abc27a11947085d3eafa386fa60 100644 (file)
@@ -668,7 +668,7 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles)
        CurveMap *cuma = cumap->cm + cumap->cur;
        CurveMapPoint *cmp = cuma->curve;
        rctf *clipr = &cumap->clipr;
-       float thresh = 0.01f * (clipr->xmax - clipr->xmin);
+       float thresh = 0.01f * BLI_RCT_SIZE_X(clipr);
        float dx = 0.0f, dy = 0.0f;
        int a;
 
index 92cbcd485b6f384001b2484064f3f6eae4940f4c..ac9ac39893bc5d1752f033aa63bfa59f04f875aa 100644 (file)
@@ -366,9 +366,9 @@ int BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest)
 void BLI_rcti_rctf_copy(rcti *dst, const rctf *src)
 {
        dst->xmin = floorf(src->xmin + 0.5f);
-       dst->xmax = dst->xmin + floorf((src->xmax - src->xmin) + 0.5f);
+       dst->xmax = dst->xmin + floorf(BLI_RCT_SIZE_X(src) + 0.5f);
        dst->ymin = floorf(src->ymin + 0.5f);
-       dst->ymax = dst->ymin + floorf((src->ymax - src->ymin) + 0.5f);
+       dst->ymax = dst->ymin + floorf(BLI_RCT_SIZE_Y(src) + 0.5f);
 }
 
 void BLI_rctf_rcti_copy(rctf *dst, const rcti *src)
index 1f317fa4f045c7d45ff1254158ce4afc482fb879..c5f2ad4254b39cda27f24f5dc490876c255e4354 100644 (file)
@@ -819,8 +819,8 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], shor
                                y0 = (int)(gps->points->y / 100 * p->ar->winy);
                        }
                        else { /* camera view, use subrect */
-                               x0 = (int)((gps->points->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin;
-                               y0 = (int)((gps->points->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin;
+                               x0 = (int)((gps->points->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin;
+                               y0 = (int)((gps->points->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin;
                        }
                }
                
@@ -866,10 +866,10 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], shor
                                        y1 = (int)(pt2->y / 100 * p->ar->winy);
                                }
                                else { /* camera view, use subrect */ 
-                                       x0 = (int)((pt1->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin;
-                                       y0 = (int)((pt1->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin;
-                                       x1 = (int)((pt2->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin;
-                                       y1 = (int)((pt2->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin;
+                                       x0 = (int)((pt1->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin;
+                                       y0 = (int)((pt1->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin;
+                                       x1 = (int)((pt2->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin;
+                                       y1 = (int)((pt2->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin;
                                }
                        }
                        
index c3edd38f8d9c5f4f15430480a0b929d47c9e2939..77dbbc878a7729a7a191fd38e79946486e1d02d9 100644 (file)
@@ -1733,8 +1733,8 @@ void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int UNUSE
        
        glEnable(GL_BLEND);
        
-       if (radius > (rct->ymax - rct->ymin - 10.0f) / 2.0f)
-               rad = (rct->ymax - rct->ymin - 10.0f) / 2.0f;
+       if (radius > (BLI_RCT_SIZE_Y(rct) - 10.0f) / 2.0f)
+               rad = (BLI_RCT_SIZE_Y(rct) - 10.0f) / 2.0f;
        else
                rad = radius;
 
index 86322b0c0ea9c7776cf6f0959f47b112b890abab..c3059b8d575852a901321a9df065faea3d0258a7 100644 (file)
@@ -1458,7 +1458,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
        if (scroll & V2D_SCROLL_HORIZONTAL) {
                /* scroller 'button' extents */
                totsize = BLI_RCT_SIZE_X(&v2d->tot);
-               scrollsize = (float)(hor.xmax - hor.xmin);
+               scrollsize = (float)BLI_RCT_SIZE_X(&hor);
                if (totsize == 0.0f) totsize = 1.0f;  /* avoid divide by zero */
 
                fac1 = (v2d->cur.xmin - v2d->tot.xmin) / totsize;
@@ -1498,8 +1498,8 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
        /* vertical scrollers */
        if (scroll & V2D_SCROLL_VERTICAL) {
                /* scroller 'button' extents */
-               totsize = BLI_RCT_SIZE_Y(&v2d->tot);
-               scrollsize = (float)(vert.ymax - vert.ymin);
+               totsize    =        BLI_RCT_SIZE_Y(&v2d->tot);
+               scrollsize = (float)BLI_RCT_SIZE_Y(&vert);
                if (totsize == 0.0f) totsize = 1.0f;  /* avoid divide by zero */
 
                fac1 = (v2d->cur.ymin - v2d->tot.ymin) / totsize;
@@ -1545,7 +1545,9 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
                scrollers->yclamp = yclamp;
                scrollers->yunits = yunits;
                
-               scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, xunits, xclamp, yunits, yclamp, (hor.xmax - hor.xmin), (vert.ymax - vert.ymin));
+               scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d,
+                                                     xunits, xclamp, yunits, yclamp,
+                                                     BLI_RCT_SIZE_X(&hor), BLI_RCT_SIZE_Y(&vert));
        }
        
        /* return scrollers */
@@ -1629,7 +1631,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
                         */
                        if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 &&
                            (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) &&
-                           (slider.xmax - slider.xmin > V2D_SCROLLER_HANDLE_SIZE))
+                           (BLI_RCT_SIZE_X(&slider) > V2D_SCROLLER_HANDLE_SIZE))
                        {
                                state |= UI_SCROLL_ARROWS;
                        }
@@ -1650,10 +1652,10 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
                         *      - dfac is gap between scale markings
                         */
                        fac = (grid->startx - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
-                       fac = (float)hor.xmin + fac * (hor.xmax - hor.xmin);
+                       fac = (float)hor.xmin + fac * BLI_RCT_SIZE_X(&hor);
                        
                        dfac = grid->dx / BLI_RCT_SIZE_X(&v2d->cur);
-                       dfac = dfac * (hor.xmax - hor.xmin);
+                       dfac = dfac * BLI_RCT_SIZE_X(&hor);
                        
                        /* set starting value, and text color */
                        UI_ThemeColor(TH_TEXT);
@@ -1740,7 +1742,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
                         */
                        if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 &&
                            (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) &&
-                           (slider.ymax - slider.ymin > V2D_SCROLLER_HANDLE_SIZE))
+                           (BLI_RCT_SIZE_Y(&slider) > V2D_SCROLLER_HANDLE_SIZE))
                        {
                                state |= UI_SCROLL_ARROWS;
                        }
@@ -1764,10 +1766,10 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
                         *        NOTE: it's assumed that that scrollbar is there if this is involved!
                         */
                        fac = (grid->starty - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
-                       fac = vert.ymin + fac * (vert.ymax - vert.ymin);
+                       fac = vert.ymin + fac * BLI_RCT_SIZE_Y(&vert);
                        
                        dfac = grid->dy / BLI_RCT_SIZE_Y(&v2d->cur);
-                       dfac = dfac * (vert.ymax - vert.ymin);
+                       dfac = dfac     * BLI_RCT_SIZE_Y(&vert);
                        
                        /* set starting value, and text color */
                        UI_ThemeColor(TH_TEXT);
@@ -2140,7 +2142,7 @@ void UI_view2d_text_cache_draw(ARegion *ar)
                const char *str = (const char *)(v2s + 1);
                int xofs = 0, yofs;
 
-               yofs = ceil(0.5f * (v2s->rect.ymax - v2s->rect.ymin - default_height));
+               yofs = ceil(0.5f * (BLI_RCT_SIZE_Y(&v2s->rect) - default_height));
                if (yofs < 1) yofs = 1;
 
                if (col_pack_prev != v2s->col.pack) {
index 258025eefc929d7e793e4ed7a8d42e9f28cf52b5..84c3abf2ae24a2134c0149f3fee440284642ddd9 100644 (file)
@@ -471,7 +471,7 @@ static int view_scrollup_exec(bContext *C, wmOperator *op)
        
        if (RNA_boolean_get(op->ptr, "page")) {
                ARegion *ar = CTX_wm_region(C);
-               RNA_int_set(op->ptr, "deltay", ar->v2d.mask.ymax - ar->v2d.mask.ymin);
+               RNA_int_set(op->ptr, "deltay", BLI_RCT_SIZE_Y(&ar->v2d.mask));
        }
        
        /* apply movement, then we're done */
@@ -1137,7 +1137,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
                
                /* TODO: is this zoom factor calculation valid? It seems to produce same results everytime... */
                if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
-                       size = (cur_new.xmax - cur_new.xmin);
+                       size = BLI_RCT_SIZE_X(&cur_new);
                        zoom = size / BLI_RCT_SIZE_X(&rect);
                        center = BLI_RCT_CENTER_X(&cur_new);
                        
@@ -1145,7 +1145,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
                        cur_new.xmax = center + (size * zoom);
                }
                if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
-                       size = (cur_new.ymax - cur_new.ymin);
+                       size = BLI_RCT_SIZE_Y(&cur_new);
                        zoom = size / BLI_RCT_SIZE_Y(&rect);
                        center = BLI_RCT_CENTER_Y(&cur_new);
                        
@@ -1197,10 +1197,10 @@ struct SmoothView2DStore {
  */
 static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b)
 {
-       float size_a[2] = {rect_a->xmax - rect_a->xmin,
-                          rect_a->ymax - rect_a->ymin};
-       float size_b[2] = {rect_b->xmax - rect_b->xmin,
-                          rect_b->ymax - rect_b->ymin};
+       float size_a[2] = {BLI_RCT_SIZE_X(rect_a),
+                          BLI_RCT_SIZE_Y(rect_a)};
+       float size_b[2] = {BLI_RCT_SIZE_X(rect_b),
+                          BLI_RCT_SIZE_Y(rect_b)};
        float cent_a[2] = {BLI_RCT_CENTER_X(rect_a),
                           BLI_RCT_CENTER_Y(rect_a)};
        float cent_b[2] = {BLI_RCT_CENTER_X(rect_b),
@@ -1477,7 +1477,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
 
        if (in_scroller == 'h') {
                /* horizontal scroller - calculate adjustment factor first */
-               mask_size = (float)(v2d->hor.xmax - v2d->hor.xmin);
+               mask_size = (float)BLI_RCT_SIZE_X(&v2d->hor);
                vsm->fac = BLI_RCT_SIZE_X(&v2d->tot) / mask_size;
                
                /* get 'zone' (i.e. which part of scroller is activated) */
@@ -1493,7 +1493,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
        }
        else {
                /* vertical scroller - calculate adjustment factor first */
-               mask_size = (float)(v2d->vert.ymax - v2d->vert.ymin);
+               mask_size = (float)BLI_RCT_SIZE_Y(&v2d->vert);
                vsm->fac = BLI_RCT_SIZE_Y(&v2d->tot) / mask_size;
                
                /* get 'zone' (i.e. which part of scroller is activated) */
index 10bc17ff59e64e1235290f81008a003ab5e4ae90..59310f9e675ca6de1ca1d8c6b3a6abf4769f1dc8 100644 (file)
@@ -1096,8 +1096,8 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
        if (ar->alignment & RGN_SPLIT_PREV) {
                if (ar->prev) {
                        remainder = remainder_prev;
-                       ar->prev->winx = ar->prev->winrct.xmax - ar->prev->winrct.xmin + 1;
-                       ar->prev->winy = ar->prev->winrct.ymax - ar->prev->winrct.ymin + 1;
+                       ar->prev->winx = BLI_RCT_SIZE_X(&ar->prev->winrct) + 1;
+                       ar->prev->winy = BLI_RCT_SIZE_Y(&ar->prev->winrct) + 1;
                }
        }
        
@@ -1769,7 +1769,7 @@ void ED_region_header(const bContext *C, ARegion *ar)
        }
 
        /* always as last  */
-       UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, ar->v2d.tot.ymax - ar->v2d.tot.ymin);
+       UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, BLI_RCT_SIZE_Y(&ar->v2d.tot));
 
        /* restore view matrix? */
        UI_view2d_view_restore(C);
index a534124d2c01e216c3e437116ad30b9d7bad5462..967c6e855904fa8e3d008c9b8c89702a9d2dbc33 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "DNA_vec_types.h"
 
+#include "BLI_rect.h"
 #include "BLI_utildefines.h"
 
 #include "BKE_colortools.h"
@@ -668,8 +669,8 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo
 
 void glaDefine2DArea(rcti *screen_rect)
 {
-       int sc_w = screen_rect->xmax - screen_rect->xmin + 1;
-       int sc_h = screen_rect->ymax - screen_rect->ymin + 1;
+       const int sc_w = BLI_RCT_SIZE_X(screen_rect) + 1;
+       const int sc_h = BLI_RCT_SIZE_Y(screen_rect) + 1;
 
        glViewport(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h);
        glScissor(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h);
@@ -713,10 +714,10 @@ void gla2DSetMap(gla2DDrawInfo *di, rctf *rect)
 
        di->world_rect = *rect;
        
-       sc_w = (di->screen_rect.xmax - di->screen_rect.xmin);
-       sc_h = (di->screen_rect.ymax - di->screen_rect.ymin);
-       wo_w = (di->world_rect.xmax - di->world_rect.xmin);
-       wo_h = (di->world_rect.ymax - di->world_rect.ymin);
+       sc_w = BLI_RCT_SIZE_X(&di->screen_rect);
+       sc_h = BLI_RCT_SIZE_Y(&di->screen_rect);
+       wo_w = BLI_RCT_SIZE_X(&di->world_rect);
+       wo_h = BLI_RCT_SIZE_Y(&di->world_rect);
        
        di->wo_to_sc[0] = sc_w / wo_w;
        di->wo_to_sc[1] = sc_h / wo_h;
@@ -744,10 +745,10 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect)
                di->world_rect.ymax = di->screen_rect.ymax;
        }
 
-       sc_w = (di->screen_rect.xmax - di->screen_rect.xmin);
-       sc_h = (di->screen_rect.ymax - di->screen_rect.ymin);
-       wo_w = (di->world_rect.xmax - di->world_rect.xmin);
-       wo_h = (di->world_rect.ymax - di->world_rect.ymin);
+       sc_w = BLI_RCT_SIZE_X(&di->screen_rect);
+       sc_h = BLI_RCT_SIZE_Y(&di->screen_rect);
+       wo_w = BLI_RCT_SIZE_X(&di->world_rect);
+       wo_h = BLI_RCT_SIZE_Y(&di->world_rect);
 
        di->wo_to_sc[0] = sc_w / wo_w;
        di->wo_to_sc[1] = sc_h / wo_h;
index 97a63bb0df08d41a73a7b967459f960a63443949..6b42b2f9de81e618de957e76e9c3904943df956e 100644 (file)
@@ -1615,7 +1615,7 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
                dist = BLI_RCT_SIZE_X(&sa->totrct);
        }
        else {  /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */
-               dist = sa->totrct.ymax - sa->totrct.ymin;
+               dist = BLI_RCT_SIZE_Y(&sa->totrct);
        }
        
        /* subtractwidth of regions on opposite side 
index 41e2f0b16a437d15c06d5b0a654de5b2636946d2..4e71c49465f979a6444f5e1dab1104b2a099772e 100644 (file)
@@ -149,14 +149,16 @@ static void screenshot_crop(ImBuf *ibuf, rcti crop)
 {
        unsigned int *to = ibuf->rect;
        unsigned int *from = ibuf->rect + crop.ymin * ibuf->x + crop.xmin;
-       int y, cropw = crop.xmax - crop.xmin, croph = crop.ymax - crop.ymin;
+       int crop_x = BLI_RCT_SIZE_X(&crop);
+       int crop_y = BLI_RCT_SIZE_Y(&crop);
+       int y;
 
-       if (cropw > 0 && croph > 0) {
-               for (y = 0; y < croph; y++, to += cropw, from += ibuf->x)
-                       memmove(to, from, sizeof(unsigned int) * cropw);
+       if (crop_x > 0 && crop_y > 0) {
+               for (y = 0; y < crop_y; y++, to += crop_x, from += ibuf->x)
+                       memmove(to, from, sizeof(unsigned int) * crop_x);
 
-               ibuf->x = cropw;
-               ibuf->y = croph;
+               ibuf->x = crop_x;
+               ibuf->y = crop_y;
        }
 }
 
index 7f51f54ee4b6af674c143cd86a73cb2d14e846df..8616d4e66eb300678ecc6d5a726715faaf01ba63 100644 (file)
@@ -31,6 +31,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "BLI_math.h"
+#include "BLI_rect.h"
 #include "BLI_utildefines.h"
 
 #include "DNA_brush_types.h"
@@ -440,8 +441,8 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
                else {
                        quad.xmin = 0;
                        quad.ymin = 0;
-                       quad.xmax = vc->ar->winrct.xmax - vc->ar->winrct.xmin;
-                       quad.ymax = vc->ar->winrct.ymax - vc->ar->winrct.ymin;
+                       quad.xmax = BLI_RCT_SIZE_X(&vc->ar->winrct);
+                       quad.ymax = BLI_RCT_SIZE_Y(&vc->ar->winrct);
                }
 
                /* set quad color */
index 199875fdc7be42269391287b98b92359daba6747..4bcd4a933edc0636cf83732c17ade0bfa96e0727 100644 (file)
@@ -148,7 +148,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
        uiBlockEndAlign(block);
        
        /* always as last  */
-       UI_view2d_totRect_set(&ar->v2d, xco + (UI_UNIT_X / 2), ar->v2d.tot.ymax - ar->v2d.tot.ymin);
+       UI_view2d_totRect_set(&ar->v2d, xco + (UI_UNIT_X / 2), BLI_RCT_SIZE_Y(&ar->v2d.tot));
        
        uiEndBlock(C, block);
        uiDrawBlock(C, block);
index de6aa42d5a6ce700c3f731b5b46615c8b6b4d073..f01d64b46b81dd8c1e5731298898aa72f4fc6307 100644 (file)
@@ -224,16 +224,16 @@ static int graphkeys_viewall(bContext *C, const short do_sel_only, const short i
                return OPERATOR_CANCELLED;
 
        /* set the horizontal range, with an extra offset so that the extreme keys will be in view */
-       get_graph_keyframe_extents(&ac, 
-                                                          &cur_new.xmin, &cur_new.xmax,
-                                                          &cur_new.ymin, &cur_new.ymax,
-                                                          do_sel_only, include_handles);
+       get_graph_keyframe_extents(&ac,
+                                  &cur_new.xmin, &cur_new.xmax,
+                                  &cur_new.ymin, &cur_new.ymax,
+                                  do_sel_only, include_handles);
 
-       extra = 0.1f * (cur_new.xmax - cur_new.xmin);
+       extra = 0.1f * BLI_RCT_SIZE_X(&cur_new);
        cur_new.xmin -= extra;
        cur_new.xmax += extra;
 
-       extra = 0.1f * (cur_new.ymax - cur_new.ymin);
+       extra = 0.1f * BLI_RCT_SIZE_Y(&cur_new);
        cur_new.ymin -= extra;
        cur_new.ymax += extra;
 
index d0f4fe9225770aba9893ad93e2579ec94d8447a4..40f0683a8524e87b1fc8c8886b232d17f4355d7e 100644 (file)
@@ -268,8 +268,8 @@ static void preview_cb(ScrArea *sa, struct uiBlock *block)
        int mval[2];
        
        if (G.scene->r.mode & R_BORDER) {
-               winx *= (G.scene->r.border.xmax - G.scene->r.border.xmin);
-               winy *= (G.scene->r.border.ymax - G.scene->r.border.ymin);
+               winx *= BLI_RCT_SIZE_X(&G.scene->r.border);
+               winy *= BLI_RCT_SIZE_Y(&G.scene->r.border);
        }
        
        /* while dragging we need to update the rects, otherwise it doesn't end with correct one */
index bb31ba42716634c8801fe3ef38dbe005565864bc..ac9883b411dd0b5aeea92edb1679cc6961f10b05 100644 (file)
@@ -182,8 +182,8 @@ void ED_space_image_get_size(SpaceImage *sima, int *width, int *height)
                *height = (scene->r.ysch * scene->r.size) / 100;
 
                if ((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) {
-                       *width *= (scene->r.border.xmax - scene->r.border.xmin);
-                       *height *= (scene->r.border.ymax - scene->r.border.ymin);
+                       *width  *= BLI_RCT_SIZE_X(&scene->r.border);
+                       *height *= BLI_RCT_SIZE_Y(&scene->r.border);
                }
 
        }
index f58448b39ac0ab279f177453fa0348599db6a579..a3d7785d5500e03d0e93c2a324399b131a4c08a7 100644 (file)
@@ -343,7 +343,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
                        if (node->prvr.ymax < node->prvr.ymin) SWAP(float, node->prvr.ymax, node->prvr.ymin);
                }
                else {
-                       float oldh = node->prvr.ymax - node->prvr.ymin;
+                       float oldh = BLI_RCT_SIZE_Y(&node->prvr);
                        if (oldh == 0.0f)
                                oldh = 0.6f * node->width - NODE_DY;
                        dy -= NODE_DYS / 2;
@@ -584,9 +584,9 @@ void node_socket_circle_draw(bNodeTree *UNUSED(ntree), bNodeSocket *sock, float
 /* not a callback */
 static void node_draw_preview(bNodePreview *preview, rctf *prv)
 {
-       float xscale = (prv->xmax - prv->xmin) / ((float)preview->xsize);
-       float yscale = (prv->ymax - prv->ymin) / ((float)preview->ysize);
-       float tile = (prv->xmax - prv->xmin) / 10.0f;
+       float xscale = BLI_RCT_SIZE_X(prv) / ((float)preview->xsize);
+       float yscale = BLI_RCT_SIZE_Y(prv) / ((float)preview->ysize);
+       float tile   = BLI_RCT_SIZE_X(prv) / 10.0f;
        float x, y;
        
        /* draw checkerboard backdrop to show alpha */
@@ -852,8 +852,8 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
 {
        bNodeSocket *sock;
        rctf *rct = &node->totr;
-       float dx, centy = 0.5f * (rct->ymax + rct->ymin);
-       float hiddenrad = 0.5f * (rct->ymax - rct->ymin);
+       float dx, centy = BLI_RCT_CENTER_Y(rct);
+       float hiddenrad = BLI_RCT_SIZE_Y(rct) / 2.0f;
        float socket_size = NODE_SOCKSIZE * U.dpi / 72;
        int color_id = node_get_colorid(node);
        char showname[128]; /* 128 is used below */
@@ -932,7 +932,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
 
                uiDefBut(node->block, LABEL, 0, showname,
                         (int)(rct->xmin + (NODE_MARGIN_X / snode->aspect_sqrt)), (int)(centy - 10),
-                        (short)(rct->xmax - rct->xmin - 18.0f - 12.0f), (short)NODE_DY,
+                        (short)(BLI_RCT_SIZE_X(rct) - 18.0f - 12.0f), (short)NODE_DY,
                         NULL, 0, 0, 0, 0, "");
        }       
 
index 6f549bd252f5d2910a30742ce6d717eccf25abf1..e89e798a6fabbe1532177edc600987b29e32a89a 100644 (file)
@@ -91,8 +91,8 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons
        }
 
        if (tot) {
-               width = cur_new.xmax - cur_new.xmin;
-               height = cur_new.ymax - cur_new.ymin;
+               width  = BLI_RCT_SIZE_X(&cur_new);
+               height = BLI_RCT_SIZE_Y(&cur_new);
 
                /* for single non-frame nodes, don't zoom in, just pan view,
                 * but do allow zooming out, this allows for big nodes to be zoomed out */
@@ -104,9 +104,6 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons
                        BLI_rctf_resize(&cur_new, oldwidth, oldheight);
                }
                else {
-                       width = cur_new.xmax - cur_new.xmin;
-                       height = cur_new.ymax - cur_new.ymin;
-
                        if (width > height) {
                                float newheight;
                                newheight = oldheight * width / oldwidth;
index b669e705a25efa503dd8d52cc088784874ccca94..0874ddcb279b24d98a163dc2fc7bb2f7efd289b3 100644 (file)
@@ -615,7 +615,7 @@ void OUTLINER_OT_show_active(wmOperatorType *ot)
 static int outliner_scroll_page_exec(bContext *C, wmOperator *op)
 {
        ARegion *ar = CTX_wm_region(C);
-       int dy = ar->v2d.mask.ymax - ar->v2d.mask.ymin;
+       int dy = BLI_RCT_SIZE_Y(&ar->v2d.mask);
        int up = 0;
        
        if (RNA_boolean_get(op->ptr, "up"))
@@ -760,10 +760,10 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
                        tselem->flag |= TSE_SELECTED;
                        
                        /* make te->ys center of view */
-                       ytop = (int)(te->ys + (ar->v2d.mask.ymax - ar->v2d.mask.ymin) / 2);
+                       ytop = (int)(te->ys + BLI_RCT_SIZE_Y(&ar->v2d.mask) / 2);
                        if (ytop > 0) ytop = 0;
                        ar->v2d.cur.ymax = (float)ytop;
-                       ar->v2d.cur.ymin = (float)(ytop - (ar->v2d.mask.ymax - ar->v2d.mask.ymin));
+                       ar->v2d.cur.ymin = (float)(ytop - BLI_RCT_SIZE_Y(&ar->v2d.mask));
                        
                        /* make te->xs ==> te->xend center of view */
                        xdelta = (int)(te->xs - ar->v2d.cur.xmin);
index 2dc26a9d5b8f3cbf974ca10c4041a05e49315b49..010ed177b72b6dcddee77d791149ddf1d57efbaa 100644 (file)
@@ -2246,7 +2246,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
                ymax += ymargin;
                ymin -= ymargin;
 
-               orig_height = cur_new.ymax - cur_new.ymin;
+               orig_height = BLI_RCT_SIZE_Y(&cur_new);
 
                cur_new.xmin = xmin;
                cur_new.xmax = xmax;
@@ -2255,7 +2255,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
                cur_new.ymax = ymax;
 
                /* only zoom out vertically */
-               if (orig_height > cur_new.ymax - cur_new.ymin) {
+               if (orig_height > BLI_RCT_SIZE_Y(&cur_new)) {
                        ymid = BLI_RCT_CENTER_Y(&cur_new);
 
                        cur_new.ymin = ymid - (orig_height / 2);
index 6240d17457579230cef4d804be57ea2fcfe31f54..97eb5b41db75361447663cd2302be971c365c03e 100644 (file)
@@ -39,6 +39,7 @@
 #include "BLF_api.h"
 
 #include "BLI_blenlib.h"
+#include "BLI_math.h"
 #include "BLI_utildefines.h"
 
 #include "DNA_text_types.h"
@@ -1231,7 +1232,7 @@ static void draw_textscroll(SpaceText *st, rcti *scroll, rcti *back)
        uiWidgetScrollDraw(&wcol, scroll, &st->txtbar, (st->flags & ST_SCROLL_SELECT) ? UI_SCROLL_PRESSED : 0);
 
        uiSetRoundBox(UI_CNR_ALL);
-       rad = 0.4f * MIN2(st->txtscroll.xmax - st->txtscroll.xmin, st->txtscroll.ymax - st->txtscroll.ymin);
+       rad = 0.4f * mini(BLI_RCT_SIZE_X(&st->txtscroll), BLI_RCT_SIZE_Y(&st->txtscroll));
        UI_GetThemeColor3ubv(TH_HILITE, col);
        col[3] = 48;
        glColor4ubv(col);
index 93f8457e7a374c5784125c3b81c14223584d939e..24395865a5e757f2d2503a6d425cd5278f0c6502 100644 (file)
@@ -971,10 +971,10 @@ static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionV
        rect_camera = params.viewplane;
 
        /* get camera border within viewport */
-       viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin) / (rect_view.xmax - rect_view.xmin)) * ar->winx;
-       viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin) / (rect_view.xmax - rect_view.xmin)) * ar->winx;
-       viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin) / (rect_view.ymax - rect_view.ymin)) * ar->winy;
-       viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin) / (rect_view.ymax - rect_view.ymin)) * ar->winy;
+       viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin) / BLI_RCT_SIZE_X(&rect_view)) * ar->winx;
+       viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin) / BLI_RCT_SIZE_X(&rect_view)) * ar->winx;
+       viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin) / BLI_RCT_SIZE_Y(&rect_view)) * ar->winy;
+       viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin) / BLI_RCT_SIZE_Y(&rect_view)) * ar->winy;
 }
 
 void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, float size_r[2])
@@ -982,8 +982,8 @@ void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, R
        rctf viewborder;
 
        view3d_camera_border(scene, ar, v3d, rv3d, &viewborder, TRUE, TRUE);
-       size_r[0] = viewborder.xmax - viewborder.xmin;
-       size_r[1] = viewborder.ymax - viewborder.ymin;
+       size_r[0] = BLI_RCT_SIZE_X(&viewborder);
+       size_r[1] = BLI_RCT_SIZE_Y(&viewborder);
 }
 
 void ED_view3d_calc_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d,
@@ -1339,7 +1339,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
                glDisable(GL_MULTISAMPLE_ARB);
 
        region_scissor_winrct(ar, &winrct);
-       glScissor(winrct.xmin, winrct.ymin, winrct.xmax - winrct.xmin, winrct.ymax - winrct.ymin);
+       glScissor(winrct.xmin, winrct.ymin, BLI_RCT_SIZE_X(&winrct), BLI_RCT_SIZE_Y(&winrct));
 
        glClearColor(0.0, 0.0, 0.0, 0.0); 
        if (v3d->zbuf) {
@@ -2846,10 +2846,10 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
 
                ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE);
 
-               cliprct.xmin = viewborder.xmin + scene->r.border.xmin * (viewborder.xmax - viewborder.xmin);
-               cliprct.ymin = viewborder.ymin + scene->r.border.ymin * (viewborder.ymax - viewborder.ymin);
-               cliprct.xmax = viewborder.xmin + scene->r.border.xmax * (viewborder.xmax - viewborder.xmin);
-               cliprct.ymax = viewborder.ymin + scene->r.border.ymax * (viewborder.ymax - viewborder.ymin);
+               cliprct.xmin = viewborder.xmin + scene->r.border.xmin * BLI_RCT_SIZE_X(&viewborder);
+               cliprct.ymin = viewborder.ymin + scene->r.border.ymin * BLI_RCT_SIZE_Y(&viewborder);
+               cliprct.xmax = viewborder.xmin + scene->r.border.xmax * BLI_RCT_SIZE_X(&viewborder);
+               cliprct.ymax = viewborder.ymin + scene->r.border.ymax * BLI_RCT_SIZE_Y(&viewborder);
 
                cliprct.xmin += ar->winrct.xmin;
                cliprct.xmax += ar->winrct.xmin;
@@ -2863,7 +2863,7 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
 
                if (cliprct.xmax > cliprct.xmin && cliprct.ymax > cliprct.ymin) {
                        glGetIntegerv(GL_SCISSOR_BOX, scissor);
-                       glScissor(cliprct.xmin, cliprct.ymin, cliprct.xmax - cliprct.xmin, cliprct.ymax - cliprct.ymin);
+                       glScissor(cliprct.xmin, cliprct.ymin, BLI_RCT_SIZE_X(&cliprct), BLI_RCT_SIZE_Y(&cliprct));
                }
                else
                        return 0;
index 6e0c598d0cee597aac4553a2b5c5154f81343073..db47f88c8f29320c54b7895c46bdc66c33e27ed2 100644 (file)
@@ -2617,10 +2617,10 @@ static int render_border_exec(bContext *C, wmOperator *op)
        /* calculate range */
        ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE);
 
-       scene->r.border.xmin = ((float)rect.xmin - vb.xmin) / (vb.xmax - vb.xmin);
-       scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / (vb.ymax - vb.ymin);
-       scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / (vb.xmax - vb.xmin);
-       scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / (vb.ymax - vb.ymin);
+       scene->r.border.xmin = ((float)rect.xmin - vb.xmin) / BLI_RCT_SIZE_X(&vb);
+       scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / BLI_RCT_SIZE_Y(&vb);
+       scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / BLI_RCT_SIZE_X(&vb);
+       scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / BLI_RCT_SIZE_Y(&vb);
 
        /* actually set border */
        CLAMP(scene->r.border.xmin, 0.0f, 1.0f);
index fcb857be4e0403260e2729ec33f592b9dc96cde7..89cb83e3661e764058e1ba3f2e46097077113ee4 100644 (file)
@@ -961,8 +961,8 @@ static void TargetSnapOffset(TransInfo *t, TransData *td)
        if (t->spacetype == SPACE_NODE && td != NULL) {
                bNode *node = td->extra;
                char border = t->tsnap.snapNodeBorder;
-               float width = node->totr.xmax - node->totr.xmin;
-               float height = node->totr.ymax - node->totr.ymin;
+               float width  = BLI_RCT_SIZE_X(&node->totr);
+               float height = BLI_RCT_SIZE_Y(&node->totr);
                
                if (border & NODE_LEFT)
                        t->tsnap.snapTarget[0] -= 0.5f * width;
index b44454f38d93daabf494dc9ec55c21bf9dd0bebd..2277c5a2836880762b7229188b019c252ec8cd02 100644 (file)
@@ -146,7 +146,7 @@ CompBuf *get_cropped_compbuf(rcti *drect, float *rectf, int rectx, int recty, in
        if (disprect.xmin>= disprect.xmax) return NULL;
        if (disprect.ymin>= disprect.ymax) return NULL;
        
-       cbuf= alloc_compbuf(disprect.xmax-disprect.xmin, disprect.ymax-disprect.ymin, type, 1);
+       cbuf= alloc_compbuf(BLI_RCT_SIZE_X(&disprect), BLI_RCT_SIZE_Y(&disprect), type, 1);
        outfp= cbuf->rect;
        rectf += type*(disprect.ymin*rectx + disprect.xmin);
        dx= type*cbuf->x;
index 6bd95e824eb02e04511b0fd6b1a752309e2318ef..ebacdee0c97f270f412ba40c85759a3bb61d0106 100644 (file)
@@ -5247,13 +5247,15 @@ static void speedvector_project(Render *re, float zco[2], const float co[3], con
                /* precalculate amount of radians 1 pixel rotates */
                if (pano) {
                        /* size of 1 pixel mapped to viewplane coords */
-                       float psize= (re->viewplane.xmax-re->viewplane.xmin)/(float)re->winx;
+                       float psize;
+
+                       psize = BLI_RCT_SIZE_X(&re->viewplane) / (float)re->winx;
                        /* x angle of a pixel */
-                       pixelphix= atan(psize/re->clipsta);
+                       pixelphix = atan(psize / re->clipsta);
                        
-                       psize= (re->viewplane.ymax-re->viewplane.ymin)/(float)re->winy;
+                       psize = BLI_RCT_SIZE_Y(&re->viewplane) / (float)re->winy;
                        /* y angle of a pixel */
-                       pixelphiy= atan(psize/re->clipsta);
+                       pixelphiy = atan(psize / re->clipsta);
                }
                zmulx= re->winx/2;
                zmuly= re->winy/2;
index 0a90a55b3bc896dae440f8206a54258234378e8f..56bf5242f366ec3591d640d3ee7afe10db0129af 100644 (file)
@@ -396,16 +396,16 @@ static float square_rctf(rctf *rf)
 {
        float x, y;
 
-       x= rf->xmax- rf->xmin;
-       y= rf->ymax- rf->ymin;
-       return (x*y);
+       x = BLI_RCT_SIZE_X(rf);
+       y = BLI_RCT_SIZE_Y(rf);
+       return x * y;
 }
 
 static float clipx_rctf(rctf *rf, float x1, float x2)
 {
        float size;
 
-       size= rf->xmax - rf->xmin;
+       size = BLI_RCT_SIZE_X(rf);
 
        if (rf->xmin<x1) {
                rf->xmin = x1;
@@ -418,7 +418,7 @@ static float clipx_rctf(rctf *rf, float x1, float x2)
                return 0.0;
        }
        else if (size!=0.0f) {
-               return (rf->xmax - rf->xmin)/size;
+               return BLI_RCT_SIZE_X(rf) / size;
        }
        return 1.0;
 }
@@ -427,7 +427,7 @@ static float clipy_rctf(rctf *rf, float y1, float y2)
 {
        float size;
 
-       size= rf->ymax - rf->ymin;
+       size = BLI_RCT_SIZE_Y(rf);
 
        if (rf->ymin<y1) {
                rf->ymin = y1;
@@ -440,8 +440,8 @@ static float clipy_rctf(rctf *rf, float y1, float y2)
                rf->ymin = rf->ymax;
                return 0.0;
        }
-       else if (size!=0.0f) {
-               return (rf->ymax - rf->ymin)/size;
+       else if (size != 0.0f) {
+               return BLI_RCT_SIZE_Y(rf) / size;
        }
        return 1.0;
 
index cc8f6682781a011fe2d8ff7312099815423d1f14..7efdba779435eff02b8f8fd2b7984d0f8aaef825 100644 (file)
@@ -610,8 +610,8 @@ void initparts(Render *re)
                }
                else disprect.ymax = ymaxb;
                
-               rectx = disprect.xmax - disprect.xmin;
-               recty = disprect.ymax - disprect.ymin;
+               rectx = BLI_RCT_SIZE_X(&disprect);
+               recty = BLI_RCT_SIZE_Y(&disprect);
                
                /* so, now can we add this part? */
                if (rectx > 0 && recty > 0) {
index 01b1f00ff9808710c37a3d8b2e0824884fcc1c13..9a524831388bfbcdaf2191c3aa4a789bb33a884a 100644 (file)
@@ -439,8 +439,8 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer *
        re->winy = winy;
        if (disprect) {
                re->disprect = *disprect;
-               re->rectx = disprect->xmax - disprect->xmin;
-               re->recty = disprect->ymax - disprect->ymin;
+               re->rectx = BLI_RCT_SIZE_X(disprect);
+               re->recty = BLI_RCT_SIZE_Y(disprect);
        }
        else {
                re->disprect.xmin = re->disprect.ymin = 0;
@@ -672,15 +672,15 @@ static void *do_part_thread(void *pa_v)
 float panorama_pixel_rot(Render *re)
 {
        float psize, phi, xfac;
-       float borderfac = (float)(re->disprect.xmax - re->disprect.xmin) / (float)re->winx;
+       float borderfac = (float)BLI_RCT_SIZE_X(&re->disprect) / (float)re->winx;
        
        /* size of 1 pixel mapped to viewplane coords */
-       psize = (re->viewplane.xmax - re->viewplane.xmin) / (float)(re->winx);
+       psize = BLI_RCT_SIZE_X(&re->viewplane) / (float)re->winx;
        /* angle of a pixel */
        phi = atan(psize / re->clipsta);
        
        /* correction factor for viewplane shifting, first calculate how much the viewplane angle is */
-       xfac = borderfac * ((re->viewplane.xmax - re->viewplane.xmin)) / (float)re->xparts;
+       xfac = borderfac * BLI_RCT_SIZE_X(&re->viewplane) / (float)re->xparts;
        xfac = atan(0.5f * xfac / re->clipsta);
        /* and how much the same viewplane angle is wrapped */
        psize = 0.5f * phi * ((float)re->partx);
@@ -713,7 +713,7 @@ static RenderPart *find_next_pano_slice(Render *re, int *minx, rctf *viewplane)
                float phi = panorama_pixel_rot(re);
 
                R.panodxp = (re->winx - (best->disprect.xmin + best->disprect.xmax) ) / 2;
-               R.panodxv = ((viewplane->xmax - viewplane->xmin) * R.panodxp) / (float)(re->winx);
+               R.panodxv = (BLI_RCT_SIZE_X(viewplane) * R.panodxp) / (float)(re->winx);
 
                /* shift viewplane */
                R.viewplane.xmin = viewplane->xmin + R.panodxv;
index a6b2c98f9d3c55d7b85fc0db718639871b3f5a73..c009c7b7394ef4dfb9ea1cbddc386737b1a5ecae 100644 (file)
@@ -107,11 +107,11 @@ void calc_view_vector(float *view, float x, float y)
                }
                
                /* move x and y to real viewplane coords */
-               x= (x/(float)R.winx);
-               view[0]= R.viewplane.xmin + x*(R.viewplane.xmax - R.viewplane.xmin);
+               x = (x / (float)R.winx);
+               view[0] = R.viewplane.xmin + x * BLI_RCT_SIZE_X(&R.viewplane);
                
-               y= (y/(float)R.winy);
-               view[1]= R.viewplane.ymin + y*(R.viewplane.ymax - R.viewplane.ymin);
+               y = (y / (float)R.winy);
+               view[1] = R.viewplane.ymin + y * BLI_RCT_SIZE_Y(&R.viewplane);
                
 //             if (R.flag & R_SEC_FIELD) {
 //                     if (R.r.mode & R_ODDFIELD) view[1]= (y+R.ystart)*R.ycor;
index 44e81215c3756d48e3d41196f1c45f73b89f920d..dce4d681ec9ff1000f56e9809cd9b0d9b02167c2 100644 (file)
@@ -1506,10 +1506,10 @@ static void isb_bsp_split_init(ISBBranch *root, MemArena *mem, int level)
                root->divider[1]= 0.5f*(root->box.ymin+root->box.ymax);
                
                /* find best splitpoint */
-               if (root->box.xmax-root->box.xmin > root->box.ymax-root->box.ymin)
-                       i= root->index= 0;
+               if (BLI_RCT_SIZE_X(&root->box) > BLI_RCT_SIZE_Y(&root->box))
+                       i = root->index = 0;
                else
-                       i= root->index= 1;
+                       i = root->index = 1;
                
                left= root->left= BLI_memarena_alloc(mem, sizeof(ISBBranch));
                right= root->right= BLI_memarena_alloc(mem, sizeof(ISBBranch));
@@ -1551,10 +1551,10 @@ static void isb_bsp_split(ISBBranch *root, MemArena *mem)
        root->divider[1]/= BSPMAX_SAMPLE;
        
        /* find best splitpoint */
-       if (root->box.xmax-root->box.xmin > root->box.ymax-root->box.ymin)
-               i= root->index= 0;
+       if (BLI_RCT_SIZE_X(&root->box) > BLI_RCT_SIZE_Y(&root->box))
+               i = root->index = 0;
        else
-               i= root->index= 1;
+               i = root->index = 1;
        
        /* new branches */
        left= root->left= BLI_memarena_alloc(mem, sizeof(ISBBranch));
index 0fa29bf3f1463abf1288c8cbb1733cbef7a476d6..adf54af240bc46c5d3be5722b94e8c36f22391b7 100644 (file)
@@ -256,13 +256,13 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct)
        win->curswin = _curswin;
        _curwindow = win;
        
-       width = _curswin->winrct.xmax - _curswin->winrct.xmin + 1;
-       height = _curswin->winrct.ymax - _curswin->winrct.ymin + 1;
+       width  = BLI_RCT_SIZE_X(&_curswin->winrct) + 1;
+       height = BLI_RCT_SIZE_Y(&_curswin->winrct) + 1;
        glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
 
        if (srct) {
-               width = srct->xmax - srct->xmin + 1;
-               height = srct->ymax - srct->ymin + 1;
+               width  = BLI_RCT_SIZE_X(srct) + 1;
+               height = BLI_RCT_SIZE_Y(srct) + 1;
                glScissor(srct->xmin, srct->ymin, width, height);
        }
        else