Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt.c')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c78
1 files changed, 58 insertions, 20 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 5a830a90092..79c4becd405 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -356,9 +356,6 @@ static void SCULPT_vertex_face_set_set(SculptSession *ss, int index, int face_se
if (ss->face_sets[vert_map->indices[j]] > 0) {
ss->face_sets[vert_map->indices[j]] = abs(face_set);
}
- else {
- ss->face_sets[vert_map->indices[j]] = -abs(face_set);
- }
}
} break;
case PBVH_BMESH:
@@ -628,6 +625,10 @@ static bool sculpt_vertex_is_boundary(SculptSession *ss, const int index)
return false;
}
+ if (!SCULPT_vertex_all_face_sets_visible_get(ss, index)) {
+ return false;
+ }
+
for (int i = 0; i < vert_map->count; i++) {
const MPoly *p = &ss->mpoly[vert_map->indices[i]];
unsigned f_adj_v[2];
@@ -836,7 +837,7 @@ void SCULPT_floodfill_execute(
sculpt_vertex_duplicates_and_neighbors_iter_begin(ss, from_v, ni)
{
const int to_v = ni.index;
- if (flood->visited_vertices[to_v] == 0) {
+ if (flood->visited_vertices[to_v] == 0 && SCULPT_vertex_visible_get(ss, to_v)) {
flood->visited_vertices[to_v] = 1;
if (func(ss, from_v, to_v, ni.is_duplicate, userdata)) {
@@ -1633,17 +1634,11 @@ static float *sculpt_face_sets_automasking_init(Sculpt *sd, Object *ob, float *a
#define EDGE_DISTANCE_INF -1
-static float *sculpt_boundary_edges_automasking_init(Sculpt *sd,
- Object *ob,
+static float *sculpt_boundary_edges_automasking_init(Object *ob,
+ int propagation_steps,
float *automask_factor)
{
SculptSession *ss = ob->sculpt;
- Brush *brush = BKE_paint_brush(&sd->paint);
- const int propagation_steps = brush->automasking_boundary_edges_propagation_steps;
-
- if (!sculpt_automasking_enabled(ss, brush)) {
- return NULL;
- }
if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && !ss->pmap) {
BLI_assert(!"Boundary Edges masking: pmap missing");
@@ -1693,6 +1688,10 @@ static void sculpt_automasking_init(Sculpt *sd, Object *ob)
Brush *brush = BKE_paint_brush(&sd->paint);
const int totvert = SCULPT_vertex_count_get(ss);
+ if (!sculpt_automasking_enabled(ss, brush)) {
+ return;
+ }
+
ss->cache->automask = MEM_callocN(sizeof(float) * SCULPT_vertex_count_get(ss),
"automask_factor");
@@ -1711,7 +1710,8 @@ static void sculpt_automasking_init(Sculpt *sd, Object *ob)
if (brush->automasking_flags & BRUSH_AUTOMASKING_BOUNDARY_EDGES) {
SCULPT_vertex_random_access_init(ss);
- sculpt_boundary_edges_automasking_init(sd, ob, ss->cache->automask);
+ sculpt_boundary_edges_automasking_init(
+ ob, brush->automasking_boundary_edges_propagation_steps, ss->cache->automask);
}
}
@@ -3401,7 +3401,7 @@ static void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata,
vd.index,
tls->thread_id);
- if (fade > 0.05f && SCULPT_vertex_all_face_sets_visible_get(ss, vd.index)) {
+ if (fade > 0.05f) {
SCULPT_vertex_face_set_set(ss, vd.index, ss->cache->paint_face_set);
}
}
@@ -3662,6 +3662,10 @@ void SCULPT_relax_vertex(SculptSession *ss,
if (count > 0) {
mul_v3_fl(smooth_pos, 1.0f / (float)count);
}
+ else {
+ copy_v3_v3(r_final_pos, vd->co);
+ return;
+ }
float plane[4];
float smooth_closest_plane[3];
@@ -3672,6 +3676,12 @@ void SCULPT_relax_vertex(SculptSession *ss,
else {
copy_v3_v3(vno, vd->fno);
}
+
+ if (is_zero_v3(vno)) {
+ copy_v3_v3(r_final_pos, vd->co);
+ return;
+ }
+
plane_from_point_normal_v3(plane, vd->co, vno);
closest_to_plane_v3(smooth_closest_plane, plane, smooth_pos);
sub_v3_v3v3(final_disp, smooth_closest_plane, vd->co);
@@ -9143,6 +9153,10 @@ static void sculpt_filter_cache_free(SculptSession *ss)
if (ss->filter_cache->prev_face_set) {
MEM_freeN(ss->filter_cache->prev_face_set);
}
+ if (ss->filter_cache->automask) {
+ MEM_freeN(ss->filter_cache->automask);
+ }
+
MEM_freeN(ss->filter_cache);
ss->filter_cache = NULL;
}
@@ -9310,7 +9324,8 @@ static void mesh_filter_task_cb(void *__restrict userdata,
break;
}
case MESH_FILTER_RELAX: {
- SCULPT_relax_vertex(ss, &vd, clamp_f(fade, 0.0f, 1.0f), false, val);
+ SCULPT_relax_vertex(
+ ss, &vd, clamp_f(fade * ss->filter_cache->automask[vd.index], 0.0f, 1.0f), false, val);
sub_v3_v3v3(disp, val, vd.co);
break;
}
@@ -9443,6 +9458,16 @@ static int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent
ss->filter_cache->enabled_axis[1] = deform_axis & MESH_FILTER_DEFORM_Y;
ss->filter_cache->enabled_axis[2] = deform_axis & MESH_FILTER_DEFORM_Z;
+ if (RNA_enum_get(op->ptr, "type") == MESH_FILTER_RELAX) {
+ const int totvert = SCULPT_vertex_count_get(ss);
+ ss->filter_cache->automask = MEM_mallocN(totvert * sizeof(float),
+ "Relax filter edge automask");
+ for (int i = 0; i < totvert; i++) {
+ ss->filter_cache->automask[i] = 1.0f;
+ }
+ sculpt_boundary_edges_automasking_init(ob, 1, ss->filter_cache->automask);
+ }
+
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
}
@@ -10844,7 +10869,7 @@ static int sculpt_face_set_create_invoke(bContext *C, wmOperator *op, const wmEv
if (mode == SCULPT_FACE_SET_VISIBLE) {
for (int i = 0; i < tot_vert; i++) {
- if (SCULPT_vertex_visible_get(ss, i) && SCULPT_vertex_all_face_sets_visible_get(ss, i)) {
+ if (SCULPT_vertex_visible_get(ss, i)) {
SCULPT_vertex_face_set_set(ss, i, next_face_set);
}
}
@@ -11017,6 +11042,18 @@ static int sculpt_face_sets_change_visibility_invoke(bContext *C,
SCULPT_face_sets_visibility_invert(ss);
}
+ /* For modes that use the cursor active vertex, update the rotation origin for viewport
+ * navigation. */
+ if (ELEM(mode, SCULPT_FACE_SET_VISIBILITY_TOGGLE, SCULPT_FACE_SET_VISIBILITY_SHOW_ACTIVE)) {
+ UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
+ float location[3];
+ copy_v3_v3(location, SCULPT_active_vertex_co_get(ss));
+ mul_m4_v3(ob->obmat, location);
+ copy_v3_v3(ups->average_stroke_accum, location);
+ ups->average_stroke_counter = 1;
+ ups->last_stroke_valid = true;
+ }
+
/* Sync face sets visibility and vertex visibility. */
SCULPT_visibility_sync_all_face_sets_to_vertices(ss);
@@ -11084,12 +11121,13 @@ static int sculpt_face_sets_randomize_colors_invoke(bContext *C,
int totnode;
Mesh *mesh = ob->data;
- int new_seed = BLI_hash_int(PIL_check_seconds_timer_i() & UINT_MAX);
- mesh->face_sets_color_seed = new_seed;
+ mesh->face_sets_color_seed += 1;
if (ss->face_sets) {
- mesh->face_sets_color_default = ss->face_sets[0];
+ const int random_index = clamp_i(
+ ss->totpoly * BLI_hash_int_01(mesh->face_sets_color_seed), 0, max_ii(0, ss->totpoly - 1));
+ mesh->face_sets_color_default = ss->face_sets[random_index];
}
- BKE_pbvh_face_sets_color_set(pbvh, new_seed, mesh->face_sets_color_default);
+ BKE_pbvh_face_sets_color_set(pbvh, mesh->face_sets_color_seed, mesh->face_sets_color_default);
BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
for (int i = 0; i < totnode; i++) {