Revision: 48838
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48838
Author:   campbellbarton
Date:     2012-07-11 18:17:48 +0000 (Wed, 11 Jul 2012)
Log Message:
-----------
vector versions of BLI_in_rctf / BLI_in_rcti, (BLI_in_rctf_v, BLI_in_rcti_v)
use where possible.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/displist.c
    trunk/blender/source/blender/blenlib/BLI_rect.h
    trunk/blender/source/blender/blenlib/BLI_scanfill.h
    trunk/blender/source/blender/blenlib/intern/rct.c
    trunk/blender/source/blender/editors/animation/keyframes_edit.c
    trunk/blender/source/blender/editors/interface/interface_panel.c
    trunk/blender/source/blender/editors/mask/mask_select.c
    trunk/blender/source/blender/editors/screen/screen_edit.c
    trunk/blender/source/blender/editors/screen/screen_intern.h
    trunk/blender/source/blender/editors/screen/screen_ops.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/editors/space_clip/tracking_select.c
    trunk/blender/source/blender/editors/space_view3d/view3d_select.c
    trunk/blender/source/blender/editors/uvedit/uvedit_ops.c
    trunk/blender/source/blender/render/intern/source/shadbuf.c
    trunk/blender/source/blender/windowmanager/intern/wm_event_system.c
    trunk/blender/source/blender/windowmanager/intern/wm_gesture.c

Modified: trunk/blender/source/blender/blenkernel/intern/displist.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/displist.c   2012-07-11 
16:08:04 UTC (rev 48837)
+++ trunk/blender/source/blender/blenkernel/intern/displist.c   2012-07-11 
18:17:48 UTC (rev 48838)
@@ -499,16 +499,14 @@
                                /* vert data */
                                f1 = dlnew->verts;
                                totvert = 0;
-                               sf_vert = sf_ctx.fillvertbase.first;
-                               while (sf_vert) {
+
+                               for (sf_vert = sf_ctx.fillvertbase.first; 
sf_vert; sf_vert = sf_vert->next) {
                                        copy_v3_v3(f1, sf_vert->co);
                                        f1 += 3;
 
                                        /* index number */
                                        sf_vert->tmp.l = totvert;
                                        totvert++;
-
-                                       sf_vert = sf_vert->next;
                                }
 
                                /* index data */

Modified: trunk/blender/source/blender/blenlib/BLI_rect.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_rect.h     2012-07-11 16:08:04 UTC 
(rev 48837)
+++ trunk/blender/source/blender/blenlib/BLI_rect.h     2012-07-11 18:17:48 UTC 
(rev 48838)
@@ -48,26 +48,30 @@
  *
  * \return True if \a rect is empty.
  */
-int  BLI_rcti_is_empty(struct rcti *rect);
-int  BLI_rctf_is_empty(struct rctf *rect);
+int  BLI_rcti_is_empty(const struct rcti *rect);
+int  BLI_rctf_is_empty(const struct rctf *rect);
 void BLI_init_rctf(struct rctf *rect, float xmin, float xmax, float ymin, 
float ymax);
 void BLI_init_rcti(struct rcti *rect, int xmin, int xmax, int ymin, int ymax);
 void BLI_translate_rctf(struct rctf *rect, float x, float y);
 void BLI_translate_rcti(struct rcti *rect, int x, int y);
 void BLI_resize_rcti(struct rcti *rect, int x, int y);
 void BLI_resize_rctf(struct rctf *rect, float x, float y);
-int  BLI_in_rcti(struct rcti *rect, int x, int y);
-int  BLI_in_rctf(struct rctf *rect, float x, float y);
-int BLI_segment_in_rcti(struct rcti *rect, int s1[2], int s2[2]);
-// int  BLI_segment_in_rctf(struct rcti *rect, int s1[2], int s2[2]); // NOT 
NEEDED YET
-int  BLI_isect_rctf(struct rctf *src1, struct rctf *src2, struct rctf *dest);
-int  BLI_isect_rcti(struct rcti *src1, struct rcti *src2, struct rcti *dest);
-void BLI_union_rctf(struct rctf *rcta, struct rctf *rctb);
-void BLI_union_rcti(struct rcti *rcti1, struct rcti *rcti2);
+int  BLI_in_rcti(const struct rcti *rect, const int x, const int y);
+int  BLI_in_rcti_v(const struct rcti *rect, const int xy[2]);
+int  BLI_in_rctf(const struct rctf *rect, const float x, const float y);
+int  BLI_in_rctf_v(const struct rctf *rect, const float xy[2]);
+int  BLI_segment_in_rcti(const struct rcti *rect, const int s1[2], const int 
s2[2]);
+#if 0 /* NOT NEEDED YET */
+int  BLI_segment_in_rctf(struct rcti *rect, int s1[2], int s2[2]);
+#endif
+int  BLI_isect_rctf(const struct rctf *src1, const struct rctf *src2, struct 
rctf *dest);
+int  BLI_isect_rcti(const struct rcti *src1, const struct rcti *src2, struct 
rcti *dest);
+void BLI_union_rctf(struct rctf *rctf1, const struct rctf *rctf2);
+void BLI_union_rcti(struct rcti *rcti1, const struct rcti *rcti2);
 void BLI_copy_rcti_rctf(struct rcti *tar, const struct rctf *src);
 
-void print_rctf(const char *str, struct rctf *rect);
-void print_rcti(const char *str, struct rcti *rect);
+void print_rctf(const char *str, const struct rctf *rect);
+void print_rcti(const char *str, const struct rcti *rect);
 
 #ifdef __cplusplus
 }

