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 | |
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')
4 files changed, 20 insertions, 10 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 6f51d740e55..302862b1a8f 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -5099,14 +5099,15 @@ void ED_view3d_cursor3d_position_rotation(bContext *C, float ray_no[3]; float ray_co[3]; - struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d( - scene, 0, region, v3d); + struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create(scene, 0); float obmat[4][4]; Object *ob_dummy = NULL; float dist_px = 0; if (ED_transform_snap_object_project_view3d_ex(snap_context, CTX_data_ensure_evaluated_depsgraph(C), + region, + v3d, SCE_SNAP_MODE_FACE, &(const struct SnapObjectParams){ .snap_select = SNAP_ALL, diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index f8278edbcae..573f5348b5e 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -356,8 +356,7 @@ static bool view3d_ruler_item_mousemove(struct Depsgraph *depsgraph, if (do_thickness && inter->co_index != 1) { Scene *scene = DEG_get_input_scene(depsgraph); View3D *v3d = ruler_info->area->spacedata.first; - SnapObjectContext *snap_context = ED_gizmotypes_snap_3d_context_ensure( - scene, ruler_info->region, v3d, snap_gizmo); + SnapObjectContext *snap_context = ED_gizmotypes_snap_3d_context_ensure(scene, snap_gizmo); const float mval_fl[2] = {UNPACK2(mval)}; float ray_normal[3]; float ray_start[3]; @@ -367,6 +366,8 @@ static bool view3d_ruler_item_mousemove(struct Depsgraph *depsgraph, if (ED_transform_snap_object_project_view3d(snap_context, depsgraph, + ruler_info->region, + v3d, SCE_SNAP_MODE_FACE, &(const struct SnapObjectParams){ .snap_select = SNAP_ALL, @@ -382,6 +383,7 @@ static bool view3d_ruler_item_mousemove(struct Depsgraph *depsgraph, madd_v3_v3v3fl(ray_start, co, ray_normal, eps_bias); ED_transform_snap_object_project_ray(snap_context, depsgraph, + v3d, &(const struct SnapObjectParams){ .snap_select = SNAP_ALL, .edit_mode_type = SNAP_GEOM_CAGE, diff --git a/source/blender/editors/space_view3d/view3d_navigate_walk.c b/source/blender/editors/space_view3d/view3d_navigate_walk.c index 1ac241013ed..83b8c04acb6 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_walk.c +++ b/source/blender/editors/space_view3d/view3d_navigate_walk.c @@ -423,6 +423,7 @@ static bool walk_floor_distance_get(RegionView3D *rv3d, ret = ED_transform_snap_object_project_ray( walk->snap_context, walk->depsgraph, + walk->v3d, &(const struct SnapObjectParams){ .snap_select = SNAP_ALL, /* Avoid having to convert the edit-mesh to a regular mesh. */ @@ -464,6 +465,7 @@ static bool walk_ray_cast(RegionView3D *rv3d, ret = ED_transform_snap_object_project_ray(walk->snap_context, walk->depsgraph, + walk->v3d, &(const struct SnapObjectParams){ .snap_select = SNAP_ALL, }, @@ -602,8 +604,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->rv3d->rflag |= RV3D_NAVIGATING; - walk->snap_context = ED_transform_snap_object_context_create_view3d( - walk->scene, 0, walk->region, walk->v3d); + walk->snap_context = ED_transform_snap_object_context_create(walk->scene, 0); walk->v3d_camera_control = ED_view3d_cameracontrol_acquire( walk->depsgraph, walk->scene, walk->v3d, walk->rv3d); 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, |