From 444885848d6b5de53af94758ddca6b4b6dcd5d68 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Wed, 22 Feb 2012 22:37:01 +0000 Subject: 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. --- source/blender/blenlib/BLI_pbvh.h | 31 ++++--------------------------- source/blender/blenlib/intern/pbvh.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 27 deletions(-) (limited to 'source/blender/blenlib') 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.ggrid= 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; +} -- cgit v1.2.3