Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_cursor_snap.c
| Show All 31 Lines | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_screen.h" | |||||
| #include "GPU_immediate.h" | #include "GPU_immediate.h" | ||||
| #include "GPU_matrix.h" | #include "GPU_matrix.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "ED_transform.h" | #include "ED_transform.h" | ||||
| #include "ED_transform_snap_object_context.h" | #include "ED_transform_snap_object_context.h" | ||||
| #include "ED_view3d.h" | #include "ED_view3d.h" | ||||
| ▲ Show 20 Lines • Show All 711 Lines • ▼ Show 20 Lines | |||||
| * \{ */ | * \{ */ | ||||
| static bool v3d_cursor_snap_pool_fn(bContext *C) | static bool v3d_cursor_snap_pool_fn(bContext *C) | ||||
| { | { | ||||
| if (G.moving) { | if (G.moving) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| ARegion *region = CTX_wm_region(C); | |||||
| if (region->regiontype != RGN_TYPE_WINDOW) { | |||||
| return false; | |||||
| } | |||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| if (area->spacetype != SPACE_VIEW3D) { | if (area->spacetype != SPACE_VIEW3D) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); | |||||
| RegionView3D *rv3d = region->regiondata; | RegionView3D *rv3d = region->regiondata; | ||||
| if (rv3d->rflag & RV3D_NAVIGATING) { | if (rv3d->rflag & RV3D_NAVIGATING) { | ||||
| /* Don't draw the cursor while navigating. It can be distracting. */ | /* Don't draw the cursor while navigating. It can be distracting. */ | ||||
| return false; | return false; | ||||
| }; | }; | ||||
| V3DSnapCursorState *state = ED_view3d_cursor_snap_state_get(); | |||||
| if (state->region && (state->region != region)) { | |||||
| /* Some gizmos are still available even when the region is not available. | |||||
| * We need to disable the cursor in these cases. */ | |||||
| return false; | |||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| static void v3d_cursor_snap_draw_fn(bContext *C, int x, int y, void *UNUSED(customdata)) | static void v3d_cursor_snap_draw_fn(bContext *C, int x, int y, void *UNUSED(customdata)) | ||||
| { | { | ||||
| SnapCursorDataIntern *data_intern = &g_data_intern; | SnapCursorDataIntern *data_intern = &g_data_intern; | ||||
| V3DSnapCursorState *state = ED_view3d_cursor_snap_state_get(); | V3DSnapCursorState *state = ED_view3d_cursor_snap_state_get(); | ||||
| V3DSnapCursorData *snap_data = &data_intern->snap_data; | V3DSnapCursorData *snap_data = &data_intern->snap_data; | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| ARegion *region = CTX_wm_region(C); | ScrArea *area = CTX_wm_area(C); | ||||
| ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); | |||||
| x -= region->winrct.xmin; | x -= region->winrct.xmin; | ||||
| y -= region->winrct.ymin; | y -= region->winrct.ymin; | ||||
| if (v3d_cursor_eventstate_has_changed(data_intern, state, wm, x, y)) { | if (v3d_cursor_eventstate_has_changed(data_intern, state, wm, x, y)) { | ||||
| Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| Scene *scene = DEG_get_input_scene(depsgraph); | Scene *scene = DEG_get_input_scene(depsgraph); | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| v3d_cursor_snap_update(state, C, wm, depsgraph, scene, region, v3d, x, y); | v3d_cursor_snap_update(state, C, wm, depsgraph, scene, region, v3d, x, y); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | V3DSnapCursorData *ED_view3d_cursor_snap_data_get(V3DSnapCursorState *state, | ||||
| const int y) | const int y) | ||||
| { | { | ||||
| SnapCursorDataIntern *data_intern = &g_data_intern; | SnapCursorDataIntern *data_intern = &g_data_intern; | ||||
| if (C) { | if (C) { | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| if (v3d_cursor_eventstate_has_changed(data_intern, state, wm, x, y)) { | if (v3d_cursor_eventstate_has_changed(data_intern, state, wm, x, y)) { | ||||
| Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| Scene *scene = DEG_get_input_scene(depsgraph); | Scene *scene = DEG_get_input_scene(depsgraph); | ||||
| ARegion *region = CTX_wm_region(C); | ScrArea *area = CTX_wm_area(C); | ||||
| ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); | |||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| if (!state) { | if (!state) { | ||||
| state = ED_view3d_cursor_snap_state_get(); | state = ED_view3d_cursor_snap_state_get(); | ||||
| } | } | ||||
| v3d_cursor_snap_update(state, C, wm, depsgraph, scene, region, v3d, x, y); | v3d_cursor_snap_update(state, C, wm, depsgraph, scene, region, v3d, x, y); | ||||
| } | } | ||||
| } | } | ||||
| Show All 10 Lines | |||||