=bmesh=
authorJoseph Eagar <joeedh@gmail.com>
Thu, 3 Mar 2011 07:10:42 +0000 (07:10 +0000)
committerJoseph Eagar <joeedh@gmail.com>
Thu, 3 Mar 2011 07:10:42 +0000 (07:10 +0000)
Fixed view selected code.  Made MDisps->disps use the
special allocation library I wrote as a
temporary fix to MDeformGroup->dw problems.

Why was the vgroup solution reused?  It's really slow,
and its hard to tie in something like mempool or memarena.
The hackish allocator I wrote really needs to go, eventually,
or be folded into guardedalloc.

Also fixed a customdata bug with modifiers.

intern/opennl/superlu/sgstrf.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/multires.c
source/blender/blenlib/intern/BLI_cellalloc.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_view3d/view3d_snap.c
source/blender/modifiers/intern/MOD_mirror.c

index 335f21165ca22877284dbc6159a03d69ba6953c1..143b6bfd61e22d4a734e809d3b31cacec092c1ad 100644 (file)
@@ -399,7 +399,7 @@ sgstrf (superlu_options_t *options, SuperMatrix *A,
                resetrep_col (nseg, segrep, &repfnz[k]);
                
 #ifdef DEBUG
-               sprint_lu_col("[2]: ", jj, pivrow, xprune, &Glu);
+//             sprint_lu_col("[2]: ", jj, pivrow, xprune, &Glu);
 #endif
 
            }
index a23663d12754135c1f841d83d270e51bab999817..9617218f37c745b169aad2a5fc873fba68913d26 100644 (file)
@@ -2415,7 +2415,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, int *vtargetmap)
        }
        
        /*create new cddm*/     
-       cddm2 = (CDDerivedMesh*) CDDM_new(BLI_array_count(mvert), BLI_array_count(medge), 0, BLI_array_count(mloop), BLI_array_count(mpoly));
+       cddm2 = (CDDerivedMesh*) CDDM_from_template(cddm, BLI_array_count(mvert), BLI_array_count(medge), 0, BLI_array_count(mloop), BLI_array_count(mpoly));
        
        /*update edge indices and copy customdata*/
        me = medge;
index 0612a57d85d9055f7a237ef99b22677dbd51084f..628d8698f3622bd80282eb30c32e030e1b2b8c6a 100644 (file)
@@ -433,18 +433,18 @@ static void layerSwap_mdisps(void *data, const int *ci)
                        /* happens when face changed vertex count in edit mode
                           if it happened, just forgot displacement */
 
-                       MEM_freeN(s->disps);
+                       BLI_cellalloc_free(s->disps);
                        s->totdisp= (s->totdisp/corners)*nverts;
-                       s->disps= MEM_callocN(s->totdisp*sizeof(float)*3, "mdisp swap");
+                       s->disps= BLI_cellalloc_calloc(s->totdisp*sizeof(float)*3, "mdisp swap");
                        return;
                }
 
-               d= MEM_callocN(sizeof(float) * 3 * s->totdisp, "mdisps swap");
+               d= BLI_cellalloc_calloc(sizeof(float) * 3 * s->totdisp, "mdisps swap");
 
                for(S = 0; S < corners; S++)
                        memcpy(d + cornersize*S, s->disps + cornersize*ci[S], cornersize*3*sizeof(float));
                
-               MEM_freeN(s->disps);
+               BLI_cellalloc_free(s->disps);
                s->disps= d;
        }
 }
@@ -496,14 +496,14 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights),
                                                sw_m4[2][x] = 1;
 
                                tris[i] = *((MDisps*)sources[i]);
-                               tris[i].disps = MEM_dupallocN(tris[i].disps);
+                               tris[i].disps = BLI_cellalloc_dupalloc(tris[i].disps);
                                layerInterp_mdisps(&sources[i], NULL, (float*)sw_m4, 1, &tris[i]);
                        }
 
                        mdisp_join_tris(d, &tris[0], &tris[1]);
 
                        for(i = 0; i < 2; i++)
-                               MEM_freeN(tris[i].disps);
+                               BLI_cellalloc_free(tris[i].disps);
 
                        return;
                }
@@ -518,7 +518,7 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights),
        }
 
        /* Initialize the destination */
-       out = disps = MEM_callocN(3*d->totdisp*sizeof(float), "iterp disps");
+       out = disps = BLI_cellalloc_calloc(3*d->totdisp*sizeof(float), "iterp disps");
 
        side = sqrt(d->totdisp / dst_corners);
        st = (side<<1)-1;
@@ -559,7 +559,7 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights),
                }
        }
 
-       MEM_freeN(d->disps);
+       BLI_cellalloc_free(d->disps);
        d->disps = disps;
 }
 
@@ -571,7 +571,7 @@ static void layerCopy_mdisps(const void *source, void *dest, int count)
 
        for(i = 0; i < count; ++i) {
                if(s[i].disps) {
-                       d[i].disps = MEM_dupallocN(s[i].disps);
+                       d[i].disps = BLI_cellalloc_dupalloc(s[i].disps);
                        d[i].totdisp = s[i].totdisp;
                }
                else {
@@ -591,7 +591,7 @@ static void layerValidate_mdisps(void *data, int sub_elements)
                if(corners != sub_elements) {
                        MEM_freeN(disps->disps);
                        disps->totdisp = disps->totdisp / corners * sub_elements;
-                       disps->disps = MEM_callocN(3*disps->totdisp*sizeof(float), "layerValidate_mdisps");
+                       disps->disps = BLI_cellalloc_calloc(3*disps->totdisp*sizeof(float), "layerValidate_mdisps");
                }
        }
 }
@@ -603,7 +603,7 @@ static void layerFree_mdisps(void *data, int count, int UNUSED(size))
 
        for(i = 0; i < count; ++i) {
                if(d[i].disps)
-                       MEM_freeN(d[i].disps);
+                       BLI_cellalloc_free(d[i].disps);
                d[i].disps = NULL;
                d[i].totdisp = 0;
        }
