diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2021-10-12 23:05:56 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2021-10-13 23:43:29 +0300 |
commit | 91c33c8b99520b6b094265a826cd391929a81716 (patch) | |
tree | ad5f250137549de94c0ea4c93a5a5643ceaf3692 /source/blender/editors/space_view3d/view3d_placement.c | |
parent | 988b9bc40ce846cdce05961315dc0e2c1dd95e4b (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/space_view3d/view3d_placement.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_placement.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/editors/space_view3d/view3d_placement.c b/source/blender/editors/space_view3d/view3d_placement.c index aa3bf46d2e5..6cd6d85d204 100644 --- a/source/blender/editors/space_view3d/view3d_placement.c +++ b/source/blender/editors/space_view3d/view3d_placement.c @@ -306,6 +306,8 @@ static bool idp_snap_normal_from_gizmo(wmGizmo *gz, float r_normal[3]) */ static bool idp_poject_surface_normal(SnapObjectContext *snap_context, struct Depsgraph *depsgraph, + ARegion *region, + View3D *v3d, const float mval_fl[2], const float mat_fallback[3][3], const float normal_fallback[3], @@ -320,6 +322,8 @@ static bool idp_poject_surface_normal(SnapObjectContext *snap_context, if (ED_transform_snap_object_project_view3d_ex(snap_context, depsgraph, + region, + v3d, SCE_SNAP_MODE_FACE, &(const struct SnapObjectParams){ .snap_select = SNAP_ALL, @@ -885,11 +889,9 @@ static void view3d_interactive_add_calc_plane(bContext *C, /* Set the orientation. */ if ((plane_orient == PLACE_ORIENT_SURFACE) || (plane_depth == PLACE_DEPTH_SURFACE)) { - snap_context = (snap_gizmo ? - ED_gizmotypes_snap_3d_context_ensure(scene, region, v3d, snap_gizmo) : - NULL); + snap_context = (snap_gizmo ? ED_gizmotypes_snap_3d_context_ensure(scene, snap_gizmo) : NULL); if (snap_context == NULL) { - snap_context = ED_transform_snap_object_context_create_view3d(scene, 0, region, v3d); + snap_context = ED_transform_snap_object_context_create(scene, 0); snap_context_free = true; } } @@ -908,6 +910,8 @@ static void view3d_interactive_add_calc_plane(bContext *C, if ((snap_context != NULL) && idp_poject_surface_normal(snap_context, CTX_data_ensure_evaluated_depsgraph(C), + region, + v3d, mval_fl, use_normal_fallback ? r_matrix_orient : NULL, use_normal_fallback ? normal_fallback : NULL, @@ -938,6 +942,8 @@ static void view3d_interactive_add_calc_plane(bContext *C, if ((snap_context != NULL) && ED_transform_snap_object_project_view3d(snap_context, CTX_data_ensure_evaluated_depsgraph(C), + region, + v3d, SCE_SNAP_MODE_FACE, &(const struct SnapObjectParams){ .snap_select = SNAP_ALL, |