diff options
Diffstat (limited to 'source/blender/blenlib')
-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; +} |