From e3afec146116900b1af0296c65b8b3765385ae4c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 10 Jun 2013 03:56:50 +0000 Subject: fix [#35669] Snap curvepoints dont work correct when another object is selected Ctrl+Click extrude curves now supports snapping to faces as with meshes. --- source/blender/editors/curve/editcurve.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 0383c0d1d1a..ae65cc9dbbe 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -4624,19 +4624,20 @@ static int add_vertex_exec(bContext *C, wmOperator *op) static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - RegionView3D *rv3d = CTX_wm_region_view3d(C); + ViewContext vc; + + view3d_set_viewcontext(C, &vc); - if (rv3d && !RNA_struct_property_is_set(op->ptr, "location")) { + if (vc.rv3d && !RNA_struct_property_is_set(op->ptr, "location")) { Curve *cu; - ViewContext vc; float location[3]; + const bool use_proj = ((vc.scene->toolsettings->snap_flag & SCE_SNAP) && + (vc.scene->toolsettings->snap_mode == SCE_SNAP_MODE_FACE)); Nurb *nu; BezTriple *bezt; BPoint *bp; - view3d_set_viewcontext(C, &vc); - cu = vc.obedit->data; findselectedNurbvert(&cu->editnurb->nurbs, &nu, &bezt, &bp); @@ -4652,6 +4653,14 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event) } ED_view3d_win_to_3d_int(vc.ar, location, event->mval, location); + + if (use_proj) { + const float mval[2] = {UNPACK2(event->mval)}; + float no_dummy[3]; + float dist_px_dummy; + snapObjectsContext(C, mval, &dist_px_dummy, location, no_dummy, SNAP_NOT_OBEDIT); + } + RNA_float_set_array(op->ptr, "location", location); } -- cgit v1.2.3