svn merge ^/trunk/blender -r50091:50107
authorCampbell Barton <ideasman42@gmail.com>
Wed, 22 Aug 2012 09:36:49 +0000 (09:36 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 22 Aug 2012 09:36:49 +0000 (09:36 +0000)
46 files changed:
CMakeLists.txt
build_files/scons/config/win64-mingw-config.py
build_files/scons/tools/Blender.py
source/blender/blenfont/intern/blf_font.c
source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/intern/colortools.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/scene.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/interface_handlers.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/interface/view2d.c
source/blender/editors/interface/view2d_ops.c
source/blender/editors/object/object_vgroup.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_group.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 77af06f6260c2dda9c4244d64f26d43cbcb411c2..0b6bb3f44bd56a70d88e94a42603c1e2f814c31b 100644 (file)
@@ -1070,6 +1070,8 @@ elseif(WIN32)
                        set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -lpthread")
                        
                        add_definitions(-DFREE_WINDOWS64 -DMS_WIN64)
+                       #Turn off OpenMP since it causes crashes on render for subsurfed/multiresolution meshes
+                       set(WITH_OPENMP OFF)
                endif()
 
                add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
index 3eb9803c785a5cd891dc2a41d0102f2489cd5df5..6848d78d95962de47440ef9433e5c5bf745f7776 100644 (file)
@@ -176,7 +176,7 @@ WITH_BF_RAYOPTIMIZATION = True
 BF_RAYOPTIMIZATION_SSE_FLAGS = ['-mmmx', '-msse', '-msse2']
 
 #May produce errors with unsupported MinGW-w64 builds
-WITH_BF_OPENMP = True
+WITH_BF_OPENMP = False
 
 ##
 CC = 'gcc'
index 40e9179f12b7cd669aa0926d32a17846a65471e5..1e114a43ae0aff0381a2d5e4617df6f5ca0ad1d7 100644 (file)
@@ -857,6 +857,8 @@ class BlenderEnvironment(SConsEnvironment):
         print bc.HEADER+'Configuring program '+bc.ENDC+bc.OKGREEN+progname+bc.ENDC
         lenv = self.Clone()
         lenv.Append(LINKFLAGS = lenv['PLATFORM_LINKFLAGS'])
+        if lenv['OURPLATFORM'] in ('win32-mingw', 'win64-mingw', 'linuxcross', 'cygwin', 'linux'):
+            lenv.Replace(LINK = '$CXX')
         if lenv['OURPLATFORM'] in ('win32-vc', 'cygwin', 'win64-vc'):
             if lenv['BF_DEBUG']:
                 lenv.Prepend(LINKFLAGS = ['/DEBUG','/PDB:'+progname+'.pdb','/NODEFAULTLIB:libcmt'])
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 c45afbe77a9cd53cbbfad95e44bd4b2b59e4c4da..2a0679e39772d0402b5cc861db91faca40422deb 100644 (file)
@@ -301,21 +301,29 @@ struct bNodeType *ntreeGetNodeType(struct bNodeTree *ntree);
 struct bNodeSocketType *ntreeGetSocketType(int type);
 
 struct bNodeTree *ntreeAddTree(const char *name, int type, int nodetype);
-void            ntreeInitTypes(struct bNodeTree *ntree);
+void              ntreeInitTypes(struct bNodeTree *ntree);
 
-void            ntreeFreeTree(struct bNodeTree *ntree);
+/* copy/free funcs, need to manage ID users */
+void              ntreeFreeTree_ex(struct bNodeTree *ntree, const short do_id_user);
+void              ntreeFreeTree(struct bNodeTree *ntree);
+struct bNodeTree *ntreeCopyTree_ex(struct bNodeTree *ntree, const short do_id_user);
 struct bNodeTree *ntreeCopyTree(struct bNodeTree *ntree);
-void            ntreeSwitchID(struct bNodeTree *ntree, struct ID *sce_from, struct ID *sce_to);
-void            ntreeMakeLocal(struct bNodeTree *ntree);
-int             ntreeHasType(struct bNodeTree *ntree, int type);
+void              ntreeSwitchID_ex(struct bNodeTree *ntree, struct ID *sce_from, struct ID *sce_to, const short do_id_user);
+void              ntreeSwitchID(struct bNodeTree *ntree, struct ID *sce_from, struct ID *sce_to);
+/* node->id user count */
+void              ntreeUserIncrefID(struct bNodeTree *ntree);
+void              ntreeUserDecrefID(struct bNodeTree *ntree);
 
-void            ntreeUpdateTree(struct bNodeTree *ntree);
+
+void              ntreeMakeLocal(struct bNodeTree *ntree);
+int               ntreeHasType(struct bNodeTree *ntree, int type);
+void              ntreeUpdateTree(struct bNodeTree *ntree);
 /* XXX Currently each tree update call does call to ntreeVerifyNodes too.
  * Some day this should be replaced by a decent depsgraph automatism!
  */
-void            ntreeVerifyNodes(struct Main *main, struct ID *id);
+void              ntreeVerifyNodes(struct Main *main, struct ID *id);
 
-void            ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, int *totnodes);
+void              ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, int *totnodes);
 
 /* XXX old trees handle output flags automatically based on special output node types and last active selection.
  * new tree types have a per-output socket flag to indicate the final output to use explicitly.
index 2a045d8b54f4abc7337161119c56d73dc2878f64..d0901ad93ff591c60f5b1cc740c239785e6b84d3 100644 (file)
@@ -669,7 +669,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 e5f392e4bced3c96e7511f7dd25add06d6f257aa..8a26a1b52c5c9805af3c1ca2b461f18a776dd1be 100644 (file)
@@ -235,7 +235,7 @@ Material *BKE_material_copy(Material *ma)
        if (ma->preview) man->preview = BKE_previewimg_copy(ma->preview);
 
        if (ma->nodetree) {
-               man->nodetree = ntreeCopyTree(ma->nodetree); /* 0 == full new tree */
+               man->nodetree = ntreeCopyTree(ma->nodetree);
        }
 
        man->gpumaterial.first = man->gpumaterial.last = NULL;
