Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Bishop <nicholasbishop@gmail.com>2012-03-29 15:31:44 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2012-03-29 15:31:44 +0400
commit7474397f854cbe23bd7e55dc46469c722d8eda9c (patch)
tree0f93685d2d1b2b69ecb8daa093564331ab2a5d85
parent7661f429c6bc0b146187cb8a7522460577f334d8 (diff)
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
-rw-r--r--source/blender/blenkernel/intern/customdata.c2
-rw-r--r--source/blender/modifiers/intern/MOD_array.c64
2 files changed, 37 insertions, 29 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 17a29d89d19..638ba2ddc4d 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -2165,6 +2165,7 @@ void CustomData_bmesh_merge(CustomData *source, CustomData *dest,
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 @@ void CustomData_bmesh_merge(CustomData *source, CustomData *dest,
/*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;
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index bf46c10b720..41b1d18fc5f 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -337,15 +337,18 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
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 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
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,10 +420,10 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
}
/* 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);