Blender  V3.3
draw_select_buffer.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2019 Blender Foundation. */
3 
10 #include "MEM_guardedalloc.h"
11 
12 #include "BLI_array_utils.h"
13 #include "BLI_bitmap.h"
14 #include "BLI_bitmap_draw_2d.h"
15 #include "BLI_rect.h"
16 
17 #include "DNA_screen_types.h"
18 
19 #include "GPU_select.h"
20 
21 #include "DEG_depsgraph.h"
22 #include "DEG_depsgraph_query.h"
23 
24 #include "DRW_engine.h"
25 #include "DRW_select_buffer.h"
26 
27 #include "draw_manager.h"
28 
29 #include "../engines/select/select_engine.h"
30 
31 /* -------------------------------------------------------------------- */
36  struct ARegion *region,
37  struct View3D *v3d,
38  const rcti *rect,
39  uint *r_buf_len)
40 {
41  uint *r_buf = NULL;
42  uint buf_len = 0;
43 
44  /* Clamp rect. */
45  rcti r = {
46  .xmin = 0,
47  .xmax = region->winx,
48  .ymin = 0,
49  .ymax = region->winy,
50  };
51 
52  /* Make sure that the rect is within the bounds of the viewport.
53  * Some GPUs have problems reading pixels off limits. */
54  rcti rect_clamp = *rect;
55  if (BLI_rcti_isect(&r, &rect_clamp, &rect_clamp)) {
56  struct SELECTID_Context *select_ctx = DRW_select_engine_context_get();
57 
59  /* Update the drawing. */
60  DRW_draw_select_id(depsgraph, region, v3d, rect);
61 
62  if (select_ctx->index_drawn_len > 1) {
65 
66  /* Read the UI32 pixels. */
67  buf_len = BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect);
68  r_buf = MEM_mallocN(buf_len * sizeof(*r_buf), __func__);
69 
71  GPU_framebuffer_bind(select_id_fb);
72  GPU_framebuffer_read_color(select_id_fb,
73  rect_clamp.xmin,
74  rect_clamp.ymin,
75  BLI_rcti_size_x(&rect_clamp),
76  BLI_rcti_size_y(&rect_clamp),
77  1,
78  0,
80  r_buf);
81 
82  if (!BLI_rcti_compare(rect, &rect_clamp)) {
83  /* The rect has been clamped so you need to realign the buffer and fill in the blanks */
84  GPU_select_buffer_stride_realign(rect, &rect_clamp, r_buf);
85  }
86  }
87 
90  }
91 
92  if (r_buf_len) {
93  *r_buf_len = buf_len;
94  }
95 
96  return r_buf;
97 }
98 
101 /* -------------------------------------------------------------------- */
110  struct ARegion *region,
111  struct View3D *v3d,
112  const rcti *rect,
113  uint *r_bitmap_len)
114 {
115  struct SELECTID_Context *select_ctx = DRW_select_engine_context_get();
116 
117  rcti rect_px = *rect;
118  rect_px.xmax += 1;
119  rect_px.ymax += 1;
120 
121  uint buf_len;
122  uint *buf = DRW_select_buffer_read(depsgraph, region, v3d, &rect_px, &buf_len);
123  if (buf == NULL) {
124  return NULL;
125  }
126 
127  BLI_assert(select_ctx->index_drawn_len > 0);
128  const uint bitmap_len = select_ctx->index_drawn_len - 1;
129 
130  BLI_bitmap *bitmap_buf = BLI_BITMAP_NEW(bitmap_len, __func__);
131  const uint *buf_iter = buf;
132  while (buf_len--) {
133  const uint index = *buf_iter - 1;
134  if (index < bitmap_len) {
135  BLI_BITMAP_ENABLE(bitmap_buf, index);
136  }
137  buf_iter++;
138  }
139  MEM_freeN((void *)buf);
140 
141  if (r_bitmap_len) {
142  *r_bitmap_len = bitmap_len;
143  }
144 
145  return bitmap_buf;
146 }
147 
149  struct ARegion *region,
150  struct View3D *v3d,
151  const int center[2],
152  const int radius,
153  uint *r_bitmap_len)
154 {
155  struct SELECTID_Context *select_ctx = DRW_select_engine_context_get();
156 
157  const rcti rect = {
158  .xmin = center[0] - radius,
159  .xmax = center[0] + radius + 1,
160  .ymin = center[1] - radius,
161  .ymax = center[1] + radius + 1,
162  };
163 
164  const uint *buf = DRW_select_buffer_read(depsgraph, region, v3d, &rect, NULL);
165 
166  if (buf == NULL) {
167  return NULL;
168  }
169 
170  BLI_assert(select_ctx->index_drawn_len > 0);
171  const uint bitmap_len = select_ctx->index_drawn_len - 1;
172 
173  BLI_bitmap *bitmap_buf = BLI_BITMAP_NEW(bitmap_len, __func__);
174  const uint *buf_iter = buf;
175  const int radius_sq = radius * radius;
176  for (int yc = -radius; yc <= radius; yc++) {
177  for (int xc = -radius; xc <= radius; xc++, buf_iter++) {
178  if (xc * xc + yc * yc < radius_sq) {
179  /* Intentionally wrap to max value if this is zero. */
180  const uint index = *buf_iter - 1;
181  if (index < bitmap_len) {
182  BLI_BITMAP_ENABLE(bitmap_buf, index);
183  }
184  }
185  }
186  }
187  MEM_freeN((void *)buf);
188 
189  if (r_bitmap_len) {
190  *r_bitmap_len = bitmap_len;
191  }
192 
193  return bitmap_buf;
194 }
195 
196 struct PolyMaskData {
198  int width;
199 };
200 
201 static void drw_select_mask_px_cb(int x, int x_end, int y, void *user_data)
202 {
203  struct PolyMaskData *data = user_data;
204  BLI_bitmap *px = data->px;
205  int i = (y * data->width) + x;
206  do {
207  BLI_BITMAP_ENABLE(px, i);
208  i++;
209  } while (++x != x_end);
210 }
211 
213  struct ARegion *region,
214  struct View3D *v3d,
215  const int poly[][2],
216  const int poly_len,
217  const rcti *rect,
218  uint *r_bitmap_len)
219 {
220  struct SELECTID_Context *select_ctx = DRW_select_engine_context_get();
221 
222  rcti rect_px = *rect;
223  rect_px.xmax += 1;
224  rect_px.ymax += 1;
225 
226  uint buf_len;
227  uint *buf = DRW_select_buffer_read(depsgraph, region, v3d, &rect_px, &buf_len);
228  if (buf == NULL) {
229  return NULL;
230  }
231 
232  BLI_bitmap *buf_mask = BLI_BITMAP_NEW(buf_len, __func__);
233 
234  struct PolyMaskData poly_mask_data;
235  poly_mask_data.px = buf_mask;
236  poly_mask_data.width = (rect->xmax - rect->xmin) + 1;
237 
239  rect_px.ymin,
240  rect_px.xmax,
241  rect_px.ymax,
242  poly,
243  poly_len,
245  &poly_mask_data);
246 
247  BLI_assert(select_ctx->index_drawn_len > 0);
248  const uint bitmap_len = select_ctx->index_drawn_len - 1;
249 
250  BLI_bitmap *bitmap_buf = BLI_BITMAP_NEW(bitmap_len, __func__);
251  const uint *buf_iter = buf;
252  int i = 0;
253  while (buf_len--) {
254  const uint index = *buf_iter - 1;
255  if (index < bitmap_len && BLI_BITMAP_TEST(buf_mask, i)) {
256  BLI_BITMAP_ENABLE(bitmap_buf, index);
257  }
258  buf_iter++;
259  i++;
260  }
261  MEM_freeN((void *)buf);
262  MEM_freeN(buf_mask);
263 
264  if (r_bitmap_len) {
265  *r_bitmap_len = bitmap_len;
266  }
267 
268  return bitmap_buf;
269 }
270 
273 /* -------------------------------------------------------------------- */
281  struct ARegion *region,
282  struct View3D *v3d,
283  const int center[2])
284 {
285  uint ret = 0;
286 
287  const rcti rect = {
288  .xmin = center[0],
289  .xmax = center[0] + 1,
290  .ymin = center[1],
291  .ymax = center[1] + 1,
292  };
293 
294  uint buf_len;
295  uint *buf = DRW_select_buffer_read(depsgraph, region, v3d, &rect, &buf_len);
296  if (buf) {
297  BLI_assert(0 != buf_len);
298  ret = buf[0];
299  MEM_freeN(buf);
300  }
301 
302  return ret;
303 }
304 
306  const void *val_ptr;
310 };
311 
312 static bool select_buffer_test_fn(const void *__restrict value, void *__restrict userdata)
313 {
314  struct SelectReadData *data = userdata;
315  uint hit_id = *(uint *)value;
316  if (hit_id && hit_id >= data->id_min && hit_id < data->id_max) {
317  /* Start at 1 to confirm. */
318  data->val_ptr = value;
319  data->r_index = (hit_id - data->id_min) + 1;
320  return true;
321  }
322  return false;
323 }
324 
326  struct ARegion *region,
327  struct View3D *v3d,
328  const int center[2],
329  const uint id_min,
330  const uint id_max,
331  uint *dist)
332 {
333  /* Create region around center (typically the mouse cursor).
334  * This must be square and have an odd width. */
335 
336  rcti rect;
337  BLI_rcti_init_pt_radius(&rect, center, *dist);
338  rect.xmax += 1;
339  rect.ymax += 1;
340 
341  int width = BLI_rcti_size_x(&rect);
342  int height = width;
343 
344  /* Read from selection framebuffer. */
345 
346  uint buf_len;
347  const uint *buf = DRW_select_buffer_read(depsgraph, region, v3d, &rect, &buf_len);
348 
349  if (buf == NULL) {
350  return 0;
351  }
352 
353  const int shape[2] = {height, width};
354  const int center_yx[2] = {(height - 1) / 2, (width - 1) / 2};
355  struct SelectReadData data = {NULL, id_min, id_max, 0};
356  BLI_array_iter_spiral_square(buf, shape, center_yx, select_buffer_test_fn, &data);
357 
358  if (data.val_ptr) {
359  size_t offset = ((size_t)data.val_ptr - (size_t)buf) / sizeof(*buf);
360  int hit_x = offset % width;
361  int hit_y = offset / width;
362  *dist = (uint)(abs(hit_y - center_yx[0]) + abs(hit_x - center_yx[1]));
363  }
364 
365  MEM_freeN((void *)buf);
366  return data.r_index;
367 }
368 
371 /* -------------------------------------------------------------------- */
376  uint *r_elem,
377  uint *r_base_index,
378  char *r_elem_type)
379 {
380  struct SELECTID_Context *select_ctx = DRW_select_engine_context_get();
381 
382  char elem_type = 0;
383  uint elem_id = 0;
384  uint base_index = 0;
385 
386  for (; base_index < select_ctx->objects_drawn_len; base_index++) {
387  struct ObjectOffsets *base_ofs = &select_ctx->index_offsets[base_index];
388 
389  if (base_ofs->face > sel_id) {
390  elem_id = sel_id - base_ofs->face_start;
391  elem_type = SCE_SELECT_FACE;
392  break;
393  }
394  if (base_ofs->edge > sel_id) {
395  elem_id = sel_id - base_ofs->edge_start;
396  elem_type = SCE_SELECT_EDGE;
397  break;
398  }
399  if (base_ofs->vert > sel_id) {
400  elem_id = sel_id - base_ofs->vert_start;
401  elem_type = SCE_SELECT_VERTEX;
402  break;
403  }
404  }
405 
406  if (base_index == select_ctx->objects_drawn_len) {
407  return false;
408  }
409 
410  *r_elem = elem_id;
411 
412  if (r_base_index) {
413  Object *obj_orig = DEG_get_original_object(select_ctx->objects_drawn[base_index]);
414  *r_base_index = obj_orig->runtime.select_id;
415  }
416 
417  if (r_elem_type) {
418  *r_elem_type = elem_type;
419  }
420 
421  return true;
422 }
423 
425  Object *object,
426  char elem_type)
427 {
428  struct SELECTID_Context *select_ctx = DRW_select_engine_context_get();
429 
430  Object *ob_eval = DEG_get_evaluated_object(depsgraph, object);
431 
433  &ob_eval->id, &draw_engine_select_type);
434 
435  if (!sel_data || !sel_data->is_drawn) {
436  return 0;
437  }
438 
439  struct ObjectOffsets *base_ofs = &select_ctx->index_offsets[sel_data->drawn_index];
440 
441  if (elem_type == SCE_SELECT_VERTEX) {
442  return base_ofs->vert_start;
443  }
444  if (elem_type == SCE_SELECT_EDGE) {
445  return base_ofs->edge_start;
446  }
447  if (elem_type == SCE_SELECT_FACE) {
448  return base_ofs->face_start;
449  }
450  BLI_assert(0);
451  return 0;
452 }
453 
456 /* -------------------------------------------------------------------- */
460 void DRW_select_buffer_context_create(Base **bases, const uint bases_len, short select_mode)
461 {
462  struct SELECTID_Context *select_ctx = DRW_select_engine_context_get();
463 
464  select_ctx->objects = MEM_reallocN(select_ctx->objects,
465  sizeof(*select_ctx->objects) * bases_len);
466 
467  select_ctx->index_offsets = MEM_reallocN(select_ctx->index_offsets,
468  sizeof(*select_ctx->index_offsets) * bases_len);
469 
470  select_ctx->objects_drawn = MEM_reallocN(select_ctx->objects_drawn,
471  sizeof(*select_ctx->objects_drawn) * bases_len);
472 
473  for (uint base_index = 0; base_index < bases_len; base_index++) {
474  Object *obj = bases[base_index]->object;
475  select_ctx->objects[base_index] = obj;
476 
477  /* Weak but necessary for `DRW_select_buffer_elem_get`. */
478  obj->runtime.select_id = base_index;
479  }
480 
481  select_ctx->objects_len = bases_len;
482  select_ctx->select_mode = select_mode;
483  memset(select_ctx->persmat, 0, sizeof(select_ctx->persmat));
484 }
485 
Generic array manipulation API.
#define BLI_array_iter_spiral_square(arr, arr_shape, center, test_fn, user_data)
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_BITMAP_NEW(_num, _alloc_string)
Definition: BLI_bitmap.h:40
#define BLI_BITMAP_TEST(_bitmap, _index)
Definition: BLI_bitmap.h:64
#define BLI_BITMAP_ENABLE(_bitmap, _index)
Definition: BLI_bitmap.h:81
unsigned int BLI_bitmap
Definition: BLI_bitmap.h:16
void BLI_bitmap_draw_2d_poly_v2i_n(int xmin, int ymin, int xmax, int ymax, const int verts[][2], int verts_len, void(*callback)(int x, int x_end, int y, void *), void *user_data)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition: BLI_rect.h:190
bool BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b)
void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size)
Definition: rct.c:469
bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition: BLI_rect.h:186
unsigned int uint
Definition: BLI_sys_types.h:67
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
struct Object * DEG_get_original_object(struct Object *object)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
#define SCE_SELECT_FACE
#define SCE_SELECT_VERTEX
#define SCE_SELECT_EDGE
void DRW_opengl_context_enable(void)
void DRW_draw_select_id(struct Depsgraph *depsgraph, struct ARegion *region, struct View3D *v3d, const struct rcti *rect)
void DRW_opengl_context_disable(void)
NSNotificationCenter * center
struct GPUFrameBuffer GPUFrameBuffer
void GPU_framebuffer_restore(void)
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
void GPU_select_buffer_stride_realign(const struct rcti *src, const struct rcti *dst, uint *r_buf)
int GPU_texture_height(const GPUTexture *tex)
Definition: gpu_texture.cc:607
int GPU_texture_width(const GPUTexture *tex)
Definition: gpu_texture.cc:602
@ GPU_DATA_UINT
Definition: GPU_texture.h:173
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
const Depsgraph * depsgraph
void * user_data
DrawData * DRW_drawdata_get(ID *id, DrawEngineType *engine_type)
Definition: draw_manager.c:850
void DRW_select_buffer_context_create(Base **bases, const uint bases_len, short select_mode)
bool DRW_select_buffer_elem_get(const uint sel_id, uint *r_elem, uint *r_base_index, char *r_elem_type)
static bool select_buffer_test_fn(const void *__restrict value, void *__restrict userdata)
uint * DRW_select_buffer_bitmap_from_rect(struct Depsgraph *depsgraph, struct ARegion *region, struct View3D *v3d, const rcti *rect, uint *r_bitmap_len)
uint * DRW_select_buffer_read(struct Depsgraph *depsgraph, struct ARegion *region, struct View3D *v3d, const rcti *rect, uint *r_buf_len)
uint DRW_select_buffer_context_offset_for_object_elem(Depsgraph *depsgraph, Object *object, char elem_type)
uint * DRW_select_buffer_bitmap_from_poly(struct Depsgraph *depsgraph, struct ARegion *region, struct View3D *v3d, const int poly[][2], const int poly_len, const rcti *rect, uint *r_bitmap_len)
uint * DRW_select_buffer_bitmap_from_circle(struct Depsgraph *depsgraph, struct ARegion *region, struct View3D *v3d, const int center[2], const int radius, uint *r_bitmap_len)
uint DRW_select_buffer_find_nearest_to_point(struct Depsgraph *depsgraph, struct ARegion *region, struct View3D *v3d, const int center[2], const uint id_min, const uint id_max, uint *dist)
uint DRW_select_buffer_sample_point(struct Depsgraph *depsgraph, struct ARegion *region, struct View3D *v3d, const int center[2])
static void drw_select_mask_px_cb(int x, int x_end, int y, void *user_data)
void GPU_framebuffer_read_color(GPUFrameBuffer *gpu_fb, int x, int y, int w, int h, int channels, int slot, eGPUDataFormat format, void *data)
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
T abs(const T &a)
return ret
DrawEngineType draw_engine_select_type
struct SELECTID_Context * DRW_select_engine_context_get(void)
GPUFrameBuffer * DRW_engine_select_framebuffer_get(void)
GPUTexture * DRW_engine_select_texture_get(void)
struct Object * object
Object_Runtime runtime
BLI_bitmap * px
struct Object ** objects_drawn
struct ObjectOffsets * index_offsets
struct Object ** objects
const void * val_ptr
int ymin
Definition: DNA_vec_types.h:64
int ymax
Definition: DNA_vec_types.h:64
int xmin
Definition: DNA_vec_types.h:63
int xmax
Definition: DNA_vec_types.h:63