Cleanup: Return PBVH node vertex indices with span instead of pointer
This commit is contained in:
@@ -404,7 +404,7 @@ void BKE_pbvh_node_get_grids(PBVH *pbvh,
|
||||
int *gridsize,
|
||||
CCGElem ***r_griddata);
|
||||
void BKE_pbvh_node_num_verts(PBVH *pbvh, PBVHNode *node, int *r_uniquevert, int *r_totvert);
|
||||
const int *BKE_pbvh_node_get_vert_indices(PBVHNode *node);
|
||||
blender::Span<int> BKE_pbvh_node_get_vert_indices(PBVHNode *node);
|
||||
void BKE_pbvh_node_get_loops(PBVH *pbvh,
|
||||
PBVHNode *node,
|
||||
const int **r_loop_indices,
|
||||
|
||||
@@ -1958,9 +1958,9 @@ int BKE_pbvh_num_faces(const PBVH *pbvh)
|
||||
return 0;
|
||||
}
|
||||
|
||||
const int *BKE_pbvh_node_get_vert_indices(PBVHNode *node)
|
||||
blender::Span<int> BKE_pbvh_node_get_vert_indices(PBVHNode *node)
|
||||
{
|
||||
return node->vert_indices.data();
|
||||
return node->vert_indices;
|
||||
}
|
||||
|
||||
void BKE_pbvh_node_num_verts(PBVH *pbvh, PBVHNode *node, int *r_uniquevert, int *r_totvert)
|
||||
|
||||
@@ -76,11 +76,9 @@ static void partialvis_update_mesh(Object *ob,
|
||||
Mesh *me = static_cast<Mesh *>(ob->data);
|
||||
const float(*positions)[3] = BKE_pbvh_get_vert_positions(pbvh);
|
||||
const float *paint_mask;
|
||||
int totvert, i;
|
||||
bool any_changed = false, any_visible = false;
|
||||
|
||||
BKE_pbvh_node_num_verts(pbvh, node, nullptr, &totvert);
|
||||
const int *vert_indices = BKE_pbvh_node_get_vert_indices(node);
|
||||
const blender::Span<int> verts = BKE_pbvh_node_get_vert_indices(node);
|
||||
paint_mask = static_cast<const float *>(CustomData_get_layer(&me->vert_data, CD_PAINT_MASK));
|
||||
|
||||
bool *hide_vert = static_cast<bool *>(CustomData_get_layer_named_for_write(
|
||||
@@ -92,16 +90,16 @@ static void partialvis_update_mesh(Object *ob,
|
||||
|
||||
SCULPT_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN);
|
||||
|
||||
for (i = 0; i < totvert; i++) {
|
||||
float vmask = paint_mask ? paint_mask[vert_indices[i]] : 0;
|
||||
for (const int vert : verts) {
|
||||
float vmask = paint_mask ? paint_mask[vert] : 0;
|
||||
|
||||
/* Hide vertex if in the hide volume. */
|
||||
if (is_effected(area, planes, positions[vert_indices[i]], vmask)) {
|
||||
hide_vert[vert_indices[i]] = (action == PARTIALVIS_HIDE);
|
||||
if (is_effected(area, planes, positions[vert], vmask)) {
|
||||
hide_vert[vert] = (action == PARTIALVIS_HIDE);
|
||||
any_changed = true;
|
||||
}
|
||||
|
||||
if (!hide_vert[vert_indices[i]]) {
|
||||
if (!hide_vert[vert]) {
|
||||
any_visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,28 +319,26 @@ static void update_cb_partial(PBVHNode *node, void *userdata)
|
||||
if (BKE_pbvh_node_has_vert_with_normal_update_tag(data->pbvh, node)) {
|
||||
BKE_pbvh_node_mark_update(node);
|
||||
}
|
||||
int verts_num;
|
||||
BKE_pbvh_node_num_verts(data->pbvh, node, nullptr, &verts_num);
|
||||
const int *vert_indices = BKE_pbvh_node_get_vert_indices(node);
|
||||
const blender::Span<int> verts = BKE_pbvh_node_get_vert_indices(node);
|
||||
if (data->modified_mask_verts != nullptr) {
|
||||
for (int i = 0; i < verts_num; i++) {
|
||||
if (data->modified_mask_verts[vert_indices[i]]) {
|
||||
for (const int vert : verts) {
|
||||
if (data->modified_mask_verts[vert]) {
|
||||
BKE_pbvh_node_mark_update_mask(node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data->modified_color_verts != nullptr) {
|
||||
for (int i = 0; i < verts_num; i++) {
|
||||
if (data->modified_color_verts[vert_indices[i]]) {
|
||||
for (const int vert : verts) {
|
||||
if (data->modified_color_verts[vert]) {
|
||||
BKE_pbvh_node_mark_update_color(node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data->modified_hidden_verts != nullptr) {
|
||||
for (int i = 0; i < verts_num; i++) {
|
||||
if (data->modified_hidden_verts[vert_indices[i]]) {
|
||||
for (const int vert : verts) {
|
||||
if (data->modified_hidden_verts[vert]) {
|
||||
if (data->rebuild) {
|
||||
BKE_pbvh_node_mark_update_visibility(node);
|
||||
}
|
||||
@@ -1449,13 +1447,9 @@ static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode)
|
||||
/* Already stored during allocation. */
|
||||
}
|
||||
else {
|
||||
int allvert;
|
||||
|
||||
BKE_pbvh_node_num_verts(pbvh, node, nullptr, &allvert);
|
||||
const int *vert_indices = BKE_pbvh_node_get_vert_indices(node);
|
||||
for (int i = 0; i < allvert; i++) {
|
||||
BLI_BITMAP_SET(unode->vert_hidden, i, hide_vert[vert_indices[i]]);
|
||||
}
|
||||
const blender::Span<int> verts = BKE_pbvh_node_get_vert_indices(node);
|
||||
for (const int i : verts.index_range())
|
||||
BLI_BITMAP_SET(unode->vert_hidden, i, hide_vert[verts[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1646,8 +1640,8 @@ SculptUndoNode *SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
|
||||
int allvert, allloop;
|
||||
|
||||
BKE_pbvh_node_num_verts(ss->pbvh, static_cast<PBVHNode *>(unode->node), nullptr, &allvert);
|
||||
const int *vert_indices = BKE_pbvh_node_get_vert_indices(node);
|
||||
memcpy(unode->index, vert_indices, sizeof(int) * allvert);
|
||||
const blender::Span<int> vert_indices = BKE_pbvh_node_get_vert_indices(node);
|
||||
memcpy(unode->index, vert_indices.data(), sizeof(int) * allvert);
|
||||
|
||||
if (unode->loop_index) {
|
||||
BKE_pbvh_node_num_loops(ss->pbvh, static_cast<PBVHNode *>(unode->node), &allloop);
|
||||
|
||||
Reference in New Issue
Block a user