diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2006-12-20 11:33:30 +0300 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2006-12-20 11:33:30 +0300 |
commit | 56b79bb66eaf354e746f660035d4f89a7f518fe9 (patch) | |
tree | 2501e4a7df5267ea66fba7d23a9469bfd2e5f6d2 /source/blender/src/sculptmode.c | |
parent | 547be2a5ce4a73a633fbf13a11d82141ba8b16d3 (diff) |
Modified sculptmode's vertex_users to use one large chunk of memory rather than many small pieces.
Diffstat (limited to 'source/blender/src/sculptmode.c')
-rw-r--r-- | source/blender/src/sculptmode.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/source/blender/src/sculptmode.c b/source/blender/src/sculptmode.c index e60aa99d3d3..d67d7b767f6 100644 --- a/source/blender/src/sculptmode.c +++ b/source/blender/src/sculptmode.c @@ -189,12 +189,10 @@ void sculptmode_free_vertexusers(struct Scene *sce) sd= &sce->sculptdata; if(sd->vertex_users){ - int i; - for(i=0; i<sd->vertex_users_size; ++i){ - BLI_freelistN(&sd->vertex_users[i]); - } MEM_freeN(sd->vertex_users); + MEM_freeN(sd->vertex_users_mem); sd->vertex_users= NULL; + sd->vertex_users_mem= NULL; sd->vertex_users_size= 0; } } @@ -546,26 +544,23 @@ void sculptmode_free_all(Scene *sce) void calc_vertex_users() { int i,j; - IndexNode *node= 0; - Mesh *me= get_mesh(G.scene->sculptdata.active_ob); + IndexNode *node= NULL; + SculptData *sd= &G.scene->sculptdata; + Mesh *me= get_mesh(sd->active_ob); sculptmode_free_vertexusers(G.scene); - + /* Allocate an array of ListBases, one per vertex */ - G.scene->sculptdata.vertex_users= (ListBase*)MEM_mallocN(sizeof(ListBase) * me->totvert, "vertex_users"); - G.scene->sculptdata.vertex_users_size= me->totvert; - - /* Initialize */ - for(i=0; i<me->totvert; ++i){ - G.scene->sculptdata.vertex_users[i].first=G.scene->sculptdata.vertex_users[i].last= 0; - } + sd->vertex_users= (ListBase*)MEM_callocN(sizeof(ListBase) * me->totvert, "vertex_users"); + sd->vertex_users_size= me->totvert; + sd->vertex_users_mem= MEM_mallocN(sizeof(IndexNode)*me->totvert*4, "vertex_users_mem"); + node= sd->vertex_users_mem; /* Find the users */ for(i=0; i<me->totface; ++i){ - for(j=0; j<(me->mface[i].v4?4:3); ++j){ - node= (IndexNode*)MEM_mallocN(sizeof(IndexNode), "faceindex"); + for(j=0; j<(me->mface[i].v4?4:3); ++j, ++node) { node->Index=i; - BLI_addtail(&G.scene->sculptdata.vertex_users[((unsigned int*)(&me->mface[i]))[j]], node); + BLI_addtail(&sd->vertex_users[((unsigned int*)(&me->mface[i]))[j]], node); } } } |