Bugfix #24999
authorTon Roosendaal <ton@blender.org>
Wed, 1 Dec 2010 17:47:38 +0000 (17:47 +0000)
committerTon Roosendaal <ton@blender.org>
Wed, 1 Dec 2010 17:47:38 +0000 (17:47 +0000)
Array Modifier: edge indices could be equal to numVerts, causing
bad crashes in derivedmesh. Similar fix to previous here with
face indices. Should poke the coder of this... for now it survives OK.

source/blender/modifiers/intern/MOD_array.c

index c02ccd1fbcdcc4c71a94c6bc81075e3e8aaf583f..f371bfd556716b3325ac1e1637be864687b11337 100644 (file)
@@ -443,7 +443,13 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
                          }
 
                          if(med.v1 == med.v2) continue;
-
+                         
+                         /* XXX Unfortunately the calc_mapping returns sometimes numVerts... leads to bad crashes */
+                         if(med.v1 >= numVerts)
+                                 med.v1= numVerts-1;
+                         if(med.v2 >= numVerts)
+                                 med.v2= numVerts-1;
+                         
                          if (initFlags) {
                                  med.flag |= ME_EDGEDRAW | ME_EDGERENDER;
                          }
@@ -460,9 +466,15 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
                          {
                                  vert1 = calc_mapping(indexMap, inMED.v1, j);
                                  vert2 = calc_mapping(indexMap, inMED.v2, j);
-
+                                 
                                  /* edge could collapse to single point after mapping */
                                  if(vert1 == vert2) continue;
+                                 
+                                 /* XXX Unfortunately the calc_mapping returns sometimes numVerts... leads to bad crashes */
+                                 if(vert1 >= numVerts)
+                                         vert1= numVerts-1;
+                                 if(vert2 >= numVerts)
+                                         vert2= numVerts-1;
 
                                  /* avoid duplicate edges */
                                  if(!BLI_edgehash_haskey(edges, vert1, vert2)) {