Revision: 23252 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23252 Author: joeedh Date: 2009-09-15 17:32:09 +0200 (Tue, 15 Sep 2009)
Log Message: ----------- made subsurf object mode conversion faster, though still needs a bit more work Modified Paths: -------------- branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h branches/bmesh/blender/source/blender/blenkernel/BKE_utildefines.h branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c branches/bmesh/blender/source/blender/blenkernel/intern/cloth.c branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c branches/bmesh/blender/source/blender/blenkernel/intern/fluidsim.c branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c branches/bmesh/blender/source/blender/blenkernel/intern/modifier.c branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c branches/bmesh/blender/source/blender/blenkernel/intern/particle.c branches/bmesh/blender/source/blender/blenkernel/intern/smoke.c branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c branches/bmesh/blender/source/blender/blenlib/BLI_edgehash.h branches/bmesh/blender/source/blender/blenlib/intern/BLI_cellalloc.c branches/bmesh/blender/source/blender/blenlib/intern/edgehash.c branches/bmesh/blender/source/blender/blenloader/intern/readfile.c branches/bmesh/blender/source/blender/editors/transform/transform_orientations.c branches/bmesh/blender/source/blender/makesdna/DNA_customdata_types.h Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h =================================================================== --- branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h 2009-09-15 15:15:43 UTC (rev 23251) +++ branches/bmesh/blender/source/blender/blenkernel/BKE_cdderivedmesh.h 2009-09-15 15:32:09 UTC (rev 23252) @@ -65,7 +65,7 @@ /* Copies the given DerivedMesh with verts, faces & edges stored as * custom element data. */ -struct DerivedMesh *CDDM_copy(struct DerivedMesh *dm); +struct DerivedMesh *CDDM_copy(struct DerivedMesh *dm, int faces_from_tessfaces); /* creates a CDDerivedMesh with the same layer stack configuration as the * given DerivedMesh and containing the requested numbers of elements. Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_utildefines.h =================================================================== --- branches/bmesh/blender/source/blender/blenkernel/BKE_utildefines.h 2009-09-15 15:15:43 UTC (rev 23251) +++ branches/bmesh/blender/source/blender/blenkernel/BKE_utildefines.h 2009-09-15 15:32:09 UTC (rev 23252) @@ -194,7 +194,7 @@ #define SET_INT_IN_POINTER(i) ((void*)(intptr_t)(i)) #define GET_INT_FROM_POINTER(i) ((int)(intptr_t)(i)) -/*little pointer array macro library. example of usage: +/*little array macro library. example of usage: int *arr = NULL; V_DECLARE(arr); Modified: branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c =================================================================== --- branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c 2009-09-15 15:15:43 UTC (rev 23251) +++ branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c 2009-09-15 15:32:09 UTC (rev 23252) @@ -366,17 +366,8 @@ { DMFaceIter *iter = source->newFaceIter(source); DMLoopIter *liter; - int totloop = 0; + int totloop = source->numLoopData; - for (; !iter->done; iter->step(iter)) { - liter = iter->getLoopsIter(iter); - for (; !liter->done; liter->step(liter)) { - totloop++; - } - } - - iter->free(iter); - dm_add_polys_from_iter(&target->loopData, &target->polyData, source, totloop); target->numLoopData = totloop; @@ -1821,6 +1812,8 @@ } CustomData_add_layer(&dm->loopData, CD_WEIGHT_MLOOPCOL, CD_ASSIGN, wlcol, totloop); + + dfiter->free(dfiter); } /* new value for useDeform -1 (hack for the gameengine): @@ -1965,7 +1958,7 @@ /* apply vertex coordinates or build a DerivedMesh as necessary */ if(dm) { if(deformedVerts) { - DerivedMesh *tdm = CDDM_copy(dm); + DerivedMesh *tdm = CDDM_copy(dm, 0); dm->release(dm); dm = tdm; @@ -2039,7 +2032,7 @@ * DerivedMesh then we need to build one. */ if(dm && deformedVerts) { - finaldm = CDDM_copy(dm); + finaldm = CDDM_copy(dm, 0); dm->release(dm); @@ -2180,7 +2173,7 @@ /* apply vertex coordinates or build a DerivedMesh as necessary */ if(dm) { if(deformedVerts) { - DerivedMesh *tdm = CDDM_copy(dm); + DerivedMesh *tdm = CDDM_copy(dm, 0); if(!(cage_r && dm == *cage_r)) dm->release(dm); dm = tdm; @@ -2189,7 +2182,7 @@ } else if(cage_r && dm == *cage_r) { /* dm may be changed by this modifier, so we need to copy it */ - dm = CDDM_copy(dm); + dm = CDDM_copy(dm, 0); } } else { @@ -2242,7 +2235,7 @@ if(cage_r && i == cageIndex) { if(dm && deformedVerts) { - *cage_r = CDDM_copy(dm); + *cage_r = CDDM_copy(dm, 0); CDDM_apply_vert_coords(*cage_r, deformedVerts); } else if(dm) { *cage_r = dm; @@ -2261,7 +2254,7 @@ * then we need to build one. */ if(dm && deformedVerts) { - *final_r = CDDM_copy(dm); + *final_r = CDDM_copy(dm, 0); if(!(cage_r && dm == *cage_r)) dm->release(dm); Modified: branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c =================================================================== --- branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c 2009-09-15 15:15:43 UTC (rev 23251) +++ branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c 2009-09-15 15:32:09 UTC (rev 23252) @@ -1410,7 +1410,7 @@ return (DMFaceIter*) iter; } -DerivedMesh *CDDM_copy(DerivedMesh *source) +DerivedMesh *CDDM_copy(DerivedMesh *source, int faces_from_tessfaces) { CDDerivedMesh *cddm = cdDM_create("CDDM_copy cddm"); DerivedMesh *dm = &cddm->dm; @@ -1438,8 +1438,10 @@ CustomData_add_layer(&dm->edgeData, CD_MEDGE, CD_ASSIGN, cddm->medge, numEdges); CustomData_add_layer(&dm->faceData, CD_MFACE, CD_ASSIGN, cddm->mface, numFaces); - DM_DupPolys(source, dm); - //CDDM_tessfaces_to_faces(dm); + if (!faces_from_tessfaces) + DM_DupPolys(source, dm); + else + CDDM_tessfaces_to_faces(dm); cddm->mloop = CustomData_get_layer(&dm->loopData, CD_MLOOP); cddm->mpoly = CustomData_get_layer(&dm->polyData, CD_MPOLY); Modified: branches/bmesh/blender/source/blender/blenkernel/intern/cloth.c =================================================================== --- branches/bmesh/blender/source/blender/blenkernel/intern/cloth.c 2009-09-15 15:15:43 UTC (rev 23251) +++ branches/bmesh/blender/source/blender/blenkernel/intern/cloth.c 2009-09-15 15:32:09 UTC (rev 23252) @@ -432,7 +432,7 @@ clmd->scene= scene; /* nice to pass on later :) */ framenr= (int)scene->r.cfra; cache= clmd->point_cache; - result = CDDM_copy(dm); + result = CDDM_copy(dm, 0); BKE_ptcache_id_from_cloth(&pid, ob, clmd); BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, ×cale); Modified: branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c =================================================================== --- branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c 2009-09-15 15:15:43 UTC (rev 23251) +++ branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c 2009-09-15 15:32:09 UTC (rev 23252) @@ -922,13 +922,29 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data, int type, int alloctype, void *layerdata, int totelem, const char *name); +void customData_update_typemap(CustomData *data) +{ + int i, lasttype = -1; + + for (i=0; i<CD_NUMTYPES; i++) { + data->typemap[i] = -1; + } + + for (i=0; i<data->totlayer; i++) { + if (data->layers[i].type != lasttype) { + data->typemap[data->layers[i].type] = i; + } + lasttype = data->layers[i].type; + } +} + void CustomData_merge(const struct CustomData *source, struct CustomData *dest, CustomDataMask mask, int alloctype, int totelem) { const LayerTypeInfo *typeInfo; CustomDataLayer *layer, *newlayer; int i, type, number = 0, lasttype = -1, lastactive = 0, lastrender = 0, lastclone = 0, lastmask = 0; - + for(i = 0; i < source->totlayer; ++i) { layer = &source->layers[i]; typeInfo = layerType_getInfo(layer->type); @@ -964,6 +980,8 @@ newlayer->active_mask = lastmask; } } + + customData_update_typemap(dest); } void CustomData_copy(const struct CustomData *source, struct CustomData *dest, @@ -1041,11 +1059,12 @@ int CustomData_get_active_layer_index(const CustomData *data, int type) { - int i; + if (!data->totlayer) + return -1; - for(i=0; i < data->totlayer; ++i) - if(data->layers[i].type == type) - return i + data->layers[i].active; + if (data->typemap[type] != -1) { + return data->typemap[type] + data->layers[data->typemap[type]].active; + } return -1; } @@ -1307,6 +1326,7 @@ layer = customData_add_layer__internal(data, type, alloctype, layerdata, totelem, typeInfo->defaultname); + customData_update_typemap(data); if(layer) return layer->data; @@ -1322,6 +1342,7 @@ layer = customData_add_layer__internal(data, type, alloctype, layerdata, totelem, name); + customData_update_typemap(data); if(layer) return layer->data; @@ -1360,6 +1381,7 @@ customData_resize(data, -CUSTOMDATA_GROW); customData_update_offsets(data); + customData_update_typemap(data); return 1; } @@ -1644,7 +1666,7 @@ int offset; /* get the layer index of the first layer of type */ - layer_index = CustomData_get_layer_index(data, type); + layer_index = data->typemap[type]; if(layer_index < 0) return NULL; offset = layerType_getInfo(type)->size * index; @@ -1996,7 +2018,7 @@ } else if(fdata->layers[i].type == CD_MCOL) CustomData_add_layer(ldata, CD_MLOOPCOL, CD_CALLOC, &(fdata->layers[i].name), totloop); - } + } } void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata, int total){ int i; Modified: branches/bmesh/blender/source/blender/blenkernel/intern/fluidsim.c =================================================================== --- branches/bmesh/blender/source/blender/blenkernel/intern/fluidsim.c 2009-09-15 15:15:43 UTC (rev 23251) +++ branches/bmesh/blender/source/blender/blenkernel/intern/fluidsim.c 2009-09-15 15:32:09 UTC (rev 23252) @@ -226,7 +226,7 @@ } } - result = CDDM_copy(dm); + result = CDDM_copy(dm, 0); if(result) { Modified: branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c =================================================================== --- branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c 2009-09-15 15:15:43 UTC (rev 23251) +++ branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c 2009-09-15 15:32:09 UTC (rev 23252) @@ -268,7 +268,7 @@ /* Free any special data from the verts */ for (i=0; i<totvert; i++){ - if (dvert[i].dw) MEM_freeN (dvert[i].dw); + if (dvert[i].dw) BLI_cellalloc_free (dvert[i].dw); } MEM_freeN (dvert); } Modified: branches/bmesh/blender/source/blender/blenkernel/intern/modifier.c =================================================================== --- branches/bmesh/blender/source/blender/blenkernel/intern/modifier.c 2009-09-15 15:15:43 UTC (rev 23251) +++ branches/bmesh/blender/source/blender/blenkernel/intern/modifier.c 2009-09-15 15:32:09 UTC (rev 23252) @@ -2274,7 +2274,7 @@ DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd) { - DerivedMesh *cddm = CDDM_copy(dm); + DerivedMesh *cddm = CDDM_copy(dm, 0); MEdge *medge; V_DECLARE(medge); MLoop *mloop, *ml, *prevl; @@ -2954,7 +2954,7 @@ { DerivedMesh *dm; - if(derivedData) dm = CDDM_copy(derivedData); + if(derivedData) dm = CDDM_copy(derivedData, 0); else if(ob->type==OB_MESH) dm = CDDM_from_mesh(ob->data, ob); else return; @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs