[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48855] trunk/blender/source/blender: add bli rect min/max functions.

Campbell Barton ideasman42 at gmail.com
Thu Jul 12 11:24:17 CEST 2012


Revision: 48855
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48855
Author:   campbellbarton
Date:     2012-07-12 09:24:17 +0000 (Thu, 12 Jul 2012)
Log Message:
-----------
add bli rect min/max functions.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_rect.h
    trunk/blender/source/blender/blenlib/intern/rct.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c

Modified: trunk/blender/source/blender/blenlib/BLI_rect.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_rect.h	2012-07-12 09:03:45 UTC (rev 48854)
+++ trunk/blender/source/blender/blenlib/BLI_rect.h	2012-07-12 09:24:17 UTC (rev 48855)
@@ -46,6 +46,9 @@
 void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax);
 void BLI_rcti_init_minmax(struct rcti *rect);
 void BLI_rctf_init_minmax(struct rctf *rect);
+void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2]);
+void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2]);
+
 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);

Modified: trunk/blender/source/blender/blenlib/intern/rct.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/rct.c	2012-07-12 09:03:45 UTC (rev 48854)
+++ trunk/blender/source/blender/blenlib/intern/rct.c	2012-07-12 09:24:17 UTC (rev 48855)
@@ -211,6 +211,22 @@
 	rect->xmax = rect->ymax = FLT_MIN;
 }
 
+void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
+{
+	if (xy[0] < rect->xmin) rect->xmin = xy[0];
+	if (xy[0] > rect->xmax) rect->xmax = xy[0];
+	if (xy[1] < rect->ymin) rect->ymin = xy[1];
+	if (xy[1] > rect->ymax) rect->ymax = xy[1];
+}
+
+void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2])
+{
+	if (xy[0] < rect->xmin) rect->xmin = xy[0];
+	if (xy[0] > rect->xmax) rect->xmax = xy[0];
+	if (xy[1] < rect->ymin) rect->ymin = xy[1];
+	if (xy[1] > rect->ymax) rect->ymax = xy[1];
+}
+
 void BLI_translate_rcti(rcti *rect, int x, int y)
 {
 	rect->xmin += x;

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c	2012-07-12 09:03:45 UTC (rev 48854)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c	2012-07-12 09:24:17 UTC (rev 48855)
@@ -93,16 +93,19 @@
 		for (j = 0; j < 2; ++j) {
 			for (k = 0; k < 2; ++k) {
 				float vec[3], proj[2];
+				int proj_i[2];
 				vec[0] = i ? bb_min[0] : bb_max[0];
 				vec[1] = j ? bb_min[1] : bb_max[1];
 				vec[2] = k ? bb_min[2] : bb_max[2];
 				/* convert corner to screen space */
 				ED_view3d_project_float_v2(ar, vec, proj, projection_mat);
 				/* expand 2D rectangle */
-				rect->xmin = MIN2(rect->xmin, proj[0]);
-				rect->xmax = MAX2(rect->xmax, proj[0]);
-				rect->ymin = MIN2(rect->ymin, proj[1]);
-				rect->ymax = MAX2(rect->ymax, proj[1]);
+
+				/* we could project directly to int? */
+				proj_i[0] = proj[0];
+				proj_i[1] = proj[1];
+
+				BLI_rcti_do_minmax_v(rect, proj_i);
 			}
 		}
 	}




More information about the Bf-blender-cvs mailing list