replace BLI_array_growone() with BLI_array_growitems() when the size of the increase...
authorCampbell Barton <ideasman42@gmail.com>
Mon, 23 Jan 2012 13:51:44 +0000 (13:51 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 23 Jan 2012 13:51:44 +0000 (13:51 +0000)
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/modifiers_bmesh.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/bmesh/intern/bmesh_construct.c
source/blender/editors/mesh/loopcut.c
source/blender/editors/uvedit/uvedit_draw.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/editors/uvedit/uvedit_unwrap_ops.c

index 6a98ab324cbffd17d7111037c6daecf05a87f729..67a4d6657c959c4204064018eee55abc8613529b 100644 (file)
@@ -1112,8 +1112,8 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
                        for (i=0; i<dm->numPolyData; i++, mp++) {
                                ml = mloop + mp->loopstart;
 
-                               for (j=0; j<mp->totloop; j++, ml++, totloop++) {
-                                       BLI_array_growone(wtcol_l);
+                               BLI_array_growitems(wtcol_l, mp->totloop);
+                               for (j = 0; j < mp->totloop; j++, ml++, totloop++) {
                                        copy_v4_v4_char((char *)&wtcol_l[totloop],
                                                        (char *)&wtcol_v[4 * ml->v]);
                                }
index 3d1349f09ed62d0a7fb94baaac63e147f6989448..c54a622be7e19faad507af635d0279b056eafb96 100644 (file)
@@ -171,10 +171,11 @@ BMEditMesh *CDDM_To_BMesh(Object *ob, DerivedMesh *dm, BMEditMesh *existing, int
                BLI_array_empty(verts);
                BLI_array_empty(edges);
 
+               BLI_array_growitems(verts, mp->totloop);
+               BLI_array_growitems(edges, mp->totloop);
+
                ml = mloop + mp->loopstart;
-               for (j=0; j<mp->totloop; j++, ml++) {
-                       BLI_array_growone(verts);
-                       BLI_array_growone(edges);
+               for (j = 0; j < mp->totloop; j++, ml++) {
 
                        verts[j] = vtable[ml->v];
                        edges[j] = etable[ml->e];
index 76077fe3a14fd89695c7439225eefc21afabc40f..f8fec9911fb99d475b42fd2ce9da5e74d24384c3 100644 (file)
@@ -3040,17 +3040,16 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
                /* set the face base vert */
                *((int*)ccgSubSurf_getFaceUserData(ss, f)) = vertNum;
 
-               BLI_array_empty(loopidx);               
-               for (s=0; s<numVerts; s++) {
-                       BLI_array_growone(loopidx);
+               BLI_array_empty(loopidx);
+               BLI_array_growitems(loopidx, numVerts);
+               for (s = 0; s < numVerts; s++) {
                        loopidx[s] = loopindex++;
                }
                
                BLI_array_empty(vertidx);
-                               for(s = 0; s < numVerts; s++) {
+               BLI_array_growitems(vertidx, numVerts);
+               for (s = 0; s < numVerts; s++) {
                        CCGVert *v = ccgSubSurf_getFaceVert(ss, f, s);
-                       
-                       BLI_array_growone(vertidx);
                        vertidx[s] = GET_INT_FROM_POINTER(ccgSubSurf_getVertVertHandle(v));
                }
                
index 2000394202383fc0a8bd018f8f47546421aad3b2..821e9393fdec6de129174755e696894708d07365 100644 (file)
@@ -528,10 +528,11 @@ BMesh *BM_Copy_Mesh(BMesh *bmold)
 
                BLI_array_empty(loops);
                BLI_array_empty(edges);
+               BLI_array_growitems(loops, f->len);
+               BLI_array_growitems(edges, f->len);
+
                l = BMIter_New(&liter, bmold, BM_LOOPS_OF_FACE, f);
                for (j=0; j<f->len; j++, l = BMIter_Step(&liter)) {
-                       BLI_array_growone(loops);
-                       BLI_array_growone(edges);
                        loops[j] = l;
                        edges[j] = etable[BM_GetIndex(l->e)];
                }
index 62711249a4f3f723b52021aca3e9dda005c73691..1aee1e9a19bdcf96a78a611f57fdef6956051f5c 100644 (file)
@@ -239,10 +239,10 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select)
                                co[1][0] = (v[1][1]->co[0] - v[1][0]->co[0])*(i/((float)previewlines+1))+v[1][0]->co[0];
                                co[1][1] = (v[1][1]->co[1] - v[1][0]->co[1])*(i/((float)previewlines+1))+v[1][0]->co[1];
                                co[1][2] = (v[1][1]->co[2] - v[1][0]->co[2])*(i/((float)previewlines+1))+v[1][0]->co[2];                                        
-                               
+
                                BLI_array_growone(edges);
-                               VECCOPY(edges[tot][0], co[0]);
-                               VECCOPY(edges[tot][1], co[1]);
+                               copy_v3_v3(edges[tot][0], co[0]);
+                               copy_v3_v3(edges[tot][1], co[1]);
                                tot++;
                        }
                }
index 77609b9618b9de32e102400634df04f9269a5c9a..9e2a2abe83718f06730e77d40ff304dbd9bdd185 100644 (file)
@@ -187,12 +187,12 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
                                
                                BLI_array_empty(tf_uv);
                                BLI_array_empty(tf_uvorig);
-                               
+                               BLI_array_growitems(tf_uv, efa->len);
+                               BLI_array_growitems(tf_uvorig, efa->len);
+
                                i = 0;
                                BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
                                        luv= CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
-                                       BLI_array_growone(tf_uv);
-                                       BLI_array_growone(tf_uvorig);
 
                                        tf_uvorig[i][0] = luv->uv[0];
                                        tf_uvorig[i][1] = luv->uv[1];
@@ -238,12 +238,12 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
 
                                                BLI_array_empty(tf_uv);
                                                BLI_array_empty(tf_uvorig);
+                                               BLI_array_growitems(tf_uv, efa->len);
+                                               BLI_array_growitems(tf_uvorig, efa->len);
 
                                                i = 0;
                                                BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
                                                        luv= CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
-                                                       BLI_array_growone(tf_uv);
-                                                       BLI_array_growone(tf_uvorig);
 
                                                        tf_uvorig[i][0] = luv->uv[0];
                                                        tf_uvorig[i][1] = luv->uv[1];
index fd868f1c935ddd817e067ed71bec98a83f6fa45d..090752d7b0214c5abf8edc9b8f75d19548f31f68 100644 (file)
@@ -1953,9 +1953,9 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
                }
 
                /* mark 1 vertex as being hit */
+               BLI_array_growitems(hitv, hit.efa->len);
+               BLI_array_growitems(hituv, hit.efa->len);
                for(i=0; i<hit.efa->len; i++) {
-                       BLI_array_growone(hitv);
-                       BLI_array_growone(hituv);
                        hitv[i]= 0xFFFFFFFF;
                }
 
@@ -1974,9 +1974,9 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
                }
 
                /* mark 2 edge vertices as being hit */
-               for(i=0; i<hit.efa->len; i++) {
-                       BLI_array_growone(hitv);
-                       BLI_array_growone(hituv);
+               BLI_array_growitems(hitv,  hit.efa->len);
+               BLI_array_growitems(hituv, hit.efa->len);
+               for (i=0; i < hit.efa->len; i++) {
                        hitv[i]= 0xFFFFFFFF;
                }
 
@@ -2002,12 +2002,12 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop)
                BM_set_actFace(em->bm, hit.efa);
 
                /* mark all face vertices as being hit */
+
+               BLI_array_growitems(hitv,  hit.efa->len);
+               BLI_array_growitems(hituv, hit.efa->len);
                i = 0;
                BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, hit.efa) {
                        luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
-
-                       BLI_array_growone(hitv);
-                       BLI_array_growone(hituv);
                        hituv[i]= luv->uv;
                        hitv[i] = BM_GetIndex(l->v);
                        i++;
index 3377fdad9db5d69e9918e5400826320650be5fac..11ea0f12a9ec5013a970a496bcc4f6bed36ade23 100644 (file)
@@ -1409,16 +1409,14 @@ static void uv_map_mirror(BMEditMesh *em, BMFace *efa, MTexPoly *UNUSED(tf))
        BMLoop *l;
        BMIter liter;
        MLoopUV *luv;
-       BLI_array_declare(uvs);
        float **uvs = NULL;
+       BLI_array_fixedstack_declare(uvs, BM_NGON_STACK_SIZE, efa->len, __func__);
        float dx;
        int i, mi;
 
        i = 0;
        BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
                luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
-               BLI_array_growone(uvs);
-
                uvs[i] = luv->uv;
                i++;
        }
@@ -1435,7 +1433,7 @@ static void uv_map_mirror(BMEditMesh *em, BMFace *efa, MTexPoly *UNUSED(tf))
                } 
        } 
 
-       BLI_array_free(uvs);
+       BLI_array_fixedstack_free(uvs);
 }
 
 static int sphere_project_exec(bContext *C, wmOperator *op)