[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45196] trunk/blender/source/blender: fix [#30651] bpy.ops.object.mode_set(...) editmode removes faces.

Campbell Barton ideasman42 at gmail.com
Tue Mar 27 02:01:44 CEST 2012


Revision: 45196
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45196
Author:   campbellbarton
Date:     2012-03-27 00:01:35 +0000 (Tue, 27 Mar 2012)
Log Message:
-----------
fix [#30651] bpy.ops.object.mode_set(...) editmode removes faces.

problem was that BMesh had tessellation call when undo pushes were called.

if python called an operator with no undo push, tessfaces would not be created.

fix this by making it the responsibility of each editmesh operator to re-tessellate, as it is with notifiers and depsgraph.
added EDBM_update_generic() function to add notifier, tag for depsgraph update and optionally re-tessellate.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_tessmesh.h
    trunk/blender/source/blender/blenkernel/intern/depsgraph.c
    trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c
    trunk/blender/source/blender/editors/include/ED_mesh.h
    trunk/blender/source/blender/editors/mesh/editmesh_add.c
    trunk/blender/source/blender/editors/mesh/editmesh_knife.c
    trunk/blender/source/blender/editors/mesh/editmesh_select.c
    trunk/blender/source/blender/editors/mesh/editmesh_tools.c
    trunk/blender/source/blender/editors/mesh/editmesh_utils.c
    trunk/blender/source/blender/editors/object/object_edit.c
    trunk/blender/source/blender/editors/util/undo.c
    trunk/blender/source/blender/makesdna/DNA_object_types.h
    trunk/blender/source/blender/makesdna/DNA_particle_types.h

Modified: trunk/blender/source/blender/blenkernel/BKE_tessmesh.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_tessmesh.h	2012-03-26 22:48:09 UTC (rev 45195)
+++ trunk/blender/source/blender/blenkernel/BKE_tessmesh.h	2012-03-27 00:01:35 UTC (rev 45196)
@@ -80,10 +80,6 @@
 	int mirr_free_arrays;
 } BMEditMesh;
 
-/* undo triggers editmesh tessface update, this is odd but works OK.
- * BMESH_TODO, look into having the update elsewhere. */
-#define BMESH_EM_UNDO_RECALC_TESSFACE_WORKAROUND
-
 void BMEdit_RecalcTessellation(BMEditMesh *tm);
 BMEditMesh *BMEdit_Create(BMesh *bm, int do_tessellate);
 BMEditMesh *BMEdit_Copy(BMEditMesh *tm);

Modified: trunk/blender/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/depsgraph.c	2012-03-26 22:48:09 UTC (rev 45195)
+++ trunk/blender/source/blender/blenkernel/intern/depsgraph.c	2012-03-27 00:01:35 UTC (rev 45196)
@@ -2716,7 +2716,6 @@
 	/* flag is for objects and particle systems */
 	if (flag) {
 		Object *ob;
-		ParticleSystem *psys;
 		short idtype = GS(id->name);
 
 		if (idtype == ID_OB) {
@@ -2725,6 +2724,7 @@
 			ob->recalc |= (flag & OB_RECALC_ALL);
 		}
 		else if (idtype == ID_PA) {
+			ParticleSystem *psys;
 			/* this is weak still, should be done delayed as well */
 			for (ob=bmain->object.first; ob; ob=ob->id.next) {
 				for (psys=ob->particlesystem.first; psys; psys=psys->next) {

Modified: trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c	2012-03-26 22:48:09 UTC (rev 45195)
+++ trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c	2012-03-27 00:01:35 UTC (rev 45196)
@@ -511,7 +511,8 @@
 		BKE_animsys_evaluate_animdata(scene, &cu->id, cu->adt, frame, ADT_RECALC_ANIM);
 	}
 
-	ob->recalc |= OB_RECALC_ALL;
+	/* was originally OB_RECALC_ALL - TODO - which flags are really needed??? */
+	ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
 	BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, frame, ADT_RECALC_ANIM);
 	if (flags & UPDATE_MESH) {
 		/* ignore cache clear during subframe updates

Modified: trunk/blender/source/blender/editors/include/ED_mesh.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_mesh.h	2012-03-26 22:48:09 UTC (rev 45195)
+++ trunk/blender/source/blender/editors/include/ED_mesh.h	2012-03-27 00:01:35 UTC (rev 45196)
@@ -168,6 +168,8 @@
 void EDBM_hide_mesh(struct BMEditMesh *em, int swap);
 void EDBM_reveal_mesh(struct BMEditMesh *em);
 
+void EDBM_update_generic(struct bContext *C, struct BMEditMesh *em, const short do_tessface);
+
 int			EDBM_check_backbuf(unsigned int index);
 int			EDBM_mask_init_backbuf_border(struct ViewContext *vc, int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax);
 void		EDBM_free_backbuf(void);

Modified: trunk/blender/source/blender/editors/mesh/editmesh_add.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_add.c	2012-03-26 22:48:09 UTC (rev 45195)
+++ trunk/blender/source/blender/editors/mesh/editmesh_add.c	2012-03-27 00:01:35 UTC (rev 45196)
@@ -98,29 +98,20 @@
 		ED_object_enter_editmode(C, EM_DO_UNDO | EM_IGNORE_LAYER); /* rare cases the active layer is messed up */
 		*state = 1;
 	}
-	else {
-		DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
-	}
 
 	*dia *= new_primitive_matrix(C, loc, rot, mat);
 }
 
 static void make_prim_finish(bContext *C, int *state, int enter_editmode)
 {
-	Object *obedit;
-	Mesh *me;
-	BMEditMesh *em;
+	Object *obedit = CTX_data_edit_object(C);
+	BMEditMesh *em = BMEdit_FromObject(obedit);
 
-	obedit = CTX_data_edit_object(C);
-	me = obedit->data;
-	em = me->edit_btmesh;
-
 	/* Primitive has all verts selected, use vert select flush
 	 * to push this up to edges & faces. */
 	EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX);
 
-	DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
-	WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+	EDBM_update_generic(C, em, TRUE);
 
 	/* userdef */
 	if (*state && !enter_editmode) {

Modified: trunk/blender/source/blender/editors/mesh/editmesh_knife.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_knife.c	2012-03-26 22:48:09 UTC (rev 45195)
+++ trunk/blender/source/blender/editors/mesh/editmesh_knife.c	2012-03-27 00:01:35 UTC (rev 45196)
@@ -2601,8 +2601,7 @@
 	knife_make_cuts(kcd);
 #endif
 
-	DAG_id_tag_update(kcd->ob->data, OB_RECALC_DATA);
-	WM_event_add_notifier(C, NC_GEOM | ND_DATA, kcd->ob->data);
+	EDBM_update_generic(C, kcd->em, TRUE);
 }
 
 /* copied from paint_image.c */

Modified: trunk/blender/source/blender/editors/mesh/editmesh_select.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_select.c	2012-03-26 22:48:09 UTC (rev 45195)
+++ trunk/blender/source/blender/editors/mesh/editmesh_select.c	2012-03-27 00:01:35 UTC (rev 45196)
@@ -115,6 +115,7 @@
 		BMO_op_callf(em->bm, "automerge verts=%hv dist=%f", BM_ELEM_SELECT, scene->toolsettings->doublimit);
 		if (update) {
 			DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
+			BMEdit_RecalcTessellation(em);
 		}
 	}
 }
@@ -722,9 +723,7 @@
 		return OPERATOR_CANCELLED;
 	}
 
-	/* dependencies graph and notification stuff */
-	DAG_id_tag_update(ob->data, OB_RECALC_DATA);
-	WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
+	EDBM_update_generic(C, em, FALSE);
 
 	/* we succeeded */
 	return OPERATOR_FINISHED;
@@ -763,9 +762,7 @@
 		return OPERATOR_CANCELLED;
 	}
 
-	/* dependencies graph and notification stuff */
-	DAG_id_tag_update(ob->data, OB_RECALC_DATA);
-	WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
+	EDBM_update_generic(C, em, FALSE);
 
 	/* we succeeded */
 	return OPERATOR_FINISHED;
@@ -807,9 +804,7 @@
 
 	EDBM_selectmode_flush(em);
 
-	/* dependencies graph and notification stuff */
-	DAG_id_tag_update(ob->data, OB_RECALC_DATA);
-	WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
+	EDBM_update_generic(C, em, FALSE);
 
 	/* we succeeded */
 	return OPERATOR_FINISHED;
@@ -1356,7 +1351,6 @@
 /* since you want to create paths with multiple selects, it doesn't have extend option */
 static void mouse_mesh_shortest_path(bContext *C, int mval[2])
 {
-	Object *ob = CTX_data_edit_object(C);
 	ViewContext vc;
 	BMEditMesh *em;
 	BMEdge *e;
@@ -1416,8 +1410,7 @@
 				break;
 		}
 		
-		DAG_id_tag_update(ob->data, OB_RECALC_DATA);
-		WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
+		EDBM_update_generic(C, em, FALSE);
 	}
 }
 
@@ -2172,8 +2165,7 @@
 		return OPERATOR_CANCELLED;
 	}
 
-	DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
-	WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+	EDBM_update_generic(C, em, FALSE);
 
 	return OPERATOR_FINISHED;
 }

Modified: trunk/blender/source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_tools.c	2012-03-26 22:48:09 UTC (rev 45195)
+++ trunk/blender/source/blender/editors/mesh/editmesh_tools.c	2012-03-27 00:01:35 UTC (rev 45196)
@@ -107,8 +107,7 @@
 	                       RNA_boolean_get(op->ptr, "quadtri"),
 	                       TRUE, RNA_int_get(op->ptr, "seed"));
 
-	DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
-	WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+	EDBM_update_generic(C, em, TRUE);
 
 	return OPERATOR_FINISHED;
 }
@@ -407,8 +406,7 @@
 	
 	EDBM_RecalcNormals(em);
 
-	DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
-	WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+	EDBM_update_generic(C, em, TRUE);
 
 	return OPERATOR_FINISHED;
 }
@@ -528,9 +526,8 @@
 	 * like this one don't push undo data until after modal mode is
 	 * done.*/
 	EDBM_RecalcNormals(em);
-	BMEdit_RecalcTessellation(em);
 
-	WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
+	EDBM_update_generic(C, em, TRUE);
 	
 	return OPERATOR_FINISHED;
 }
@@ -879,11 +876,9 @@
 	 * like this one don't push undo data until after modal mode is
 	 * done. */
 	EDBM_RecalcNormals(vc.em);
-	BMEdit_RecalcTessellation(vc.em);
 
-	WM_event_add_notifier(C, NC_GEOM | ND_DATA, vc.obedit->data);
-	DAG_id_tag_update(vc.obedit->data, OB_RECALC_DATA);
-	
+	EDBM_update_generic(C, vc.em, TRUE);
+
 	return OPERATOR_FINISHED;
 }
 
@@ -947,9 +942,7 @@
 
 	EDBM_flag_disable_all(em, BM_ELEM_SELECT);
 
-	DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
-
-	WM_event_add_notifier(C, NC_GEOM | ND_DATA | ND_SELECT, obedit);
+	EDBM_update_generic(C, em, TRUE);
 	
 	return OPERATOR_FINISHED;
 }
@@ -981,9 +974,8 @@
 
 	if (!EDBM_CallOpf(em, op, "collapse edges=%he", BM_ELEM_SELECT))
 		return OPERATOR_CANCELLED;
-	DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
 
-	WM_event_add_notifier(C, NC_GEOM | ND_DATA | ND_SELECT, obedit);
+	EDBM_update_generic(C, em, TRUE);
 
 	return OPERATOR_FINISHED;
 }
@@ -1010,9 +1002,8 @@
 
 	if (!EDBM_CallOpf(em, op, "dissolve_edge_loop edges=%he", BM_ELEM_SELECT))
 		return OPERATOR_CANCELLED;
-	DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
 
-	WM_event_add_notifier(C, NC_GEOM | ND_DATA | ND_SELECT, obedit);
+	EDBM_update_generic(C, em, TRUE);
 
 	return OPERATOR_FINISHED;
 }
@@ -1048,8 +1039,7 @@
 		return OPERATOR_CANCELLED;
 	}
 
-	WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
-	DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
+	EDBM_update_generic(C, em, TRUE);
 	
 	return OPERATOR_FINISHED;
 }
@@ -1102,8 +1092,7 @@
 		}
 	}
 
-	DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
-	WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+	EDBM_update_generic(C, em, TRUE);
 
 	return OPERATOR_FINISHED;
 }
@@ -1157,10 +1146,8 @@
 		}
 	}
 
+	EDBM_update_generic(C, em, TRUE);
 
-	DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
-	WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
-
 	return OPERATOR_FINISHED;
 }
 
@@ -1199,8 +1186,7 @@
 		return OPERATOR_CANCELLED;
 	}
 	
-	DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
-	WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+	EDBM_update_generic(C, em, TRUE);
 
 	return len ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
 }
@@ -1236,8 +1222,7 @@
 		return OPERATOR_CANCELLED;
 	}
 	

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list