ED_view3D: Remove and replace `ED_view3d_select_id_read`
authormano-wii <germano.costa@ig.com.br>
Sat, 3 Aug 2019 21:41:16 +0000 (18:41 -0300)
committermano-wii <germano.costa@ig.com.br>
Mon, 5 Aug 2019 12:30:55 +0000 (09:30 -0300)
It is very similar to `ED_view3d_select_id_read_rect`.

source/blender/editors/include/ED_view3d.h
source/blender/editors/space_view3d/view3d_draw_legacy.c
source/blender/editors/util/select_buffer_utils.c

index afdbbeedff4d4ed4a8b84b6a86d7fa7cc8ac2111..fef3ff0749f2948d75d85790cd1a1cc894282fdd 100644 (file)
@@ -465,7 +465,6 @@ int ED_view3d_backbuf_sample_size_clamp(struct ARegion *ar, const float dist);
 
 void ED_view3d_select_id_validate(struct ViewContext *vc);
 
-uint *ED_view3d_select_id_read(int xmin, int ymin, int xmax, int ymax, uint *r_buf_len);
 uint *ED_view3d_select_id_read_rect(const struct rcti *rect, uint *r_buf_len);
 
 bool ED_view3d_autodist(struct Depsgraph *depsgraph,
index 39cbc67f9965c78688bf2c5d0cc0eac473e70568..d16d90fae01e32fb60af2d9b2f4c6dbe190e0500 100644 (file)
@@ -263,30 +263,6 @@ int ED_view3d_backbuf_sample_size_clamp(ARegion *ar, const float dist)
   return (int)min_ff(ceilf(dist), (float)max_ii(ar->winx, ar->winx));
 }
 
-/* reads full rect, converts indices */
-uint *ED_view3d_select_id_read(int xmin, int ymin, int xmax, int ymax, uint *r_buf_len)
-{
-  if (UNLIKELY((xmin > xmax) || (ymin > ymax))) {
-    return NULL;
-  }
-
-  const rcti rect = {
-      .xmin = xmin,
-      .xmax = xmax + 1,
-      .ymin = ymin,
-      .ymax = ymax + 1,
-  };
-
-  uint buf_len;
-  uint *buf = ED_view3d_select_id_read_rect(&rect, &buf_len);
-
-  if (r_buf_len) {
-    *r_buf_len = buf_len;
-  }
-
-  return buf;
-}
-
 /* *********************** */
 
 void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect)
index 2201ee5cec2445121a1082a9226f10a2e761c904..fa03f8d15146894dd734d2e79a47312508edeb15 100644 (file)
  */
 uint *ED_select_buffer_bitmap_from_rect(const uint bitmap_len, const rcti *rect)
 {
+  rcti rect_px = *rect;
+  rect_px.xmax += 1;
+  rect_px.ymax += 1;
+
   uint buf_len;
-  const uint *buf = ED_view3d_select_id_read(
-      rect->xmin, rect->ymin, rect->xmax, rect->ymax, &buf_len);
+  const uint *buf = ED_view3d_select_id_read_rect(&rect_px, &buf_len);
   if (buf == NULL) {
     return NULL;
   }
@@ -91,12 +94,14 @@ uint *ED_select_buffer_bitmap_from_circle(const uint bitmap_len,
     return NULL;
   }
 
-  const int xmin = center[0] - radius;
-  const int xmax = center[0] + radius;
-  const int ymin = center[1] - radius;
-  const int ymax = center[1] + radius;
+  const rcti rect = {
+      .xmin = center[0] - radius,
+      .xmax = center[0] + radius + 1,
+      .ymin = center[1] - radius,
+      .ymax = center[1] + radius + 1,
+  };
 
-  const uint *buf = ED_view3d_select_id_read(xmin, ymin, xmax, ymax, NULL);
+  const uint *buf = ED_view3d_select_id_read_rect(&rect, NULL);
   if (buf == NULL) {
     return NULL;
   }
@@ -152,10 +157,13 @@ uint *ED_select_buffer_bitmap_from_poly(const uint bitmap_len,
     return NULL;
   }
 
+  rcti rect_px = *rect;
+  rect_px.xmax += 1;
+  rect_px.ymax += 1;
+
   struct PolyMaskData poly_mask_data;
   uint buf_len;
-  const uint *buf = ED_view3d_select_id_read(
-      rect->xmin, rect->ymin, rect->xmax, rect->ymax, &buf_len);
+  const uint *buf = ED_view3d_select_id_read_rect(&rect_px, &buf_len);
   if (buf == NULL) {
     return NULL;
   }
@@ -164,10 +172,10 @@ uint *ED_select_buffer_bitmap_from_poly(const uint bitmap_len,
   poly_mask_data.px = buf_mask;
   poly_mask_data.width = (rect->xmax - rect->xmin) + 1;
 
-  BLI_bitmap_draw_2d_poly_v2i_n(rect->xmin,
-                                rect->ymin,
-                                rect->xmax + 1,
-                                rect->ymax + 1,
+  BLI_bitmap_draw_2d_poly_v2i_n(rect_px.xmin,
+                                rect_px.ymin,
+                                rect_px.xmax,
+                                rect_px.ymax,
                                 poly,
                                 poly_len,
                                 ed_select_buffer_mask_px_cb,
@@ -205,8 +213,15 @@ uint *ED_select_buffer_bitmap_from_poly(const uint bitmap_len,
  */
 uint ED_select_buffer_sample_point(const int center[2])
 {
+  const rcti rect = {
+      .xmin = center[0],
+      .xmax = center[0] + 1,
+      .ymin = center[1],
+      .ymax = center[1] + 1,
+  };
+
   uint buf_len;
-  uint *buf = ED_view3d_select_id_read(center[0], center[1], center[0], center[1], &buf_len);
+  uint *buf = ED_view3d_select_id_read_rect(&rect, &buf_len);
   BLI_assert(0 != buf_len);
   uint ret = buf[0];
   MEM_freeN(buf);