[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45258] trunk/blender/source/blender: More array modifier fixes.
Nicholas Bishop
nicholasbishop at gmail.com
Thu Mar 29 13:32:00 CEST 2012
Revision: 45258
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45258
Author: nicholasbishop
Date: 2012-03-29 11:31:44 +0000 (Thu, 29 Mar 2012)
Log Message:
-----------
More array modifier fixes.
* Skip calculation of merge indices if merging isn't enabled
* Clean up usage of BMesh operators to fix small memory leak
* Fix harmless BLI_assert in CustomData_bmesh_merge
* Another null-initialization fix in CustomData_bmesh_merge
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/customdata.c
trunk/blender/source/blender/modifiers/intern/MOD_array.c
Modified: trunk/blender/source/blender/blenkernel/intern/customdata.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/customdata.c 2012-03-29 10:49:17 UTC (rev 45257)
+++ trunk/blender/source/blender/blenkernel/intern/customdata.c 2012-03-29 11:31:44 UTC (rev 45258)
@@ -2165,6 +2165,7 @@
int t;
CustomData_merge(source, dest, mask, alloctype, 0);
+ dest->pool = NULL;
CustomData_bmesh_init_pool(dest, 512, htype);
switch (htype) {
@@ -2198,6 +2199,7 @@
/*ensure all current elements follow new customdata layout*/
BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+ tmp = NULL;
CustomData_bmesh_copy_data(&destold, dest, l->head.data, &tmp);
CustomData_bmesh_free_block(&destold, &l->head.data);
l->head.data = tmp;
Modified: trunk/blender/source/blender/modifiers/intern/MOD_array.c
===================================================================
--- trunk/blender/source/blender/modifiers/intern/MOD_array.c 2012-03-29 10:49:17 UTC (rev 45257)
+++ trunk/blender/source/blender/modifiers/intern/MOD_array.c 2012-03-29 11:31:44 UTC (rev 45258)
@@ -337,15 +337,18 @@
BMO_push(em->bm, NULL);
bmesh_edit_begin(em->bm, 0);
- BMO_op_init(em->bm, &weld_op, "weldverts");
- BMO_op_initf(em->bm, &dupe_op, "dupe geom=%avef");
- old_dupe_op = dupe_op;
+ if (amd->flags & MOD_ARR_MERGE)
+ BMO_op_init(em->bm, &weld_op, "weldverts");
+
for (j=0; j < count - 1; j++) {
BMVert *v, *v2, *v3;
BMOpSlot *s1;
BMOpSlot *s2;
- BMO_op_initf(em->bm, &dupe_op, "dupe geom=%s", &old_dupe_op, j==0 ? "geom" : "newout");
+ if (j == 0)
+ BMO_op_initf(em->bm, &dupe_op, "dupe geom=%avef");
+ else
+ BMO_op_initf(em->bm, &dupe_op, "dupe geom=%s", &old_dupe_op, "newout");
BMO_op_exec(em->bm, &dupe_op);
s1 = BMO_slot_get(&dupe_op, "geom");
@@ -353,35 +356,38 @@
BMO_op_callf(em->bm, "transform mat=%m4 verts=%s", offset, &dupe_op, "newout");
- /*calculate merge mapping*/
- if (j == 0) {
- indexMap = find_doubles_index_map(em->bm, &dupe_op,
- amd, &indexLen);
- }
+ if (amd->flags & MOD_ARR_MERGE) {
+ /*calculate merge mapping*/
+ if (j == 0) {
+ indexMap = find_doubles_index_map(em->bm, &dupe_op,
+ amd, &indexLen);
+ }
- #define _E(s, i) ((BMVert **)(s)->data.buf)[i]
- /* generate merge mapping using index map. we do this by using the
- * operator slots as lookup arrays.*/
- #define E(i) (i) < s1->len ? _E(s1, i) : _E(s2, (i)-s1->len)
+ #define _E(s, i) ((BMVert **)(s)->data.buf)[i]
+ /* generate merge mapping using index map. we do this by using the
+ * operator slots as lookup arrays.*/
+ #define E(i) (i) < s1->len ? _E(s1, i) : _E(s2, (i)-s1->len)
- for (i=0; i<indexLen; i++) {
- if (!indexMap[i]) continue;
+ for (i=0; i<indexLen; i++) {
+ if (!indexMap[i]) continue;
- v = E(i);
- v2 = E(indexMap[i]-1);
+ v = E(i);
+ v2 = E(indexMap[i]-1);
- /* check in case the target vertex (v2) is already marked
- for merging */
- while((v3 = BMO_slot_map_ptr_get(em->bm, &weld_op, "targetmap", v2)))
- v2 = v3;
+ /* check in case the target vertex (v2) is already marked
+ for merging */
+ while((v3 = BMO_slot_map_ptr_get(em->bm, &weld_op, "targetmap", v2)))
+ v2 = v3;
- BMO_slot_map_ptr_insert(em->bm, &weld_op, "targetmap", v, v2);
+ BMO_slot_map_ptr_insert(em->bm, &weld_op, "targetmap", v, v2);
+ }
+
+ #undef E
+ #undef _E
}
- #undef E
- #undef _E
-
- BMO_op_finish(em->bm, &old_dupe_op);
+ if (j != 0)
+ BMO_op_finish(em->bm, &old_dupe_op);
old_dupe_op = dupe_op;
}
@@ -414,11 +420,11 @@
}
/* done capping */
- if (amd->flags & MOD_ARR_MERGE)
+ if (amd->flags & MOD_ARR_MERGE) {
BMO_op_exec(em->bm, &weld_op);
+ BMO_op_finish(em->bm, &weld_op);
+ }
- BMO_op_finish(em->bm, &weld_op);
-
/* Bump the stack level back down to match the adjustment up above */
BMO_pop(em->bm);
More information about the Bf-blender-cvs
mailing list