Modified: trunk/blender/source/blender/blenlib/BLI_scanfill.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_scanfill.h 2012-07-11 16:08:04 UTC 
(rev 48837)
+++ trunk/blender/source/blender/blenlib/BLI_scanfill.h 2012-07-11 18:17:48 UTC 
(rev 48838)
@@ -65,7 +65,8 @@
        union {
                struct ScanFillVert *v;
                void                *p;
-               intptr_t l;
+               intptr_t             l;
+               unsigned int         u;
        } tmp;
        float co[3]; /* vertex location */
        float xy[2]; /* 2D copy of vertex location (using dominant axis) */

Modified: trunk/blender/source/blender/blenlib/intern/rct.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/rct.c   2012-07-11 16:08:04 UTC 
(rev 48837)
+++ trunk/blender/source/blender/blenlib/intern/rct.c   2012-07-11 18:17:48 UTC 
(rev 48838)
@@ -38,17 +38,17 @@
 #include "DNA_vec_types.h"
 #include "BLI_rect.h"
 
-int BLI_rcti_is_empty(rcti *rect)
+int BLI_rcti_is_empty(const rcti *rect)
 {
        return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin));
 }
 
-int BLI_rctf_is_empty(rctf *rect)
+int BLI_rctf_is_empty(const rctf *rect)
 {
        return ((rect->xmax <= rect->xmin) || (rect->ymax <= rect->ymin));
 }
 
-int BLI_in_rcti(rcti *rect, int x, int y)
+int BLI_in_rcti(const rcti *rect, const int x, const int y)
 {
        if (x < rect->xmin) return 0;
        if (x > rect->xmax) return 0;
@@ -57,8 +57,17 @@
        return 1;
 }
 
-int BLI_in_rctf(rctf *rect, float x, float y)
+int BLI_in_rcti_v(const rcti *rect, const int xy[2])
 {
+       if (xy[0] < rect->xmin) return 0;
+       if (xy[0] > rect->xmax) return 0;
+       if (xy[1] < rect->ymin) return 0;
+       if (xy[1] > rect->ymax) return 0;
+       return 1;
+}
+
+int BLI_in_rctf(const rctf *rect, const float x, const float y)
+{
        if (x < rect->xmin) return 0;
        if (x > rect->xmax) return 0;
        if (y < rect->ymin) return 0;
@@ -66,6 +75,15 @@
        return 1;
 }
 
+int BLI_in_rctf_v(const rctf *rect, const float xy[2])
+{
+       if (xy[0] < rect->xmin) return 0;
+       if (xy[0] > rect->xmax) return 0;
+       if (xy[1] < rect->ymin) return 0;
+       if (xy[1] > rect->ymax) return 0;
+       return 1;
+}
+
 /* based closely on 'isect_line_line_v2_int', but in modified so corner cases 
are treated as intersections */
 static int isect_segments(const int v1[2], const int v2[2], const int v3[2], 
const int v4[2])
 {
@@ -80,7 +98,7 @@
        }
 }
 
-int BLI_segment_in_rcti(rcti *rect, int s1[2], int s2[2])
+int BLI_segment_in_rcti(const rcti *rect, const int s1[2], const int s2[2])
 {
        /* first do outside-bounds check for both points of the segment */
        if (s1[0] < rect->xmin && s2[0] < rect->xmin) return 0;
@@ -89,7 +107,7 @@
        if (s1[1] > rect->ymax && s2[1] > rect->ymax) return 0;
 
        /* if either points intersect then we definetly intersect */
-       if (BLI_in_rcti(rect, s1[0], s1[1]) || BLI_in_rcti(rect, s2[0], s2[1])) 
{
+       if (BLI_in_rcti_v(rect, s1) || BLI_in_rcti_v(rect, s2)) {
                return 1;
        }
        else {
@@ -115,7 +133,7 @@
        }
 }
 
-void BLI_union_rctf(rctf *rct1, rctf *rct2)
+void BLI_union_rctf(rctf *rct1, const rctf *rct2)
 {
        if (rct1->xmin > rct2->xmin) rct1->xmin = rct2->xmin;
        if (rct1->xmax < rct2->xmax) rct1->xmax = rct2->xmax;
@@ -123,7 +141,7 @@
        if (rct1->ymax < rct2->ymax) rct1->ymax = rct2->ymax;
 }
 
-void BLI_union_rcti(rcti *rct1, rcti *rct2)
+void BLI_union_rcti(rcti *rct1, const rcti *rct2)
 {
        if (rct1->xmin > rct2->xmin) rct1->xmin = rct2->xmin;
        if (rct1->xmax < rct2->xmax) rct1->xmax = rct2->xmax;
@@ -207,7 +225,7 @@
        rect->ymax = rect->ymin + y;
 }
 
-int BLI_isect_rctf(rctf *src1, rctf *src2, rctf *dest)
+int BLI_isect_rctf(const rctf *src1, const rctf *src2, rctf *dest)
 {
        float xmin, xmax;
        float ymin, ymax;
@@ -237,7 +255,7 @@
        }
 }
 
