[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36279] trunk/blender/source/blender/ editors: bugfix [#27091] Add new vertex at wrong position ( bpy.ops.mesh. dupli_extrude_cursor() ) 2

Campbell Barton ideasman42 at gmail.com
Thu Apr 21 20:33:30 CEST 2011


Revision: 36279
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36279
Author:   campbellbarton
Date:     2011-04-21 18:33:30 +0000 (Thu, 21 Apr 2011)
Log Message:
-----------
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().

Modified Paths:
--------------
    trunk/blender/source/blender/editors/curve/editcurve.c
    trunk/blender/source/blender/editors/include/ED_view3d.h
    trunk/blender/source/blender/editors/mesh/editmesh_add.c
    trunk/blender/source/blender/editors/space_view3d/view3d_select.c

Modified: trunk/blender/source/blender/editors/curve/editcurve.c
===================================================================
--- trunk/blender/source/blender/editors/curve/editcurve.c	2011-04-21 17:25:58 UTC (rev 36278)
+++ trunk/blender/source/blender/editors/curve/editcurve.c	2011-04-21 18:33:30 UTC (rev 36279)
@@ -4692,7 +4692,7 @@
 		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);
 	}
 

Modified: trunk/blender/source/blender/editors/include/ED_view3d.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_view3d.h	2011-04-21 17:25:58 UTC (rev 36278)
+++ trunk/blender/source/blender/editors/include/ED_view3d.h	2011-04-21 18:33:30 UTC (rev 36279)
@@ -153,7 +153,7 @@
 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 */

Modified: trunk/blender/source/blender/editors/mesh/editmesh_add.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_add.c	2011-04-21 17:25:58 UTC (rev 36278)
+++ trunk/blender/source/blender/editors/mesh/editmesh_add.c	2011-04-21 18:33:30 UTC (rev 36279)
@@ -198,7 +198,7 @@
 		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 @@
 		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);

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_select.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_select.c	2011-04-21 17:25:58 UTC (rev 36278)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_select.c	2011-04-21 18:33:30 UTC (rev 36279)
@@ -93,7 +93,7 @@
 	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,7 +108,19 @@
 	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;
+		}
+	}
 }
 
 /*




More information about the Bf-blender-cvs mailing list