2019-08-07 17:43:04 +02:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* Copyright 2016, Blender Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* \ingroup draw
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DRW_SELECT_BUFFER_H__
|
|
|
|
#define __DRW_SELECT_BUFFER_H__
|
|
|
|
|
|
|
|
#include "BLI_sys_types.h" /* for bool and uint */
|
|
|
|
|
|
|
|
struct ARegion;
|
|
|
|
struct Base;
|
|
|
|
struct Depsgraph;
|
|
|
|
struct Object;
|
|
|
|
struct View3D;
|
|
|
|
struct rcti;
|
|
|
|
|
2019-08-15 15:31:54 +02:00
|
|
|
typedef struct SELECTID_ObjectData {
|
|
|
|
DrawData dd;
|
|
|
|
|
|
|
|
uint drawn_index;
|
|
|
|
bool is_drawn;
|
|
|
|
} SELECTID_ObjectData;
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SELECTID_Context {
|
2019-08-15 15:31:54 +02:00
|
|
|
/* All context objects */
|
|
|
|
struct Object **objects;
|
2019-08-12 17:10:44 +02:00
|
|
|
uint objects_len;
|
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. */
|
|
|
|
struct ObjectOffsets *index_offsets;
|
|
|
|
struct Object **objects_drawn;
|
|
|
|
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
|
|
|
|
|
|
|
/* To check for updates. */
|
|
|
|
float persmat[4][4];
|
|
|
|
bool is_dirty;
|
|
|
|
|
|
|
|
/* rect is used to check which objects whose indexes need to be drawn. */
|
|
|
|
rcti last_rect;
|
2019-08-12 17:10:44 +02:00
|
|
|
};
|
|
|
|
|
2019-08-15 15:31:54 +02:00
|
|
|
/* draw_select_buffer.c */
|
2019-08-07 17:43:04 +02:00
|
|
|
bool DRW_select_buffer_elem_get(const uint sel_id,
|
|
|
|
uint *r_elem,
|
|
|
|
uint *r_base_index,
|
|
|
|
char *r_elem_type);
|
2019-08-15 15:31:54 +02:00
|
|
|
uint DRW_select_buffer_context_offset_for_object_elem(struct Depsgraph *depsgraph,
|
|
|
|
struct Object *object,
|
|
|
|
char elem_type);
|
|
|
|
uint *DRW_select_buffer_read(struct Depsgraph *depsgraph,
|
2020-03-06 16:56:42 +01:00
|
|
|
struct ARegion *region,
|
2019-08-15 15:31:54 +02:00
|
|
|
struct View3D *v3d,
|
|
|
|
const rcti *rect,
|
|
|
|
uint *r_buf_len);
|
|
|
|
uint *DRW_select_buffer_bitmap_from_rect(struct Depsgraph *depsgraph,
|
2020-03-06 16:56:42 +01:00
|
|
|
struct ARegion *region,
|
2019-08-15 15:31:54 +02:00
|
|
|
struct View3D *v3d,
|
|
|
|
const struct rcti *rect,
|
|
|
|
uint *r_bitmap_len);
|
|
|
|
uint *DRW_select_buffer_bitmap_from_circle(struct Depsgraph *depsgraph,
|
2020-03-06 16:56:42 +01:00
|
|
|
struct ARegion *region,
|
2019-08-15 15:31:54 +02:00
|
|
|
struct View3D *v3d,
|
|
|
|
const int center[2],
|
2019-08-07 17:43:04 +02:00
|
|
|
const int radius,
|
|
|
|
uint *r_bitmap_len);
|
2019-08-15 15:31:54 +02:00
|
|
|
uint *DRW_select_buffer_bitmap_from_poly(struct Depsgraph *depsgraph,
|
2020-03-06 16:56:42 +01:00
|
|
|
struct ARegion *region,
|
2019-08-15 15:31:54 +02:00
|
|
|
struct View3D *v3d,
|
|
|
|
const int poly[][2],
|
2019-08-07 17:43:04 +02:00
|
|
|
const int poly_len,
|
2019-08-15 15:31:54 +02:00
|
|
|
const struct rcti *rect,
|
|
|
|
uint *r_bitmap_len);
|
|
|
|
uint DRW_select_buffer_sample_point(struct Depsgraph *depsgraph,
|
2020-03-06 16:56:42 +01:00
|
|
|
struct ARegion *region,
|
2019-08-15 15:31:54 +02:00
|
|
|
struct View3D *v3d,
|
|
|
|
const int center[2]);
|
|
|
|
uint DRW_select_buffer_find_nearest_to_point(struct Depsgraph *depsgraph,
|
2020-03-06 16:56:42 +01:00
|
|
|
struct ARegion *region,
|
2019-08-15 15:31:54 +02:00
|
|
|
struct View3D *v3d,
|
|
|
|
const int center[2],
|
2019-08-07 17:43:04 +02:00
|
|
|
const uint id_min,
|
|
|
|
const uint id_max,
|
|
|
|
uint *dist);
|
2019-08-15 15:31:54 +02:00
|
|
|
void DRW_select_buffer_context_create(struct Base **bases,
|
|
|
|
const uint bases_len,
|
|
|
|
short select_mode);
|
2019-08-07 17:43:04 +02:00
|
|
|
|
|
|
|
#endif /* __DRW_SELECT_BUFFER_H__ */
|