-int BLI_isect_rcti(rcti *src1, rcti *src2, rcti *dest)
+int BLI_isect_rcti(const rcti *src1, const rcti *src2, rcti *dest)
 {
        int xmin, xmax;
        int ymin, ymax;
@@ -269,19 +287,19 @@
 
 void BLI_copy_rcti_rctf(rcti *tar, const rctf *src)
 {
-       tar->xmin = floor(src->xmin + 0.5f);
-       tar->xmax = floor((src->xmax - src->xmin) + 0.5f);
-       tar->ymin = floor(src->ymin + 0.5f);
-       tar->ymax = floor((src->ymax - src->ymin) + 0.5f);
+       tar->xmin = floorf(src->xmin + 0.5f);
+       tar->xmax = floorf((src->xmax - src->xmin) + 0.5f);
+       tar->ymin = floorf(src->ymin + 0.5f);
+       tar->ymax = floorf((src->ymax - src->ymin) + 0.5f);
 }
 
-void print_rctf(const char *str, rctf *rect)
+void print_rctf(const char *str, const rctf *rect)
 {
        printf("%s: xmin %.3f, xmax %.3f, ymin %.3f, ymax %.3f (%.3fx%.3f)\n", 
str,
               rect->xmin, rect->xmax, rect->ymin, rect->ymax, rect->xmax - 
rect->xmin, rect->ymax - rect->ymin);
 }
 
-void print_rcti(const char *str, rcti *rect)
+void print_rcti(const char *str, const rcti *rect)
 {
        printf("%s: xmin %d, xmax %d, ymin %d, ymax %d (%dx%d)\n", str,
               rect->xmin, rect->xmax, rect->ymin, rect->ymax, rect->xmax - 
rect->xmin, rect->ymax - rect->ymin);

Modified: trunk/blender/source/blender/editors/animation/keyframes_edit.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframes_edit.c     
2012-07-11 16:08:04 UTC (rev 48837)
+++ trunk/blender/source/blender/editors/animation/keyframes_edit.c     
2012-07-11 18:17:48 UTC (rev 48838)
@@ -505,7 +505,7 @@
        if (ked->data) {
                short ok = 0;
                
-               #define KEY_CHECK_OK(_index) BLI_in_rctf(ked->data, 
bezt->vec[_index][0], bezt->vec[_index][1])
+               #define KEY_CHECK_OK(_index) BLI_in_rctf_v(ked->data, 
bezt->vec[_index])
                KEYFRAME_OK_CHECKS(KEY_CHECK_OK);
                #undef KEY_CHECK_OK
                

Modified: trunk/blender/source/blender/editors/interface/interface_panel.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_panel.c    
2012-07-11 16:08:04 UTC (rev 48837)
+++ trunk/blender/source/blender/editors/interface/interface_panel.c    
2012-07-11 18:17:48 UTC (rev 48838)
@@ -978,7 +978,7 @@
        short align = panel_aligned(sa, ar), dx = 0, dy = 0;
        
        /* first clip for window, no dragging outside */
-       if (!BLI_in_rcti(&ar->winrct, event->x, event->y))
+       if (!BLI_in_rcti_v(&ar->winrct, &event->x))
                return;
 
        dx = (event->x - data->startx) & ~(PNL_GRID - 1);

Modified: trunk/blender/source/blender/editors/mask/mask_select.c
===================================================================
--- trunk/blender/source/blender/editors/mask/mask_select.c     2012-07-11 
16:08:04 UTC (rev 48837)
+++ trunk/blender/source/blender/editors/mask/mask_select.c     2012-07-11 
18:17:48 UTC (rev 48838)
@@ -418,7 +418,7 @@
                                /* TODO: handles? */
                                /* TODO: uw? */
 
-                               if (BLI_in_rctf(&rectf, 
point_deform->bezt.vec[1][0], point_deform->bezt.vec[1][1])) {
+                               if (BLI_in_rctf_v(&rectf, 
point_deform->bezt.vec[1])) {
                                        BKE_mask_point_select_set(point, mode 
== GESTURE_MODAL_SELECT);
                                        BKE_mask_point_select_set_handle(point, 
mode == GESTURE_MODAL_SELECT);
                                }

Modified: trunk/blender/source/blender/editors/screen/screen_edit.c
===================================================================

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to