diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-04-21 22:33:30 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-04-21 22:33:30 +0400 |
commit | b52637270d776db4845a32718272e0cc1deff3a8 (patch) | |
tree | 645e67fdfff5c279f13a8699194e39f1c439261c | |
parent | 284a0d3610b50ff45a7acdc084c21003c9af0d41 (diff) |
bugfix [#27091] Add new vertex at wrong position ( bpy.ops.mesh.dupli_extrude_cursor() ) 2
Ctrl+Click on mesh or curve view was using the selected points location or the cursors.
if either of these was behind the view it would add the point at (0, 0, 0).
now fallback to the view orbit pivot, added this option as an argument to view3d_get_view_aligned_coordinate().
-rw-r--r-- | source/blender/editors/curve/editcurve.c | 2 | ||||
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_add.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 14 |
4 files changed, 18 insertions, 6 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 4365bf69308..1ab7acef861 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -4692,7 +4692,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event) mval[0]= event->x - vc.ar->winrct.xmin; mval[1]= event->y - vc.ar->winrct.ymin; - view3d_get_view_aligned_coordinate(&vc, location, mval); + view3d_get_view_aligned_coordinate(&vc, location, mval, TRUE); RNA_float_set_array(op->ptr, "location", location); } diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 3903cfa19a3..a3e99e6358e 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -153,7 +153,7 @@ short view3d_opengl_select(struct ViewContext *vc, unsigned int *buffer, unsigne void view3d_set_viewcontext(struct bContext *C, struct ViewContext *vc); void view3d_operator_needs_opengl(const struct bContext *C); void view3d_region_operator_needs_opengl(struct wmWindow *win, struct ARegion *ar); -void view3d_get_view_aligned_coordinate(struct ViewContext *vc, float fp[3], const short mval[2]); +int view3d_get_view_aligned_coordinate(struct ViewContext *vc, float fp[3], const short mval[2], const short do_fallback); void view3d_get_transformation(struct ARegion *ar, struct RegionView3D *rv3d, struct Object *ob, struct bglMats *mats); /* XXX should move to BLI_math */ diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 1b77797d19b..b3492a5fb09 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -198,7 +198,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) copy_v3_v3(min, cent); mul_m4_v3(vc.obedit->obmat, min); // view space - view3d_get_view_aligned_coordinate(&vc, min, event->mval); + view3d_get_view_aligned_coordinate(&vc, min, event->mval, TRUE); mul_m4_v3(vc.obedit->imat, min); // back in object space sub_v3_v3(min, cent); @@ -250,8 +250,8 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) const float *curs= give_cursor(vc.scene, vc.v3d); copy_v3_v3(min, curs); - view3d_get_view_aligned_coordinate(&vc, min, event->mval); - + view3d_get_view_aligned_coordinate(&vc, min, event->mval, TRUE); + eve= addvertlist(vc.em, 0, NULL); invert_m4_m4(imat, vc.obedit->obmat); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index e8fbb3542fa..f51a780787e 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -93,7 +93,7 @@ void view3d_set_viewcontext(bContext *C, ViewContext *vc) vc->obedit= CTX_data_edit_object(C); } -void view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const short mval[2]) +int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const short mval[2], const short do_fallback) { float dvec[3]; short mval_cpy[2]; @@ -108,6 +108,18 @@ void view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const shor if(mval_cpy[0]!=IS_CLIPPED) { window_to_3d_delta(vc->ar, dvec, mval_cpy[0]-mval[0], mval_cpy[1]-mval[1]); sub_v3_v3(fp, dvec); + + return TRUE; + } + else { + /* fallback to the view center */ + if(do_fallback) { + negate_v3_v3(fp, vc->rv3d->ofs); + return view3d_get_view_aligned_coordinate(vc, fp, mval, FALSE); + } + else { + return FALSE; + } } } |