@@ -1483,7 +1483,11 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
        }
 }
 
-/* copy/paste buffer, if we had a propper py api that would be better */
+/**
+ * \brief copy/paste buffer, if we had a propper py api that would be better
+ * \note matcopybuf.nodetree does _NOT_ use ID's
+ * \todo matcopybuf.nodetree's  node->id's are NOT validated, this will crash!
+ */
 static Material matcopybuf;
 static short matcopied = 0;
 
@@ -1511,7 +1515,7 @@ void free_matcopybuf(void)
        matcopybuf.ramp_spec = NULL;
 
        if (matcopybuf.nodetree) {
-               ntreeFreeTree(matcopybuf.nodetree);
+               ntreeFreeTree_ex(matcopybuf.nodetree, FALSE);
                MEM_freeN(matcopybuf.nodetree);
                matcopybuf.nodetree = NULL;
        }
@@ -1537,7 +1541,7 @@ void copy_matcopybuf(Material *ma)
                        matcopybuf.mtex[a] = MEM_dupallocN(mtex);
                }
        }
-       matcopybuf.nodetree = ntreeCopyTree(ma->nodetree);
+       matcopybuf.nodetree = ntreeCopyTree_ex(ma->nodetree, FALSE);
        matcopybuf.preview = NULL;
        matcopybuf.gpumaterial.first = matcopybuf.gpumaterial.last = NULL;
        matcopied = 1;
@@ -1582,7 +1586,7 @@ void paste_matcopybuf(Material *ma)
                }
        }
 
-       ma->nodetree = ntreeCopyTree(matcopybuf.nodetree);
+       ma->nodetree = ntreeCopyTree_ex(matcopybuf.nodetree, FALSE);
 }
 
 
index 62e80645a355e69c573b4e8f17a26f928cc5c977..37562686a99479f7aeaabadefb564f20e847f406 100644 (file)
@@ -671,7 +671,7 @@ bNodeTree *ntreeAddTree(const char *name, int type, int nodetype)
  * copying for internal use (threads for eg), where you wont want it to modify the
  * scene data.
  */