@@ -616,7 +616,7 @@ static int layerRead_mdisps(CDataFile *cdf, void *data, int count)
 
        for(i = 0; i < count; ++i) {
                if(!d[i].disps)
-                       d[i].disps = MEM_callocN(sizeof(float)*3*d[i].totdisp, "mdisps read");
+                       d[i].disps = BLI_cellalloc_calloc(sizeof(float)*3*d[i].totdisp, "mdisps read");
 
                if(!cdf_read_data(cdf, d[i].totdisp*3*sizeof(float), d[i].disps)) {
                        printf("failed to read multires displacement %d/%d %d\n", i, count, d[i].totdisp);
@@ -1726,7 +1726,12 @@ void CustomData_copy_data(const CustomData *source, CustomData *dest,
 
                        src_offset = source_index * typeInfo->size;
                        dest_offset = dest_index * typeInfo->size;
-
+                       
+                       if (!src_data || !dest_data) {
+                               printf("eek! null data in CustomData_copy_data!\n");
+                               continue;
+                       }
+                       
                        if(typeInfo->copy)
                                typeInfo->copy(src_data + src_offset,
                                                                dest_data + dest_offset,
index f2c5a9cbf37e2937bb57c24dc613e29c70ce6ca0..a3d74e953093d8731b7a1a3a77f1e2bf55341397 100644 (file)
@@ -39,6 +39,7 @@
 #include "BLI_pbvh.h"
 #include "BLI_editVert.h"
 #include "BLI_utildefines.h"
+#include "BLI_cellalloc.h"
 
 #include "BKE_cdderivedmesh.h"
 #include "BKE_mesh.h"
@@ -320,10 +321,10 @@ static void multires_reallocate_mdisps(Mesh *me, MDisps *mdisps, int lvl)
        /* reallocate displacements to be filled in */
        for(i = 0; i < me->totloop; ++i) {
                int totdisp = multires_grid_tot[lvl];
-               float (*disps)[3] = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps");
+               float (*disps)[3] = BLI_cellalloc_calloc(sizeof(float) * 3 * totdisp, "multires disps");
 
                if(mdisps[i].disps)
-                       MEM_freeN(mdisps[i].disps);
+                       BLI_cellalloc_free(mdisps[i].disps);
 
                mdisps[i].disps = disps;
                mdisps[i].totdisp = totdisp;
@@ -402,7 +403,7 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
                                        float (*disps)[3], (*ndisps)[3], (*hdisps)[3];
                                        int totdisp = multires_grid_tot[lvl];
 
-                                       disps = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps");
+                                       disps = BLI_cellalloc_calloc(sizeof(float) * 3 * totdisp, "multires disps");
 
                                        ndisps = disps;
                                        hdisps = mdisp->disps;
@@ -412,7 +413,7 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
                                        ndisps += nsize*nsize;
                                        hdisps += hsize*hsize;
 
-                                       MEM_freeN(mdisp->disps);
+                                       BLI_cellalloc_free(mdisp->disps);
                                        mdisp->disps = disps;
                                        mdisp->totdisp = totdisp;
                                }
@@ -737,7 +738,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, int invert, int
                int S, x, y, gIndex = gridOffset[i];
 
                for(S = 0; S < numVerts; ++S, ++gIndex, ++k) {
-                       MDisps *mdisp = &mdisps[k];
+                       MDisps *mdisp = &mdisps[mpoly[i].loopstart+S];
                        DMGridData *grid = gridData[gIndex];
                        DMGridData *subgrid = subGridData[gIndex];
                        float (*dispgrid)[3] = NULL;
@@ -1033,7 +1034,7 @@ static void old_mdisps_convert(MFace *mface, MDisps *mdisp)
        int x, y, S;
        float (*disps)[3], (*out)[3], u, v;
 
-       disps = MEM_callocN(sizeof(float) * 3 * newtotdisp, "multires disps");
+       disps = BLI_cellalloc_calloc(sizeof(float) * 3 * newtotdisp, "multires disps");
 
        out = disps;
        for(S = 0; S < nvert; S++) {
@@ -1050,7 +1051,7 @@ static void old_mdisps_convert(MFace *mface, MDisps *mdisp)
                }
        }
 
-       MEM_freeN(mdisp->disps);
+       BLI_cellalloc_free(mdisp->disps);
 
        mdisp->totdisp= newtotdisp;
        mdisp->disps= disps;
@@ -1079,7 +1080,7 @@ void multires_load_old_250(Mesh *me)
                        int totdisp = mdisps[i].totdisp / nvert;
                        
                        for (j=0; j < mf->v4 ? 4 : 3; j++, k++) {
-                               mdisps2[k].disps = MEM_callocN(sizeof(float)*3*totdisp, "multires disp in conversion");                 
+                               mdisps2[k].disps = BLI_cellalloc_calloc(sizeof(float)*3*totdisp, "multires disp in conversion");                        
                                mdisps2[k].totdisp = totdisp;
                                memcpy(mdisps2[k].disps, mdisps[i].disps + totdisp*j, totdisp);
                        }
@@ -1781,7 +1782,7 @@ void multires_topology_changed(Scene *scene, Object *ob)
                if(!mdisp->totdisp) {
                        if(grid) {
                                mdisp->totdisp= nvert*grid;
-                               mdisp->disps= MEM_callocN(mdisp->totdisp*sizeof(float)*3, "mdisp topology");
+                               mdisp->disps= BLI_cellalloc_calloc(mdisp->totdisp*sizeof(float)*3, "mdisp topology");
                        }
 
                        continue;
@@ -1793,9 +1794,9 @@ void multires_topology_changed(Scene *scene, Object *ob)
                        mdisp->totdisp= (mdisp->totdisp/corners)*nvert;
 
                        if(mdisp->disps)
-                               MEM_freeN(mdisp->disps);
+                               BLI_cellalloc_free(mdisp->disps);
 
-                       mdisp->disps= MEM_callocN(mdisp->totdisp*sizeof(float)*3, "mdisp topology");
+                       mdisp->disps= BLI_cellalloc_calloc(mdisp->totdisp*sizeof(float)*3, "mdisp topology");
                }
        }
 }
@@ -2150,13 +2151,13 @@ void mdisp_join_tris(MDisps *dst, MDisps *tri1, MDisps *tri2)
        MDisps *src;
 
        if(dst->disps)
-               MEM_freeN(dst->disps);
+               BLI_cellalloc_free(dst->disps);
 
        side = sqrt(tri1->totdisp / 3);
        st = (side<<1)-1;
 
        dst->totdisp = 4 * side * side;
-       out = dst->disps = MEM_callocN(3*dst->totdisp*sizeof(float), "join disps");
+       out = dst->disps = BLI_cellalloc_calloc(3*dst->totdisp*sizeof(float), "join disps");
 
        for(S = 0; S < 4; S++)
                for(y = 0; y < side; ++y)
index 14237a1285b1c7a4cc1479d7358d6de2506fd363..88236a78ffcf65d8ae322c1845202997f7c2598a 100644 (file)
@@ -33,6 +33,9 @@
        this is a temporary and inperfect fix for performance issues caused
        by vgroups.  it needs to be replaced with something better, preferably
        integrated into guardedalloc.
+       
+       Basically, it's a quick fix for vgroups and MDisps (both of which
+       are major performance hitters).
 */
 
 #include "MEM_guardedalloc.h"
index 4fbc19e1c2ce9271c1e1e5fc7f9784ab55c3b97a..c4aadcfbe803cec9dd8919eb11cd2b068439d04b 100644 (file)
@@ -3448,7 +3448,18 @@ static void direct_link_mdisps(FileData *fd, int count, MDisps *mdisps, int exte
 
                for(i = 0; i < count; ++i) {
                        mdisps[i].disps = newdataadr(fd, mdisps[i].disps);
-
+                       
+                       /*put .disps into cellalloc system*/
+                       if (mdisps[i].disps) {
+                               float *disp2;
+                               
+                               disp2 = BLI_cellalloc_malloc(MEM_allocN_len(mdisps[i].disps), "cellalloc .disps copy");
+                               memcpy(disp2, mdisps[i].disps, MEM_allocN_len(mdisps[i].disps));
+                               
+                               MEM_freeN(mdisps[i].disps);
+                               mdisps[i].disps = disp2;
+                       }
+                       
                        if( (fd->flags & FD_FLAGS_SWITCH_ENDIAN) && (mdisps[i].disps) ) {
                                /* DNA_struct_switch_endian doesn't do endian swap for (*disps)[] */
                                /* this does swap for data written at write_mdisps() - readfile.c */
index 04b097ba0972ff964576e0500d9037d2a05c926e..84985a7b81e2c26d4028d8c0656cbe4f5f07c0d7 100644 (file)
@@ -258,18 +258,6 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode)
                                if(BMINDEX_GET(eve)) tottrans++;
                }
                
-               /* proportional edit exception... */
-               if((mode & 1) && tottrans) {
-                       BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) {
-                               if(BMINDEX_GET(eve)) tottrans++;
-                               if(!BM_TestHFlag(eve, BM_HIDDEN)) {
-                                       BMINDEX_SET(eve, BMINDEX_GET(eve)|2);
-                                       proptrans++;
-                               }
-                       }
-                       if(proptrans>tottrans) tottrans= proptrans;
-               }
-               
                /* and now make transverts */
                if(tottrans) {
                        tv=transvmain= MEM_callocN(tottrans*sizeof(TransVert), "maketransverts");
index a4ab28a6d7c96de3636487938e57963a842eb21e..eceb1e356dce45d0cccc229212fc8fdaf86be769 100644 (file)
@@ -224,7 +224,9 @@ DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
                }
        }
        
-       cddm = CDDM_merge_verts(cddm, vtargetmap);
+       if (!(mmd->flag & MOD_MIR_NO_MERGE))
+               cddm = CDDM_merge_verts(cddm, vtargetmap);
+       
        BLI_array_free(vtargetmap);
        
        if (vector_def) MEM_freeN(vector_def);