Correct armature-sketch snap context use

Use scene snap mode.
Also allow passing NULL ray-depth which falls back to BVH_RAYCAST_DIST_MAX.
This commit is contained in:
Campbell Barton
2016-05-10 16:36:46 +10:00
parent ce65fae8f3
commit 401e710807
3 changed files with 10 additions and 7 deletions

View File

@@ -1092,13 +1092,13 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
CTX_data_main(C), CTX_data_scene(C), 0, CTX_data_main(C), CTX_data_scene(C), 0,
CTX_wm_region(C), CTX_wm_view3d(C)); CTX_wm_region(C), CTX_wm_view3d(C));
found = ED_transform_snap_object_project_view3d_mixed( found = ED_transform_snap_object_project_view3d(
snap_context, snap_context,
&(const struct SnapObjectParams){ &(const struct SnapObjectParams){
.snap_select = SNAP_NOT_SELECTED, .snap_select = SNAP_NOT_SELECTED,
.snap_to_flag = SCE_SELECT_FACE, .snap_to = ts->snap_mode,
}, },
mval, &dist_px, true, mval, &dist_px, NULL,
vec, no); vec, no);
ED_transform_snap_object_context_destroy(snap_context); ED_transform_snap_object_context_destroy(snap_context);

View File

@@ -1287,8 +1287,6 @@ bool snapObjectsTransform(
float *dist_px, float *dist_px,
float r_loc[3], float r_no[3]) float r_loc[3], float r_no[3])
{ {
float ray_dist = BVH_RAYCAST_DIST_MAX;
return ED_transform_snap_object_project_view3d_ex( return ED_transform_snap_object_project_view3d_ex(
t->tsnap.object_context, t->tsnap.object_context,
&(const struct SnapObjectParams){ &(const struct SnapObjectParams){
@@ -1297,8 +1295,7 @@ bool snapObjectsTransform(
.use_object_edit = (t->flag & T_EDIT) != 0, .use_object_edit = (t->flag & T_EDIT) != 0,
.use_object_active = (t->options & CTX_GPENCIL_STROKES) == 0, .use_object_active = (t->options & CTX_GPENCIL_STROKES) == 0,
}, },
mval, dist_px, mval, dist_px, NULL,
&ray_dist,
r_loc, r_no, NULL); r_loc, r_no, NULL);
} }

View File

@@ -1449,6 +1449,12 @@ bool ED_transform_snap_object_project_view3d_ex(
{ {
float ray_start[3], ray_normal[3], ray_orgigin[3]; float ray_start[3], ray_normal[3], ray_orgigin[3];
float ray_depth_fallback;
if (ray_depth == NULL) {
ray_depth_fallback = BVH_RAYCAST_DIST_MAX;
ray_depth = &ray_depth_fallback;
}
if (!ED_view3d_win_to_ray_ex( if (!ED_view3d_win_to_ray_ex(
sctx->v3d_data.ar, sctx->v3d_data.v3d, sctx->v3d_data.ar, sctx->v3d_data.v3d,
mval, ray_orgigin, ray_normal, ray_start, true)) mval, ray_orgigin, ray_normal, ray_start, true))