diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-01-05 17:26:38 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-01-05 17:26:38 +0300 |
commit | d16547ab73e7086d5358bba67093173827d12afe (patch) | |
tree | cdcc994222129063aaf916f972f8ed3311675266 /source/blender/editors | |
parent | 01b762e8463ec6192d43b3bfac7d29b0c24757c0 (diff) |
Alt+B view clipping is now taken into account properly for sculpt, particle
edit and snapping, by clipping the view ray.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 6 |
2 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index cfcd0d90e2c..11ce41c5ff8 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1841,7 +1841,7 @@ int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float ou ViewContext *vc = paint_stroke_view_context(stroke); SculptSession *ss= vc->obact->sculpt; StrokeCache *cache= ss->cache; - float ray_start[3], ray_normal[3]; + float ray_start[3], ray_end[3], ray_normal[3], dist; float obimat[4][4]; float mval[2] = {mouse[0] - vc->ar->winrct.xmin, mouse[1] - vc->ar->winrct.ymin}; @@ -1849,7 +1849,9 @@ int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float ou sculpt_stroke_modifiers_check(C, ss); - viewray(vc->ar, vc->v3d, mval, ray_start, ray_normal); + viewline(vc->ar, vc->v3d, mval, ray_start, ray_end); + sub_v3_v3v3(ray_normal, ray_end, ray_start); + dist= normalize_v3(ray_normal); invert_m4_m4(obimat, ss->ob->obmat); mul_m4_v3(obimat, ray_start); @@ -1859,7 +1861,7 @@ int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float ou srd.ss = vc->obact->sculpt; srd.ray_start = ray_start; srd.ray_normal = ray_normal; - srd.dist = FLT_MAX; + srd.dist = dist; srd.hit = 0; srd.original = (cache)? cache->original: 0; BLI_pbvh_raycast(ss->tree, sculpt_raycast_cb, &srd, diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 48f3c77091f..c7b62dd7ef4 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -536,6 +536,7 @@ void viewline(ARegion *ar, View3D *v3d, float mval[2], float ray_start[3], float { RegionView3D *rv3d= ar->regiondata; float vec[4]; + int a; if(rv3d->persp != RV3D_ORTHO){ vec[0]= 2.0f * mval[0] / ar->winx - 1; @@ -564,6 +565,11 @@ void viewline(ARegion *ar, View3D *v3d, float mval[2], float ray_start[3], float VECADDFAC(ray_start, vec, rv3d->viewinv[2], 1000.0f); VECADDFAC(ray_end, vec, rv3d->viewinv[2], -1000.0f); } + + /* clipping */ + if(rv3d->rflag & RV3D_CLIPPING) + for(a=0; a<4; a++) + clip_line_plane(ray_start, ray_end, rv3d->clip[a]); } /* create intersection ray in view Z direction at mouse coordinates */ |