-static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, const short do_make_extern)
+static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, const short do_id_user, const short do_make_extern)
 {
        bNodeTree *newtree;
        bNode *node /*, *nnode */ /* UNUSED */, *last;
@@ -702,6 +702,11 @@ static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, const short do_make_e
        last = ntree->nodes.last;
        for (node = ntree->nodes.first; node; node = node->next) {
 
+               /* ntreeUserDecrefID inline */
+               if (do_id_user) {
+                       id_us_plus(node->id);
+               }
+
                if (do_make_extern) {
                        id_lib_extern(node->id);
                }
@@ -751,22 +756,56 @@ static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, const short do_make_e
        return newtree;
 }
 
+bNodeTree *ntreeCopyTree_ex(bNodeTree *ntree, const short do_id_user)
+{
+       return ntreeCopyTree_internal(ntree, do_id_user, TRUE);
+}
 bNodeTree *ntreeCopyTree(bNodeTree *ntree)
 {
-       return ntreeCopyTree_internal(ntree, TRUE);
+       return ntreeCopyTree_ex(ntree, TRUE);
 }
 
 /* use when duplicating scenes */
-void ntreeSwitchID(bNodeTree *ntree, ID *id_from, ID *id_to)
+void ntreeSwitchID_ex(bNodeTree *ntree, ID *id_from, ID *id_to, const short do_id_user)
 {
        bNode *node;
+
+       if (id_from == id_to) {
+               /* should never happen but may as well skip if it does */
+               return;
+       }
+
        /* for scene duplication only */
        for (node = ntree->nodes.first; node; node = node->next) {
                if (node->id == id_from) {
+                       if (do_id_user) {
+                               id_us_min(id_from);
+                               id_us_plus(id_to);
+                       }
+
                        node->id = id_to;
                }
        }
 }
+void ntreeSwitchID(bNodeTree *ntree, ID *id_from, ID *id_to)
+{
+       ntreeSwitchID_ex(ntree, id_from, id_to, TRUE);
+}
+
+void ntreeUserIncrefID(bNodeTree *ntree)
+{
+       bNode *node;
+       for (node = ntree->nodes.first; node; node = node->next) {
+               id_us_plus(node->id);
+       }
+}
+void ntreeUserDecrefID(bNodeTree *ntree)
+{
+       bNode *node;
+       for (node = ntree->nodes.first; node; node = node->next) {
+               id_us_min(node->id);
+       }
+}
 
 /* *************** preview *********** */
 /* if node->preview, then we assume the rect to exist */
@@ -913,6 +952,7 @@ static void node_unlink_attached(bNodeTree *ntree, bNode *parent)
        }
 }
 
+/** \note caller needs to manage node->id user */
 void nodeFreeNode(bNodeTree *ntree, bNode *node)
 {
        bNodeSocket *sock, *nextsock;
@@ -956,7 +996,7 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node)
 }
 
 /* do not free ntree itself here, BKE_libblock_free calls this function too */
-void ntreeFreeTree(bNodeTree *ntree)
+void ntreeFreeTree_ex(bNodeTree *ntree, const short do_id_user)
 {
        bNode *node, *next;
        bNodeSocket *sock;
@@ -990,6 +1030,12 @@ void ntreeFreeTree(bNodeTree *ntree)
        
        for (node = ntree->nodes.first; node; node = next) {
                next = node->next;
+
+               /* ntreeUserIncrefID inline */
+               if (do_id_user) {
+                       id_us_min(node->id);
+               }
+
                nodeFreeNode(ntree, node);
        }
        
@@ -1000,6 +1046,11 @@ void ntreeFreeTree(bNodeTree *ntree)
                node_socket_free_default_value(sock->type, sock->default_value);
        BLI_freelistN(&ntree->outputs);
 }
+/* same as ntreeFreeTree_ex but always manage users */
+void ntreeFreeTree(bNodeTree *ntree)
+{
+       ntreeFreeTree_ex(ntree, TRUE);
+}
 
 void ntreeFreeCache(bNodeTree *ntree)
 {
@@ -1188,7 +1239,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
        }
 
        /* node copy func */
-       ltree = ntreeCopyTree_internal(ntree, FALSE);
+       ltree = ntreeCopyTree_internal(ntree, FALSE, FALSE);
 
        if (adt) {
                AnimData *ladt = BKE_animdata_from_id(&ltree->id);
@@ -1248,7 +1299,7 @@ void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree)
        if (ntreetype->local_merge)
                ntreetype->local_merge(localtree, ntree);
 
-       ntreeFreeTree(localtree);
+       ntreeFreeTree_ex(localtree, FALSE);
        MEM_freeN(localtree);
 }
 
