diff options
author | Joseph Eagar <joeedh@gmail.com> | 2009-09-10 05:46:52 +0400 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2009-09-10 05:46:52 +0400 |
commit | b0a1904d33a1c097a8e8fd56fe9b3c1d3a34ca55 (patch) | |
tree | 7a89f984f91cc4c20b365219f9de5663122a01ae /source/blender/blenkernel | |
parent | ae446d79e027cf4eb6ea7290ea24c536711249d8 (diff) |
another optimization pass. biggest change is MDeformGroup->dw is now allocated via a somewhat simplistic, if effective allocator. This needs a little bit more work; I'd really prefer building this into guardedalloc, but the method requires mempools, which currently live in blenlib. and I'm not sure if we can have guardedalloc linking with blenlib? anyway, current allocator code is more of a temporary fix until I figure that out.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/BME_tools.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cloth.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/deform.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/editderivedbmesh.c | 49 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/key.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifiers_bmesh.c | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/softbody.c | 1 |
14 files changed, 66 insertions, 17 deletions
diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index 32065ea5151..15ef809158b 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -44,6 +44,7 @@ #include "BKE_bmesh.h" #include "BLI_arithb.h" #include "BLI_blenlib.h" +#include "BLI_cellalloc.h" /*split this all into a seperate bevel.c file in src*/ diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 7b894d79b45..31ae4d6cbec 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -38,6 +38,7 @@ #include "BLI_arithb.h" #include "BLI_blenlib.h" +#include "BLI_cellalloc.h" #include "DNA_armature_types.h" #include "DNA_action_types.h" diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 9e105b00e15..c3a3f57cd40 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -48,6 +48,7 @@ #include "BKE_pointcache.h" #include "BLI_kdopbvh.h" +#include "BLI_cellalloc.h" #ifdef _WIN32 void tstart ( void ) diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index f1420db706f..a9611039dab 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" #include "BLI_editVert.h" +#include "BLI_cellalloc.h" #include "DNA_armature_types.h" #include "DNA_constraint_types.h" diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 7e67391743a..bda204409b2 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_linklist.h" #include "BLI_mempool.h" +#include "BLI_cellalloc.h" #include "DNA_customdata_types.h" #include "DNA_listBase.h" @@ -112,7 +113,7 @@ static void layerCopy_mdeformvert(const void *source, void *dest, MDeformVert *dvert = (MDeformVert *)((char *)dest + i * size); if(dvert->totweight) { - MDeformWeight *dw = MEM_callocN(dvert->totweight * sizeof(*dw), + MDeformWeight *dw = BLI_cellalloc_calloc(dvert->totweight * sizeof(*dw), "layerCopy_mdeformvert dw"); memcpy(dw, dvert->dw, dvert->totweight * sizeof(*dw)); @@ -131,7 +132,7 @@ static void layerFree_mdeformvert(void *data, int count, int size) MDeformVert *dvert = (MDeformVert *)((char *)data + i * size); if(dvert->dw) { - MEM_freeN(dvert->dw); + BLI_cellalloc_free(dvert->dw); dvert->dw = NULL; dvert->totweight = 0; } @@ -173,7 +174,7 @@ static void layerInterp_mdeformvert(void **sources, float *weights, /* if this def_nr is not in the list, add it */ if(!node) { - MDeformWeight *tmp_dw = MEM_callocN(sizeof(*tmp_dw), + MDeformWeight *tmp_dw = BLI_cellalloc_calloc(sizeof(*tmp_dw), "layerInterp_mdeformvert tmp_dw"); tmp_dw->def_nr = dw->def_nr; tmp_dw->weight = dw->weight * interp_weight; @@ -184,10 +185,10 @@ static void layerInterp_mdeformvert(void **sources, float *weights, } /* now we know how many unique deform weights there are, so realloc */ - if(dvert->dw) MEM_freeN(dvert->dw); + if(dvert->dw) BLI_cellalloc_free(dvert->dw); if(totweight) { - dvert->dw = MEM_callocN(sizeof(*dvert->dw) * totweight, + dvert->dw = BLI_cellalloc_calloc(sizeof(*dvert->dw) * totweight, "layerInterp_mdeformvert dvert->dw"); dvert->totweight = totweight; diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 47736865273..9ad004cff5f 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -60,6 +60,7 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" +#include "BLI_cellalloc.h" #ifdef HAVE_CONFIG_H #include <config.h> diff --git a/source/blender/blenkernel/intern/editderivedbmesh.c b/source/blender/blenkernel/intern/editderivedbmesh.c index d6f31847ca5..b9f81911518 100644 --- a/source/blender/blenkernel/intern/editderivedbmesh.c +++ b/source/blender/blenkernel/intern/editderivedbmesh.c @@ -132,6 +132,45 @@ static void BMEdit_RecalcTesselation_intern(BMEditMesh *tm) if (tm->looptris) MEM_freeN(tm->looptris); +#if 0 //simple quad/triangle code for performance testing purposes + looptris = MEM_callocN(sizeof(void*)*bm->totface*8, "looptris"); + + f = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL); + for ( ; f; f=BMIter_Step(&iter)) { + EditVert *v, *lastv=NULL, *firstv=NULL; + EditEdge *e; + EditFace *efa; + + /*don't consider two-edged faces*/ + if (f->len < 3) continue; + + //V_GROW(looptris); + //V_GROW(looptris); + //V_GROW(looptris); + + looptris[i*3] = f->loopbase; + looptris[i*3+1] = f->loopbase->head.next; + looptris[i*3+2] = f->loopbase->head.next->next; + i++; + + if (f->len > 3) { + //V_GROW(looptris); + //V_GROW(looptris); + //V_GROW(looptris); + + looptris[i*3] = f->loopbase; + looptris[i*3+1] = f->loopbase->head.next->next; + looptris[i*3+2] = f->loopbase->head.next->next->next; + i++; + } + + } + + tm->tottri = i; + tm->looptris = looptris; + return; +#endif + f = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL); for ( ; f; f=BMIter_Step(&iter)) { EditVert *v, *lastv=NULL, *firstv=NULL; @@ -360,7 +399,7 @@ static void bmDM_recalcTesselation(DerivedMesh *dm) { EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; - bmdm_recalc_lookups(bmdm); + //bmdm_recalc_lookups(bmdm); } static void bmDM_foreachMappedVert(DerivedMesh *dm, void (*func)(void *userData, int index, float *co, float *no_f, short *no_s), void *userData) @@ -1463,9 +1502,9 @@ static void bmDM_release(void *dm) MEM_freeN(bmdm->faceNos); } - BLI_ghash_free(bmdm->fhash, NULL, NULL); - BLI_ghash_free(bmdm->ehash, NULL, NULL); - BLI_ghash_free(bmdm->vhash, NULL, NULL); + if (bmdm->fhash) BLI_ghash_free(bmdm->fhash, NULL, NULL); + if (bmdm->ehash) BLI_ghash_free(bmdm->ehash, NULL, NULL); + if (bmdm->vhash) BLI_ghash_free(bmdm->vhash, NULL, NULL); if (bmdm->vtable) MEM_freeN(bmdm->vtable); if (bmdm->etable) MEM_freeN(bmdm->etable); @@ -1630,7 +1669,7 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em, Object *ob, } } - bmdm_recalc_lookups(bmdm); + //bmdm_recalc_lookups(bmdm); return (DerivedMesh*) bmdm; } diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index a2fa97cabc9..4ba1c46d0c3 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -58,6 +58,7 @@ #include "BKE_utildefines.h" #include "BLI_blenlib.h" +#include "BLI_cellalloc.h" #ifdef HAVE_CONFIG_H diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 67d63d527cb..70d76d25e93 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -40,6 +40,7 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" +#include "BLI_cellalloc.h" #include "DNA_armature_types.h" #include "DNA_mesh_types.h" diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 4448b690af9..617eb370e9f 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -246,7 +246,7 @@ void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount) for (i=0; i<copycount; i++){ if (src[i].dw){ - dst[i].dw = MEM_callocN (sizeof(MDeformWeight)*src[i].totweight, "copy_deformWeight"); + dst[i].dw = BLI_cellalloc_calloc (sizeof(MDeformWeight)*src[i].totweight, "copy_deformWeight"); memcpy (dst[i].dw, src[i].dw, sizeof (MDeformWeight)*src[i].totweight); } } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 2e4146437a2..d796b5b36b1 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -50,6 +50,7 @@ #include "BLI_edgehash.h" #include "BLI_ghash.h" #include "BLI_memarena.h" +#include "BLI_cellalloc.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c index 36b661e3b1c..d281fb9bd2a 100644 --- a/source/blender/blenkernel/intern/modifiers_bmesh.c +++ b/source/blender/blenkernel/intern/modifiers_bmesh.c @@ -45,6 +45,7 @@ #include "BLI_edgehash.h" #include "BLI_ghash.h" #include "BLI_memarena.h" +#include "BLI_cellalloc.h" #include "MEM_guardedalloc.h" @@ -288,7 +289,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, int numVerts, numEdges, numFaces; int maxVerts, maxEdges, maxFaces; int finalVerts, finalEdges, finalFaces; - int *indexMap; + int *indexMap = NULL; DerivedMesh *result, *start_cap = NULL, *end_cap = NULL; MVert *src_mvert; @@ -406,7 +407,6 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, #define _E(s, i) ((BMVert**)(s)->data.buf)[i] -#if 0 /*calculate merge mapping*/ if (j == 0) { BMOperator findop; @@ -444,20 +444,19 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, BMO_Finish_Op(em->bm, &findop); } -#endif /*generate merge mappping using index map. we do this by using the operator slots as lookup arrays.*/ #define E(i) (i) < s1->len ? _E(s1, i) : _E(s2, (i)-s1->len) - /*for (i=0; i<indexLen; i++) { + for (i=0; i<indexLen; i++) { if (!indexMap[i]) continue; v = E(i); v2 = E(indexMap[i]-1); BMO_Insert_MapPointer(em->bm, &weldop, "targetmap", v, v2); - }*/ + } #undef E #undef _E @@ -477,7 +476,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, cddm = CDDM_from_BMEditMesh(em, NULL); BMEdit_Free(em); - //MEM_freeN(indexMap); + MEM_freeN(indexMap); return cddm; } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 3d895c37884..9aaff82de84 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -56,6 +56,7 @@ #include "BLI_linklist.h" #include "BLI_rand.h" #include "BLI_threads.h" +#include "BLI_cellalloc.h" #include "BKE_anim.h" diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index aeadbb05cb1..094ea37afff 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -70,6 +70,7 @@ variables on the UI for now #include "BLI_arithb.h" #include "BLI_ghash.h" #include "BLI_threads.h" +#include "BLI_cellalloc.h" #include "BKE_curve.h" #include "BKE_effect.h" |