diff options
author | Joseph Eagar <joeedh@gmail.com> | 2009-09-18 03:05:33 +0400 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2009-09-18 03:05:33 +0400 |
commit | 0c65f27c796393e9aa8a3d5ba44c574e6ec878d4 (patch) | |
tree | c74b1e46e10ad21c734e08fbe265a2a1264dba47 /source/blender/blenkernel/intern | |
parent | b2c16fb401b0242bf840c9b080c134696c937dc3 (diff) |
part 1 of cleaning up my little array macro library to be a formal API. also removed some extraneous selection calls from loopcut.c.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/editderivedbmesh.c | 21 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 21 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifiers_bmesh.c | 17 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 51 |
6 files changed, 65 insertions, 59 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 57af8ce9ae2..b679e892606 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -58,6 +58,7 @@ #include "BLI_editVert.h" #include "BLI_linklist.h" #include "BLI_memarena.h" +#include "BLI_array.h" #include "BKE_cdderivedmesh.h" #include "BKE_customdata.h" @@ -1782,7 +1783,7 @@ static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm) ColorBand *coba= stored_cb; /* warning, not a local var */ unsigned char *wtcol; unsigned char(*wlcol)[4] = NULL; - V_DECLARE(wlcol); + BLI_array_declare(wlcol); int i, totface=dm->getNumTessFaces(dm), totpoly=dm->getNumFaces, totloop; int *origIndex = dm->getVertDataArray(dm, CD_ORIGINDEX); @@ -1806,7 +1807,7 @@ static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm) for (; !dfiter->done; dfiter->step(dfiter)) { dliter = dfiter->getLoopsIter(dfiter); for (; !dliter->done; dliter->step(dliter), totloop++) { - V_GROW(wlcol); + BLI_array_growone(wlcol); calc_weightpaint_vert_color(ob, coba, dliter->vindex, &wlcol[totloop]); } } diff --git a/source/blender/blenkernel/intern/editderivedbmesh.c b/source/blender/blenkernel/intern/editderivedbmesh.c index b9f81911518..6aca8d51bc2 100644 --- a/source/blender/blenkernel/intern/editderivedbmesh.c +++ b/source/blender/blenkernel/intern/editderivedbmesh.c @@ -60,6 +60,7 @@ #include "BLI_memarena.h" #include "BLI_scanfill.h" #include "BLI_ghash.h" +#include "BLI_array.h" #include "BKE_cdderivedmesh.h" #include "BKE_customdata.h" @@ -124,7 +125,7 @@ static void BMEdit_RecalcTesselation_intern(BMEditMesh *tm) { BMesh *bm = tm->bm; BMLoop **looptris = NULL; - V_DYNDECLARE(looptris); + BLI_array_declare(looptris); BMIter iter, liter; BMFace *f; BMLoop *l; @@ -144,9 +145,9 @@ static void BMEdit_RecalcTesselation_intern(BMEditMesh *tm) /*don't consider two-edged faces*/ if (f->len < 3) continue; - //V_GROW(looptris); - //V_GROW(looptris); - //V_GROW(looptris); + //BLI_array_growone(looptris); + //BLI_array_growone(looptris); + //BLI_array_growone(looptris); looptris[i*3] = f->loopbase; looptris[i*3+1] = f->loopbase->head.next; @@ -154,9 +155,9 @@ static void BMEdit_RecalcTesselation_intern(BMEditMesh *tm) i++; if (f->len > 3) { - //V_GROW(looptris); - //V_GROW(looptris); - //V_GROW(looptris); + //BLI_array_growone(looptris); + //BLI_array_growone(looptris); + //BLI_array_growone(looptris); looptris[i*3] = f->loopbase; looptris[i*3+1] = f->loopbase->head.next->next; @@ -205,9 +206,9 @@ static void BMEdit_RecalcTesselation_intern(BMEditMesh *tm) for (efa = fillfacebase.first; efa; efa=efa->next) { BMLoop *l1, *l2, *l3; - V_GROW(looptris); - V_GROW(looptris); - V_GROW(looptris); + BLI_array_growone(looptris); + BLI_array_growone(looptris); + BLI_array_growone(looptris); looptris[i*3] = l1 = efa->v1->tmp.p; looptris[i*3+1] = l2 = efa->v2->tmp.p; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 18a88cdb36a..5f7fb2f71f0 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -72,6 +72,7 @@ #include "BLI_editVert.h" #include "BLI_arithb.h" #include "BLI_cellalloc.h" +#include "BLI_array.h" #include "bmesh.h" @@ -1476,10 +1477,10 @@ int mesh_recalcTesselation(CustomData *fdata, MPoly *mp, *mpoly; MLoop *ml, *mloop; MFace *mf = NULL, *mface; - V_DECLARE(mf); + BLI_array_declare(mf); EditVert *v, *lastv, *firstv; EditFace *f; - V_DECLARE(origIndex); + BLI_array_declare(origIndex); int i, j, k, lindex[3], *origIndex = NULL, *polyorigIndex; int numTex, numCol; @@ -1516,8 +1517,8 @@ int mesh_recalcTesselation(CustomData *fdata, BLI_edgefill(0, 0); for (f=fillfacebase.first; f; f=f->next) { - V_GROW(mf); - V_GROW(origIndex); + BLI_array_growone(mf); + BLI_array_growone(origIndex); /*these are loop indices, they'll be transformed into vert indices later.*/ diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index a4813eb0247..66f345b7e44 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -52,6 +52,7 @@ #include "BLI_memarena.h" #include "BLI_cellalloc.h" #include "BLI_mempool.h" +#include "BLI_array.h" #include "MEM_guardedalloc.h" @@ -2276,13 +2277,13 @@ DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd) { DerivedMesh *cddm = CDDM_copy(dm, 0); MEdge *medge; - V_DECLARE(medge); + BLI_array_declare(medge); MLoop *mloop, *ml, *prevl; MPoly *mpoly, *mp; MVert *mvert; - V_DECLARE(mvert); + BLI_array_declare(mvert); EdgeData *etags, *e, *enext; - V_DECLARE(etags); + BLI_array_declare(etags); VertUser *vu, *vu2; MemBase *membase; CustomData edata, vdata; @@ -2296,12 +2297,12 @@ DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd) membase = new_membase(); etags = MEM_callocN(sizeof(EdgeData)*cddm->numEdgeData, "edgedata tag thingies"); - V_SETCOUNT(etags, cddm->numEdgeData); + BLI_array_set_length(etags, cddm->numEdgeData); mvert = cddm->getVertArray(cddm); - V_SETCOUNT(mvert, cddm->numVertData); + BLI_array_set_length(mvert, cddm->numVertData); medge = cddm->getEdgeArray(cddm); - V_SETCOUNT(medge, cddm->numEdgeData); + BLI_array_set_length(medge, cddm->numEdgeData); mloop = CustomData_get_layer(&cddm->loopData, CD_MLOOP); mpoly = CustomData_get_layer(&cddm->polyData, CD_MPOLY); @@ -2411,7 +2412,7 @@ DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd) e = etags + ml->e; if (e->v1user && !e->v1user->done) { e->v1user->done = 1; - V_GROW(mvert); + BLI_array_growone(mvert); mvert[curv] = mvert[e->v1user->ov]; e->v1user->v = curv; @@ -2421,7 +2422,7 @@ DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd) if (e->v2user && !e->v2user->done) { e->v2user->done = 1; - V_GROW(mvert); + BLI_array_growone(mvert); mvert[curv] = mvert[e->v2user->ov]; e->v2user->v = curv; @@ -2438,8 +2439,8 @@ DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd) /*ok, now we have to deal with edges. . .*/ if (etags[ml->e].tag) { if (etags[ml->e].used) { - V_GROW(medge); - V_GROW(etags); + BLI_array_growone(medge); + BLI_array_growone(etags); medge[cure] = medge[ml->e]; ml->e = cure; diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c index b502c21188f..84bbb1fb5d7 100644 --- a/source/blender/blenkernel/intern/modifiers_bmesh.c +++ b/source/blender/blenkernel/intern/modifiers_bmesh.c @@ -66,6 +66,7 @@ #include "DNA_texture_types.h" #include "BLI_editVert.h" +#include "BLI_array.h" #include "BKE_main.h" #include "BKE_anim.h" @@ -119,8 +120,8 @@ BMEditMesh *CDDM_To_BMesh(DerivedMesh *dm, BMEditMesh *existing) BMEdge *e, **etable, **edges=NULL; BMFace *f; BMIter liter; - V_DECLARE(verts); - V_DECLARE(edges); + BLI_array_declare(verts); + BLI_array_declare(edges); int numTex, numCol; int i, j, k, totvert, totedge, totface; @@ -180,13 +181,13 @@ BMEditMesh *CDDM_To_BMesh(DerivedMesh *dm, BMEditMesh *existing) for (; !dfiter->done; dfiter->step(dfiter)) { BMLoop *l; - V_RESET(verts); - V_RESET(edges); + BLI_array_empty(verts); + BLI_array_empty(edges); dliter = dfiter->getLoopsIter(dfiter); for (j=0; !dliter->done; dliter->step(dliter), j++) { - V_GROW(verts); - V_GROW(edges); + BLI_array_growone(verts); + BLI_array_growone(edges); verts[j] = vtable[dliter->vindex]; edges[j] = etable[dliter->eindex]; @@ -218,8 +219,8 @@ BMEditMesh *CDDM_To_BMesh(DerivedMesh *dm, BMEditMesh *existing) MEM_freeN(vtable); MEM_freeN(etable); - V_FREE(verts); - V_FREE(edges); + BLI_array_free(verts); + BLI_array_free(edges); if (!em) em = BMEdit_Create(bm); else BMEdit_RecalcTesselation(em); diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 64e892458a5..782da0f5c10 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -60,6 +60,7 @@ #include "BLI_memarena.h" #include "BLI_edgehash.h" #include "PIL_time.h" +#include "BLI_array.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -583,7 +584,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CSubSurf *ss, int ssFromEditmesh, int edgeBase, faceBase; int i, j, k, S, x, y, index; int *vertIdx = NULL; - V_DECLARE(vertIdx); + BLI_array_declare(vertIdx); CCVertIterator *vi; CCEdgeIterator *ei; CCFaceIterator *fi; @@ -595,7 +596,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CSubSurf *ss, int ssFromEditmesh, MEdge *med; float *w = NULL; WeightTable wtable; - V_DECLARE(w); + BLI_array_declare(w); MFace *mf; int *origIndex; @@ -658,11 +659,11 @@ static DerivedMesh *ss_to_cdderivedmesh(CSubSurf *ss, int ssFromEditmesh, int x, y, S, numVerts = CCS_getFaceNumVerts(f); FaceVertWeight *weight = 0;//get_ss_weights(&wtable, gridFaces-1, numVerts); - V_RESET(vertIdx); + BLI_array_empty(vertIdx); for(S = 0; S < numVerts; S++) { CCVert *v = CCS_getFaceVert(ss, f, S); - V_GROW(vertIdx); + BLI_array_growone(vertIdx); vertIdx[S] = GET_INT_FROM_POINTER(CCS_getVertVertHandle(v)); } @@ -676,9 +677,9 @@ static DerivedMesh *ss_to_cdderivedmesh(CSubSurf *ss, int ssFromEditmesh, ++origIndex; i++; - V_RESET(w); + BLI_array_empty(w); for (x=0; x<numVerts; x++) { - V_GROW(w); + BLI_array_growone(w); } for(S = 0; S < numVerts; S++) { @@ -705,9 +706,9 @@ static DerivedMesh *ss_to_cdderivedmesh(CSubSurf *ss, int ssFromEditmesh, } } - V_RESET(w); + BLI_array_empty(w); for (x=0; x<numVerts; x++) { - V_GROW(w); + BLI_array_growone(w); } for(S = 0; S < numVerts; S++) { @@ -934,7 +935,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CSubSurf *ss, int ssFromEditmesh, free_ss_weights(&wtable); - V_FREE(vertIdx); + BLI_array_free(vertIdx); if(useSubsurfUv) { CustomData *fdata = &result->faceData; @@ -949,7 +950,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CSubSurf *ss, int ssFromEditmesh, CDDM_calc_normals(result); CDDM_tessfaces_to_faces(result); - V_FREE(w); + BLI_array_free(w); return result; #endif } @@ -959,7 +960,7 @@ static void ss_sync_from_derivedmesh(CSubSurf *ss, DerivedMesh *dm, { float creaseFactor = (float) CCS_getSubdivisionLevels(ss); CCVertHDL *fVerts = NULL; - V_DECLARE(fVerts); + BLI_array_declare(fVerts); int totvert = dm->getNumVerts(dm); int totedge = dm->getNumEdges(dm); int totface = dm->getNumTessFaces(dm); @@ -1009,14 +1010,14 @@ static void ss_sync_from_derivedmesh(CSubSurf *ss, DerivedMesh *dm, fiter = dm->newFaceIter(dm); for (i=0; !fiter->done; fiter->step(fiter), i++) { CCFace *f; - V_RESET(fVerts); + BLI_array_empty(fVerts); index = (int*) fiter->getCDData(fiter, CD_ORIGINDEX, -1); liter = fiter->getLoopsIter(fiter); for (; !liter->done; liter->step(liter)) { - V_GROW(fVerts); - fVerts[V_COUNT(fVerts)-1] = SET_INT_IN_POINTER(liter->vindex); + BLI_array_growone(fVerts); + fVerts[BLI_array_count(fVerts)-1] = SET_INT_IN_POINTER(liter->vindex); } /* this is very bad, means mesh is internally inconsistent. @@ -1043,7 +1044,7 @@ static void ss_sync_from_derivedmesh(CSubSurf *ss, DerivedMesh *dm, CCS_processSync(ss); - V_FREE(fVerts); + BLI_array_free(fVerts); } /***/ @@ -2629,8 +2630,8 @@ static CCGDerivedMesh *getCCGDerivedMesh(CSubSurf *ss, int *edgeFlags; char *faceFlags, *polyFlags; int *loopidx = NULL, *vertidx = NULL; - V_DECLARE(loopidx); - V_DECLARE(vertidx); + BLI_array_declare(loopidx); + BLI_array_declare(vertidx); int loopindex, loopindex2; int edgeSize; int gridSize; @@ -2800,17 +2801,17 @@ static CCGDerivedMesh *getCCGDerivedMesh(CSubSurf *ss, /* set the face base vert */ *((int*)CCS_getFaceUserData(ss, f)) = vertNum; - V_RESET(loopidx); + BLI_array_empty(loopidx); for (s=0; s<numVerts; s++) { - V_GROW(loopidx); + BLI_array_growone(loopidx); loopidx[s] = loopindex++; } - V_RESET(vertidx); + BLI_array_empty(vertidx); for(s = 0; s < numVerts; s++) { CCVert *v = CCS_getFaceVert(ss, f, s); - V_GROW(vertidx); + BLI_array_growone(vertidx); vertidx[s] = GET_INT_FROM_POINTER(CCS_getVertVertHandle(v)); } @@ -2978,8 +2979,8 @@ static CCGDerivedMesh *getCCGDerivedMesh(CSubSurf *ss, cgdm->dm.numLoopData = loopindex2; cgdm->dm.numPolyData = faceNum; - V_FREE(vertidx); - V_FREE(loopidx); + BLI_array_free(vertidx); + BLI_array_free(loopidx); free_ss_weights(&wtable); cgdm->ehash = BLI_edgehash_new(); @@ -3005,7 +3006,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CSubSurf *ss, *((int*)CCS_getFaceUserData(ss, f)) = vertNum; for(S = 0; S < numVerts; S++) { CCVert *v = CCS_getFaceVert(ss, f, S); - V_GROW(vertIdx); + BLI_array_growone(vertIdx); vertIdx[S] = GET_INT_FROM_POINTER(CCS_getVertVertHandle(v)); } @@ -3177,7 +3178,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CSubSurf *ss, MEM_freeN(qweight); MEM_freeN(tweight); - V_FREE(vertIdx); + BLI_array_free(vertIdx); #endif return cgdm; } |