Cleanup: slightly more efficient access to PBVH multires grid key
This commit is contained in:
@@ -25,6 +25,9 @@
|
||||
#include "BLI_bitmap.h"
|
||||
#include "BLI_ghash.h"
|
||||
|
||||
/* For embedding CCGKey in iterator. */
|
||||
#include "BKE_ccg.h"
|
||||
|
||||
struct BMLog;
|
||||
struct BMesh;
|
||||
struct CCGElem;
|
||||
@@ -209,7 +212,7 @@ int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden,
|
||||
int gridsize);
|
||||
|
||||
/* multires level, only valid for type == PBVH_GRIDS */
|
||||
void BKE_pbvh_get_grid_key(const PBVH *pbvh, struct CCGKey *key);
|
||||
const struct CCGKey *BKE_pbvh_get_grid_key(const PBVH *pbvh);
|
||||
|
||||
struct CCGElem **BKE_pbvh_get_grids(const PBVH *pbvh, int *num_grids);
|
||||
|
||||
@@ -320,9 +323,9 @@ typedef struct PBVHVertexIter {
|
||||
int index;
|
||||
|
||||
/* grid */
|
||||
struct CCGKey key;
|
||||
struct CCGElem **grids;
|
||||
struct CCGElem *grid;
|
||||
struct CCGKey *key;
|
||||
BLI_bitmap **grid_hidden, *gh;
|
||||
int *grid_indices;
|
||||
int totgrid;
|
||||
@@ -371,10 +374,10 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, PBVHVertexIter *vi, int mo
|
||||
for (vi.gy = 0; vi.gy < vi.height; vi.gy++) { \
|
||||
for (vi.gx = 0; vi.gx < vi.width; vi.gx++, vi.i++) { \
|
||||
if (vi.grid) { \
|
||||
vi.co = CCG_elem_co(vi.key, vi.grid); \
|
||||
vi.fno = CCG_elem_no(vi.key, vi.grid); \
|
||||
vi.mask = vi.key->has_mask ? CCG_elem_mask(vi.key, vi.grid) : NULL; \
|
||||
vi.grid = CCG_elem_next(vi.key, vi.grid); \
|
||||
vi.co = CCG_elem_co(&vi.key, vi.grid); \
|
||||
vi.fno = CCG_elem_no(&vi.key, vi.grid); \
|
||||
vi.mask = vi.key.has_mask ? CCG_elem_mask(&vi.key, vi.grid) : NULL; \
|
||||
vi.grid = CCG_elem_next(&vi.key, vi.grid); \
|
||||
if (vi.gh) { \
|
||||
if (BLI_BITMAP_TEST(vi.gh, vi.gy * vi.gridsize + vi.gx)) \
|
||||
continue; \
|
||||
|
||||
@@ -1478,10 +1478,10 @@ BLI_bitmap **BKE_pbvh_grid_hidden(const PBVH *bvh)
|
||||
return bvh->grid_hidden;
|
||||
}
|
||||
|
||||
void BKE_pbvh_get_grid_key(const PBVH *bvh, CCGKey *key)
|
||||
const CCGKey *BKE_pbvh_get_grid_key(const PBVH *bvh)
|
||||
{
|
||||
BLI_assert(bvh->type == PBVH_GRIDS);
|
||||
*key = bvh->gridkey;
|
||||
return &bvh->gridkey;
|
||||
}
|
||||
|
||||
struct CCGElem **BKE_pbvh_get_grids(const PBVH *bvh, int *num_grids)
|
||||
@@ -2654,7 +2654,7 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, PBVHVertexIter *vi, int mo
|
||||
BKE_pbvh_node_get_grids(bvh, node, &grid_indices, &totgrid, NULL, &gridsize, &grids);
|
||||
BKE_pbvh_node_num_verts(bvh, node, &uniq_verts, &totvert);
|
||||
BKE_pbvh_node_get_verts(bvh, node, &vert_indices, &verts);
|
||||
vi->key = &bvh->gridkey;
|
||||
vi->key = bvh->gridkey;
|
||||
|
||||
vi->grids = grids;
|
||||
vi->grid_indices = grid_indices;
|
||||
|
||||
@@ -134,7 +134,6 @@ static void partialvis_update_grids(Depsgraph *depsgraph,
|
||||
float planes[4][4])
|
||||
{
|
||||
CCGElem **grids;
|
||||
CCGKey key;
|
||||
BLI_bitmap **grid_hidden;
|
||||
int *grid_indices, totgrid, i;
|
||||
bool any_changed = false, any_visible = false;
|
||||
@@ -142,7 +141,7 @@ static void partialvis_update_grids(Depsgraph *depsgraph,
|
||||
/* get PBVH data */
|
||||
BKE_pbvh_node_get_grids(pbvh, node, &grid_indices, &totgrid, NULL, NULL, &grids);
|
||||
grid_hidden = BKE_pbvh_grid_hidden(pbvh);
|
||||
BKE_pbvh_get_grid_key(pbvh, &key);
|
||||
CCGKey key = *BKE_pbvh_get_grid_key(pbvh);
|
||||
|
||||
sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN);
|
||||
|
||||
|
||||
@@ -2581,7 +2581,6 @@ static void do_smooth_brush_multires_task_cb_ex(void *__restrict userdata,
|
||||
float bstrength = data->strength;
|
||||
|
||||
CCGElem **griddata, *gddata;
|
||||
CCGKey key;
|
||||
|
||||
float(*tmpgrid_co)[3] = NULL;
|
||||
float tmprow_co[2][3];
|
||||
@@ -2600,7 +2599,7 @@ static void do_smooth_brush_multires_task_cb_ex(void *__restrict userdata,
|
||||
|
||||
BKE_pbvh_node_get_grids(
|
||||
ss->pbvh, data->nodes[n], &grid_indices, &totgrid, NULL, &gridsize, &griddata);
|
||||
BKE_pbvh_get_grid_key(ss->pbvh, &key);
|
||||
CCGKey key = *BKE_pbvh_get_grid_key(ss->pbvh);
|
||||
|
||||
grid_hidden = BKE_pbvh_grid_hidden(ss->pbvh);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user