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:
authorTon Roosendaal <ton@blender.org>2010-11-11 18:33:28 +0300
committerTon Roosendaal <ton@blender.org>2010-11-11 18:33:28 +0300
commitd9e7e716758467627557a29294653411f419130b (patch)
tree33b5b8f22dd64a63af2444b9f61ee0b579e8beae /source/blender/modifiers
parenta583ea509682a21ff3829453be3942c0285535d9 (diff)
Bugfix #19534
Crash in Array Modifier. The merging-vertices option (mysteriously named "First Last") caused invalid indices in faces to exist. This commit solves the crash, but not the cause. For that Ben Batt's assistance is needed.
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_array.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 2c672ed8e33..c02ccd1fbcd 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -151,6 +151,30 @@ static float vertarray_size(MVert *mvert, int numVerts, int axis)
return max_co - min_co;
}
+/* XXX This function fixes bad merging code, in some cases removing vertices creates indices > maxvert */
+
+static int test_index_face_maxvert(MFace *mface, CustomData *fdata, int mfindex, int nr, int maxvert)
+{
+ if(mface->v1 >= maxvert) {
+ // printf("bad index in array\n");
+ mface->v1= maxvert - 1;
+ }
+ if(mface->v2 >= maxvert) {
+ // printf("bad index in array\n");
+ mface->v2= maxvert - 1;
+ }
+ if(mface->v3 >= maxvert) {
+ // printf("bad index in array\n");
+ mface->v3= maxvert - 1;
+ }
+ if(mface->v4 >= maxvert) {
+ // printf("bad index in array\n");
+ mface->v4= maxvert - 1;
+ }
+
+ return test_index_face(mface, fdata, mfindex, nr);
+}
+
typedef struct IndexMapEntry {
/* the new vert index that this old vert index maps to */
int new;
@@ -485,7 +509,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
if(inMF.v4 && indexMap[inMF.v4].merge_final)
mf->v4 = calc_mapping(indexMap, indexMap[inMF.v4].merge, count-1);
- if(test_index_face(mf, &result->faceData, numFaces, inMF.v4?4:3) < 3)
+ if(test_index_face_maxvert(mf, &result->faceData, numFaces, inMF.v4?4:3, numVerts) < 3)
continue;
numFaces++;
@@ -509,7 +533,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
if (inMF.v4)
mf2->v4 = calc_mapping(indexMap, inMF.v4, j);
- test_index_face(mf2, &result->faceData, numFaces, inMF.v4?4:3);
+ test_index_face_maxvert(mf2, &result->faceData, numFaces, inMF.v4?4:3, numVerts);
numFaces++;
/* if the face has fewer than 3 vertices, don't create it */
@@ -605,8 +629,8 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
if(mface[numFaces].v4) {
mface[numFaces].v4 = vert_map[mface[numFaces].v4];
- test_index_face(&mface[numFaces], &result->faceData,
- numFaces, 4);
+ test_index_face_maxvert(&mface[numFaces], &result->faceData,
+ numFaces, 4, numVerts);
}
else
{