[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35321] branches/bmesh/blender: =bmesh=
Joseph Eagar
joeedh at gmail.com
Thu Mar 3 08:10:42 CET 2011
Revision: 35321
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35321
Author: joeedh
Date: 2011-03-03 07:10:42 +0000 (Thu, 03 Mar 2011)
Log Message:
-----------
=bmesh=
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.
Modified Paths:
--------------
branches/bmesh/blender/intern/opennl/superlu/sgstrf.c
branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c
branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c
branches/bmesh/blender/source/blender/blenkernel/intern/multires.c
branches/bmesh/blender/source/blender/blenlib/intern/BLI_cellalloc.c
branches/bmesh/blender/source/blender/blenloader/intern/readfile.c
branches/bmesh/blender/source/blender/editors/space_view3d/view3d_snap.c
branches/bmesh/blender/source/blender/modifiers/intern/MOD_mirror.c
Modified: branches/bmesh/blender/intern/opennl/superlu/sgstrf.c
===================================================================
--- branches/bmesh/blender/intern/opennl/superlu/sgstrf.c 2011-03-03 06:14:55 UTC (rev 35320)
+++ branches/bmesh/blender/intern/opennl/superlu/sgstrf.c 2011-03-03 07:10:42 UTC (rev 35321)
@@ -399,7 +399,7 @@
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
}
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c 2011-03-03 06:14:55 UTC (rev 35320)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c 2011-03-03 07:10:42 UTC (rev 35321)
@@ -2415,7 +2415,7 @@
}
/*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;
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c 2011-03-03 06:14:55 UTC (rev 35320)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c 2011-03-03 07:10:42 UTC (rev 35321)
@@ -433,18 +433,18 @@
/* 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 @@
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 @@
}
/* 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 @@
}
}
- MEM_freeN(d->disps);
+ BLI_cellalloc_free(d->disps);
d->disps = disps;
}
@@ -571,7 +571,7 @@
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 @@
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 @@
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 @@
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 @@
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,
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/multires.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/multires.c 2011-03-03 06:14:55 UTC (rev 35320)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/multires.c 2011-03-03 07:10:42 UTC (rev 35321)
@@ -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 @@
/* 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 @@
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 @@
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 @@
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 @@
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 @@
}
}
- MEM_freeN(mdisp->disps);
+ BLI_cellalloc_free(mdisp->disps);
mdisp->totdisp= newtotdisp;
mdisp->disps= disps;
@@ -1079,7 +1080,7 @@
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 @@
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 @@
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 @@
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)
Modified: branches/bmesh/blender/source/blender/blenlib/intern/BLI_cellalloc.c
===================================================================
--- branches/bmesh/blender/source/blender/blenlib/intern/BLI_cellalloc.c 2011-03-03 06:14:55 UTC (rev 35320)
+++ branches/bmesh/blender/source/blender/blenlib/intern/BLI_cellalloc.c 2011-03-03 07:10:42 UTC (rev 35321)
@@ -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"
Modified: branches/bmesh/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/bmesh/blender/source/blender/blenloader/intern/readfile.c 2011-03-03 06:14:55 UTC (rev 35320)
+++ branches/bmesh/blender/source/blender/blenloader/intern/readfile.c 2011-03-03 07:10:42 UTC (rev 35321)
@@ -3448,7 +3448,18 @@
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 */
Modified: branches/bmesh/blender/source/blender/editors/space_view3d/view3d_snap.c
===================================================================
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list