diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2007-12-17 07:52:46 +0300 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2007-12-17 07:52:46 +0300 |
commit | efb2d5fc975354d42b2850279648ede4f7ee53a1 (patch) | |
tree | 624ee1f3282c83754e85ef6233fc5e037804813f /source/blender/src | |
parent | bda2c40763d1f789b977bb666fd5c29b466a498f (diff) |
== Sculpt Mode ==
Improved some memory allocation; it doesn't actually use less memory now, just avoids reallocating the same block of memory over and over again.
Diffstat (limited to 'source/blender/src')
-rw-r--r-- | source/blender/src/sculptmode.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/source/blender/src/sculptmode.c b/source/blender/src/sculptmode.c index c9952d4ab7e..8afd1dafd6a 100644 --- a/source/blender/src/sculptmode.c +++ b/source/blender/src/sculptmode.c @@ -269,6 +269,11 @@ void sculptmode_free_all(Scene *sce) sculptmode_free_session(sce); + if(projverts) { + MEM_freeN(projverts); + projverts = NULL; + } + for(a=0; a<MAX_MTEX; a++) { MTex *mtex= sd->mtex[a]; if(mtex) { @@ -1563,8 +1568,9 @@ void sculptmode_update_all_projverts(float *vertcosnos) Mesh *me= get_mesh(OBACT); unsigned i; - if(projverts) MEM_freeN(projverts); - projverts= MEM_mallocN(sizeof(ProjVert)*me->totvert,"ProjVerts"); + if(!projverts) + projverts = MEM_mallocN(sizeof(ProjVert)*me->totvert,"ProjVerts"); + for(i=0; i<me->totvert; ++i) { project(vertcosnos ? &vertcosnos[i * 6] : me->mvert[i].co, projverts[i].co); projverts[i].inside= 0; @@ -1708,9 +1714,12 @@ void sculpt(void) ss->vertexcosnos = NULL; /* Check that vertex users are up-to-date */ - if(ob != active_ob || ss->vertex_users_size != get_mesh(ob)->totvert) { + if(ob != active_ob || !ss->vertex_users || ss->vertex_users_size != get_mesh(ob)->totvert) { sculptmode_free_vertexusers(ss); calc_vertex_users(); + if(projverts) + MEM_freeN(projverts); + projverts = NULL; active_ob= ob; } @@ -1721,9 +1730,6 @@ void sculpt(void) getmouseco_areawin(mvalo); - /* Make sure sculptdata has been init'd properly */ - if(!ss->vertex_users) calc_vertex_users(); - /* Init texture FIXME: Shouldn't be doing this every time! */ if(sd->texrept!=SCULPTREPT_3D) @@ -1859,8 +1865,6 @@ void sculpt(void) BLI_freelistN(&ss->damaged_rects); } - if(projverts) MEM_freeN(projverts); - projverts= NULL; if(e.layer_disps) MEM_freeN(e.layer_disps); if(e.layer_store) MEM_freeN(e.layer_store); /* Free GrabData */ |