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().
This commit is contained in:
Campbell Barton
2011-04-21 18:33:30 +00:00
parent 284a0d3610
commit b52637270d
4 changed files with 18 additions and 6 deletions

View File

@@ -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);
}

View File

@@ -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 */

View File

@@ -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);

View File

@@ -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;
}
}
}