2023-08-15 16:20:26 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2016 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2019-08-07 17:43:04 +02:00
|
|
|
|
|
|
|
/** \file
|
|
|
|
* \ingroup draw
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BLI_sys_types.h" /* for bool and uint */
|
|
|
|
|
|
|
|
struct ARegion;
|
|
|
|
struct Base;
|
|
|
|
struct Depsgraph;
|
|
|
|
struct Object;
|
|
|
|
struct View3D;
|
|
|
|
struct rcti;
|
|
|
|
|
2023-10-04 19:32:18 +02:00
|
|
|
struct SELECTID_ObjectData {
|
2019-08-15 15:31:54 +02:00
|
|
|
DrawData dd;
|
|
|
|
|
|
|
|
uint drawn_index;
|
|
|
|
bool is_drawn;
|
2023-10-04 19:32:18 +02:00
|
|
|
};
|
2019-08-15 15:31:54 +02:00
|
|
|
|
2019-08-12 17:29:18 +02:00
|
|
|
struct ObjectOffsets {
|
2019-08-12 17:10:44 +02:00
|
|
|
/* For convenience only. */
|
|
|
|
union {
|
|
|
|
uint offset;
|
|
|
|
uint face_start;
|
|
|
|
};
|
|
|
|
union {
|
|
|
|
uint face;
|
|
|
|
uint edge_start;
|
|
|
|
};
|
|
|
|
union {
|
|
|
|
uint edge;
|
|
|
|
uint vert_start;
|
|
|
|
};
|
|
|
|
uint vert;
|
|
|
|
};
|
|
|
|
|
2023-10-04 19:32:18 +02:00
|
|
|
struct SELECTID_Context {
|
2019-08-15 15:31:54 +02:00
|
|
|
/* All context objects */
|
2023-10-04 19:32:18 +02:00
|
|
|
Object **objects;
|
2019-08-15 15:31:54 +02:00
|
|
|
|
|
|
|
/* Array with only drawn objects. When a new object is found within the rect,
|
|
|
|
* it is added to the end of the list.
|
|
|
|
* The list is reset to any viewport or context update. */
|
2023-10-04 19:32:18 +02:00
|
|
|
Object **objects_drawn;
|
|
|
|
ObjectOffsets *index_offsets;
|
2020-06-17 17:08:55 +02:00
|
|
|
uint objects_len;
|
2019-08-15 15:31:54 +02:00
|
|
|
uint objects_drawn_len;
|
|
|
|
|
|
|
|
/** Total number of element indices `index_offsets[object_drawn_len - 1].vert`. */
|
|
|
|
uint index_drawn_len;
|
2019-08-12 17:10:44 +02:00
|
|
|
|
|
|
|
short select_mode;
|
2019-08-15 15:31:54 +02:00
|
|
|
|
2020-06-17 17:08:55 +02:00
|
|
|
/* rect is used to check which objects whose indexes need to be drawn. */
|
|
|
|
rcti last_rect;
|
|
|
|
|
2019-08-15 15:31:54 +02:00
|
|
|
/* To check for updates. */
|
|
|
|
float persmat[4][4];
|
|
|
|
bool is_dirty;
|
2023-10-04 19:32:18 +02:00
|
|
|
};
|
2019-08-12 17:10:44 +02:00
|
|
|
|
2023-07-31 03:50:54 +02:00
|
|
|
/* `draw_select_buffer.cc` */
|
2021-12-08 10:29:39 +01:00
|
|
|
|
2022-01-07 01:38:08 +01:00
|
|
|
bool DRW_select_buffer_elem_get(uint sel_id, uint *r_elem, uint *r_base_index, char *r_elem_type);
|
2023-10-04 19:32:18 +02:00
|
|
|
uint DRW_select_buffer_context_offset_for_object_elem(Depsgraph *depsgraph,
|
|
|
|
Object *object,
|
2019-08-15 15:31:54 +02:00
|
|
|
char elem_type);
|
2021-12-08 10:29:39 +01:00
|
|
|
/**
|
|
|
|
* Main function to read a block of pixels from the select frame buffer.
|
|
|
|
*/
|
2023-10-04 19:32:18 +02:00
|
|
|
uint *DRW_select_buffer_read(
|
|
|
|
Depsgraph *depsgraph, ARegion *region, View3D *v3d, const rcti *rect, uint *r_buf_len);
|
2021-12-08 10:29:39 +01:00
|
|
|
/**
|
|
|
|
* \param rect: The rectangle to sample indices from (min/max inclusive).
|
|
|
|
* \returns a #BLI_bitmap the length of \a bitmap_len or NULL on failure.
|
|
|
|
*/
|
2023-10-04 19:32:18 +02:00
|
|
|
uint *DRW_select_buffer_bitmap_from_rect(
|
|
|
|
Depsgraph *depsgraph, ARegion *region, View3D *v3d, const rcti *rect, uint *r_bitmap_len);
|
2021-12-08 10:29:39 +01:00
|
|
|
/**
|
|
|
|
* \param center: Circle center.
|
|
|
|
* \param radius: Circle radius.
|
|
|
|
* \param r_bitmap_len: Number of indices in the selection id buffer.
|
|
|
|
* \returns a #BLI_bitmap the length of \a r_bitmap_len or NULL on failure.
|
|
|
|
*/
|
2023-10-04 19:32:18 +02:00
|
|
|
uint *DRW_select_buffer_bitmap_from_circle(Depsgraph *depsgraph,
|
|
|
|
ARegion *region,
|
|
|
|
View3D *v3d,
|
2019-08-15 15:31:54 +02:00
|
|
|
const int center[2],
|
2022-01-07 01:38:08 +01:00
|
|
|
int radius,
|
2019-08-07 17:43:04 +02:00
|
|
|
uint *r_bitmap_len);
|
2021-12-08 10:29:39 +01:00
|
|
|
/**
|
|
|
|
* \param poly: The polygon coordinates.
|
2023-07-24 22:06:55 +02:00
|
|
|
* \param face_len: Length of the polygon.
|
2021-12-08 10:29:39 +01:00
|
|
|
* \param rect: Polygon boundaries.
|
|
|
|
* \returns a #BLI_bitmap.
|
|
|
|
*/
|
2023-10-04 19:32:18 +02:00
|
|
|
uint *DRW_select_buffer_bitmap_from_poly(Depsgraph *depsgraph,
|
|
|
|
ARegion *region,
|
|
|
|
View3D *v3d,
|
2019-08-15 15:31:54 +02:00
|
|
|
const int poly[][2],
|
2023-07-24 22:06:55 +02:00
|
|
|
int face_len,
|
2023-10-04 19:32:18 +02:00
|
|
|
const rcti *rect,
|
2019-08-15 15:31:54 +02:00
|
|
|
uint *r_bitmap_len);
|
2021-12-08 10:29:39 +01:00
|
|
|
/**
|
|
|
|
* Samples a single pixel.
|
|
|
|
*/
|
2023-10-04 19:32:18 +02:00
|
|
|
uint DRW_select_buffer_sample_point(Depsgraph *depsgraph,
|
|
|
|
ARegion *region,
|
|
|
|
View3D *v3d,
|
2019-08-15 15:31:54 +02:00
|
|
|
const int center[2]);
|
2021-12-08 10:29:39 +01:00
|
|
|
/**
|
|
|
|
* Find the selection id closest to \a center.
|
|
|
|
* \param dist: Use to initialize the distance,
|
|
|
|
* when found, this value is set to the distance of the selection that's returned.
|
|
|
|
*/
|
2023-10-04 19:32:18 +02:00
|
|
|
uint DRW_select_buffer_find_nearest_to_point(Depsgraph *depsgraph,
|
|
|
|
ARegion *region,
|
|
|
|
View3D *v3d,
|
2019-08-15 15:31:54 +02:00
|
|
|
const int center[2],
|
2022-01-07 01:38:08 +01:00
|
|
|
uint id_min,
|
|
|
|
uint id_max,
|
2019-08-07 17:43:04 +02:00
|
|
|
uint *dist);
|
2023-10-04 19:32:18 +02:00
|
|
|
void DRW_select_buffer_context_create(Base **bases, uint bases_len, short select_mode);
|