diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-02-23 02:37:01 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-02-23 02:37:01 +0400 |
commit | 444885848d6b5de53af94758ddca6b4b6dcd5d68 (patch) | |
tree | cdb29b6bd7c348dea46fa750b8452ea57f057b5f | |
parent | de595d995f56e887a33497f3b989c2af36e4398f (diff) |
Code cleanup: move the PBVH iterator's initialization into a function.
Should be no functional changes, just shortens the amount of code
living in the macro.
-rw-r--r-- | source/blender/blenlib/BLI_pbvh.h | 31 | ||||
-rw-r--r-- | source/blender/blenlib/intern/pbvh.c | 31 |
2 files changed, 35 insertions, 27 deletions
diff --git a/source/blender/blenlib/BLI_pbvh.h b/source/blender/blenlib/BLI_pbvh.h index ef32ec03a61..e7dc5c4b065 100644 --- a/source/blender/blenlib/BLI_pbvh.h +++ b/source/blender/blenlib/BLI_pbvh.h @@ -171,34 +171,11 @@ typedef struct PBVHVertexIter { #pragma warning (disable:4127) // conditional expression is constant #endif +void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, + PBVHVertexIter *vi, int mode); + #define BLI_pbvh_vertex_iter_begin(bvh, node, vi, mode) \ - { \ - struct DMGridData **grids; \ - struct MVert *verts; \ - int *grid_indices, totgrid, gridsize, *vert_indices, uniq_verts, totvert; \ - \ - vi.grid= 0; \ - vi.no= 0; \ - vi.fno= 0; \ - vi.mvert= 0; \ - vi.skip= 0; \ - \ - BLI_pbvh_node_get_grids(bvh, node, &grid_indices, &totgrid, NULL, &gridsize, &grids, NULL); \ - BLI_pbvh_node_num_verts(bvh, node, &uniq_verts, &totvert); \ - BLI_pbvh_node_get_verts(bvh, node, &vert_indices, &verts); \ - \ - vi.grids= grids; \ - vi.grid_indices= grid_indices; \ - vi.totgrid= (grids)? totgrid: 1; \ - vi.gridsize= gridsize; \ - \ - if(mode == PBVH_ITER_ALL) \ - vi.totvert = totvert; \ - else \ - vi.totvert= uniq_verts; \ - vi.vert_indices= vert_indices; \ - vi.mverts= verts; \ - }\ + pbvh_vertex_iter_init(bvh, node, &vi, mode); \ \ for(vi.i=0, vi.g=0; vi.g<vi.totgrid; vi.g++) { \ if(vi.grids) { \ diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index 56f0dff2847..51d6b85e3d9 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -1683,3 +1683,34 @@ void BLI_pbvh_gather_proxies(PBVH* pbvh, PBVHNode*** r_array, int* r_tot) *r_array= array; *r_tot= tot; } + +void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, + PBVHVertexIter *vi, int mode) +{ + struct DMGridData **grids; + struct MVert *verts; + int *grid_indices, *vert_indices; + int totgrid, gridsize, uniq_verts, totvert; + + vi->grid= 0; + vi->no= 0; + vi->fno= 0; + vi->mvert= 0; + vi->skip= 0; + + BLI_pbvh_node_get_grids(bvh, node, &grid_indices, &totgrid, NULL, &gridsize, &grids, NULL); + BLI_pbvh_node_num_verts(bvh, node, &uniq_verts, &totvert); + BLI_pbvh_node_get_verts(bvh, node, &vert_indices, &verts); + + vi->grids= grids; + vi->grid_indices= grid_indices; + vi->totgrid= (grids)? totgrid: 1; + vi->gridsize= gridsize; + + if(mode == PBVH_ITER_ALL) + vi->totvert = totvert; + else + vi->totvert= uniq_verts; + vi->vert_indices= vert_indices; + vi->mverts= verts; +} |