Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Eagar <joeedh@gmail.com>2011-03-03 10:10:42 +0300
committerJoseph Eagar <joeedh@gmail.com>2011-03-03 10:10:42 +0300
commita147a91899f97adccb7049965a4cd4dfd5693eb6 (patch)
treebf2734c1e5a82d9e1726d64ad33061f7ea1156eb
parent065a7f4e2f4509c99cef33af6a4446292224699f (diff)
=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.
-rw-r--r--intern/opennl/superlu/sgstrf.c2
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c2
-rw-r--r--source/blender/blenkernel/intern/customdata.c31
-rw-r--r--source/blender/blenkernel/intern/multires.c27
-rw-r--r--source/blender/blenlib/intern/BLI_cellalloc.c3
-rw-r--r--source/blender/blenloader/intern/readfile.c13
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c12
-rw-r--r--source/blender/modifiers/intern/MOD_mirror.c4
8 files changed, 52 insertions, 42 deletions
diff --git a/intern/opennl/superlu/sgstrf.c b/intern/opennl/superlu/sgstrf.c
index 335f21165ca..143b6bfd61e 100644
--- a/intern/opennl/superlu/sgstrf.c
+++ b/intern/opennl/superlu/sgstrf.c
@@ -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
}
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index a23663d1275..9617218f37c 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -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;
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 0612a57d85d..628d8698f36 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -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,
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index f2c5a9cbf37..a3d74e95309 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -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)
diff --git a/source/blender/blenlib/intern/BLI_cellalloc.c b/source/blender/blenlib/intern/BLI_cellalloc.c
index 14237a1285b..88236a78ffc 100644
--- a/source/blender/blenlib/intern/BLI_cellalloc.c
+++ b/source/blender/blenlib/intern/BLI_cellalloc.c
@@ -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"
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 4fbc19e1c2c..c4aadcfbe80 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -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 */
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 04b097ba097..84985a7b81e 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -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");
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index a4ab28a6d7c..eceb1e356dc 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -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);