[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50462] trunk/blender/source/blender/ editors: remove makeDerivedMesh from ED_mesh_pick_face(), this was added 44256 (bmesh merge), but is pretty bad ( rebuilding entire derived mesh to pick a face), tested with subsurf modifier, sintel mesh - it works ok without it.

Campbell Barton ideasman42 at gmail.com
Fri Sep 7 02:58:03 CEST 2012


Revision: 50462
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50462
Author:   campbellbarton
Date:     2012-09-07 00:58:00 +0000 (Fri, 07 Sep 2012)
Log Message:
-----------
remove makeDerivedMesh from ED_mesh_pick_face(), this was added 44256 (bmesh merge), but is pretty bad (rebuilding entire derived mesh to pick a face), tested with subsurf modifier, sintel mesh - it works ok without it.
Also - other select modes like border-select dont do this, so looks safe to disable.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/ED_mesh.h
    trunk/blender/source/blender/editors/mesh/editface.c
    trunk/blender/source/blender/editors/mesh/meshtools.c
    trunk/blender/source/blender/editors/space_view3d/view3d_select.c

Modified: trunk/blender/source/blender/editors/include/ED_mesh.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_mesh.h	2012-09-07 00:22:10 UTC (rev 50461)
+++ trunk/blender/source/blender/editors/include/ED_mesh.h	2012-09-07 00:58:00 UTC (rev 50462)
@@ -279,9 +279,12 @@
 struct BMVert *editbmesh_get_x_mirror_vert(struct Object *ob, struct BMEditMesh *em, struct BMVert *eve, const float co[3], int index);
 int           *mesh_get_x_mirror_faces(struct Object *ob, struct BMEditMesh *em);
 
-int ED_mesh_pick_face(struct bContext *C, struct Mesh *me, struct Object *ob, const int mval[2], unsigned int *index, short rect);
 int ED_mesh_pick_vert(struct bContext *C, struct Mesh *me, const int mval[2], unsigned int *index, int size);
+int ED_mesh_pick_face(struct bContext *C, struct Mesh *me, const int mval[2], unsigned int *index, int size);
 
+#define ED_MESH_PICK_DEFAULT_VERT_SIZE 50
+#define ED_MESH_PICK_DEFAULT_FACE_SIZE 3
+
 #include "../mesh/editmesh_bvh.h"
 
 #ifdef __cplusplus

Modified: trunk/blender/source/blender/editors/mesh/editface.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editface.c	2012-09-07 00:22:10 UTC (rev 50461)
+++ trunk/blender/source/blender/editors/mesh/editface.c	2012-09-07 00:58:00 UTC (rev 50462)
@@ -294,7 +294,7 @@
 	if (mode == 0 || mode == 1) {
 		/* XXX - Causes glitches, not sure why */
 #if 0
-		if (!ED_mesh_pick_face(C, me, mval, &index, 1))
+		if (!ED_mesh_pick_face(C, me, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE))
 			return;
 #endif
 	}
@@ -481,7 +481,7 @@
 	/* Get the face under the cursor */
 	me = BKE_mesh_from_object(ob);
 
-	if (!ED_mesh_pick_face(C, me, ob, mval, &index, 1))
+	if (!ED_mesh_pick_face(C, me, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE))
 		return 0;
 	
 	if (index >= me->totpoly)

Modified: trunk/blender/source/blender/editors/mesh/meshtools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/meshtools.c	2012-09-07 00:22:10 UTC (rev 50461)
+++ trunk/blender/source/blender/editors/mesh/meshtools.c	2012-09-07 00:58:00 UTC (rev 50462)
@@ -42,6 +42,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "DNA_mesh_types.h"
+#include "DNA_view3d_types.h"
 #include "DNA_key_types.h"
 #include "DNA_material_types.h"
 #include "DNA_meshdata_types.h"
@@ -1156,28 +1157,21 @@
  *
  * \return boolean TRUE == Found
  */
-int ED_mesh_pick_face(bContext *C, Mesh *me, Object *ob, const int mval[2], unsigned int *index, short rect)
+int ED_mesh_pick_face(bContext *C, Mesh *me, const int mval[2], unsigned int *index, int size)
 {
-	Scene *scene = CTX_data_scene(C);
 	ViewContext vc;
-	view3d_set_viewcontext(C, &vc);
 
 	if (!me || me->totpoly == 0)
 		return 0;
 
-	makeDerivedMesh(scene, ob, NULL, CD_MASK_BAREMESH, 0);
+	view3d_set_viewcontext(C, &vc);
 
-	// XXX  if (v3d->flag & V3D_INVALID_BACKBUF) {
-// XXX drawview.c!		check_backbuf();
-// XXX		persp(PERSP_VIEW);
-// XXX  }
-
-	if (rect) {
-		/* sample rect to increase changes of selecting, so that when clicking
+	if (size) {
+		/* sample rect to increase chances of selecting, so that when clicking
 		 * on an edge in the backbuf, we can still select a face */
 
-		int dist;
-		*index = view3d_sample_backbuf_rect(&vc, mval, 3, 1, me->totpoly + 1, &dist, 0, NULL, NULL);
+		int dummy_dist;
+		*index = view3d_sample_backbuf_rect(&vc, mval, size, 1, me->totpoly + 1, &dummy_dist, 0, NULL, NULL);
 	}
 	else {
 		/* sample only on the exact position */
@@ -1201,17 +1195,18 @@
 int ED_mesh_pick_vert(bContext *C, Mesh *me, const int mval[2], unsigned int *index, int size)
 {
 	ViewContext vc;
-	view3d_set_viewcontext(C, &vc);
 
 	if (!me || me->totvert == 0)
 		return 0;
 
+	view3d_set_viewcontext(C, &vc);
+
 	if (size > 0) {
-		/* sample rect to increase changes of selecting, so that when clicking
+		/* sample rect to increase chances of selecting, so that when clicking
 		 * on an face in the backbuf, we can still select a vert */
 
-		int dist;
-		*index = view3d_sample_backbuf_rect(&vc, mval, size, 1, me->totvert + 1, &dist, 0, NULL, NULL);
+		int dummy_dist;
+		*index = view3d_sample_backbuf_rect(&vc, mval, size, 1, me->totvert + 1, &dummy_dist, 0, NULL, NULL);
 	}
 	else {
 		/* sample only on the exact position */

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_select.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_select.c	2012-09-07 00:22:10 UTC (rev 50461)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_select.c	2012-09-07 00:58:00 UTC (rev 50462)
@@ -2035,8 +2035,8 @@
 	unsigned int index = 0;
 	MVert *mv;
 
-	if (ED_mesh_pick_vert(C, me, mval, &index, 50)) {
-		mv = me->mvert + index;
+	if (ED_mesh_pick_vert(C, me, mval, &index, ED_MESH_PICK_DEFAULT_VERT_SIZE)) {
+		mv = &me->mvert[index];
 		if (extend) {
 			mv->flag |= SELECT;
 		}




More information about the Bf-blender-cvs mailing list