- bug fix, crash with edges with no face in subsurf
authorDaniel Dunbar <daniel@zuster.org>
Fri, 24 Jun 2005 05:30:41 +0000 (05:30 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 24 Jun 2005 05:30:41 +0000 (05:30 +0000)
source/blender/blenkernel/intern/CCGSubSurf.c

index 98eb2a0bd3c0d813a7dbfbb8d7c2315d1f1a9fb8..bd935505ea90efab8fd6385d836be3a33833abc8 100644 (file)
@@ -1848,24 +1848,27 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
                }
                for (ptrIdx=0; ptrIdx<numEffectedE; ptrIdx++) {
                        CCGEdge *e = (CCGEdge*) effectedE[ptrIdx];
-                       CCGFace *fLast = e->faces[e->numFaces-1];
-                       int x;
 
-                       for (i=0; i<e->numFaces-1; i++) {
-                               CCGFace *f = e->faces[i];
+                       if (e->numFaces) {
+                               CCGFace *fLast = e->faces[e->numFaces-1];
+                               int x;
 
-                               for (x=1; x<edgeSize-1; x++) {
-                                       NormAdd(_face_getIFNoEdge(fLast, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset),
-                                                       _face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
+                               for (i=0; i<e->numFaces-1; i++) {
+                                       CCGFace *f = e->faces[i];
+
+                                       for (x=1; x<edgeSize-1; x++) {
+                                               NormAdd(_face_getIFNoEdge(fLast, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset),
+                                                               _face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
+                                       }
                                }
-                       }
 
-                       for (i=0; i<e->numFaces-1; i++) {
-                               CCGFace *f = e->faces[i];
+                               for (i=0; i<e->numFaces-1; i++) {
+                                       CCGFace *f = e->faces[i];
 
-                               for (x=1; x<edgeSize-1; x++) {
-                                       NormCopy(_face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset),
-                                                        _face_getIFNoEdge(fLast, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
+                                       for (x=1; x<edgeSize-1; x++) {
+                                               NormCopy(_face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset),
+                                                               _face_getIFNoEdge(fLast, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset));
+                                       }
                                }
                        }
                }