Cleanup: Move Sculpt boundary functions into a namespace
Pull Request: https://projects.blender.org/blender/blender/pulls/125108
This commit is contained in:
@@ -1321,7 +1321,7 @@ void do_relax_face_sets_brush(const Sculpt &sd, Object &object, Span<PBVHNode *>
|
||||
{
|
||||
const Brush &brush = *BKE_paint_brush_for_read(&sd.paint);
|
||||
|
||||
SCULPT_boundary_info_ensure(object);
|
||||
boundary::ensure_boundary_info(object);
|
||||
|
||||
const SculptSession &ss = *object.sculpt;
|
||||
const std::array<float, 4> strengths = iteration_strengths(ss.cache->bstrength,
|
||||
@@ -1359,7 +1359,7 @@ void do_topology_relax_brush(const Sculpt &sd, Object &object, Span<PBVHNode *>
|
||||
|
||||
const float strength = ss.cache->bstrength;
|
||||
|
||||
SCULPT_boundary_info_ensure(object);
|
||||
boundary::ensure_boundary_info(object);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
switch (BKE_pbvh_type(*ss.pbvh)) {
|
||||
|
||||
@@ -285,7 +285,7 @@ void do_smooth_brush(const Sculpt &sd,
|
||||
SculptSession &ss = *object.sculpt;
|
||||
const Brush &brush = *BKE_paint_brush_for_read(&sd.paint);
|
||||
|
||||
SCULPT_boundary_info_ensure(object);
|
||||
boundary::ensure_boundary_info(object);
|
||||
|
||||
switch (BKE_pbvh_type(*object.sculpt->pbvh)) {
|
||||
case PBVH_FACES:
|
||||
|
||||
@@ -286,7 +286,7 @@ void do_smooth_mask_brush(const Sculpt &sd,
|
||||
{
|
||||
SculptSession &ss = *object.sculpt;
|
||||
const Brush &brush = *BKE_paint_brush_for_read(&sd.paint);
|
||||
SCULPT_boundary_info_ensure(object);
|
||||
boundary::ensure_boundary_info(object);
|
||||
switch (BKE_pbvh_type(*object.sculpt->pbvh)) {
|
||||
case PBVH_FACES: {
|
||||
do_smooth_brush_mesh(brush, object, nodes, brush_strength);
|
||||
|
||||
@@ -829,9 +829,12 @@ static bool sculpt_check_boundary_vertex_in_base_mesh(const SculptSession &ss, c
|
||||
return ss.vertex_info.boundary[index];
|
||||
}
|
||||
|
||||
bool SCULPT_vertex_is_boundary(const SculptSession &ss, const PBVHVertRef vertex)
|
||||
namespace blender::ed::sculpt_paint {
|
||||
|
||||
namespace boundary {
|
||||
|
||||
bool vert_is_boundary(const SculptSession &ss, const PBVHVertRef vertex)
|
||||
{
|
||||
using namespace blender::ed::sculpt_paint;
|
||||
switch (BKE_pbvh_type(*ss.pbvh)) {
|
||||
case PBVH_FACES: {
|
||||
if (!hide::vert_all_faces_visible_get(ss, vertex)) {
|
||||
@@ -869,6 +872,10 @@ bool SCULPT_vertex_is_boundary(const SculptSession &ss, const PBVHVertRef vertex
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace boundary
|
||||
|
||||
} // namespace blender::ed::sculpt_paint
|
||||
|
||||
/* Utilities */
|
||||
|
||||
bool SCULPT_stroke_is_main_symmetry_pass(const blender::ed::sculpt_paint::StrokeCache &cache)
|
||||
@@ -6250,9 +6257,10 @@ struct SculptTopologyIDFloodFillData {
|
||||
|
||||
} // namespace blender::ed::sculpt_paint
|
||||
|
||||
void SCULPT_boundary_info_ensure(Object &object)
|
||||
namespace blender::ed::sculpt_paint::boundary {
|
||||
|
||||
void ensure_boundary_info(Object &object)
|
||||
{
|
||||
using namespace blender;
|
||||
SculptSession &ss = *object.sculpt;
|
||||
if (!ss.vertex_info.boundary.is_empty()) {
|
||||
return;
|
||||
@@ -6264,7 +6272,7 @@ void SCULPT_boundary_info_ensure(Object &object)
|
||||
Array<int> adjacent_faces_edge_count(base_mesh->edges_num, 0);
|
||||
array_utils::count_indices(base_mesh->corner_edges(), adjacent_faces_edge_count);
|
||||
|
||||
const blender::Span<int2> edges = base_mesh->edges();
|
||||
const Span<int2> edges = base_mesh->edges();
|
||||
for (const int e : edges.index_range()) {
|
||||
if (adjacent_faces_edge_count[e] < 2) {
|
||||
const int2 &edge = edges[e];
|
||||
@@ -6274,6 +6282,8 @@ void SCULPT_boundary_info_ensure(Object &object)
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace blender::ed::sculpt_paint::boundary
|
||||
|
||||
void SCULPT_fake_neighbors_ensure(Object &ob, const float max_dist)
|
||||
{
|
||||
using namespace blender::ed::sculpt_paint;
|
||||
|
||||
@@ -562,7 +562,7 @@ float factor_get(const Cache *automasking,
|
||||
}
|
||||
|
||||
if (automasking->settings.flags & BRUSH_AUTOMASKING_BOUNDARY_EDGES) {
|
||||
if (SCULPT_vertex_is_boundary(ss, vert)) {
|
||||
if (boundary::vert_is_boundary(ss, vert)) {
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
@@ -807,7 +807,7 @@ static void init_boundary_masking(Object &ob, eBoundaryAutomaskMode mode, int pr
|
||||
edge_distance[i] = EDGE_DISTANCE_INF;
|
||||
switch (mode) {
|
||||
case AUTOMASK_INIT_BOUNDARY_EDGES:
|
||||
if (SCULPT_vertex_is_boundary(ss, vertex)) {
|
||||
if (boundary::vert_is_boundary(ss, vertex)) {
|
||||
edge_distance[i] = 0;
|
||||
}
|
||||
break;
|
||||
@@ -944,7 +944,7 @@ std::unique_ptr<Cache> cache_init(const Sculpt &sd, const Brush *brush, Object &
|
||||
|
||||
std::unique_ptr<Cache> automasking = std::make_unique<Cache>();
|
||||
cache_settings_update(*automasking, ss, sd, brush);
|
||||
SCULPT_boundary_info_ensure(ob);
|
||||
boundary::ensure_boundary_info(ob);
|
||||
|
||||
automasking->current_stroke_id = ss.stroke_id;
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ std::unique_ptr<SculptBoundary> data_init(Object &object,
|
||||
}
|
||||
|
||||
SCULPT_vertex_random_access_ensure(ss);
|
||||
SCULPT_boundary_info_ensure(object);
|
||||
boundary::ensure_boundary_info(object);
|
||||
|
||||
const PBVHVertRef boundary_initial_vert = get_closest_boundary_vert(ss, initial_vert, radius);
|
||||
|
||||
@@ -118,7 +118,7 @@ static bool is_vert_in_editable_boundary(SculptSession &ss, const PBVHVertRef in
|
||||
SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, initial_vert, ni) {
|
||||
if (hide::vert_visible_get(ss, ni.vertex)) {
|
||||
neighbor_count++;
|
||||
if (SCULPT_vertex_is_boundary(ss, ni.vertex)) {
|
||||
if (boundary::vert_is_boundary(ss, ni.vertex)) {
|
||||
boundary_vertex_count++;
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,7 @@ static bool initial_vert_floodfill_fn(SculptSession &ss,
|
||||
data->floodfill_steps[to_v_i] = data->floodfill_steps[from_v_i];
|
||||
}
|
||||
|
||||
if (SCULPT_vertex_is_boundary(ss, to_v)) {
|
||||
if (boundary::vert_is_boundary(ss, to_v)) {
|
||||
if (data->floodfill_steps[to_v_i] < data->boundary_initial_vert_steps) {
|
||||
data->boundary_initial_vert_steps = data->floodfill_steps[to_v_i];
|
||||
data->boundary_initial_vert_i = to_v_i;
|
||||
@@ -192,7 +192,7 @@ static PBVHVertRef get_closest_boundary_vert(SculptSession &ss,
|
||||
const float radius)
|
||||
{
|
||||
|
||||
if (SCULPT_vertex_is_boundary(ss, initial_vert)) {
|
||||
if (boundary::vert_is_boundary(ss, initial_vert)) {
|
||||
return initial_vert;
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ static bool floodfill_fn(SculptSession &ss,
|
||||
const float3 to_v_co = SCULPT_vertex_co_get(ss, to_v);
|
||||
|
||||
SculptBoundary &boundary = *data->boundary;
|
||||
if (!SCULPT_vertex_is_boundary(ss, to_v)) {
|
||||
if (!boundary::vert_is_boundary(ss, to_v)) {
|
||||
return false;
|
||||
}
|
||||
const float edge_len = len_v3v3(from_v_co, to_v_co);
|
||||
@@ -1021,7 +1021,7 @@ std::unique_ptr<SculptBoundaryPreview> preview_data_init(Object &object,
|
||||
}
|
||||
|
||||
SCULPT_vertex_random_access_ensure(ss);
|
||||
SCULPT_boundary_info_ensure(object);
|
||||
boundary::ensure_boundary_info(object);
|
||||
|
||||
const PBVHVertRef boundary_initial_vert = get_closest_boundary_vert(ss, initial_vert, radius);
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ static void relax_vertex_boundary(SculptSession &ss,
|
||||
|
||||
/* When the vertex to relax is boundary, use only connected boundary vertices for the average
|
||||
* position. */
|
||||
if (!SCULPT_vertex_is_boundary(ss, ni.vertex)) {
|
||||
if (!boundary::vert_is_boundary(ss, ni.vertex)) {
|
||||
continue;
|
||||
}
|
||||
add_v3_v3(smooth_pos, SCULPT_vertex_co_get(ss, ni.vertex));
|
||||
@@ -216,7 +216,7 @@ void relax_vertex(SculptSession &ss,
|
||||
const bool filter_boundary_face_sets,
|
||||
float *r_final_pos)
|
||||
{
|
||||
if (SCULPT_vertex_is_boundary(ss, vd->vertex)) {
|
||||
if (boundary::vert_is_boundary(ss, vd->vertex)) {
|
||||
relax_vertex_boundary(ss, vd, factor, filter_boundary_face_sets, r_final_pos);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -400,7 +400,7 @@ static BitVector<> boundary_from_enabled(SculptSession &ss,
|
||||
}
|
||||
SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
|
||||
|
||||
if (use_mesh_boundary && SCULPT_vertex_is_boundary(ss, vertex)) {
|
||||
if (use_mesh_boundary && boundary::vert_is_boundary(ss, vertex)) {
|
||||
is_expand_boundary = true;
|
||||
}
|
||||
|
||||
@@ -1868,7 +1868,7 @@ static void ensure_sculptsession_data(Object &ob)
|
||||
SculptSession &ss = *ob.sculpt;
|
||||
SCULPT_topology_islands_ensure(ob);
|
||||
SCULPT_vertex_random_access_ensure(ss);
|
||||
SCULPT_boundary_info_ensure(ob);
|
||||
boundary::ensure_boundary_info(ob);
|
||||
if (!ss.tex_pool) {
|
||||
ss.tex_pool = BKE_image_pool_new();
|
||||
}
|
||||
@@ -2361,7 +2361,7 @@ static int sculpt_expand_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
||||
RNA_enum_get(op->ptr, "falloff_type"));
|
||||
|
||||
/* When starting from a boundary vertex, set the initial falloff to boundary. */
|
||||
if (SCULPT_vertex_is_boundary(ss, ss.expand_cache->initial_active_vertex)) {
|
||||
if (boundary::vert_is_boundary(ss, ss.expand_cache->initial_active_vertex)) {
|
||||
falloff_type = SCULPT_EXPAND_FALLOFF_BOUNDARY_TOPOLOGY;
|
||||
}
|
||||
|
||||
|
||||
@@ -1171,13 +1171,13 @@ static void edit_fairing(Object &ob,
|
||||
orig_positions.resize(totvert);
|
||||
fair_verts.resize(totvert);
|
||||
|
||||
SCULPT_boundary_info_ensure(ob);
|
||||
boundary::ensure_boundary_info(ob);
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(*ss.pbvh, i);
|
||||
|
||||
orig_positions[i] = SCULPT_vertex_co_get(ss, vertex);
|
||||
fair_verts[i] = !SCULPT_vertex_is_boundary(ss, vertex) &&
|
||||
fair_verts[i] = !boundary::vert_is_boundary(ss, vertex) &&
|
||||
vert_has_face_set(ss, vertex, active_face_set_id) &&
|
||||
vert_has_unique_face_set(ss, vertex);
|
||||
}
|
||||
|
||||
@@ -942,7 +942,7 @@ static int sculpt_mesh_filter_start(bContext *C, wmOperator *op)
|
||||
|
||||
SCULPT_vertex_random_access_ensure(ss);
|
||||
if (needs_topology_info) {
|
||||
SCULPT_boundary_info_ensure(ob);
|
||||
boundary::ensure_boundary_info(ob);
|
||||
}
|
||||
|
||||
undo::push_begin(ob, op);
|
||||
|
||||
@@ -924,19 +924,25 @@ void SCULPT_fake_neighbors_enable(Object &ob);
|
||||
void SCULPT_fake_neighbors_disable(Object &ob);
|
||||
void SCULPT_fake_neighbors_free(Object &ob);
|
||||
|
||||
namespace blender::ed::sculpt_paint {
|
||||
|
||||
namespace boundary {
|
||||
|
||||
/**
|
||||
* Populates boundary information for a mesh.
|
||||
*
|
||||
* \see SculptVertexInfo
|
||||
*/
|
||||
void SCULPT_boundary_info_ensure(Object &object);
|
||||
void ensure_boundary_info(Object &object);
|
||||
|
||||
/**
|
||||
* Determine if a vertex is a boundary vertex.
|
||||
*
|
||||
* Requires #SCULPT_boundary_info_ensure to have been called.
|
||||
* Requires #ensure_boundary_info to have been called.
|
||||
*/
|
||||
bool SCULPT_vertex_is_boundary(const SculptSession &ss, PBVHVertRef vertex);
|
||||
bool vert_is_boundary(const SculptSession &ss, PBVHVertRef vertex);
|
||||
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -944,8 +950,6 @@ bool SCULPT_vertex_is_boundary(const SculptSession &ss, PBVHVertRef vertex);
|
||||
/** \name Sculpt Visibility API
|
||||
* \{ */
|
||||
|
||||
namespace blender::ed::sculpt_paint {
|
||||
|
||||
namespace hide {
|
||||
|
||||
Span<int> node_visible_verts(const PBVHNode &node, Span<bool> hide_vert, Vector<int> &indices);
|
||||
|
||||
@@ -210,14 +210,14 @@ float3 neighbor_coords_average_interior(const SculptSession &ss, PBVHVertRef ver
|
||||
float3 avg(0);
|
||||
int total = 0;
|
||||
int neighbor_count = 0;
|
||||
const bool is_boundary = SCULPT_vertex_is_boundary(ss, vertex);
|
||||
const bool is_boundary = boundary::vert_is_boundary(ss, vertex);
|
||||
|
||||
SculptVertexNeighborIter ni;
|
||||
SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vertex, ni) {
|
||||
neighbor_count++;
|
||||
if (is_boundary) {
|
||||
/* Boundary vertices use only other boundary vertices. */
|
||||
if (SCULPT_vertex_is_boundary(ss, ni.vertex)) {
|
||||
if (boundary::vert_is_boundary(ss, ni.vertex)) {
|
||||
avg += SCULPT_vertex_co_get(ss, ni.vertex);
|
||||
total++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user