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-10-12 23:05:56 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-10-13 23:43:29 +0300
commit91c33c8b99520b6b094265a826cd391929a81716 (patch)
treead5f250137549de94c0ea4c93a5a5643ceaf3692 /source/blender/editors/gizmo_library
parent988b9bc40ce846cdce05961315dc0e2c1dd95e4b (diff)
Cleanup: Snap Context Refactor
Move runtime parameters out of context creation. Not being able to choose another region and v3d limits the use of the snap API.
Diffstat (limited to 'source/blender/editors/gizmo_library')
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c5
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c18
2 files changed, 13 insertions, 10 deletions
diff --git a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
index 68322ed56af..ec4837aec3c 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
@@ -289,6 +289,8 @@ static int gizmo_move_modal(bContext *C,
if (ED_transform_snap_object_project_view3d(
inter->snap_context_v3d,
CTX_data_ensure_evaluated_depsgraph(C),
+ region,
+ CTX_wm_view3d(C),
(SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE),
&(const struct SnapObjectParams){
.snap_select = SNAP_ALL,
@@ -381,8 +383,7 @@ static int gizmo_move_invoke(bContext *C, wmGizmo *gz, const wmEvent *event)
if (area) {
switch (area->spacetype) {
case SPACE_VIEW3D: {
- inter->snap_context_v3d = ED_transform_snap_object_context_create_view3d(
- CTX_data_scene(C), 0, CTX_wm_region(C), CTX_wm_view3d(C));
+ inter->snap_context_v3d = ED_transform_snap_object_context_create(CTX_data_scene(C), 0);
break;
}
default:
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 ae2cc05c01b..f673d3e85ef 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
@@ -278,15 +278,11 @@ void ED_gizmotypes_snap_3d_draw_util(RegionView3D *rv3d,
immUnbindProgram();
}
-SnapObjectContext *ED_gizmotypes_snap_3d_context_ensure(Scene *scene,
- const ARegion *region,
- const View3D *v3d,
- wmGizmo *gz)
+SnapObjectContext *ED_gizmotypes_snap_3d_context_ensure(Scene *scene, wmGizmo *gz)
{
SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
if (snap_gizmo->snap_context_v3d == NULL) {
- snap_gizmo->snap_context_v3d = ED_transform_snap_object_context_create_view3d(
- scene, 0, region, v3d);
+ snap_gizmo->snap_context_v3d = ED_transform_snap_object_context_create(scene, 0);
}
return snap_gizmo->snap_context_v3d;
}
@@ -387,6 +383,8 @@ short ED_gizmotypes_snap_3d_update(wmGizmo *gz,
snap_elem = ED_transform_snap_object_project_view3d_ex(
snap_gizmo->snap_context_v3d,
depsgraph,
+ region,
+ v3d,
snap_elements,
&(const struct SnapObjectParams){
.snap_select = snap_select,
@@ -576,8 +574,12 @@ static void snap_gizmo_setup(wmGizmo *gz)
#ifdef USE_SNAP_DETECT_FROM_KEYMAP_HACK
SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
- snap_gizmo->keymap = WM_modalkeymap_find(gz->parent_gzgroup->type->keyconf,
- "Generic Gizmo Tweak Modal Map");
+ wmKeyConfig *keyconf = gz->parent_gzgroup->type->keyconf;
+ if (!keyconf) {
+ /* It can happen when gizmogrouptype is not linked at startup. */
+ keyconf = ((wmWindowManager *)G.main->wm.first)->defaultconf;
+ }
+ snap_gizmo->keymap = WM_modalkeymap_find(keyconf, "Generic Gizmo Tweak Modal Map");
RNA_enum_value_from_id(snap_gizmo->keymap->modal_items, "SNAP_ON", &snap_gizmo->snap_on);
#endif
}