Patch #4751 - Array modifier merge segfault fix.
authorBen Batt <benbatt@gmail.com>
Sun, 13 Aug 2006 15:23:57 +0000 (15:23 +0000)
committerBen Batt <benbatt@gmail.com>
Sun, 13 Aug 2006 15:23:57 +0000 (15:23 +0000)
source/blender/blenkernel/intern/modifier.c

index b796d8f0216e8a90ef79fe20d40587c4f552a950..c565cfa5979d242d1c6dd9eee4e879d948004320 100644 (file)
@@ -649,7 +649,12 @@ static int calc_mapping(IndexMapEntry *indexMap, int oldVert, int copy)
                /* vert was merged with another vert */
                int mergeVert = indexMap[oldVert].merge;
 
                /* vert was merged with another vert */
                int mergeVert = indexMap[oldVert].merge;
 
-               if (mergeVert == indexMap[mergeVert].merge)
+               /* follow the chain of merges to the end */
+               while(indexMap[mergeVert].merge >= 0
+                     && indexMap[mergeVert].merge != mergeVert)
+                       mergeVert = indexMap[mergeVert].merge;
+
+               if(indexMap[mergeVert].merge == mergeVert)
                        /* vert merged with vert that was merged with itself */
                        newVert = indexMap[mergeVert].new;
                else
                        /* vert merged with vert that was merged with itself */
                        newVert = indexMap[mergeVert].new;
                else