Sculpt: Skip fully hidden nodes in sculpt tools

As tools iterators skip not visible vertices, fully hidden nodes can
also be skipped and considered as masked.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8244
This commit is contained in:
Pablo Dobarro 2020-07-08 18:10:31 +02:00
parent 1fb667da01
commit 78b629a98f
5 changed files with 19 additions and 9 deletions

View File

@ -264,6 +264,7 @@ void BKE_pbvh_node_mark_redraw(PBVHNode *node);
void BKE_pbvh_node_mark_normals_update(PBVHNode *node);
void BKE_pbvh_node_mark_topology_update(PBVHNode *node);
void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden);
bool BKE_pbvh_node_fully_hidden_get(PBVHNode *node);
void BKE_pbvh_node_fully_masked_set(PBVHNode *node, int fully_masked);
bool BKE_pbvh_node_fully_masked_get(PBVHNode *node);
void BKE_pbvh_node_fully_unmasked_set(PBVHNode *node, int fully_masked);

View File

@ -1772,6 +1772,11 @@ void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden)
}
}
bool BKE_pbvh_node_fully_hidden_get(PBVHNode *node)
{
return (node->flag & PBVH_Leaf) && (node->flag & PBVH_FullyHidden);
}
void BKE_pbvh_node_fully_masked_set(PBVHNode *node, int fully_masked)
{
BLI_assert(node->flag & PBVH_Leaf);

View File

@ -2471,7 +2471,10 @@ bool SCULPT_search_sphere_cb(PBVHNode *node, void *data_v)
}
float t[3], bb_min[3], bb_max[3];
if (data->ignore_fully_masked) {
if (data->ignore_fully_ineffective) {
if (BKE_pbvh_node_fully_hidden_get(node)) {
return false;
}
if (BKE_pbvh_node_fully_masked_get(node)) {
return false;
}
@ -2507,7 +2510,7 @@ bool SCULPT_search_circle_cb(PBVHNode *node, void *data_v)
SculptSearchCircleData *data = data_v;
float bb_min[3], bb_max[3];
if (data->ignore_fully_masked) {
if (data->ignore_fully_ineffective) {
if (BKE_pbvh_node_fully_masked_get(node)) {
return false;
}
@ -2560,7 +2563,7 @@ static PBVHNode **sculpt_pbvh_gather_cursor_update(Object *ob,
.sd = sd,
.radius_squared = ss->cursor_radius,
.original = use_original,
.ignore_fully_masked = false,
.ignore_fully_ineffective = false,
.center = NULL,
};
BKE_pbvh_search_gather(ss->pbvh, SCULPT_search_sphere_cb, &data, &nodes, r_totnode);
@ -2585,7 +2588,7 @@ static PBVHNode **sculpt_pbvh_gather_generic(Object *ob,
.sd = sd,
.radius_squared = square_f(ss->cache->radius * radius_scale),
.original = use_original,
.ignore_fully_masked = brush->sculpt_tool != SCULPT_TOOL_MASK,
.ignore_fully_ineffective = brush->sculpt_tool != SCULPT_TOOL_MASK,
.center = NULL,
};
BKE_pbvh_search_gather(ss->pbvh, SCULPT_search_sphere_cb, &data, &nodes, r_totnode);
@ -2601,7 +2604,7 @@ static PBVHNode **sculpt_pbvh_gather_generic(Object *ob,
ss->cursor_radius,
.original = use_original,
.dist_ray_to_aabb_precalc = &dist_ray_to_aabb_precalc,
.ignore_fully_masked = brush->sculpt_tool != SCULPT_TOOL_MASK,
.ignore_fully_ineffective = brush->sculpt_tool != SCULPT_TOOL_MASK,
};
BKE_pbvh_search_gather(ss->pbvh, SCULPT_search_circle_cb, &data, &nodes, r_totnode);
}
@ -5482,7 +5485,7 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
.sd = sd,
.radius_squared = square_f(ss->cache->radius * (1.0 + brush->cloth_sim_limit)),
.original = false,
.ignore_fully_masked = false,
.ignore_fully_ineffective = false,
.center = ss->cache->initial_location,
};
BKE_pbvh_search_gather(ss->pbvh, SCULPT_search_sphere_cb, &data, &nodes, &totnode);

View File

@ -87,7 +87,7 @@ void SCULPT_filter_cache_init(Object *ob, Sculpt *sd, const int undo_type)
.original = true,
.center = center,
.radius_squared = FLT_MAX,
.ignore_fully_masked = true,
.ignore_fully_ineffective = true,
};
BKE_pbvh_search_gather(pbvh,

View File

@ -676,7 +676,8 @@ typedef struct {
float radius_squared;
const float *center;
bool original;
bool ignore_fully_masked;
/* This ignores fully masked and fully hidden nodes. */
bool ignore_fully_ineffective;
} SculptSearchSphereData;
typedef struct {
@ -684,7 +685,7 @@ typedef struct {
struct SculptSession *ss;
float radius_squared;
bool original;
bool ignore_fully_masked;
bool ignore_fully_ineffective;
struct DistRayAABB_Precalc *dist_ray_to_aabb_precalc;
} SculptSearchCircleData;