Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
| Show First 20 Lines • Show All 534 Lines • ▼ Show 20 Lines | static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos, | ||||
| const int visible_gizmos_len, | const int visible_gizmos_len, | ||||
| const bContext *C, | const bContext *C, | ||||
| const int co[2], | const int co[2], | ||||
| const int hotspot) | const int hotspot) | ||||
| { | { | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| View3D *v3d = sa->spacedata.first; | View3D *v3d = sa->spacedata.first; | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | |||||
| rcti rect; | rcti rect; | ||||
| /* Almost certainly overkill, but allow for many custom gizmos. */ | /* Almost certainly overkill, but allow for many custom gizmos. */ | ||||
| GLuint buffer[MAXPICKBUF]; | GLuint buffer[MAXPICKBUF]; | ||||
| short hits; | short hits; | ||||
| BLI_rcti_init_pt_radius(&rect, co, hotspot); | BLI_rcti_init_pt_radius(&rect, co, hotspot); | ||||
| ED_view3d_draw_setup_view( | ED_view3d_draw_setup_view( | ||||
| CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, v3d, NULL, NULL, &rect); | CTX_wm_window(C), depsgraph, CTX_data_scene(C), ar, v3d, NULL, NULL, &rect); | ||||
| bool use_select_bias = false; | bool use_select_bias = false; | ||||
| /* TODO: waiting for the GPU in the middle of the event loop for every | /* TODO: waiting for the GPU in the middle of the event loop for every | ||||
| * mouse move is bad for performance, we need to find a solution to not | * mouse move is bad for performance, we need to find a solution to not | ||||
| * use the GPU or draw something once. (see T61474) */ | * use the GPU or draw something once. (see T61474) */ | ||||
| GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_FIRST_PASS, 0); | GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_FIRST_PASS, 0); | ||||
| /* do the drawing */ | /* do the drawing */ | ||||
| gizmo_draw_select_3d_loop(C, visible_gizmos, visible_gizmos_len, &use_select_bias); | gizmo_draw_select_3d_loop(C, visible_gizmos, visible_gizmos_len, &use_select_bias); | ||||
| hits = GPU_select_end(); | hits = GPU_select_end(); | ||||
| if (hits > 0) { | if (hits > 0) { | ||||
| GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits); | GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits); | ||||
| gizmo_draw_select_3d_loop(C, visible_gizmos, visible_gizmos_len, &use_select_bias); | gizmo_draw_select_3d_loop(C, visible_gizmos, visible_gizmos_len, &use_select_bias); | ||||
| GPU_select_end(); | GPU_select_end(); | ||||
| } | } | ||||
| ED_view3d_draw_setup_view( | ED_view3d_draw_setup_view( | ||||
| CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, v3d, NULL, NULL, NULL); | CTX_wm_window(C), depsgraph, CTX_data_scene(C), ar, v3d, NULL, NULL, NULL); | ||||
| if (use_select_bias && (hits > 1)) { | if (use_select_bias && (hits > 1)) { | ||||
| float co_direction[3]; | float co_direction[3]; | ||||
| float co_screen[3] = {co[0], co[1], 0.0f}; | float co_screen[3] = {co[0], co[1], 0.0f}; | ||||
| ED_view3d_win_to_vector(ar, (float[2]){UNPACK2(co)}, co_direction); | ED_view3d_win_to_vector(ar, (float[2]){UNPACK2(co)}, co_direction); | ||||
| RegionView3D *rv3d = ar->regiondata; | RegionView3D *rv3d = ar->regiondata; | ||||
| const int viewport[4] = {0, 0, ar->winx, ar->winy}; | const int viewport[4] = {0, 0, ar->winx, ar->winy}; | ||||
| ▲ Show 20 Lines • Show All 808 Lines • Show Last 20 Lines | |||||