diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-07-11 14:09:22 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-07-11 16:21:41 +0300 |
commit | 114e7eaa0994b07d44b5a9ed5a4b8b14ef9b0791 (patch) | |
tree | cb5ddc3e98086fb47213ccdb90a2be45357974d9 /source/blender/editors/space_view3d/view3d_select.c | |
parent | 02b36188737b3e15fe8173dec7a57da7da610922 (diff) |
Add WM_framebuffer_to_index_array
Convert buffer to index in one loop,
also minor cleanup to backbuf/selection functions.
- Use IMB_rectcpy instead of inline pixel copy.
- Redundant WM_framebuffer_to_index call.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_select.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 49e42cf164a..5a35e9fcad1 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1648,14 +1648,15 @@ static int do_paintvert_box_select(ViewContext *vc, rcti *rect, bool select, boo unsigned int *rt; int a, index; char *selar; - int sx = BLI_rcti_size_x(rect) + 1; - int sy = BLI_rcti_size_y(rect) + 1; + const int size[2] = { + BLI_rcti_size_x(rect) + 1, + BLI_rcti_size_y(rect) + 1}; me = vc->obact->data; - if (me == NULL || me->totvert == 0 || sx * sy <= 0) + if ((me == NULL) || (me->totvert == 0) || (size[0] * size[1] <= 0)) { return OPERATOR_CANCELLED; - + } if (extend == false && select) paintvert_deselect_all_visible(vc->obact, SEL_DESELECT, false); @@ -1664,16 +1665,24 @@ static int do_paintvert_box_select(ViewContext *vc, rcti *rect, bool select, boo selar = MEM_callocN(me->totvert + 1, "selar"); ED_view3d_backbuf_validate(vc); - ibuf = IMB_allocImBuf(sx, sy, 32, IB_rect); + ibuf = IMB_allocImBuf(size[0], size[1], 32, IB_rect); rt = ibuf->rect; - glReadPixels(rect->xmin + vc->ar->winrct.xmin, rect->ymin + vc->ar->winrct.ymin, sx, sy, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); - if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf); + glReadPixels( + rect->xmin + vc->ar->winrct.xmin, + rect->ymin + vc->ar->winrct.ymin, + size[0], size[1], GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + if (ENDIAN_ORDER == B_ENDIAN) { + IMB_convert_rgba_to_abgr(ibuf); + } + WM_framebuffer_to_index_array(ibuf->rect, size[0] * size[1]); - a = sx * sy; + a = size[0] * size[1]; while (a--) { if (*rt) { - index = WM_framebuffer_to_index(*rt); - if (index <= me->totvert) selar[index] = 1; + index = *rt; + if (index <= me->totvert) { + selar[index] = 1; + } } rt++; } |