index fc261d48132e74ff5d0f66521622c853e5c69c89..c0ec1cc9297bf3f279e14b1dfe64d44eee59d8fe 100644 (file)
@@ -156,7 +156,8 @@ Scene *BKE_scene_copy(Scene *sce, int type)
                BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets));
 
                if (sce->nodetree) {
-                       scen->nodetree = ntreeCopyTree(sce->nodetree); /* copies actions */
+                       /* ID's are managed on both copy and switch */
+                       scen->nodetree = ntreeCopyTree(sce->nodetree);
                        ntreeSwitchID(scen->nodetree, &sce->id, &scen->id);
                }
 
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 a8b50f5c76e7d4c0b58e6f8d5277e20128b05e06..77dbbc878a7729a7a191fd38e79946486e1d02d9 100644 (file)
@@ -493,8 +493,8 @@ static void ui_draw_but_CHARTAB(uiBut *but)
                charmax = G.charmax = 0xffff;
 
        /* Calculate the size of the button */
-       width = absBLI_RCT_SIZE_X(rect);
-       height = absBLI_RCT_SIZE_Y(rect);
+       width  = abs(BLI_RCT_SIZE_X(rect));
+       height = abs(BLI_RCT_SIZE_Y(rect));
        
        butw = floor(width / 12);
        buth = floor(height / 6);
@@ -1371,8 +1371,11 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
        scissor_new.xmax = ar->winrct.xmin + rect->xmax;
        scissor_new.ymax = ar->winrct.ymin + rect->ymax;
        BLI_rcti_isect(&scissor_new, &ar->winrct, &scissor_new);
-       glScissor(scissor_new.xmin, scissor_new.ymin, scissor_new.xmax - scissor_new.xmin, scissor_new.ymax - scissor_new.ymin);
-       
+       glScissor(scissor_new.xmin,
+                 scissor_new.ymin,
+                 BLI_RCT_SIZE_X(&scissor_new),
+                 BLI_RCT_SIZE_Y(&scissor_new));
+
        /* calculate offset and zoom */
        zoomx = (BLI_RCT_SIZE_X(rect) - 2.0f * but->aspect) / BLI_RCT_SIZE_X(&cumap->curr);
        zoomy = (BLI_RCT_SIZE_Y(rect) - 2.0f * but->aspect) / BLI_RCT_SIZE_Y(&cumap->curr);
@@ -1730,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 957482bb3793e998614504f5a242ed4dfc8e7de4..f0d2cb183b59a8aaad8a5760b131c3489a40d3fc 100644 (file)
@@ -4241,8 +4241,8 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa
                                scopes->marker = BKE_tracking_marker_ensure(scopes->track, scopes->framenr);
 
                        scopes->marker->flag &= ~(MARKER_DISABLED | MARKER_TRACKED);
-                       scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / (but->block->rect.xmax - but->block->rect.xmin);
-                       scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / (but->block->rect.ymax - but->block->rect.ymin);
+                       scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / BLI_RCT_SIZE_X(&but->block->rect);
+                       scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / BLI_RCT_SIZE_Y(&but->block->rect);
 
                        WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL);
                }
index 350aab728c406e1d8e261da535f25dc7d830787b..deef36de56165534d42de5e56b5704c195afc48d 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "BLI_listbase.h"
 #include "BLI_string.h"
+#include "BLI_rect.h"
 #include "BLI_utildefines.h"
 
 #include "BLF_translation.h"
