Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-07-11 14:09:22 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-07-11 16:21:41 +0300
commit114e7eaa0994b07d44b5a9ed5a4b8b14ef9b0791 (patch)
treecb5ddc3e98086fb47213ccdb90a2be45357974d9 /source/blender/editors/mesh/editface.c
parent02b36188737b3e15fe8173dec7a57da7da610922 (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/mesh/editface.c')
-rw-r--r--source/blender/editors/mesh/editface.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 35fc4483702..de37d5c0a0c 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -426,13 +426,15 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten
unsigned int *rt;
char *selar;
int a, index;
- 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 = BKE_mesh_from_object(ob);
- if (me == NULL || me->totpoly == 0 || sx * sy <= 0)
+ if ((me == NULL) || (me->totpoly == 0) || (size[0] * size[1] <= 0)) {
return OPERATOR_CANCELLED;
+ }
selar = MEM_callocN(me->totpoly + 1, "selar");
@@ -448,16 +450,21 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten
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;
- view3d_opengl_read_pixels(vc->ar, rect->xmin, rect->ymin, sx, sy, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
- if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
+ view3d_opengl_read_pixels(vc->ar, rect->xmin, rect->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->totpoly) selar[index] = 1;
+ index = *rt;
+ if (index <= me->totpoly) {
+ selar[index] = 1;
+ }
}
rt++;
}