62 uint *r_buf =
nullptr;
68 r.xmax = region->winx;
70 r.ymax = region->winy;
74 rcti rect_clamp = *rect;
92 r_buf =
static_cast<uint *
>(
MEM_mallocN(buf_len *
sizeof(*r_buf), __func__));
117 *r_buf_len = buf_len;
138 rcti rect_px = *rect;
144 if (buf ==
nullptr) {
152 const uint *buf_iter = buf;
154 const uint index = *buf_iter - 1;
155 if (index < bitmap_len) {
163 *r_bitmap_len = bitmap_len;
179 rect.
xmin = center[0] - radius;
180 rect.xmax = center[0] + radius + 1;
181 rect.ymin = center[1] - radius;
182 rect.ymax = center[1] + radius + 1;
186 if (buf ==
nullptr) {
194 const uint *buf_iter = buf;
195 const int radius_sq = radius * radius;
196 for (
int yc = -radius; yc <= radius; yc++) {
197 for (
int xc = -radius; xc <= radius; xc++, buf_iter++) {
198 if (xc * xc + yc * yc < radius_sq) {
200 const uint index = *buf_iter - 1;
201 if (index < bitmap_len) {
210 *r_bitmap_len = bitmap_len;
225 int i = (y * data->width) + x;
229 }
while (++x != x_end);
241 rcti rect_px = *rect;
247 if (buf ==
nullptr) {
254 poly_mask_data.
px = buf_mask;
269 const uint *buf_iter = buf;
272 const uint index = *buf_iter - 1;
283 *r_bitmap_len = bitmap_len;
306 rect.
xmin = center[0];
307 rect.xmax = center[0] + 1;
308 rect.ymin = center[1];
309 rect.ymax = center[1] + 1;
333 if (hit_id && hit_id >= data->id_min && hit_id < data->id_max) {
336 data->r_index = (hit_id - data->id_min) + 1;
366 if (buf ==
nullptr) {
370 const int shape[2] = {height, width};
371 const int center_yx[2] = {(height - 1) / 2, (width - 1) / 2};
376 size_t offset = (size_t(data.val_ptr) - size_t(buf)) /
sizeof(*buf);
377 int hit_x = offset % width;
378 int hit_y = offset / width;
379 *dist =
uint(
abs(hit_y - center_yx[0]) +
abs(hit_x - center_yx[1]));
403 for (; base_index < select_ctx->
objects.
size(); base_index++) {
406 if (base_ofs->
face > sel_id) {
411 if (base_ofs->
edge > sel_id) {
416 if (base_ofs->
vert > sel_id) {
430 *r_base_index = base_index;
434 *r_elem_type = elem_type;
486 Object *obj = bases[i]->object;
Generic array manipulation API.
#define BLI_array_iter_spiral_square(arr, arr_shape, center, test_fn, user_data)
#define BLI_BITMAP_NEW(_num, _alloc_string)
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
void BLI_bitmap_draw_2d_poly_v2i_n(int xmin, int ymin, int xmax, int ymax, blender::Span< blender::int2 > verts, void(*callback)(int x, int x_end, int y, void *), void *user_data)
bool compare_m4m4(const float mat1[4][4], const float mat2[4][4], float limit)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
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)
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)
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
void DRW_gpu_context_disable()
void DRW_gpu_context_enable()
void DRW_draw_select_id(Depsgraph *depsgraph, ARegion *region, View3D *v3d)
void GPU_framebuffer_restore()
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
void GPU_framebuffer_read_color(GPUFrameBuffer *framebuffer, int x, int y, int width, int height, int channels, int slot, eGPUDataFormat data_format, void *r_data)
void GPU_select_buffer_stride_realign(const rcti *src, const rcti *dst, uint *r_buf)
int GPU_texture_height(const GPUTexture *texture)
int GPU_texture_width(const GPUTexture *texture)
Read Guarded memory(de)allocation.
void reinitialize(const int64_t new_size)
constexpr int64_t size() const
constexpr IndexRange index_range() const
const Depsgraph * depsgraph
DrawData * DRW_drawdata_get(ID *id, DrawEngineType *engine_type)
uint * DRW_select_buffer_bitmap_from_rect(Depsgraph *depsgraph, ARegion *region, View3D *v3d, const rcti *rect, uint *r_bitmap_len)
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_circle(Depsgraph *depsgraph, ARegion *region, View3D *v3d, const int center[2], const int radius, uint *r_bitmap_len)
void DRW_select_buffer_context_create(Depsgraph *depsgraph, const blender::Span< Base * > bases, short select_mode)
uint * DRW_select_buffer_bitmap_from_poly(Depsgraph *depsgraph, ARegion *region, View3D *v3d, const Span< int2 > poly, const rcti *rect, uint *r_bitmap_len)
uint DRW_select_buffer_sample_point(Depsgraph *depsgraph, ARegion *region, View3D *v3d, const int center[2])
uint DRW_select_buffer_context_offset_for_object_elem(Depsgraph *depsgraph, Object *object, char elem_type)
uint DRW_select_buffer_find_nearest_to_point(Depsgraph *depsgraph, ARegion *region, View3D *v3d, const int center[2], const uint id_min, const uint id_max, uint *dist)
uint * DRW_select_buffer_read(Depsgraph *depsgraph, ARegion *region, View3D *v3d, const rcti *rect, uint *r_buf_len)
static void drw_select_mask_px_cb(int x, int x_end, int y, void *user_data)
draw_view in_light_buf[] float
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
DrawEngineType draw_engine_select_type
SELECTID_Context * DRW_select_engine_context_get()
GPUFrameBuffer * DRW_engine_select_framebuffer_get()
GPUTexture * DRW_engine_select_texture_get()
blender::Array< Object * > objects
blender::Array< ObjectOffsets > index_offsets
bool is_dirty(RegionView3D *rv3d)
ccl_device_inline int abs(int x)