Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <germano.costa@ig.com.br>2021-11-08 02:44:20 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-11-08 02:44:20 +0300
commit56ee96349dce3826999a1ebcfff890d8066dce50 (patch)
treed338d4dd52489b0b2edba21cf63fa8040cb8c58f
parent7a5b8cb2028450d7c1030460865b1ad6c328f44d (diff)
Fix snap cursor not active even if gizmo is available
Error introduced in rB69d6222481b4 and partially fixed in rB24310441ddc8. When gizmo was turned on but the scene has more than one 3D viewport, one of them the snap cursor did not appear.
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c6
-rw-r--r--source/blender/editors/include/ED_view3d.h2
-rw-r--r--source/blender/editors/space_view3d/view3d_cursor_snap.c11
-rw-r--r--source/blender/editors/space_view3d/view3d_placement.c2
4 files changed, 11 insertions, 10 deletions
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 60642158820..b618aa41f4c 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
@@ -226,6 +226,7 @@ static void snap_gizmo_setup(wmGizmo *gz)
SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
snap_gizmo->snap_state = ED_view3d_cursor_snap_active();
if (snap_gizmo->snap_state) {
+ snap_gizmo->snap_state->gzgrp_type = gz->parent_gzgroup->type;
snap_gizmo->snap_state->draw_point = true;
snap_gizmo->snap_state->draw_plane = false;
}
@@ -241,10 +242,6 @@ 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);
@@ -255,6 +252,7 @@ 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 ebf3316a509..aa86f07692d 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -277,7 +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. */
+ struct wmGizmoGroupType *gzgrp_type; /* Force cursor to be drawn only when gizmo is available. */
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 479acb3cb1a..fbdab71ec1d 100644
--- a/source/blender/editors/space_view3d/view3d_cursor_snap.c
+++ b/source/blender/editors/space_view3d/view3d_cursor_snap.c
@@ -778,10 +778,13 @@ static bool v3d_cursor_snap_pool_fn(bContext *C)
};
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;
+ if (state->gzgrp_type) {
+ /* Check the respective gizmo group is in the region. */
+ wmGizmoMap *gzmap = region->gizmo_map;
+ if (WM_gizmomap_group_find_ptr(gzmap, state->gzgrp_type) == NULL) {
+ /* Wrong viewport. */
+ 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 7ad512fd029..f60df27d0f9 100644
--- a/source/blender/editors/space_view3d/view3d_placement.c
+++ b/source/blender/editors/space_view3d/view3d_placement.c
@@ -1519,7 +1519,7 @@ 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->gzgrp_type = gzgroup->type;
snap_state->draw_plane = true;
gzgroup->customdata = snap_state;