Cleanup: Remove now unused PBVH vertex iteration macro
Part of #118145.
This commit is contained in:
@@ -527,147 +527,6 @@ void BKE_pbvh_vert_coords_apply(blender::bke::pbvh::Tree &pbvh,
|
||||
blender::Span<blender::float3> vert_positions);
|
||||
bool BKE_pbvh_is_deformed(const blender::bke::pbvh::Tree &pbvh);
|
||||
|
||||
/* Vertex Iterator. */
|
||||
|
||||
/* This iterator has quite a lot of code, but it's designed to:
|
||||
* - allow the compiler to eliminate dead code and variables
|
||||
* - spend most of the time in the relatively simple inner loop */
|
||||
|
||||
/* NOTE: PBVH_ITER_ALL does not skip hidden vertices,
|
||||
* PBVH_ITER_UNIQUE does */
|
||||
#define PBVH_ITER_ALL 0
|
||||
#define PBVH_ITER_UNIQUE 1
|
||||
|
||||
struct PBVHVertexIter {
|
||||
/* iteration */
|
||||
int g;
|
||||
int width;
|
||||
int height;
|
||||
int gx;
|
||||
int gy;
|
||||
int i;
|
||||
int index;
|
||||
PBVHVertRef vertex;
|
||||
|
||||
/* grid */
|
||||
CCGKey key;
|
||||
CCGElem *const *grids;
|
||||
CCGElem *grid;
|
||||
const blender::BitGroupVector<> *grid_hidden;
|
||||
std::optional<blender::BoundedBitSpan> gh;
|
||||
const int *grid_indices;
|
||||
int totgrid;
|
||||
int gridsize;
|
||||
|
||||
/* mesh */
|
||||
blender::MutableSpan<blender::float3> vert_positions;
|
||||
blender::Span<blender::float3> vert_normals;
|
||||
const bool *hide_vert;
|
||||
int totvert;
|
||||
const int *vert_indices;
|
||||
const float *vmask;
|
||||
bool is_mesh;
|
||||
|
||||
/* bmesh */
|
||||
std::optional<blender::Set<BMVert *, 0>::Iterator> bm_unique_verts;
|
||||
std::optional<blender::Set<BMVert *, 0>::Iterator> bm_unique_verts_end;
|
||||
std::optional<blender::Set<BMVert *, 0>::Iterator> bm_other_verts;
|
||||
std::optional<blender::Set<BMVert *, 0>::Iterator> bm_other_verts_end;
|
||||
CustomData *bm_vdata;
|
||||
int cd_vert_mask_offset;
|
||||
|
||||
/* result: these are all computed in the macro, but we assume
|
||||
* that compiler optimization's will skip the ones we don't use */
|
||||
BMVert *bm_vert;
|
||||
float *co;
|
||||
const float *no;
|
||||
const float *fno;
|
||||
float mask;
|
||||
bool visible;
|
||||
};
|
||||
|
||||
void pbvh_vertex_iter_init(blender::bke::pbvh::Tree &pbvh,
|
||||
blender::bke::pbvh::Node *node,
|
||||
PBVHVertexIter *vi,
|
||||
int mode);
|
||||
|
||||
#define BKE_pbvh_vertex_iter_begin(pbvh, node, vi, mode) \
|
||||
pbvh_vertex_iter_init(pbvh, node, &vi, mode); \
|
||||
\
|
||||
for (vi.i = 0, vi.g = 0; vi.g < vi.totgrid; vi.g++) { \
|
||||
if (vi.grids) { \
|
||||
vi.width = vi.gridsize; \
|
||||
vi.height = vi.gridsize; \
|
||||
vi.index = vi.vertex.i = vi.grid_indices[vi.g] * vi.key.grid_area - 1; \
|
||||
vi.grid = CCG_elem_offset(vi.key, vi.grids[vi.grid_indices[vi.g]], -1); \
|
||||
if (mode == PBVH_ITER_UNIQUE) { \
|
||||
if (vi.grid_hidden) { \
|
||||
vi.gh.emplace((*vi.grid_hidden)[vi.grid_indices[vi.g]]); \
|
||||
} \
|
||||
else { \
|
||||
vi.gh.reset(); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
vi.width = vi.totvert; \
|
||||
vi.height = 1; \
|
||||
} \
|
||||
\
|
||||
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.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) : 0.0f; \
|
||||
vi.index++; \
|
||||
vi.vertex.i++; \
|
||||
vi.visible = true; \
|
||||
if (vi.gh) { \
|
||||
if ((*vi.gh)[vi.gy * vi.gridsize + vi.gx]) { \
|
||||
continue; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
else if (!vi.vert_positions.is_empty()) { \
|
||||
vi.visible = !(vi.hide_vert && vi.hide_vert[vi.vert_indices[vi.gx]]); \
|
||||
if (mode == PBVH_ITER_UNIQUE && !vi.visible) { \
|
||||
continue; \
|
||||
} \
|
||||
vi.co = vi.vert_positions[vi.vert_indices[vi.gx]]; \
|
||||
vi.no = vi.vert_normals[vi.vert_indices[vi.gx]]; \
|
||||
vi.index = vi.vertex.i = vi.vert_indices[vi.i]; \
|
||||
vi.mask = vi.vmask ? vi.vmask[vi.index] : 0.0f; \
|
||||
} \
|
||||
else { \
|
||||
if (*vi.bm_unique_verts != *vi.bm_unique_verts_end) { \
|
||||
vi.bm_vert = **vi.bm_unique_verts; \
|
||||
(*vi.bm_unique_verts)++; \
|
||||
} \
|
||||
else { \
|
||||
vi.bm_vert = **vi.bm_other_verts; \
|
||||
(*vi.bm_other_verts)++; \
|
||||
} \
|
||||
vi.visible = !BM_elem_flag_test_bool(vi.bm_vert, BM_ELEM_HIDDEN); \
|
||||
if (mode == PBVH_ITER_UNIQUE && !vi.visible) { \
|
||||
continue; \
|
||||
} \
|
||||
vi.co = vi.bm_vert->co; \
|
||||
vi.fno = vi.bm_vert->no; \
|
||||
vi.vertex = BKE_pbvh_make_vref((intptr_t)vi.bm_vert); \
|
||||
vi.index = BM_elem_index_get(vi.bm_vert); \
|
||||
vi.mask = BM_ELEM_CD_GET_FLOAT(vi.bm_vert, vi.cd_vert_mask_offset); \
|
||||
}
|
||||
|
||||
#define BKE_pbvh_vertex_iter_end \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
((void)0)
|
||||
|
||||
#define PBVH_FACE_ITER_VERTS_RESERVED 8
|
||||
|
||||
void BKE_pbvh_node_get_bm_orco_data(blender::bke::pbvh::Node *node,
|
||||
int (**r_orco_tris)[3],
|
||||
int *r_orco_tris_num,
|
||||
|
||||
@@ -2689,87 +2689,6 @@ bool BKE_pbvh_is_deformed(const blender::bke::pbvh::Tree &pbvh)
|
||||
{
|
||||
return pbvh.deformed_;
|
||||
}
|
||||
/* Proxies */
|
||||
|
||||
void pbvh_vertex_iter_init(blender::bke::pbvh::Tree &pbvh,
|
||||
blender::bke::pbvh::Node *node,
|
||||
PBVHVertexIter *vi,
|
||||
int mode)
|
||||
{
|
||||
vi->grid = nullptr;
|
||||
vi->no = nullptr;
|
||||
vi->fno = nullptr;
|
||||
vi->vert_positions = {};
|
||||
vi->vertex.i = 0LL;
|
||||
|
||||
int uniq_verts;
|
||||
int totvert;
|
||||
switch (pbvh.type()) {
|
||||
case blender::bke::pbvh::Type::Grids:
|
||||
totvert = node->prim_indices_.size() *
|
||||
BKE_subdiv_ccg_key_top_level(*pbvh.subdiv_ccg_).grid_area;
|
||||
uniq_verts = totvert;
|
||||
break;
|
||||
case blender::bke::pbvh::Type::Mesh:
|
||||
totvert = node->vert_indices_.size();
|
||||
uniq_verts = node->unique_verts_num_;
|
||||
break;
|
||||
case blender::bke::pbvh::Type::BMesh:
|
||||
totvert = node->bm_unique_verts_.size() + node->bm_other_verts_.size();
|
||||
uniq_verts = node->bm_unique_verts_.size();
|
||||
break;
|
||||
}
|
||||
|
||||
if (pbvh.type() == blender::bke::pbvh::Type::Grids) {
|
||||
vi->key = BKE_subdiv_ccg_key_top_level(*pbvh.subdiv_ccg_);
|
||||
vi->grids = pbvh.subdiv_ccg_->grids.data();
|
||||
vi->grid_indices = node->prim_indices_.data();
|
||||
vi->totgrid = node->prim_indices_.size();
|
||||
vi->gridsize = vi->key.grid_size;
|
||||
}
|
||||
else {
|
||||
vi->key = {};
|
||||
vi->grids = nullptr;
|
||||
vi->grid_indices = nullptr;
|
||||
vi->totgrid = 1;
|
||||
vi->gridsize = 0;
|
||||
}
|
||||
|
||||
if (mode == PBVH_ITER_ALL) {
|
||||
vi->totvert = totvert;
|
||||
}
|
||||
else {
|
||||
vi->totvert = uniq_verts;
|
||||
}
|
||||
vi->vert_indices = node->vert_indices_.data();
|
||||
vi->vert_positions = pbvh.vert_positions_;
|
||||
vi->is_mesh = !pbvh.vert_positions_.is_empty();
|
||||
|
||||
if (pbvh.type() == blender::bke::pbvh::Type::BMesh) {
|
||||
vi->bm_unique_verts = node->bm_unique_verts_.begin();
|
||||
vi->bm_unique_verts_end = node->bm_unique_verts_.end();
|
||||
vi->bm_other_verts = node->bm_other_verts_.begin();
|
||||
vi->bm_other_verts_end = node->bm_other_verts_.end();
|
||||
vi->bm_vdata = &pbvh.bm_->vdata;
|
||||
vi->cd_vert_mask_offset = CustomData_get_offset_named(
|
||||
vi->bm_vdata, CD_PROP_FLOAT, ".sculpt_mask");
|
||||
}
|
||||
|
||||
vi->gh.reset();
|
||||
if (vi->grids && mode == PBVH_ITER_UNIQUE) {
|
||||
vi->grid_hidden = pbvh.subdiv_ccg_->grid_hidden.is_empty() ? nullptr :
|
||||
&pbvh.subdiv_ccg_->grid_hidden;
|
||||
}
|
||||
|
||||
vi->mask = 0.0f;
|
||||
if (pbvh.type() == blender::bke::pbvh::Type::Mesh) {
|
||||
vi->vert_normals = pbvh.vert_normals_;
|
||||
vi->hide_vert = static_cast<const bool *>(
|
||||
CustomData_get_layer_named(&pbvh.mesh_->vert_data, CD_PROP_BOOL, ".hide_vert"));
|
||||
vi->vmask = static_cast<const float *>(
|
||||
CustomData_get_layer_named(&pbvh.mesh_->vert_data, CD_PROP_FLOAT, ".sculpt_mask"));
|
||||
}
|
||||
}
|
||||
|
||||
bool pbvh_has_mask(const blender::bke::pbvh::Tree &pbvh)
|
||||
{
|
||||
|
||||
@@ -1266,31 +1266,6 @@ SculptOrigVertData SCULPT_orig_vert_data_init(const Object &ob,
|
||||
return data;
|
||||
}
|
||||
|
||||
void SCULPT_orig_vert_data_update(SculptOrigVertData &orig_data, const PBVHVertexIter &iter)
|
||||
{
|
||||
using namespace blender::ed::sculpt_paint;
|
||||
if (orig_data.undo_type == undo::Type::Position) {
|
||||
if (orig_data.bm_log) {
|
||||
BM_log_original_vert_data(orig_data.bm_log, iter.bm_vert, &orig_data.co, &orig_data.no);
|
||||
}
|
||||
else {
|
||||
orig_data.co = orig_data.coords[iter.i];
|
||||
orig_data.no = orig_data.normals[iter.i];
|
||||
}
|
||||
}
|
||||
else if (orig_data.undo_type == undo::Type::Color) {
|
||||
orig_data.col = orig_data.colors[iter.i];
|
||||
}
|
||||
else if (orig_data.undo_type == undo::Type::Mask) {
|
||||
if (orig_data.bm_log) {
|
||||
orig_data.mask = BM_log_original_mask(orig_data.bm_log, iter.bm_vert);
|
||||
}
|
||||
else {
|
||||
orig_data.mask = orig_data.vmasks[iter.i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SCULPT_orig_vert_data_update(SculptOrigVertData &orig_data, const BMVert &vert)
|
||||
{
|
||||
using namespace blender::ed::sculpt_paint;
|
||||
|
||||
@@ -703,13 +703,6 @@ NodeData node_begin(const Object &object, const Cache *automasking, const bke::p
|
||||
return automask_data;
|
||||
}
|
||||
|
||||
void node_update(auto_mask::NodeData &automask_data, const PBVHVertexIter &vd)
|
||||
{
|
||||
if (automask_data.orig_data) {
|
||||
SCULPT_orig_vert_data_update(*automask_data.orig_data, vd);
|
||||
}
|
||||
}
|
||||
|
||||
void node_update(auto_mask::NodeData &automask_data, const BMVert &vert)
|
||||
{
|
||||
if (automask_data.orig_data) {
|
||||
|
||||
@@ -1060,7 +1060,6 @@ SculptOrigVertData SCULPT_orig_vert_data_init(const Object &ob,
|
||||
/**
|
||||
* Update a #SculptOrigVertData for a particular vertex from the blender::bke::pbvh::Tree iterator.
|
||||
*/
|
||||
void SCULPT_orig_vert_data_update(SculptOrigVertData &orig_data, const PBVHVertexIter &iter);
|
||||
void SCULPT_orig_vert_data_update(SculptOrigVertData &orig_data, const BMVert &vert);
|
||||
void SCULPT_orig_vert_data_update(SculptOrigVertData &orig_data, int i);
|
||||
|
||||
@@ -1387,7 +1386,6 @@ struct NodeData {
|
||||
NodeData node_begin(const Object &object, const Cache *automasking, const bke::pbvh::Node &node);
|
||||
|
||||
/* Call before factor_get. */
|
||||
void node_update(NodeData &automask_data, const PBVHVertexIter &vd);
|
||||
void node_update(NodeData &automask_data, const BMVert &vert);
|
||||
/**
|
||||
* Call before factor_get. The index is in the range of the pbvh::Tree node's vertex indices.
|
||||
|
||||
Reference in New Issue
Block a user