- modify CCG to not crash when passed invalid faces, just ignores
authorDaniel Dunbar <daniel@zuster.org>
Wed, 3 Aug 2005 19:27:19 +0000 (19:27 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 3 Aug 2005 19:27:19 +0000 (19:27 +0000)
   that face... this situation should still not happen with well
   written modifiers but at least it won't crash now
 - bug fix in mirror modifier, calculation during editmode did not
   check to make sure built mface's had valid indices... grr the
   ==0 tagging system is really a pain.
 - convert a few uiDefBut calls to use explicit type

source/blender/blenkernel/intern/CCGSubSurf.c
source/blender/blenkernel/intern/modifier.c
source/blender/src/drawnla.c
source/blender/src/space.c

index e88137bc1c9a02554fdadc63c95a0cb3ae6cd01f..bec741c64e6dee206b1b1bc27401880bb1dc91fb 100644 (file)
@@ -1016,15 +1016,22 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
 
                for (k=0; k<numVerts; k++) {
                        ss->tempVerts[k] = _ehash_lookup(ss->vMap, vHDLs[k]);
+
+                       if (!ss->tempVerts[k])
+                               return eCCGError_InvalidValue;
                }
                for (k=0; k<numVerts; k++) {
                        ss->tempEdges[k] = _vert_findEdgeTo(ss->tempVerts[k], ss->tempVerts[(k+1)%numVerts]);
 
-                       if (ss->allowEdgeCreation && !ss->tempEdges[k]) {
-                               CCGEdge *e = ss->tempEdges[k] = _edge_new((CCGEdgeHDL) -1, ss->tempVerts[k], ss->tempVerts[(k+1)%numVerts], ss->defaultCreaseValue, ss->subdivLevels, ss->meshIFC.vertDataSize, ss);
-                               _ehash_insert(ss->eMap, (EHEntry*) e);
-                               e->v0->flags |= Vert_eEffected;
-                               e->v1->flags |= Vert_eEffected;
+                       if (!ss->tempEdges[k]) {
+                               if (ss->allowEdgeCreation) {
+                                       CCGEdge *e = ss->tempEdges[k] = _edge_new((CCGEdgeHDL) -1, ss->tempVerts[k], ss->tempVerts[(k+1)%numVerts], ss->defaultCreaseValue, ss->subdivLevels, ss->meshIFC.vertDataSize, ss);
+                                       _ehash_insert(ss->eMap, (EHEntry*) e);
+                                       e->v0->flags |= Vert_eEffected;
+                                       e->v1->flags |= Vert_eEffected;
+                               } else {
+                                       return eCCGError_InvalidValue;
+                               }
                        }
                }
 
index d86b429193bdd555e719e37478a07c73cc272468..1eb80220fac028f5d348902166e77aa933c0f061 100644 (file)
@@ -543,53 +543,6 @@ static void mirrorModifier__doMirror(MirrorModifierData *mmd, DispListMesh *ndlm
                if (nmf->v1==mf->v1 && nmf->v2==mf->v2 && nmf->v3==mf->v3 && nmf->v4==mf->v4)
                        continue;
 
-       /* Decided this wasn't worth the effort, esp. because the mesh still
-        * has wierd topology. Can put it back if it appears useful in the end.
-        * Note it needs some test_mface or so added.
-        */
-#if 0
-                               int copyIdx;
-
-                                       /* If three in order vertices are shared then duplicating the face 
-                                       * will be strange (don't want two quads sharing three vertices in a
-                                       * mesh. Instead modify the original quad to leave out the middle vertice
-                                       * and span the gap. Vertice will remain in mesh and still have edges
-                                       * to it but will not interfere with normals.
-                                       */
-                               if (nmf->v4==mf->v4 && nmf->v1==mf->v1 && nmf->v2==mf->v2) {
-                                       mf->v1 = nmf->v3;
-                                       copyIdx = 0;
-                               } else if (nmf->v1==mf->v1 && nmf->v2==mf->v2 && nmf->v3==mf->v3) {
-                                       mf->v2 = nmf->v4;
-                                       copyIdx = 1;
-                               }  else if (nmf->v2==mf->v2 && nmf->v3==mf->v3 && nmf->v4==mf->v4) {
-                                       mf->v3 = nmf->v1;
-                                       copyIdx = 2;
-                               } else if (nmf->v3==mf->v3 && nmf->v4==mf->v4 && nmf->v1==mf->v1) {
-                                       mf->v4 = nmf->v2;
-                                       copyIdx = 3;
-                               } else {
-                                       copyIdx = -1;
-                               }
-
-                               if (copyIdx!=-1) {
-                                       int fromIdx = (copyIdx+2)%4;
-
-                                       if (ndlm->tface) {
-                                               tf->col[copyIdx] = ntf->col[fromIdx];
-                                               tf->uv[copyIdx][0] = ntf->uv[fromIdx][0];
-                                               tf->uv[copyIdx][1] = ntf->uv[fromIdx][1];
-                                       } else if (ndlm->mcol) {
-                                               mc[copyIdx] = nmc[fromIdx];
-                                       }
-
-                                       if (mf->v3==0 || nmf->v3==0 || (has4 && (mf->v4==0 || nmf->v4==0))) {
-                                               int i = 0;
-                                       }
-                                       continue;
-                               }
-#endif
-
                if (nmf->v3) {
                                /* Need to flip face normal, pick which verts to flip
                                * in order to prevent nmf->v3==0 or nmf->v4==0
@@ -740,6 +693,8 @@ static void *mirrorModifier_applyModifierEM(ModifierData *md, Object *ob, void *
                        mf->v4 = efa->v4?(int) efa->v4->prev:0;
                        mf->mat_nr = efa->mat_nr;
                        mf->flag = efa->flag;
+
+                       test_index_mface(mf, efa->v4?4:3);
                }
 
                mirrorModifier__doMirror(mmd, ndlm, vertexCos);
index 1b6718a2b5185f3f7a48adfd4c954495a70fae3f..0fd3aed4229fdfebf004e1145bbeed1ad66bdbdf 100644 (file)
@@ -486,20 +486,20 @@ static void nla_panel_properties(short cntrl)     // NLA_HANDLER_PROPERTIES
        uiDefBut(block, LABEL, 0, "Options:",                   10,60,300,19, 0, 0, 0, 0, 0, "");
 
        uiBlockBeginAlign(block);
-       uiDefBut(block, NUM|FLO, B_REDR, "Strip Start:", 10,160,150,19, &strip->start, 1.0, MAXFRAMEF, 100, 0, "First frame in the timeline");
-       uiDefBut(block, NUM|FLO, B_REDR, "Strip End:",  160,160,150,19, &strip->end, 1.0, MAXFRAMEF, 100, 0, "Last frame in the timeline");
+       uiDefButF(block, NUM, B_REDR, "Strip Start:", 10,160,150,19, &strip->start, 1.0, MAXFRAMEF, 100, 0, "First frame in the timeline");
+       uiDefButF(block, NUM, B_REDR, "Strip End:",     160,160,150,19, &strip->end, 1.0, MAXFRAMEF, 100, 0, "Last frame in the timeline");
 
        uiBlockBeginAlign(block);
-       uiDefBut(block, NUM|FLO, B_REDR, "Action Start:", 10,120,150,19, &strip->actstart, 1.0, MAXFRAMEF, 100, 0, "First frame of the action to map to the playrange");
-       uiDefBut(block, NUM|FLO, B_REDR, "Action End:", 160,120,150,19, &strip->actend, 1.0, MAXFRAMEF, 100, 0, "Last frame of the action to map to the playrange");
+       uiDefButF(block, NUM, B_REDR, "Action Start:", 10,120,150,19, &strip->actstart, 1.0, MAXFRAMEF, 100, 0, "First frame of the action to map to the playrange");
+       uiDefButF(block, NUM, B_REDR, "Action End:", 160,120,150,19, &strip->actend, 1.0, MAXFRAMEF, 100, 0, "Last frame of the action to map to the playrange");
 
        uiBlockBeginAlign(block);
-       uiDefBut(block, NUM|FLO, B_REDR, "Blendin:",    10,80,150,19, &strip->blendin, 0.0, MAXFRAMEF, 100, 0, "Number of frames of ease-in");
-       uiDefBut(block, NUM|FLO, B_REDR, "Blendout:",   160,80,150,19, &strip->blendout, 0.0, MAXFRAMEF, 100, 0, "Number of frames of ease-out");
+       uiDefButF(block, NUM, B_REDR, "Blendin:",       10,80,150,19, &strip->blendin, 0.0, MAXFRAMEF, 100, 0, "Number of frames of ease-in");
+       uiDefButF(block, NUM, B_REDR, "Blendout:",      160,80,150,19, &strip->blendout, 0.0, MAXFRAMEF, 100, 0, "Number of frames of ease-out");
 
        uiBlockBeginAlign(block);
-       uiDefBut(block, NUM|FLO, B_REDR, "Repeat:",     10,40,150,19, &strip->repeat, 0.0001, MAXFRAMEF, 100, 0, "Number of times the action should repeat");
-       uiDefBut(block, NUM|FLO, B_REDR, "Stride:",     160,40,150,19, &strip->stridelen, 0.0001, MAXFRAMEF, 100, 0, "Distance covered by one complete cycle of the action specified in the Action Range");
+       uiDefButF(block, NUM, B_REDR, "Repeat:",        10,40,150,19, &strip->repeat, 0.0001, MAXFRAMEF, 100, 0, "Number of times the action should repeat");
+       uiDefButF(block, NUM, B_REDR, "Stride:",        160,40,150,19, &strip->stridelen, 0.0001, MAXFRAMEF, 100, 0, "Distance covered by one complete cycle of the action specified in the Action Range");
 
        uiBlockBeginAlign(block);
        uiDefButBitS(block, TOG, ACTSTRIP_USESTRIDE, B_REDR, "Use Path",        10,0,100,19, &strip->flag, 0, 0, 0, 0, "Plays action based on path position & stride. Only armatures parented to a path");
index 9a5f7eb47e54814024be83c58c4829913b284309..0757a1c1a7396b9b2459bdeff4a3910bbc32fa46 100644 (file)
@@ -2664,12 +2664,12 @@ void drawinfospace(ScrArea *sa, void *spacedata)
                                          (xpos+edgsp+mpref+midsp),y2,mpref,buth,
                                          &U.fontsize, 0, 0, 0, 0, "Restores to using the default included antialised font");
                        
-                       uiDefButI(block, MENU|INT, B_SETFONTSIZE, fontsize_pup(),
+                       uiDefButI(block, MENU, B_SETFONTSIZE, fontsize_pup(),
                                (xpos+edgsp+mpref+midsp),y1,mpref,buth,
                                &U.fontsize, 0, 0, 0, 0, "Current interface font size (points)");
 
 /*
-                       uiDefButS(block, MENU|SHO, B_SETENCODING, encoding_pup(),
+                       uiDefButS(block, MENU, B_SETENCODING, encoding_pup(),
                                (xpos+edgsp+mpref+midsp),y1,mpref,buth,
                                &U.encoding, 0, 0, 0, 0, "Current interface font encoding");
 
@@ -2691,7 +2691,7 @@ void drawinfospace(ScrArea *sa, void *spacedata)
                                (xpos+edgsp+(2.2*mpref)+(5*midsp)+(2*spref)),y1,spref,buth,
                                &(U.transopts), 0, 0, 0, 0, "Translate toolbox menu");
 
-                       uiDefButI(block, MENU|SHO, B_SETLANGUAGE, language_pup(),
+                       uiDefButI(block, MENU, B_SETLANGUAGE, language_pup(),
                                (xpos+edgsp+(2.2*mpref)+(3*midsp)),y2,mpref+(0.5*mpref)+3,buth,
                                &U.language, 0, 0, 0, 0, "Select interface language");
                                
@@ -2791,7 +2791,7 @@ void drawinfospace(ScrArea *sa, void *spacedata)
                        (xpos+edgsp),y2,lpref,buth,
                        &(U.uiflag), 0, 0, 0, 0, "Display a list of input events in the console");
 
-               uiDefButS(block, MENU|SHO, B_CONSOLEOUT, consolemethod_pup(),
+               uiDefButS(block, MENU, B_CONSOLEOUT, consolemethod_pup(),
                        (xpos+edgsp), y1, lpref,buth,
                        &U.console_out, 0, 0, 0, 0, "Select console output method");