diff options
author | Julian Eisel <julian@blender.org> | 2020-11-11 19:35:26 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-11-11 19:35:26 +0300 |
commit | ca7079a44e773a26d6f6aa6730f53a16e7de6cd5 (patch) | |
tree | b58ff6ccca5e2afd18da8365705f47112eac0a38 /source/blender/editors/space_view3d | |
parent | fdd9cb713e2e96e430eb022f034bfa9973afc75c (diff) | |
parent | 5b5ec0a2e910a42d7c02774a47fd9c70b6f16f06 (diff) |
Merge branch 'master' into outliner-cpp-refactoroutliner-cpp-refactor
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_placement.c | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/source/blender/editors/space_view3d/view3d_placement.c b/source/blender/editors/space_view3d/view3d_placement.c index 176fc641085..25634d9f221 100644 --- a/source/blender/editors/space_view3d/view3d_placement.c +++ b/source/blender/editors/space_view3d/view3d_placement.c @@ -639,23 +639,27 @@ static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEv } } - ipd->launch_event = WM_userdef_event_type_from_keymap_type(event->type); - - ED_transform_calc_orientation_from_type(C, ipd->matrix_orient); - - /* Set the orientation. */ - if (plane_orient == PLACE_ORIENT_SURFACE) { - bool snap_context_free = false; - SnapObjectContext *snap_context = - (ipd->snap_gizmo ? ED_gizmotypes_snap_3d_context_ensure( - ipd->scene, ipd->region, ipd->v3d, ipd->snap_gizmo) : - NULL); - if (snap_context == NULL) { + SnapObjectContext *snap_context = NULL; + bool snap_context_free = false; + if ((plane_orient == PLACE_ORIENT_SURFACE) || (plane_depth == PLACE_DEPTH_SURFACE)) { + /* Need# snap_context */ + if (ipd->snap_gizmo) { + snap_context = ED_gizmotypes_snap_3d_context_ensure( + ipd->scene, ipd->region, ipd->v3d, ipd->snap_gizmo); + } + else { snap_context = ED_transform_snap_object_context_create_view3d( ipd->scene, 0, ipd->region, ipd->v3d); snap_context_free = true; } + } + ipd->launch_event = WM_userdef_event_type_from_keymap_type(event->type); + + ED_transform_calc_orientation_from_type(C, ipd->matrix_orient); + + /* Set the orientation. */ + if (snap_context && (plane_orient == PLACE_ORIENT_SURFACE)) { float matrix_orient_surface[3][3]; /* Use the snap normal as a fallback in case the cursor isn't over a surface @@ -673,10 +677,6 @@ static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEv matrix_orient_surface)) { copy_m3_m3(ipd->matrix_orient, matrix_orient_surface); } - - if (snap_context_free) { - ED_transform_snap_object_context_destroy(snap_context); - } } ipd->orient_axis = plane_axis; @@ -751,13 +751,8 @@ static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEv ipd->v3d, ipd->region, ipd->scene->cursor.location, mval_fl, ipd->co_src); use_depth_fallback = false; } - else if (plane_depth == PLACE_DEPTH_SURFACE) { - SnapObjectContext *snap_context = - (ipd->snap_gizmo ? ED_gizmotypes_snap_3d_context_ensure( - ipd->scene, ipd->region, ipd->v3d, ipd->snap_gizmo) : - NULL); - if ((snap_context != NULL) && - ED_transform_snap_object_project_view3d(snap_context, + else if (snap_context && (plane_depth == PLACE_DEPTH_SURFACE)) { + if (ED_transform_snap_object_project_view3d(snap_context, CTX_data_ensure_evaluated_depsgraph(C), SCE_SNAP_MODE_FACE, &(const struct SnapObjectParams){ @@ -804,6 +799,10 @@ static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEv ipd->step[0].plane, ipd->co_src, ipd->matrix_orient[ipd->orient_axis]); copy_v3_v3(ipd->step[0].co_dst, ipd->co_src); + + if (snap_context_free) { + ED_transform_snap_object_context_destroy(snap_context); + } } static int view3d_interactive_add_invoke(bContext *C, wmOperator *op, const wmEvent *event) |