106 msel->
len -= len_subtract;
107 if (msel->
len <= 0) {
133 for (
int i = 0; i < msel->
len; i++) {
134 if (msel->
items[i] == gz) {
135 for (
int j = i; j < (msel->
len - 1); j++) {
153 gzmap->
type = gzmap_type;
180 gzgroup = gzgroup_next) {
181 gzgroup_next = gzgroup->next;
198 memset(gzmap, 0x0,
sizeof(*gzmap));
215 if (gzgroup->type == gzgt) {
267 bool (*poll)(
const wmGizmo *,
void *),
277 if (((flag_exclude == 0) || ((gz->flag & flag_exclude) == 0)) &&
278 (!poll || poll(gz,
data))) {
320 if (gzgroup->hide.delay_refresh_for_tweak) {
405 if (gzgroup->hide.any != 0) {
410 if (gzgroup->type->draw_prepare) {
411 gzgroup->type->draw_prepare(
C, gzgroup);
437 bool is_depth_prev =
false;
440 for (
LinkData *link = draw_gizmos->
first, *link_next; link; link = link_next) {
442 link_next = link->
next;
452 if (is_depth == is_depth_prev) {
462 is_depth_prev = is_depth;
500 const int visible_gizmos_len,
501 bool *r_use_select_bias)
506 bool is_depth_prev =
false;
507 bool is_depth_skip_prev =
false;
509 for (
int select_id = 0; select_id < visible_gizmos_len; select_id++) {
510 wmGizmo *gz = visible_gizmos[select_id];
516 if (is_depth == is_depth_prev) {
526 is_depth_prev = is_depth;
529 if (is_depth_skip == is_depth_skip_prev) {
534 is_depth_skip_prev = is_depth_skip;
538 *r_use_select_bias =
true;
549 if (is_depth_skip_prev) {
555 const int visible_gizmos_len,
575 bool use_select_bias =
false;
595 if (use_select_bias && (hits > 1)) {
596 float co_direction[3];
597 float co_screen[3] = {co[0], co[1], 0.0f};
601 const int viewport[4] = {0, 0, region->
winx, region->
winy};
602 float co_3d_origin[3];
608 float dot_best = FLT_MAX;
610 for (
int i = 0; i < hits; i++, buf_iter++) {
612 wmGizmo *gz = visible_gizmos[buf_iter->
id >> 8];
621 const float dot_test =
dot_v3v3(co_3d, co_direction) - select_bias;
622 if (dot_best > dot_test) {
624 hit_found = buf_iter->
id;
631 return hit_near ? hit_near->
id : -1;
640 const int visible_gizmos_len,
644 int visible_gizmos_len_trim = visible_gizmos_len;
655 for (
int select_id = 0; select_id < visible_gizmos_len; select_id++) {
656 wmGizmo *gz = visible_gizmos[select_id];
663 visible_gizmos_len_trim = select_id;
683 if (viewport ==
NULL) {
688 GPU_framebuffer_ensure_config(&depth_read_fb,
690 GPU_ATTACHMENT_TEXTURE(depth_tx),
695 const int hotspot_radii[] = {
700 for (
int i = 0; i <
ARRAY_SIZE(hotspot_radii); i++) {
702 visible_gizmos, visible_gizmos_len_trim,
C, co, hotspot_radii[i]);
712 const int select_id = hit >> 8;
713 const int select_part = hit & 0xff;
715 *r_part = select_part;
716 result = visible_gizmos[select_id];
741 for (
int i = 0; i <
ARRAY_SIZE(do_step); i++) {
763 wm, gzgroup, event->
modifier, &visible_3d_gizmos);
767 wm, gzgroup,
C, event->
modifier, mval, r_part))) {
775 if (visible_3d_gizmos.count) {
779 C, mval, visible_3d_gizmos.data, visible_3d_gizmos.count, r_part);
810 const bool modal_running = (handler->
op !=
NULL);
829 if (modal_fn !=
NULL) {
830 int retval = modal_fn(
C, gz, event, 0);
863 for (
int i = 0; i < msel->
len; i++) {
894 bool changed =
false;
913 bool changed =
false;
949 printf(
"internal error: modal gizmo-map handler has invalid area\n");
954 for (region =
area->regionbase.first; region; region = region->
next) {
998 if (init_last_cursor) {
1004 if (init_last_cursor) {
1038 bool do_refresh =
false;
1052 const int retval = gz->
type->
invoke(
C, gz, event);
1074 if (gzop && gzop->
type) {
1160 if (gzgroup->type->message_subscribe !=
NULL) {
1161 gzgroup->type->message_subscribe(
C, gzgroup, mbus);
1175 double *
UNUSED(pass_delay),
1176 bool *r_exit_on_event)
1179 *r_exit_on_event =
false;
1186 *r_exit_on_event =
true;
1203 if (gzmap_type->spaceid == gzmap_params->
spaceid &&
1204 gzmap_type->regionid == gzmap_params->
regionid) {
1231 gzmap_type = gzmap_type_next) {
1232 gzmap_type_next = gzmap_type->next;
1233 for (
wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first, *gzgt_next; gzgt_ref;
1234 gzgt_ref = gzgt_next) {
1235 gzgt_next = gzgt_ref->next;
1301 gzgt_ref = gzgt_ref_next) {
1302 gzgt_ref_next = gzgt_ref->next;
1317 if (gzmap_type->type_update_flag & type_update_all) {
1318 gzmap_type->type_update_flag &= ~type_update_all;
1348 gzgroup = gzgroup_next) {
1349 gzgroup_next = gzgroup->next;
1350 if (gzgroup->tag_remove) {
1378 ListBase *regionbase = (sl ==
area->spacedata.first) ? &
area->regionbase : &sl->regionbase;
1381 if ((gzmap !=
NULL) && (gzmap->
is_init ==
false)) {
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
struct Scene * CTX_data_scene(const bContext *C)
void CTX_wm_region_set(bContext *C, struct ARegion *region)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
struct bScreen * CTX_wm_screen(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
void CTX_wm_area_set(bContext *C, struct ScrArea *area)
struct wmWindow * CTX_wm_window(const bContext *C)
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
#define BLI_buffer_declare_static(type_, name_, flag_, static_count_)
#define BLI_buffer_free(name_)
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
unsigned int BLI_ghash_len(const GHash *gh) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
GHash * BLI_ghash_ptr_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
#define GHASH_ITER_INDEX(gh_iter_, ghash_, i_)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
struct LinkData * BLI_genericNodeN(void *data)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size)
#define UNUSED_VARS_NDEBUG(...)
typedef double(DMatrix)[4][4]
struct Depsgraph Depsgraph
void ED_region_tag_redraw_editor_overlays(struct ARegion *region)
void ED_view3d_draw_setup_view(const struct wmWindowManager *wm, struct wmWindow *win, struct Depsgraph *depsgraph, struct Scene *scene, struct ARegion *region, struct View3D *v3d, const float viewmat[4][4], const float winmat[4][4], const struct rcti *rect)
void ED_view3d_win_to_vector(const struct ARegion *region, const float mval[2], float r_out[3])
void view3d_operator_needs_opengl(const struct bContext *C)
struct GPUFrameBuffer GPUFrameBuffer
void GPU_framebuffer_restore(void)
void GPU_framebuffer_free(GPUFrameBuffer *fb)
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
bool GPU_matrix_unproject_3fv(const float win[3], const float model_inverted[4][4], const float proj[4][4], const int view[4], float r_world[3])
void GPU_select_begin(GPUSelectResult *buffer, unsigned int buffer_len, const struct rcti *input, eGPUSelectMode mode, int oldhits)
@ GPU_SELECT_NEAREST_SECOND_PASS
@ GPU_SELECT_NEAREST_FIRST_PASS
const GPUSelectResult * GPU_select_buffer_near(const GPUSelectResult *buffer, int hits)
unsigned int GPU_select_end(void)
void GPU_line_smooth(bool enable)
void GPU_depth_mask(bool depth)
void GPU_depth_test(eGPUDepthTest test)
void GPU_polygon_smooth(bool enable)
struct GPUTexture GPUTexture
GPUTexture * GPU_viewport_depth_texture(GPUViewport *viewport)
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
struct ARegion * UI_tooltip_create_from_gizmo(struct bContext *C, struct wmGizmo *gz)
@ WM_GIZMOMAP_DRAWSTEP_3D
@ WM_GIZMOMAP_DRAWSTEP_2D
@ WM_GIZMOMAPTYPE_UPDATE_REMOVE
@ WM_GIZMOMAPTYPE_KEYMAP_INIT
@ WM_GIZMOMAPTYPE_UPDATE_INIT
@ WM_GIZMOGROUP_INIT_REFRESH
@ WM_GIZMOGROUP_INIT_SETUP
@ WM_GIZMO_SELECT_BACKGROUND
@ WM_GIZMOGROUPTYPE_DRAW_MODAL_EXCLUDE
@ WM_GIZMOGROUPTYPE_DEPTH_3D
@ WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL
@ WM_GIZMOGROUPTYPE_SELECT
@ WM_GIZMO_STATE_HIGHLIGHT
#define WM_GIZMOMAP_DRAWSTEP_MAX
const Depsgraph * depsgraph
ccl_global float * buffer
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
static void area(int d1, int d2, int e1, int e2, float weights[2])
struct wmGizmoMap * gizmo_map
struct wmGizmoMap * gizmo_map
struct wmEventHandler_Op::@1207 context
enum eWM_EventHandlerType type
wmGizmoGroupFnInvokePrepare invoke_prepare
eWM_GizmoFlagGroupTypeFlag flag
eWM_GizmoFlagMapTypeUpdateFlag type_update_flag
struct wmGizmoGroupType * type
eWM_GizmoFlagMapTypeUpdateFlag type_update_flag
char update_flag[WM_GIZMOMAP_DRAWSTEP_MAX]
struct wmGizmoMapType * type
struct wmGizmo * highlight
struct wmGizmoMapSelectState select
struct wmGizmoMap::@1182 gzmap_context
Gizmo map runtime context.
struct wmOperatorType * type
wmGizmoFnTestSelect test_select
wmGizmoFnCursorGet cursor_get
wmGizmoFnDrawSelect draw_select
struct wmGizmoGroup * parent_gzgroup
wmGizmoFnModal custom_modal
const struct wmGizmoType * type
struct wmOperatorType * type
void WM_cursor_set(wmWindow *win, int curs)
void WM_cursor_grab_enable(wmWindow *win, int wrap, bool hide, int bounds[4])
void WM_cursor_grab_disable(wmWindow *win, const int mouse_ungrab_xy[2])
GPUViewport * WM_draw_region_get_viewport(ARegion *region)
void WM_event_drag_start_mval(const wmEvent *event, const ARegion *region, int r_mval[2])
void WM_event_add_mousemove(wmWindow *win)
bool wm_gizmo_select_set_ex(wmGizmoMap *gzmap, wmGizmo *gz, bool select, bool use_array, bool use_callback)
bool WM_gizmo_context_check_drawstep(const struct bContext *C, eWM_GizmoFlagMapDrawStep step)
int WM_gizmo_operator_invoke(bContext *C, wmGizmo *gz, wmGizmoOpElem *gzop, const wmEvent *event)
void wm_gizmo_update(wmGizmo *gz, const bContext *C, const bool refresh_map)
struct wmGizmoOpElem * WM_gizmo_operator_get(wmGizmo *gz, int part_index)
bool WM_gizmo_select_set(wmGizmoMap *gzmap, wmGizmo *gz, bool select)
int wm_gizmo_is_visible(wmGizmo *gz)
int(* wmGizmoFnModal)(struct bContext *, struct wmGizmo *, const struct wmEvent *, eWM_GizmoFlagTweak)
void WM_gizmo_group_refresh(const bContext *C, wmGizmoGroup *gzgroup)
void WM_gizmomaptype_group_init_runtime_keymap(const Main *bmain, wmGizmoGroupType *gzgt)
wmGizmoGroup * wm_gizmogroup_new_from_type(wmGizmoMap *gzmap, wmGizmoGroupType *gzgt)
void WM_gizmomaptype_group_init_runtime(const Main *bmain, wmGizmoMapType *gzmap_type, wmGizmoGroupType *gzgt)
void wm_gizmogrouptype_setup_keymap(wmGizmoGroupType *gzgt, wmKeyConfig *keyconf)
void WM_gizmogroup_ensure_init(const bContext *C, wmGizmoGroup *gzgroup)
wmKeyMap * wm_gizmogroup_tweak_modal_keymap(wmKeyConfig *keyconf)
bool wm_gizmogroup_is_visible_in_drawstep(const wmGizmoGroup *gzgroup, const eWM_GizmoFlagMapDrawStep drawstep)
void WM_gizmomaptype_group_free(wmGizmoGroupTypeRef *gzgt_ref)
void wm_gizmogroup_intersectable_gizmos_to_list(wmWindowManager *wm, const wmGizmoGroup *gzgroup, const int event_modifier, BLI_Buffer *visible_gizmos)
wmGizmo * wm_gizmogroup_find_intersected_gizmo(wmWindowManager *wm, const wmGizmoGroup *gzgroup, bContext *C, const int event_modifier, const int mval[2], int *r_part)
bool WM_gizmo_group_type_poll(const bContext *C, const wmGizmoGroupType *gzgt)
void WM_gizmomaptype_group_unlink(bContext *C, Main *bmain, wmGizmoMapType *gzmap_type, const wmGizmoGroupType *gzgt)
void wm_gizmogroup_free(bContext *C, wmGizmoGroup *gzgroup)
wmGizmoGroupType * WM_gizmogrouptype_find(const char *idname, bool quiet)
@ WM_GIZMO_IS_VISIBLE_DRAW
@ WM_GIZMO_IS_VISIBLE_UPDATE
wmGizmoMapType * WM_gizmomaptype_find(const struct wmGizmoMapType_Params *gzmap_params)
static wmGizmo * gizmo_find_intersected_3d(bContext *C, const int co[2], wmGizmo **visible_gizmos, const int visible_gizmos_len, int *r_part)
void wm_gizmomap_modal_set(wmGizmoMap *gzmap, bContext *C, wmGizmo *gz, const wmEvent *event, bool enable)
eWM_GizmoFlagMapDrawStep WM_gizmomap_drawstep_from_gizmo_group(const wmGizmoGroup *gzgroup)
wmGizmoMapType * WM_gizmomaptype_ensure(const struct wmGizmoMapType_Params *gzmap_params)
static void wm_gizmomap_select_array_ensure_len_alloc(wmGizmoMap *gzmap, int len)
bool WM_gizmomap_is_any_selected(const wmGizmoMap *gzmap)
wmGizmo * wm_gizmomap_highlight_get(wmGizmoMap *gzmap)
void wm_gizmomaptypes_free(void)
wmGizmo * WM_gizmomap_get_modal(const wmGizmoMap *gzmap)
void wm_gizmomaps_handled_modal_update(bContext *C, wmEvent *event, wmEventHandler_Op *handler)
bool wm_gizmomap_highlight_set(wmGizmoMap *gzmap, const bContext *C, wmGizmo *gz, int part)
void WM_gizmomap_tag_refresh_drawstep(wmGizmoMap *gzmap, const eWM_GizmoFlagMapDrawStep drawstep)
void WM_reinit_gizmomap_all(Main *bmain)
struct ARegion * WM_gizmomap_tooltip_init(struct bContext *C, struct ARegion *region, int *UNUSED(r_pass), double *UNUSED(pass_delay), bool *r_exit_on_event)
static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos, const int visible_gizmos_len, const bContext *C, const int co[2], const int hotspot)
void WM_gizmoconfig_update_tag_group_type_init(wmGizmoMapType *gzmap_type, wmGizmoGroupType *gzgt)
bool WM_gizmomap_minmax(const wmGizmoMap *gzmap, bool UNUSED(use_hidden), bool use_select, float r_min[3], float r_max[3])
bool WM_gizmomap_tag_delay_refresh_for_tweak_check(wmGizmoMap *gzmap)
void wm_gizmomap_select_array_remove(wmGizmoMap *gzmap, wmGizmo *gz)
ListBase * wm_gizmomap_groups_get(wmGizmoMap *gzmap)
void WM_gizmomap_tag_refresh(wmGizmoMap *gzmap)
@ GIZMOMAP_IS_PREPARE_DRAW
@ GIZMOMAP_IS_REFRESH_CALLBACK
bool WM_gizmomap_select_all(bContext *C, wmGizmoMap *gzmap, const int action)
static void gizmos_draw_list(const wmGizmoMap *gzmap, const bContext *C, ListBase *draw_gizmos)
static ListBase gizmomaptypes
void WM_gizmoconfig_update_tag_group_type_remove(wmGizmoMapType *gzmap_type, wmGizmoGroupType *gzgt)
wmGizmoGroup * WM_gizmomap_group_find_ptr(struct wmGizmoMap *gzmap, const struct wmGizmoGroupType *gzgt)
static void wm_gizmomap_free_data(wmGizmoMap *gzmap)
void wm_gizmomap_remove(wmGizmoMap *gzmap)
void WM_gizmomap_draw(wmGizmoMap *gzmap, const bContext *C, const eWM_GizmoFlagMapDrawStep drawstep)
void WM_gizmomap_reinit(wmGizmoMap *gzmap)
static void gizmo_draw_select_3d_loop(const bContext *C, wmGizmo **visible_gizmos, const int visible_gizmos_len, bool *r_use_select_bias)
static bool wm_gizmomap_select_all_intern(bContext *C, wmGizmoMap *gzmap)
BLI_INLINE bool gizmo_selectable_poll(const wmGizmo *gz, void *UNUSED(data))
void wm_gizmomap_handler_context_op(bContext *C, wmEventHandler_Op *handler)
static eWM_GizmoFlagGroupTypeGlobalFlag wm_gzmap_type_update_flag
bool WM_gizmomap_cursor_set(const wmGizmoMap *gzmap, wmWindow *win)
static bool gizmo_prepare_drawing(wmGizmoMap *gzmap, wmGizmo *gz, const bContext *C, ListBase *draw_gizmos, const eWM_GizmoFlagMapDrawStep drawstep)
void wm_gizmomap_select_array_clear(wmGizmoMap *gzmap)
void WM_gizmomap_add_handlers(ARegion *region, wmGizmoMap *gzmap)
wmGizmoGroup * WM_gizmomap_group_find(struct wmGizmoMap *gzmap, const char *idname)
void WM_gizmoconfig_update_tag_group_remove(wmGizmoMap *gzmap)
static wmGizmoMap * wm_gizmomap_new_from_type_ex(struct wmGizmoMapType *gzmap_type, wmGizmoMap *gzmap)
wmGizmo * wm_gizmomap_highlight_find(wmGizmoMap *gzmap, bContext *C, const wmEvent *event, int *r_part)
void wm_gizmos_keymap(wmKeyConfig *keyconf)
void WM_gizmoconfig_update(struct Main *bmain)
eWM_GizmoFlagGroupTypeGlobalFlag
@ WM_GIZMOTYPE_GLOBAL_UPDATE_REMOVE
@ WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT
@ WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE
const ListBase * WM_gizmomap_group_list(wmGizmoMap *gzmap)
wmGizmo * wm_gizmomap_modal_get(wmGizmoMap *gzmap)
void wm_gizmomap_select_array_push_back(wmGizmoMap *gzmap, wmGizmo *gz)
void wm_gizmomap_select_array_shrink(wmGizmoMap *gzmap, int len_subtract)
bool wm_gizmomap_deselect_all(wmGizmoMap *gzmap)
void WM_gizmomap_message_subscribe(const bContext *C, wmGizmoMap *gzmap, ARegion *region, struct wmMsgBus *mbus)
void wm_gizmomap_handler_context_gizmo(bContext *UNUSED(C), wmEventHandler_Gizmo *UNUSED(handler))
static GHash * WM_gizmomap_gizmo_hash_new(const bContext *C, wmGizmoMap *gzmap, bool(*poll)(const wmGizmo *, void *), void *data, const eWM_GizmoFlag flag_exclude)
static void gizmomap_prepare_drawing(wmGizmoMap *gzmap, const bContext *C, ListBase *draw_gizmos, const eWM_GizmoFlagMapDrawStep drawstep)
wmGizmo ** wm_gizmomap_selected_get(wmGizmoMap *gzmap, int *r_selected_len)
wmGizmoMap * WM_gizmomap_new_from_type(const struct wmGizmoMapType_Params *gzmap_params)
void WM_gizmo_target_property_subscribe_all(wmGizmo *gz, struct wmMsgBus *mbus, ARegion *region)
void WM_cursor_warp(wmWindow *win, int x, int y)