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')
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c41
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h4
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c21
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c9
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c64
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c19
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c7
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c10
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_expand.c49
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_face_set.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_pose.c5
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c4
15 files changed, 182 insertions, 63 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index b44f2f66d92..7e111905883 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -545,6 +545,7 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
int x,
int y,
float zoom,
+ const ePaintMode mode,
bool col,
bool primary)
{
@@ -556,6 +557,13 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
(brush->overlay_flags & BRUSH_OVERLAY_SECONDARY) != 0);
int overlay_alpha = (primary) ? brush->texture_overlay_alpha : brush->mask_overlay_alpha;
+ if (mode == PAINT_MODE_TEXTURE_3D) {
+ if (primary && brush->imagepaint_tool != PAINT_TOOL_DRAW) {
+ /* All non-draw tools don't use the primary texture (clone, smear, soften.. etc). */
+ return false;
+ }
+ }
+
if (!(mtex->tex) ||
!((mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) ||
(valid && ELEM(mtex->brush_map_mode, MTEX_MAP_MODE_VIEW, MTEX_MAP_MODE_TILED)))) {
@@ -785,10 +793,11 @@ static bool paint_draw_alpha_overlay(UnifiedPaintSettings *ups,
/* Colored overlay should be drawn separately. */
if (col) {
if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY)) {
- alpha_overlay_active = paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, true, true);
+ alpha_overlay_active = paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, mode, true, true);
}
if (!(flags & PAINT_OVERLAY_OVERRIDE_SECONDARY)) {
- alpha_overlay_active = paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, false, false);
+ alpha_overlay_active = paint_draw_tex_overlay(
+ ups, brush, vc, x, y, zoom, mode, false, false);
}
if (!(flags & PAINT_OVERLAY_OVERRIDE_CURSOR)) {
alpha_overlay_active = paint_draw_cursor_overlay(ups, brush, vc, x, y, zoom);
@@ -796,7 +805,7 @@ static bool paint_draw_alpha_overlay(UnifiedPaintSettings *ups,
}
else {
if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY) && (mode != PAINT_MODE_WEIGHT)) {
- alpha_overlay_active = paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, false, true);
+ alpha_overlay_active = paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, mode, false, true);
}
if (!(flags & PAINT_OVERLAY_OVERRIDE_CURSOR)) {
alpha_overlay_active = paint_draw_cursor_overlay(ups, brush, vc, x, y, zoom);
@@ -1030,7 +1039,7 @@ static void cursor_draw_point_screen_space(const uint gpuattr,
float translation_vertex_cursor[3], location[3];
copy_v3_v3(location, true_location);
mul_m4_v3(obmat, location);
- ED_view3d_project(region, location, translation_vertex_cursor);
+ ED_view3d_project_v3(region, location, translation_vertex_cursor);
/* Do not draw points behind the view. Z [near, far] is mapped to [-1, 1]. */
if (translation_vertex_cursor[2] <= 1.0f) {
imm_draw_circle_fill_3d(
@@ -1315,6 +1324,13 @@ static bool paint_cursor_context_init(bContext *C,
copy_v3_fl(pcontext->outline_col, 0.8f);
}
+ const bool is_brush_tool = PAINT_brush_tool_poll(C);
+ if (!is_brush_tool) {
+ /* Use a default color for tools that are not brushes. */
+ pcontext->outline_alpha = 0.8f;
+ copy_v3_fl(pcontext->outline_col, 0.8f);
+ }
+
pcontext->is_stroke_active = pcontext->ups->stroke_active;
return true;
@@ -1601,9 +1617,11 @@ static void paint_cursor_draw_3d_view_brush_cursor_inactive(PaintCursorContext *
pcontext->radius);
}
+ const bool is_brush_tool = PAINT_brush_tool_poll(pcontext->C);
+
/* Pose brush updates and rotation origins. */
- if (brush->sculpt_tool == SCULPT_TOOL_POSE) {
+ if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_POSE) {
/* Just after switching to the Pose Brush, the active vertex can be the same and the
* cursor won't be tagged to update, so always initialize the preview chain if it is
* null before drawing it. */
@@ -1636,7 +1654,7 @@ static void paint_cursor_draw_3d_view_brush_cursor_inactive(PaintCursorContext *
2);
}
- if (brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) {
+ if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) {
paint_cursor_preview_boundary_data_update(pcontext, update_previews);
paint_cursor_preview_boundary_data_pivot_draw(pcontext);
}
@@ -1657,17 +1675,18 @@ static void paint_cursor_draw_3d_view_brush_cursor_inactive(PaintCursorContext *
GPU_matrix_mul(pcontext->vc.obact->obmat);
/* Drawing Cursor overlays in 3D object space. */
- if (brush->sculpt_tool == SCULPT_TOOL_GRAB && (brush->flag & BRUSH_GRAB_ACTIVE_VERTEX)) {
+ if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_GRAB &&
+ (brush->flag & BRUSH_GRAB_ACTIVE_VERTEX)) {
SCULPT_geometry_preview_lines_update(pcontext->C, pcontext->ss, pcontext->radius);
sculpt_geometry_preview_lines_draw(
pcontext->pos, pcontext->brush, pcontext->is_multires, pcontext->ss);
}
- if (brush->sculpt_tool == SCULPT_TOOL_POSE) {
+ if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_POSE) {
paint_cursor_pose_brush_segments_draw(pcontext);
}
- if (brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) {
+ if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) {
SCULPT_boundary_edges_preview_draw(
pcontext->pos, pcontext->ss, pcontext->outline_col, pcontext->outline_alpha);
SCULPT_boundary_pivot_line_preview_draw(pcontext->pos, pcontext->ss);
@@ -1683,7 +1702,7 @@ static void paint_cursor_draw_3d_view_brush_cursor_inactive(PaintCursorContext *
paint_cursor_draw_main_inactive_cursor(pcontext);
/* Cloth brush local simulation areas. */
- if (brush->sculpt_tool == SCULPT_TOOL_CLOTH &&
+ if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_CLOTH &&
brush->cloth_simulation_area_type != BRUSH_CLOTH_SIMULATION_AREA_GLOBAL) {
const float white[3] = {1.0f, 1.0f, 1.0f};
const float zero_v[3] = {0.0f};
@@ -1695,7 +1714,7 @@ static void paint_cursor_draw_3d_view_brush_cursor_inactive(PaintCursorContext *
}
/* Layer brush height. */
- if (brush->sculpt_tool == SCULPT_TOOL_LAYER) {
+ if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_LAYER) {
SCULPT_layer_brush_height_preview_draw(pcontext->pos,
brush,
pcontext->radius,
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 530689ce049..41db79bc134 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -300,7 +300,7 @@ typedef struct ProjPaintState {
/** Calculated from screenMin & screenMax. */
float screen_width;
float screen_height;
- /** from the carea or from the projection render. */
+ /** From the area or from the projection render. */
int winx, winy;
/* options for projection painting */
@@ -5571,7 +5571,7 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po
}
if (ps->thread_tot > 1) {
- task_pool = BLI_task_pool_create_suspended(NULL, TASK_PRIORITY_HIGH);
+ task_pool = BLI_task_pool_create_suspended(NULL, TASK_PRIORITY_HIGH, TASK_ISOLATION_ON);
}
image_pool = BKE_image_pool_new();
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 3ca0d853d6a..7341d984c91 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -87,7 +87,7 @@ struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke);
void *paint_stroke_mode_data(struct PaintStroke *stroke);
float paint_stroke_distance_get(struct PaintStroke *stroke);
void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data);
-bool paint_poll(struct bContext *C);
+bool PAINT_brush_tool_poll(struct bContext *C);
void paint_cursor_start(struct Paint *p, bool (*poll)(struct bContext *C));
void paint_cursor_delete_textures(void);
@@ -304,7 +304,7 @@ bool paint_curve_poll(struct bContext *C);
bool facemask_paint_poll(struct bContext *C);
void flip_v3_v3(float out[3], const float in[3], const enum ePaintSymmetryFlags symm);
-void flip_qt_qt(float out[3], const float in[3], const enum ePaintSymmetryFlags symm);
+void flip_qt_qt(float out[4], const float in[4], const enum ePaintSymmetryFlags symm);
/* stroke operator */
typedef enum BrushStrokeMode {
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 7671f69ee05..da34723eed4 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -1239,10 +1239,9 @@ static void sculpt_gesture_apply_trim(SculptGestureContext *sgcontext)
}));
const int looptris_tot = poly_to_tri_count(bm->totface, bm->totloop);
- int tottri;
BMLoop *(*looptris)[3];
looptris = MEM_malloc_arrayN(looptris_tot, sizeof(*looptris), __func__);
- BM_mesh_calc_tessellation_beauty(bm, looptris, &tottri);
+ BM_mesh_calc_tessellation_beauty(bm, looptris);
BMIter iter;
int i;
@@ -1290,7 +1289,7 @@ static void sculpt_gesture_apply_trim(SculptGestureContext *sgcontext)
break;
}
BM_mesh_boolean(
- bm, looptris, tottri, bm_face_isect_pair, NULL, 2, true, true, false, boolean_mode);
+ bm, looptris, looptris_tot, bm_face_isect_pair, NULL, 2, true, true, false, boolean_mode);
}
MEM_freeN(looptris);
@@ -1650,7 +1649,7 @@ void PAINT_OT_mask_lasso_gesture(wmOperatorType *ot)
ot->modal = WM_gesture_lasso_modal;
ot->exec = paint_mask_gesture_lasso_exec;
- ot->poll = SCULPT_mode_poll;
+ ot->poll = SCULPT_mode_poll_view3d;
ot->flag = OPTYPE_REGISTER;
@@ -1671,7 +1670,7 @@ void PAINT_OT_mask_box_gesture(wmOperatorType *ot)
ot->modal = WM_gesture_box_modal;
ot->exec = paint_mask_gesture_box_exec;
- ot->poll = SCULPT_mode_poll;
+ ot->poll = SCULPT_mode_poll_view3d;
ot->flag = OPTYPE_REGISTER;
@@ -1692,7 +1691,7 @@ void PAINT_OT_mask_line_gesture(wmOperatorType *ot)
ot->modal = WM_gesture_straightline_oneshot_modal;
ot->exec = paint_mask_gesture_line_exec;
- ot->poll = SCULPT_mode_poll;
+ ot->poll = SCULPT_mode_poll_view3d;
ot->flag = OPTYPE_REGISTER;
@@ -1713,6 +1712,8 @@ void SCULPT_OT_face_set_lasso_gesture(wmOperatorType *ot)
ot->modal = WM_gesture_lasso_modal;
ot->exec = face_set_gesture_lasso_exec;
+ ot->poll = SCULPT_mode_poll_view3d;
+
/* Properties. */
WM_operator_properties_gesture_lasso(ot);
sculpt_gesture_operator_properties(ot);
@@ -1728,7 +1729,7 @@ void SCULPT_OT_face_set_box_gesture(wmOperatorType *ot)
ot->modal = WM_gesture_box_modal;
ot->exec = face_set_gesture_box_exec;
- ot->poll = SCULPT_mode_poll;
+ ot->poll = SCULPT_mode_poll_view3d;
ot->flag = OPTYPE_REGISTER;
@@ -1747,7 +1748,7 @@ void SCULPT_OT_trim_lasso_gesture(wmOperatorType *ot)
ot->modal = WM_gesture_lasso_modal;
ot->exec = sculpt_trim_gesture_lasso_exec;
- ot->poll = SCULPT_mode_poll;
+ ot->poll = SCULPT_mode_poll_view3d;
ot->flag = OPTYPE_REGISTER;
@@ -1768,7 +1769,7 @@ void SCULPT_OT_trim_box_gesture(wmOperatorType *ot)
ot->modal = WM_gesture_box_modal;
ot->exec = sculpt_trim_gesture_box_exec;
- ot->poll = SCULPT_mode_poll;
+ ot->poll = SCULPT_mode_poll_view3d;
ot->flag = OPTYPE_REGISTER;
@@ -1789,7 +1790,7 @@ void SCULPT_OT_project_line_gesture(wmOperatorType *ot)
ot->modal = WM_gesture_straightline_oneshot_modal;
ot->exec = project_gesture_line_exec;
- ot->poll = SCULPT_mode_poll;
+ ot->poll = SCULPT_mode_poll_view3d;
ot->flag = OPTYPE_REGISTER;
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index e1dc8fa30b9..fed89e02e8f 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -139,13 +139,14 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Paint *paint = BKE_paint_get_active_from_context(C);
Brush *brush = BKE_paint_brush(paint);
+ const bool is_gpencil = (brush && brush->gpencil_settings != NULL);
// Object *ob = CTX_data_active_object(C);
float scalar = RNA_float_get(op->ptr, "scalar");
if (brush) {
/* pixel radius */
{
- const int old_size = BKE_brush_size_get(scene, brush);
+ const int old_size = (!is_gpencil) ? BKE_brush_size_get(scene, brush) : brush->size;
int size = (int)(scalar * old_size);
if (abs(old_size - size) < U.pixelsize) {
@@ -156,6 +157,12 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op)
size -= U.pixelsize;
}
}
+ /* Grease Pencil does not use unified size. */
+ if (is_gpencil) {
+ brush->size = max_ii(size, 1);
+ WM_main_add_notifier(NC_BRUSH | NA_EDITED, brush);
+ return OPERATOR_FINISHED;
+ }
BKE_brush_size_set(scene, brush, size);
}
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 57b1102219e..59a5ad63f0e 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -846,7 +846,7 @@ static int paint_space_stroke(bContext *C,
while (length > 0.0f) {
float spacing = paint_space_stroke_spacing_variable(
C, scene, stroke, pressure, dpressure, length);
- float mouse[3];
+ float mouse[2];
if (length >= spacing) {
if (use_scene_spacing) {
@@ -856,7 +856,7 @@ static int paint_space_stroke(bContext *C,
add_v3_v3v3(final_world_space_position,
stroke->last_world_space_position,
final_world_space_position);
- ED_view3d_project(region, final_world_space_position, mouse);
+ ED_view3d_project_v2(region, final_world_space_position, mouse);
}
else {
mouse[0] = stroke->last_mouse_position[0] + dmouse[0] * spacing;
@@ -1184,14 +1184,43 @@ static void paint_line_strokes_spacing(bContext *C,
const float new_pos[2])
{
UnifiedPaintSettings *ups = stroke->ups;
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ Brush *brush = BKE_paint_brush(paint);
+ ePaintMode mode = BKE_paintmode_get_active_from_context(C);
+ ARegion *region = CTX_wm_region(C);
+
+ const bool use_scene_spacing = paint_stroke_use_scene_spacing(brush, mode);
float mouse[2], dmouse[2];
float length;
+ float d_world_space_position[3] = {0.0f};
+ float world_space_position_old[3], world_space_position_new[3];
- sub_v2_v2v2(dmouse, new_pos, old_pos);
copy_v2_v2(stroke->last_mouse_position, old_pos);
- length = normalize_v2(dmouse);
+ if (use_scene_spacing) {
+ bool hit_old = SCULPT_stroke_get_location(C, world_space_position_old, old_pos);
+ bool hit_new = SCULPT_stroke_get_location(C, world_space_position_new, new_pos);
+ mul_m4_v3(stroke->vc.obact->obmat, world_space_position_old);
+ mul_m4_v3(stroke->vc.obact->obmat, world_space_position_new);
+ if (hit_old && hit_new && stroke->stroke_over_mesh) {
+ sub_v3_v3v3(d_world_space_position, world_space_position_new, world_space_position_old);
+ length = len_v3(d_world_space_position);
+ stroke->stroke_over_mesh = true;
+ }
+ else {
+ length = 0.0f;
+ zero_v3(d_world_space_position);
+ stroke->stroke_over_mesh = hit_new;
+ if (stroke->stroke_over_mesh) {
+ copy_v3_v3(stroke->last_world_space_position, world_space_position_old);
+ }
+ }
+ }
+ else {
+ sub_v2_v2v2(dmouse, new_pos, old_pos);
+ length = normalize_v2(dmouse);
+ }
BLI_assert(length >= 0.0f);
@@ -1205,8 +1234,18 @@ static void paint_line_strokes_spacing(bContext *C,
*length_residue = 0.0;
if (length >= spacing) {
- mouse[0] = stroke->last_mouse_position[0] + dmouse[0] * spacing_final;
- mouse[1] = stroke->last_mouse_position[1] + dmouse[1] * spacing_final;
+ if (use_scene_spacing) {
+ float final_world_space_position[3];
+ normalize_v3(d_world_space_position);
+ mul_v3_v3fl(final_world_space_position, d_world_space_position, spacing_final);
+ add_v3_v3v3(
+ final_world_space_position, world_space_position_old, final_world_space_position);
+ ED_view3d_project_v2(region, final_world_space_position, mouse);
+ }
+ else {
+ mouse[0] = stroke->last_mouse_position[0] + dmouse[0] * spacing_final;
+ mouse[1] = stroke->last_mouse_position[1] + dmouse[1] * spacing_final;
+ }
ups->overlap_factor = paint_stroke_integrate_overlap(stroke->brush, 1.0);
@@ -1302,6 +1341,13 @@ static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *str
if (!stroke->stroke_started) {
stroke->last_pressure = 1.0;
copy_v2_v2(stroke->last_mouse_position, data + 2 * j);
+
+ if (paint_stroke_use_scene_spacing(br, BKE_paintmode_get_active_from_context(C))) {
+ stroke->stroke_over_mesh = SCULPT_stroke_get_location(
+ C, stroke->last_world_space_position, data + 2 * j);
+ mul_m4_v3(stroke->vc.obact->obmat, stroke->last_world_space_position);
+ }
+
stroke->stroke_started = stroke->test_start(C, op, stroke->last_mouse_position);
if (stroke->stroke_started) {
@@ -1416,7 +1462,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (paint_supports_smooth_stroke(br, mode)) {
stroke->stroke_cursor = WM_paint_cursor_activate(
- SPACE_TYPE_ANY, RGN_TYPE_ANY, paint_poll, paint_draw_smooth_cursor, stroke);
+ SPACE_TYPE_ANY, RGN_TYPE_ANY, PAINT_brush_tool_poll, paint_draw_smooth_cursor, stroke);
}
stroke->stroke_init = true;
@@ -1443,7 +1489,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (br->flag & BRUSH_LINE) {
stroke->stroke_cursor = WM_paint_cursor_activate(
- SPACE_TYPE_ANY, RGN_TYPE_ANY, paint_poll, paint_draw_line_cursor, stroke);
+ SPACE_TYPE_ANY, RGN_TYPE_ANY, PAINT_brush_tool_poll, paint_draw_line_cursor, stroke);
}
first_dab = true;
@@ -1613,7 +1659,7 @@ void paint_stroke_set_mode_data(PaintStroke *stroke, void *mode_data)
stroke->mode_data = mode_data;
}
-bool paint_poll(bContext *C)
+bool PAINT_brush_tool_poll(bContext *C)
{
Paint *p = BKE_paint_get_active_from_context(C);
Object *ob = CTX_data_active_object(C);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index fc52f6fea7c..daccc6f228a 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -769,8 +769,8 @@ static void do_weight_paint_vertex_single(
MDeformVert *dv_mirr;
MDeformWeight *dw_mirr;
- /* from now on we can check if mirrors enabled if this var is -1 and not bother with the flag */
- if (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) {
+ /* Check if we should mirror vertex groups (X-axis). */
+ if (ME_USING_MIRROR_X_VERTEX_GROUPS(me)) {
index_mirr = mesh_get_x_mirror_vert(ob, NULL, index, topology);
vgroup_mirr = wpi->mirror.index;
@@ -979,8 +979,8 @@ static void do_weight_paint_vertex_multi(
float curw, curw_real, oldw, neww, change, curw_mirr, change_mirr;
float dw_rel_free, dw_rel_locked;
- /* from now on we can check if mirrors enabled if this var is -1 and not bother with the flag */
- if (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) {
+ /* Check if we should mirror vertex groups (X-axis). */
+ if (ME_USING_MIRROR_X_VERTEX_GROUPS(me)) {
index_mirr = mesh_get_x_mirror_vert(ob, NULL, index, topology);
if (!ELEM(index_mirr, -1, index)) {
@@ -1629,7 +1629,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo
int i;
bDeformGroup *dg;
- if (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) {
+ if (ME_USING_MIRROR_X_VERTEX_GROUPS(me)) {
BKE_object_defgroup_mirror_selection(
ob, defbase_tot, defbase_sel, defbase_sel, &defbase_tot_sel);
}
@@ -2191,7 +2191,7 @@ static void wpaint_paint_leaves(bContext *C,
/* NOTE: current mirroring code cannot be run in parallel */
TaskParallelSettings settings;
- const bool use_threading = ((me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) == 0);
+ const bool use_threading = !ME_USING_MIRROR_X_VERTEX_GROUPS(me);
BKE_pbvh_parallel_range_settings(&settings, use_threading, totnode);
switch ((eBrushWeightPaintTool)brush->weightpaint_tool) {
@@ -2322,6 +2322,13 @@ static void wpaint_do_symmetrical_brush_actions(
cache->symmetry = symm;
+ if (me->editflag & ME_EDIT_MIRROR_VERTEX_GROUPS) {
+ /* We don't do any symmetry strokes when mirroring vertex groups. */
+ copy_v3_v3(cache->true_last_location, cache->true_location);
+ cache->is_last_valid = true;
+ return;
+ }
+
/* symm is a bit combination of XYZ - 1 is mirror
* X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
for (i = 1; i <= symm; i++) {
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
index 8277b485578..0fafd3589fe 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -235,7 +235,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *even
vc.obact, defbase_tot, &defbase_tot_sel);
if (defbase_tot_sel > 1) {
- if (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) {
+ if (ME_USING_MIRROR_X_VERTEX_GROUPS(me)) {
BKE_object_defgroup_mirror_selection(
vc.obact, defbase_tot, defbase_sel, defbase_sel, &defbase_tot_sel);
}
@@ -461,7 +461,7 @@ static bool weight_paint_set(Object *ob, float paintweight)
vgroup_active = ob->actdef - 1;
/* if mirror painting, find the other group */
- if (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) {
+ if (ME_USING_MIRROR_X_VERTEX_GROUPS(me)) {
vgroup_mirror = ED_wpaint_mirror_vgroup_ensure(ob, vgroup_active);
}
@@ -489,7 +489,8 @@ static bool weight_paint_set(Object *ob, float paintweight)
dw_prev->weight = dw->weight; /* set the undo weight */
dw->weight = paintweight;
- if (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) { /* x mirror painting */
+ if (me->symmetry & ME_SYMMETRY_X) {
+ /* x mirror painting */
int j = mesh_get_x_mirror_vert(ob, NULL, vidx, topology);
if (j >= 0) {
/* copy, not paint again */
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
index a8ba87ac483..d6a118bbd59 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
@@ -118,7 +118,7 @@ bool ED_wpaint_ensure_data(bContext *C,
}
if (flag & WPAINT_ENSURE_MIRROR) {
- if (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) {
+ if (ME_USING_MIRROR_X_VERTEX_GROUPS(me)) {
int mirror = ED_wpaint_mirror_vgroup_ensure(ob, ob->actdef - 1);
if (vgroup_index) {
vgroup_index->mirror = mirror;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 964e5bdaa90..d6d54a1985d 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -780,6 +780,10 @@ static void sculpt_vertex_neighbors_get_faces(SculptSession *ss,
iter->neighbors = iter->neighbors_fixed;
for (int i = 0; i < ss->pmap[index].count; i++) {
+ if (ss->face_sets[vert_map->indices[i]] < 0) {
+ /* Skip connectivity from hidden faces. */
+ continue;
+ }
const MPoly *p = &ss->mpoly[vert_map->indices[i]];
uint f_adj_v[2];
if (poly_get_adj_loops_from_vert(p, ss->mloop, index, f_adj_v) != -1) {
@@ -1850,7 +1854,7 @@ static void flip_v3(float v[3], const ePaintSymmetryFlags symm)
flip_v3_v3(v, v, symm);
}
-static void flip_qt(float quat[3], const ePaintSymmetryFlags symm)
+static void flip_qt(float quat[4], const ePaintSymmetryFlags symm)
{
flip_qt_qt(quat, quat, symm);
}
@@ -4192,7 +4196,7 @@ void SCULPT_flip_v3_by_symm_area(float v[3],
}
}
-void SCULPT_flip_quat_by_symm_area(float quat[3],
+void SCULPT_flip_quat_by_symm_area(float quat[4],
const ePaintSymmetryFlags symm,
const ePaintSymmetryAreas symmarea,
const float pivot[3])
@@ -6602,7 +6606,7 @@ bool SCULPT_poll_view3d(bContext *C)
bool SCULPT_poll(bContext *C)
{
- return SCULPT_mode_poll(C) && paint_poll(C);
+ return SCULPT_mode_poll(C) && PAINT_brush_tool_poll(C);
}
static const char *sculpt_tool_name(Sculpt *sd)
diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c b/source/blender/editors/sculpt_paint/sculpt_expand.c
index 8b8ed42a694..40874375772 100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.c
@@ -273,7 +273,7 @@ static bool sculpt_expand_state_get(SculptSession *ss, ExpandCache *expand_cache
*/
static bool sculpt_expand_face_state_get(SculptSession *ss, ExpandCache *expand_cache, const int f)
{
- if (ss->face_sets[f] <= 0) {
+ if (expand_cache->original_face_sets[f] <= 0) {
return false;
}
@@ -1398,6 +1398,13 @@ static void sculpt_expand_face_sets_restore(SculptSession *ss, ExpandCache *expa
{
const int totfaces = ss->totfaces;
for (int i = 0; i < totfaces; i++) {
+ if (expand_cache->original_face_sets[i] <= 0) {
+ /* Do not modify hidden Face Sets, even when restoring the IDs state. */
+ continue;
+ }
+ if (!sculpt_expand_is_face_in_active_component(ss, expand_cache, i)) {
+ continue;
+ }
ss->face_sets[i] = expand_cache->initial_face_sets[i];
}
}
@@ -1892,13 +1899,22 @@ static int sculpt_expand_modal(bContext *C, wmOperator *op, const wmEvent *event
* The faces that were using the `delete_id` Face Set are filled
* using the content from their neighbors.
*/
-static void sculpt_expand_delete_face_set_id(
- int *r_face_sets, Mesh *mesh, MeshElemMap *pmap, const int totface, const int delete_id)
+static void sculpt_expand_delete_face_set_id(int *r_face_sets,
+ SculptSession *ss,
+ ExpandCache *expand_cache,
+ Mesh *mesh,
+ const int delete_id)
{
+ const int totface = ss->totfaces;
+ MeshElemMap *pmap = ss->pmap;
+
/* Check that all the face sets IDs in the mesh are not equal to `delete_id`
* before attempting to delete it. */
bool all_same_id = true;
for (int i = 0; i < totface; i++) {
+ if (!sculpt_expand_is_face_in_active_component(ss, expand_cache, i)) {
+ continue;
+ }
if (r_face_sets[i] != delete_id) {
all_same_id = false;
break;
@@ -1921,6 +1937,7 @@ static void sculpt_expand_delete_face_set_id(
}
while (BLI_LINKSTACK_SIZE(queue)) {
+ bool any_updated = false;
while (BLI_LINKSTACK_SIZE(queue)) {
const int f_index = POINTER_AS_INT(BLI_LINKSTACK_POP(queue));
int other_id = delete_id;
@@ -1931,6 +1948,10 @@ static void sculpt_expand_delete_face_set_id(
for (int i = 0; i < vert_map->count; i++) {
const int neighbor_face_index = vert_map->indices[i];
+ if (expand_cache->original_face_sets[neighbor_face_index] <= 0) {
+ /* Skip picking IDs from hidden Face Sets. */
+ continue;
+ }
if (r_face_sets[neighbor_face_index] != delete_id) {
other_id = r_face_sets[neighbor_face_index];
}
@@ -1938,18 +1959,36 @@ static void sculpt_expand_delete_face_set_id(
}
if (other_id != delete_id) {
+ any_updated = true;
r_face_sets[f_index] = other_id;
}
else {
BLI_LINKSTACK_PUSH(queue_next, POINTER_FROM_INT(f_index));
}
}
+ if (!any_updated) {
+ /* No Face Sets where updated in this iteration, which means that no more content to keep
+ * filling the polys of the deleted Face Set was found. Break to avoid entering an infinite
+ * loop trying to search for those polys again. */
+ break;
+ }
BLI_LINKSTACK_SWAP(queue, queue_next);
}
BLI_LINKSTACK_FREE(queue);
BLI_LINKSTACK_FREE(queue_next);
+
+ /* Ensure that the visibility state of the modified Face Sets is the same as the original ones.
+ */
+ for (int i = 0; i < totface; i++) {
+ if (expand_cache->original_face_sets[i] >= 0) {
+ r_face_sets[i] = abs(r_face_sets[i]);
+ }
+ else {
+ r_face_sets[i] = -abs(r_face_sets[i]);
+ }
+ }
}
static void sculpt_expand_cache_initial_config_set(bContext *C,
@@ -2070,9 +2109,9 @@ static int sculpt_expand_invoke(bContext *C, wmOperator *op, const wmEvent *even
if (ss->expand_cache->modify_active_face_set) {
sculpt_expand_delete_face_set_id(ss->expand_cache->initial_face_sets,
+ ss,
+ ss->expand_cache,
ob->data,
- ss->pmap,
- ss->totfaces,
ss->expand_cache->next_face_set);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c
index 17c4beab086..bdbdb75732a 100644
--- a/source/blender/editors/sculpt_paint/sculpt_face_set.c
+++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c
@@ -949,10 +949,6 @@ static int sculpt_face_sets_change_visibility_exec(bContext *C, wmOperator *op)
MEM_SAFE_FREE(nodes);
- if (BKE_pbvh_type(pbvh) == PBVH_FACES) {
- BKE_mesh_flush_hidden_from_verts(ob->data);
- }
-
SCULPT_tag_update_overlays(C);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 087cb6dd94a..e2ee4c9fed3 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -278,7 +278,7 @@ void SCULPT_flip_v3_by_symm_area(float v[3],
const ePaintSymmetryFlags symm,
const ePaintSymmetryAreas symmarea,
const float pivot[3]);
-void SCULPT_flip_quat_by_symm_area(float quat[3],
+void SCULPT_flip_quat_by_symm_area(float quat[4],
const ePaintSymmetryFlags symm,
const ePaintSymmetryAreas symmarea,
const float pivot[3]);
diff --git a/source/blender/editors/sculpt_paint/sculpt_pose.c b/source/blender/editors/sculpt_paint/sculpt_pose.c
index 4d2a1bf13dc..587ce346428 100644
--- a/source/blender/editors/sculpt_paint/sculpt_pose.c
+++ b/source/blender/editors/sculpt_paint/sculpt_pose.c
@@ -197,8 +197,9 @@ static void do_pose_brush_task_cb_ex(void *__restrict userdata,
mul_v3_fl(disp, segments[ik].weights[vd.index]);
/* Apply the vertex mask to the displacement. */
- float mask = vd.mask ? *vd.mask : 0.0f;
- mul_v3_fl(disp, 1.0f - mask);
+ const float mask = vd.mask ? 1.0f - *vd.mask : 1.0f;
+ const float automask = SCULPT_automasking_factor_get(ss->cache->automasking, ss, vd.index);
+ mul_v3_fl(disp, mask * automask);
/* Accumulate the displacement. */
add_v3_v3(total_disp, disp);
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index b6205db6f45..71166b7c20c 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -1189,9 +1189,7 @@ static SculptUndoNode *sculpt_undo_geometry_push(Object *object, SculptUndoType
static SculptUndoNode *sculpt_undo_face_sets_push(Object *ob, SculptUndoType type)
{
UndoSculpt *usculpt = sculpt_undo_get_nodes();
- SculptUndoNode *unode = usculpt->nodes.first;
-
- unode = MEM_callocN(sizeof(*unode), __func__);
+ SculptUndoNode *unode = MEM_callocN(sizeof(*unode), __func__);
BLI_strncpy(unode->idname, ob->id.name, sizeof(unode->idname));
unode->type = type;