[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41917] branches/bmesh/blender/source/ blender: tag index arrays as dirty when any element is removed, also check validity on operator init/exit ( check was missed in some cases before)
Campbell Barton
ideasman42 at gmail.com
Wed Nov 16 15:36:23 CET 2011
Revision: 41917
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41917
Author: campbellbarton
Date: 2011-11-16 14:36:23 +0000 (Wed, 16 Nov 2011)
Log Message:
-----------
tag index arrays as dirty when any element is removed, also check validity on operator init/exit (check was missed in some cases before)
Modified Paths:
--------------
branches/bmesh/blender/source/blender/bmesh/bmesh_operator_api.h
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c
branches/bmesh/blender/source/blender/bmesh/operators/bmesh_dupeops.c
branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c
branches/bmesh/blender/source/blender/bmesh/operators/mirror.c
branches/bmesh/blender/source/blender/bmesh/operators/removedoubles.c
branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
branches/bmesh/blender/source/blender/modifiers/intern/MOD_array.c
Modified: branches/bmesh/blender/source/blender/bmesh/bmesh_operator_api.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/bmesh_operator_api.h 2011-11-16 14:13:43 UTC (rev 41916)
+++ branches/bmesh/blender/source/blender/bmesh/bmesh_operator_api.h 2011-11-16 14:36:23 UTC (rev 41917)
@@ -133,7 +133,7 @@
have it set directly. and never use BMO_Set_Pnt to
pass in a list of edges or any arrays, really.*/
-void BMO_Init_Op(struct BMOperator *op, const char *opname);
+void BMO_Init_Op(struct BMesh *bm, struct BMOperator *op, const char *opname);
/*executes an operator, pushing and popping a new tool flag
layer as appropriate.*/
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c 2011-11-16 14:13:43 UTC (rev 41916)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mesh.c 2011-11-16 14:36:23 UTC (rev 41917)
@@ -578,6 +578,7 @@
}
}
+#if 0 /* mostly annoying, even in debug mode */
#ifdef DEBUG
if (is_any_error == 0) {
fprintf(stderr,
@@ -585,4 +586,5 @@
location, func, msg_a, msg_b);
}
#endif
+#endif
}
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c 2011-11-16 14:13:43 UTC (rev 41916)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c 2011-11-16 14:36:23 UTC (rev 41917)
@@ -460,6 +460,7 @@
bm->act_face = NULL;
bm->totface--;
+ bm->elem_index_dirty |= BM_FACE;
BM_remove_selection(bm, f);
if (f->head.data)
CustomData_bmesh_free_block(&bm->pdata, &f->head.data);
@@ -494,6 +495,7 @@
}
bm->totedge--;
+ bm->elem_index_dirty |= BM_EDGE;
BM_remove_selection(bm, e);
if (e->head.data)
CustomData_bmesh_free_block(&bm->edata, &e->head.data);
@@ -516,6 +518,7 @@
}
bm->totvert--;
+ bm->elem_index_dirty |= BM_VERT;
BM_remove_selection(bm, v);
if (v->head.data)
CustomData_bmesh_free_block(&bm->vdata, &v->head.data);
@@ -919,6 +922,9 @@
f->head.htype = BM_FACE;
BLI_addtail(&f->loops, lst);
+
+ BM_SetIndex(f, bm->totface); /* set_ok */
+
bm->totface++;
/*allocate flags*/
@@ -1339,6 +1345,8 @@
BLI_mempool_free(bm->toolflagpool, kv->head.flags);
BLI_mempool_free(bm->vpool, kv);
bm->totvert--;
+ /* account for both above */
+ bm->elem_index_dirty |= BM_VERT | BM_EDGE;
/*Validate disk cycle lengths of ov,tv are unchanged*/
edok = bmesh_disk_validate(valence1, ov->e, ov);
@@ -1505,6 +1513,8 @@
BLI_mempool_free(bm->toolflagpool, f2->head.flags);
BLI_mempool_free(bm->fpool, f2);
bm->totface--;
+ /* account for both above */
+ bm->elem_index_dirty |= BM_EDGE | BM_FACE;
BM_CHECK_ELEMENT(bm, f1);
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c 2011-11-16 14:13:43 UTC (rev 41916)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c 2011-11-16 14:36:23 UTC (rev 41917)
@@ -102,10 +102,16 @@
* Initializes an operator structure
* to a certain type
*/
-void BMO_Init_Op(BMOperator *op, const char *opname)
+void BMO_Init_Op(BMesh *bm, BMOperator *op, const char *opname)
{
int i, opcode = bmesh_opname_to_opcode(opname);
+#ifdef DEBUG
+ BM_ELEM_INDEX_VALIDATE(bm, "pre bmo", opname);
+#else
+ (void)bm;
+#endif
+
memset(op, 0, sizeof(BMOperator));
op->type = opcode;
op->flag = opdefines[opcode]->flag;
@@ -154,7 +160,7 @@
* Does housekeeping chores related to finishing
* up an operator.
*/
-void BMO_Finish_Op(BMesh *UNUSED(bm), BMOperator *op)
+void BMO_Finish_Op(BMesh *bm, BMOperator *op)
{
BMOpSlot *slot;
int i;
@@ -168,6 +174,12 @@
}
BLI_memarena_free(op->arena);
+
+#ifdef DEBUG
+ BM_ELEM_INDEX_VALIDATE(bm, "post bmo", opdefines[op->type]->name);
+#else
+ (void)bm;
+#endif
}
/*
@@ -1131,7 +1143,7 @@
if (i == bmesh_total_ops) return 0;
- BMO_Init_Op(op, opname);
+ BMO_Init_Op(bm, op, opname);
def = opdefines[i];
i = 0;
@@ -1289,10 +1301,6 @@
va_list list;
BMOperator op;
-#ifdef DEBUG
- BM_ELEM_INDEX_VALIDATE(bm, "pre bmo", fmt);
-#endif
-
va_start(list, fmt);
if (!BMO_VInitOpf(bm, &op, fmt, list)) {
printf("%s: failed, format is:\n \"%s\"\n", __func__, fmt);
@@ -1303,10 +1311,6 @@
BMO_Exec_Op(bm, &op);
BMO_Finish_Op(bm, &op);
-#ifdef DEBUG
- BM_ELEM_INDEX_VALIDATE(bm, "post bmo", fmt);
-#endif
-
va_end(list);
return 1;
}
Modified: branches/bmesh/blender/source/blender/bmesh/operators/bmesh_dupeops.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/bmesh_dupeops.c 2011-11-16 14:13:43 UTC (rev 41916)
+++ branches/bmesh/blender/source/blender/bmesh/operators/bmesh_dupeops.c 2011-11-16 14:36:23 UTC (rev 41917)
@@ -322,7 +322,7 @@
{
BMOperator dupeop;
- BMO_Init_Op(&dupeop, "dupe");
+ BMO_Init_Op(bm, &dupeop, "dupe");
BMO_HeaderFlag_To_Slot(bm, &dupeop, "geom", hflag, etypeflag);
BMO_Exec_Op(bm, &dupeop);
@@ -361,8 +361,8 @@
int found;
/*initialize our sub-operators*/
- BMO_Init_Op(&dupeop, "dupe");
- BMO_Init_Op(&delop, "del");
+ BMO_Init_Op(bm, &dupeop, "dupe");
+ BMO_Init_Op(bm, &delop, "del");
BMO_CopySlot(splitop, &dupeop, "geom", "geom");
BMO_Exec_Op(bm, &dupeop);
Modified: branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c 2011-11-16 14:13:43 UTC (rev 41916)
+++ branches/bmesh/blender/source/blender/bmesh/operators/extrudeops.c 2011-11-16 14:36:23 UTC (rev 41917)
@@ -180,7 +180,7 @@
int rlen, found, fwd, delorig=0;
/*initialize our sub-operators*/
- BMO_Init_Op(&dupeop, "dupe");
+ BMO_Init_Op(bm, &dupeop, "dupe");
BMO_Flag_Buffer(bm, op, "edgefacein", EXT_INPUT, BM_EDGE|BM_FACE);
@@ -553,7 +553,7 @@
thickness = BMO_Get_Float(op, "thickness");
/* Flip original faces (so the shell is extruded inward) */
- BMO_Init_Op(&reverseop, "reversefaces");
+ BMO_Init_Op(bm, &reverseop, "reversefaces");
BMO_CopySlot(op, &reverseop, "geom", "faces");
BMO_Exec_Op(bm, &reverseop);
BMO_Finish_Op(bm, &reverseop);
Modified: branches/bmesh/blender/source/blender/bmesh/operators/mirror.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/mirror.c 2011-11-16 14:13:43 UTC (rev 41916)
+++ branches/bmesh/blender/source/blender/bmesh/operators/mirror.c 2011-11-16 14:36:23 UTC (rev 41917)
@@ -86,7 +86,7 @@
BMO_CallOpf(bm, "scale verts=%fv vec=%v", ELE_NEW, scale);
BMO_CallOpf(bm, "transform verts=%fv mat=%m4", ELE_NEW, imtx);
- BMO_Init_Op(&weldop, "weldverts");
+ BMO_Init_Op(bm, &weldop, "weldverts");
v = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL);
for (i=0; i<ototvert; i++) {
Modified: branches/bmesh/blender/source/blender/bmesh/operators/removedoubles.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/removedoubles.c 2011-11-16 14:13:43 UTC (rev 41916)
+++ branches/bmesh/blender/source/blender/bmesh/operators/removedoubles.c 2011-11-16 14:36:23 UTC (rev 41917)
@@ -318,7 +318,7 @@
BMO_Get_Vec(op, "mergeco", vec);
//BMO_CallOpf(bm, "collapse_uvs edges=%s", op, "edges");
- BMO_Init_Op(&weldop, "weldverts");
+ BMO_Init_Op(bm, &weldop, "weldverts");
BMO_ITER(v, &siter, bm, op, "verts", BM_VERT) {
if (!snapv) {
@@ -344,7 +344,7 @@
int i, tot;
BMO_CallOpf(bm, "collapse_uvs edges=%s", op, "edges");
- BMO_Init_Op(&weldop, "weldverts");
+ BMO_Init_Op(bm, &weldop, "weldverts");
BMO_Flag_Buffer(bm, op, "edges", EDGE_MARK, BM_EDGE);
BMW_Init(&walker, bm, BMW_SHELL, EDGE_MARK, 0);
@@ -519,7 +519,7 @@
{
BMOperator weldop;
- BMO_Init_Op(&weldop, "weldverts");
+ BMO_Init_Op(bm, &weldop, "weldverts");
bmesh_finddoubles_common(bm, op, &weldop, "targetmap");
BMO_Exec_Op(bm, &weldop);
BMO_Finish_Op(bm, &weldop);
@@ -554,7 +554,7 @@
BMO_Exec_Op(bm, &findop);
/* weld the vertices */
- BMO_Init_Op(&weldop, "weldverts");
+ BMO_Init_Op(bm, &weldop, "weldverts");
BMO_CopySlot(&findop, &weldop, "targetmapout", "targetmap");
BMO_Exec_Op(bm, &weldop);
Modified: branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c 2011-11-16 14:13:43 UTC (rev 41916)
+++ branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c 2011-11-16 14:36:23 UTC (rev 41917)
@@ -274,7 +274,7 @@
ModifierData *md;
BMHeader *el;
- BMO_Init_Op(&extop, "extrudefaceregion");
+ BMO_Init_Op(bm, &extop, "extrudefaceregion");
BMO_HeaderFlag_To_Slot(bm, &extop, "edgefacein",
hflag, BM_VERT|BM_EDGE|BM_FACE);
Modified: branches/bmesh/blender/source/blender/modifiers/intern/MOD_array.c
===================================================================
--- branches/bmesh/blender/source/blender/modifiers/intern/MOD_array.c 2011-11-16 14:13:43 UTC (rev 41916)
+++ branches/bmesh/blender/source/blender/modifiers/intern/MOD_array.c 2011-11-16 14:36:23 UTC (rev 41917)
@@ -401,7 +401,7 @@
BMO_push(em->bm, NULL);
bmesh_begin_edit(em->bm, 0);
- BMO_Init_Op(&weldop, "weldverts");
+ BMO_Init_Op(em->bm, &weldop, "weldverts");
BMO_InitOpf(em->bm, &op, "dupe geom=%avef");
oldop = op;
for (j=0; j < count - 1; j++) {
More information about the Bf-blender-cvs
mailing list