@@ -238,8 +239,10 @@ static void ui_item_size(uiItem *item, int *r_w, int *r_h)
        if (item->type == ITEM_BUTTON) {
                uiButtonItem *bitem = (uiButtonItem *)item;
 
-               if (r_w) *r_w = bitem->but->rect.xmax - bitem->but->rect.xmin;
-               if (r_h) *r_h = bitem->but->rect.ymax - bitem->but->rect.ymin;
+
+
+               if (r_w) *r_w = BLI_RCT_SIZE_X(&bitem->but->rect);
+               if (r_h) *r_h = BLI_RCT_SIZE_Y(&bitem->but->rect);
        }
        else {
                uiLayout *litem = (uiLayout *)item;
index 512cda13df1576ab2f9387a4ac67a16d72d8980d..d0e66f532cca5e04080332be358affe097af7637 100644 (file)
@@ -547,7 +547,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
                
                /* itemrect smaller */  
                itemrect.xmax = headrect.xmax - 5.0f / block->aspect;
-               itemrect.xmin = itemrect.xmax - (headrect.ymax - headrect.ymin);
+               itemrect.xmin = itemrect.xmax - BLI_RCT_SIZE_Y(&headrect);
                itemrect.ymin = headrect.ymin;
                itemrect.ymax = headrect.ymax;
 
@@ -596,7 +596,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
        
        /* itemrect smaller */  
        itemrect.xmin = headrect.xmin + 5.0f / block->aspect;
-       itemrect.xmax = itemrect.xmin + (headrect.ymax - headrect.ymin);
+       itemrect.xmax = itemrect.xmin + BLI_RCT_SIZE_Y(&headrect);
        itemrect.ymin = headrect.ymin;
        itemrect.ymax = headrect.ymax;
        
index 35488430b22dbcef289bb27d75e9adb8a7e8eabb..8dee1ff6a13d7f2c9975b34274f1da1a447d89fb 100644 (file)
@@ -391,7 +391,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
        /* draw text */
        uiStyleFontSet(&data->fstyle);
 
-       bbox.ymax = bbox.ymax - 0.5f * ((bbox.ymax - bbox.ymin) - data->toth);
+       bbox.ymax = bbox.ymax - 0.5f * (BLI_RCT_SIZE_Y(&bbox) - data->toth);
        bbox.ymin = bbox.ymax - data->lineh;
 
        for (i = 0; i < data->totline; i++) {
@@ -730,9 +730,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
 
        /* widget rect, in region coords */
        data->bbox.xmin = MENU_SHADOW_SIDE;
-       data->bbox.xmax = rect_i.xmax - rect_i.xmin + MENU_SHADOW_SIDE;
+       data->bbox.xmax = BLI_RCT_SIZE_X(&rect_i) + MENU_SHADOW_SIDE;
        data->bbox.ymin = MENU_SHADOW_BOTTOM;
-       data->bbox.ymax = rect_i.ymax - rect_i.ymin + MENU_SHADOW_BOTTOM;
+       data->bbox.ymax = BLI_RCT_SIZE_Y(&rect_i) + MENU_SHADOW_BOTTOM;
        
        /* region bigger for shadow */
        ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE;
@@ -865,8 +865,8 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr)
 {
        /* thumbnail preview */
        if (data->preview) {
-               int buth = (data->bbox.ymax - data->bbox.ymin - 2 * MENU_TOP) / data->prv_rows;
-               int butw = (data->bbox.xmax - data->bbox.xmin) / data->prv_cols;
+               int butw =  BLI_RCT_SIZE_X(&data->bbox)                 / data->prv_cols;
+               int buth = (BLI_RCT_SIZE_Y(&data->bbox) - 2 * MENU_TOP) / data->prv_rows;
                int row, col;
                
                *rect = data->bbox;
@@ -882,7 +882,7 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr)
        }
        /* list view */
        else {
-               int buth = (data->bbox.ymax - data->bbox.ymin - 2 * MENU_TOP) / SEARCH_ITEMS;
+               int buth = (BLI_RCT_SIZE_Y(&data->bbox) - 2 * MENU_TOP) / SEARCH_ITEMS;
                
                *rect = data->bbox;
                rect->xmin = data->bbox.xmin + 3.0f;
@@ -1200,7 +1200,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
                BLI_rctf_translate(&rect_fl, ofsx, ofsy);
        
                /* minimal width */
-               if (rect_fl.xmax - rect_fl.xmin < 150) {
+               if (BLI_RCT_SIZE_X(&rect_fl) < 150) {
                        rect_fl.xmax = rect_fl.xmin + 150;  /* XXX arbitrary */
                }
                
@@ -1233,15 +1233,15 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
                        UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->rect.ymax + ofsy, NULL, &newy1);
                        newy1 += butregion->winrct.ymin;
 
-                       rect_i.ymax = rect_i.ymax - rect_i.ymin + newy1;
+                       rect_i.ymax = BLI_RCT_SIZE_Y(&rect_i) + newy1;
                        rect_i.ymin = newy1;
                }
 
                /* widget rect, in region coords */
                data->bbox.xmin = MENU_SHADOW_SIDE;
-               data->bbox.xmax = rect_i.xmax - rect_i.xmin + MENU_SHADOW_SIDE;
+               data->bbox.xmax = BLI_RCT_SIZE_X(&rect_i) + MENU_SHADOW_SIDE;
                data->bbox.ymin = MENU_SHADOW_BOTTOM;
-               data->bbox.ymax = rect_i.ymax - rect_i.ymin + MENU_SHADOW_BOTTOM;
+               data->bbox.ymax = BLI_RCT_SIZE_Y(&rect_i) + MENU_SHADOW_BOTTOM;
                
                /* region bigger for shadow */
                ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE;
@@ -2341,7 +2341,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
 
        if (pup->but) {
                /* minimum width to enforece */
-               minwidth = pup->but->rect.xmax - pup->but->rect.xmin;
+               minwidth = BLI_RCT_SIZE_X(&pup->but->rect);
 
                if (pup->but->type == PULLDOWN || pup->but->menu_create_func) {
                        direction = UI_DOWN;
@@ -2383,7 +2383,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
                         * button, so it doesn't overlap the text too much, also note
                         * the offset is negative because we are inverse moving the
                         * block to be under the mouse */
-                       offset[0] = -(bt->rect.xmin + 0.8f * (bt->rect.xmax - bt->rect.xmin));
+                       offset[0] = -(bt->rect.xmin + 0.8f * BLI_RCT_SIZE_X(&bt->rect));
                        offset[1] = -(bt->rect.ymin + 0.5f * UI_UNIT_Y);
                }
                else {
@@ -2391,7 +2391,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
                         * on the first item */
                        offset[0] = 0;
                        for (bt = block->buttons.first; bt; bt = bt->next)
-                               offset[0] = mini(offset[0], -(bt->rect.xmin + 0.8f * (bt->rect.xmax - bt->rect.xmin)));
+                               offset[0] = mini(offset[0], -(bt->rect.xmin + 0.8f * BLI_RCT_SIZE_X(&bt->rect)));
 
                        offset[1] = 1.5 * UI_UNIT_Y;
                }
index bf5b3fbe8c792ba71e3e27b7d1eecacbc8763527..ef8d8302fa749c3c62822ef7bcbbdf32579a16a7 100644 (file)
@@ -1760,8 +1760,8 @@ static void widget_softshadow(rcti *rect, int roundboxalign, float radin, float
        float quad_strip[WIDGET_SIZE_MAX * 2][2];
        
        /* prevent tooltips to not show round shadow */
-       if (2.0f * radout > 0.2f * (rect1.ymax - rect1.ymin) )
-               rect1.ymax -= 0.2f * (rect1.ymax - rect1.ymin);
+       if (2.0f * radout > 0.2f * BLI_RCT_SIZE_Y(&rect1))
+               rect1.ymax -= 0.2f * BLI_RCT_SIZE_Y(&rect1);
        else
                rect1.ymax -= 2.0f * radout;
        
@@ -2371,12 +2371,12 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
                /* ensure minimium size */
                min = BLI_RCT_SIZE_Y(rect);
 
-               if (rect1.xmax - rect1.xmin < min) {
+               if (BLI_RCT_SIZE_X(&rect1) < min) {
                        rect1.xmax = rect1.xmin + min;
 
                        if (rect1.xmax > rect->xmax) {
                                rect1.xmax = rect->xmax;
-                               rect1.xmin = MAX2(rect1.xmax - min, rect->xmin);
+                               rect1.xmin = maxi(rect1.xmax - min, rect->xmin);
                        }
                }
        }
@@ -2388,7 +2388,7 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
                /* ensure minimium size */
                min = BLI_RCT_SIZE_X(rect);
 
-               if (rect1.ymax - rect1.ymin < min) {
+               if (BLI_RCT_SIZE_Y(&rect1) < min) {
                        rect1.ymax = rect1.ymin + min;
 
                        if (rect1.ymax > rect->ymax) {
@@ -2416,10 +2416,10 @@ static void widget_progressbar(uiBut *but, uiWidgetColors *wcol, rcti *rect, int
        rect_prog.ymax = rect_prog.ymin + 4;
        rect_bar.ymax = rect_bar.ymin + 4;
        
-       w = value * (rect_prog.xmax - rect_prog.xmin);
+       w = value * BLI_RCT_SIZE_X(&rect_prog);
        
        /* ensure minimium size */
-       min = rect_prog.ymax - rect_prog.ymin;
+       min = BLI_RCT_SIZE_Y(&rect_prog);
        w = MAX2(w, min);
        
        rect_bar.xmax = rect_bar.xmin + w;
@@ -2483,7 +2483,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
                rect1 = *rect;
                
                value = ui_get_but_val(but);
-               fac = ((float)value - but->softmin) * (rect1.xmax - rect1.xmin - offs) / (but->softmax - but->softmin);
+               fac = ((float)value - but->softmin) * (BLI_RCT_SIZE_X(&rect1) - offs) / (but->softmax - but->softmin);
                
                /* left part of slider, always rounded */
                rect1.xmax = rect1.xmin + ceil(offs + 1.0f);
@@ -2705,10 +2705,10 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
        widget_init(&wtb);
        
        /* square */
-       recttemp.xmax = recttemp.xmin + (recttemp.ymax - recttemp.ymin);
+       recttemp.xmax = recttemp.xmin + BLI_RCT_SIZE_Y(&recttemp);
        
        /* smaller */
-       delta = 1 + (recttemp.ymax - recttemp.ymin) / 8;
+       delta = 1 + BLI_RCT_SIZE_Y(&recttemp) / 8;
        recttemp.xmin += delta;
        recttemp.ymin += delta;
        recttemp.xmax -= delta;
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 b7977c23010c9e51351d970e6871e2c4726ff2d3..c4616fc39c6166ba01b967af5bbf5674ef15815b 100644 (file)
@@ -686,8 +686,9 @@ static void vgroup_duplicate(Object *ob)
                        dw_org = defvert_find_index(dv, idg);
                        if (dw_org) {
                                /* defvert_verify_index re-allocs org so need to store the weight first */
+                               const float weight = dw_org->weight;
                                dw_cpy = defvert_verify_index(dv, icdg);
-                               dw_cpy->weight = dw_org->weight;
+                               dw_cpy->weight = weight;
                        }
                }
 
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 9bb5fb34140f29296a229646f6900a2ad2f43cb9..f2f37583ce940f7ee4fa730d92057c85d7b48010 100644 (file)
@@ -1620,7 +1620,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 295c2000796e2e1e546e0a84d795d6cb697dcdff..bc22a220adf8ca88897bdc2d8bca1cea95d0b811 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 087f86e4497d1fea236f577200a5bb2e83a442b1..9319baf99f7541b58d3088b07721bbd600db4f17 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 efd2378bf31c8ddd67362e8fc442dae3bcfa8219..77583ae132542aa6372cdc3e42675d63e33f2abb 100644 (file)
@@ -421,10 +421,11 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
                node->new_node = NULL;
 
        /* wgroup is a temporary copy of the NodeTree we're merging in
-        *      - all of wgroup's nodes are transferred across to their new home
-        *      - ngroup (i.e. the source NodeTree) is left unscathed
+        * - all of wgroup's nodes are transferred across to their new home
+        * - ngroup (i.e. the source NodeTree) is left unscathed
+        * - temp copy. don't change ID usercount
         */
-       wgroup = ntreeCopyTree(ngroup);
+       wgroup = ntreeCopyTree_ex(ngroup, FALSE);
 
        /* add the nodes into the ntree */
        for (node = wgroup->nodes.first; node; node = nextn) {
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 cdd135b0755b1cc4d881284da69ca5242fc4e0a4..41535915c05462c0e6a4f36227b4354c6334272a 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 39403d83b421a97a32cadf86d99df0dd0f163e88..10352033741a72eba2c29fd7890148539dd6b43a 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) {
@@ -2854,10 +2854,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;
@@ -2871,7 +2871,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 9d2b68b77dbb3f433baa3bee6ea4f90e5cd3a6b3..66f230a40f5a7f462db9d3a5d9cd74cf8eaf3d0a 100644 (file)
@@ -610,8 +610,8 @@ void initparts(Render *re, int do_crop)
                }
                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 17a7bed4498127b36d858521beceb4e4e3e871d9..2d4a39c51b881e952a4151c3d5357ba3c9b198a7 100644 (file)
@@ -440,8 +440,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;
@@ -673,15 +673,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);
@@ -714,7 +714,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