diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw_legacy.c | 24 | ||||
-rw-r--r-- | source/blender/editors/util/select_buffer_utils.c | 43 |
3 files changed, 29 insertions, 39 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index afdbbeedff4..fef3ff0749f 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -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, diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index 39cbc67f996..d16d90fae01 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -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) diff --git a/source/blender/editors/util/select_buffer_utils.c b/source/blender/editors/util/select_buffer_utils.c index 2201ee5cec2..fa03f8d1514 100644 --- a/source/blender/editors/util/select_buffer_utils.c +++ b/source/blender/editors/util/select_buffer_utils.c @@ -55,9 +55,12 @@ */ 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); |