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);
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;
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);
}
}
}