Commit: 24310441ddc85ecc8dc857ccc75b508db59bd844 Author: Germano Cavalcante Date: Tue Nov 2 00:41:41 2021 -0300 Branches: blender-v3.0-release https://developer.blender.org/rB24310441ddc85ecc8dc857ccc75b508db59bd844
Fix snap cursor still active even when gizmo is not available The snap cursor continued to appear even when the workspace is changed for example. So add the region to check in the cursor pool. =================================================================== M source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c M source/blender/editors/include/ED_view3d.h M source/blender/editors/space_view3d/view3d_cursor_snap.c M source/blender/editors/space_view3d/view3d_placement.c =================================================================== diff --git a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c index 93ee6ec2d81..60642158820 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c @@ -241,6 +241,10 @@ static void snap_gizmo_draw(const bContext *UNUSED(C), wmGizmo *UNUSED(gz)) static int snap_gizmo_test_select(bContext *C, wmGizmo *gz, const int mval[2]) { SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz; + ARegion *region = CTX_wm_region(C); + + /* Make sure the cursor is only drawn in the gizmo region. */ + snap_gizmo->snap_state->region = region; /* Snap Elements can change while the gizmo is active. Need to be updated somewhere. */ snap_gizmo_snap_elements_update(snap_gizmo); @@ -251,7 +255,6 @@ static int snap_gizmo_test_select(bContext *C, wmGizmo *gz, const int mval[2]) wmWindowManager *wm = CTX_wm_manager(C); const wmEvent *event = wm->winactive ? wm->winactive->eventstate : NULL; if (event) { - ARegion *region = CTX_wm_region(C); x = event->xy[0] - region->winrct.xmin; y = event->xy[1] - region->winrct.ymin; } diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 6d20044d8cf..ebf3316a509 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -277,6 +277,7 @@ typedef struct V3DSnapCursorState { uchar color_line[4]; uchar color_point[4]; uchar color_box[4]; + struct ARegion *region; /* Forces the cursor to be drawn only in this specific region. */ float *prevpoint; float box_dimensions[3]; short snap_elem_force; /* If zero, use scene settings. */ diff --git a/source/blender/editors/space_view3d/view3d_cursor_snap.c b/source/blender/editors/space_view3d/view3d_cursor_snap.c index baf61befcba..479acb3cb1a 100644 --- a/source/blender/editors/space_view3d/view3d_cursor_snap.c +++ b/source/blender/editors/space_view3d/view3d_cursor_snap.c @@ -777,6 +777,13 @@ static bool v3d_cursor_snap_pool_fn(bContext *C) 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; } diff --git a/source/blender/editors/space_view3d/view3d_placement.c b/source/blender/editors/space_view3d/view3d_placement.c index 572fc8e3156..7ad512fd029 100644 --- a/source/blender/editors/space_view3d/view3d_placement.c +++ b/source/blender/editors/space_view3d/view3d_placement.c @@ -1515,10 +1515,11 @@ static void preview_plane_free_fn(void *customdata) ED_view3d_cursor_snap_deactive(snap_state); } -static void WIDGETGROUP_placement_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) +static void WIDGETGROUP_placement_setup(const bContext *C, wmGizmoGroup *gzgroup) { V3DSnapCursorState *snap_state = ED_view3d_cursor_snap_active(); if (snap_state) { + snap_state->region = CTX_wm_region(C); snap_state->draw_plane = true; gzgroup->customdata = snap_state; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs