diff --git a/source/blender/editors/sculpt_paint/paint_mask.cc b/source/blender/editors/sculpt_paint/paint_mask.cc index 9bed9f898e8..9f34764777d 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.cc +++ b/source/blender/editors/sculpt_paint/paint_mask.cc @@ -2024,6 +2024,17 @@ static int paint_mask_gesture_line_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int face_set_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event) +{ + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + + return WM_gesture_box_invoke(C, op, event); +} + static int face_set_gesture_box_exec(bContext *C, wmOperator *op) { SculptGestureContext *sgcontext = sculpt_gesture_init_from_box(C, op); @@ -2036,6 +2047,17 @@ static int face_set_gesture_box_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int face_set_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event) +{ + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + + return WM_gesture_lasso_invoke(C, op, event); +} + static int face_set_gesture_lasso_exec(bContext *C, wmOperator *op) { SculptGestureContext *sgcontext = sculpt_gesture_init_from_lasso(C, op); @@ -2228,7 +2250,7 @@ void SCULPT_OT_face_set_lasso_gesture(wmOperatorType *ot) ot->idname = "SCULPT_OT_face_set_lasso_gesture"; ot->description = "Add face set within the lasso as you move the brush"; - ot->invoke = WM_gesture_lasso_invoke; + ot->invoke = face_set_gesture_lasso_invoke; ot->modal = WM_gesture_lasso_modal; ot->exec = face_set_gesture_lasso_exec; @@ -2247,7 +2269,7 @@ void SCULPT_OT_face_set_box_gesture(wmOperatorType *ot) ot->idname = "SCULPT_OT_face_set_box_gesture"; ot->description = "Add face set within the box as you move the brush"; - ot->invoke = WM_gesture_box_invoke; + ot->invoke = face_set_gesture_box_invoke; ot->modal = WM_gesture_box_modal; ot->exec = face_set_gesture_box_exec; diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.cc b/source/blender/editors/sculpt_paint/sculpt_cloth.cc index 77baeb354c6..052319187fe 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.cc +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.cc @@ -25,6 +25,7 @@ #include "BKE_collision.h" #include "BKE_colortools.hh" #include "BKE_context.hh" +#include "BKE_layer.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_paint.hh" @@ -1530,6 +1531,12 @@ static int sculpt_cloth_filter_invoke(bContext *C, wmOperator *op, const wmEvent Sculpt *sd = CTX_data_tool_settings(C)->sculpt; SculptSession *ss = ob->sculpt; + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + const eSculptClothFilterType filter_type = eSculptClothFilterType(RNA_enum_get(op->ptr, "type")); /* Update the active vertex */ diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index 629a4be41ef..96566d81ea3 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -37,6 +37,7 @@ #include "BKE_colortools.hh" #include "BKE_context.hh" #include "BKE_customdata.hh" +#include "BKE_layer.hh" #include "BKE_mesh.hh" #include "BKE_mesh_fair.hh" #include "BKE_mesh_mapping.hh" @@ -557,6 +558,12 @@ static int sculpt_face_set_create_exec(bContext *C, wmOperator *op) const CreateMode mode = CreateMode(RNA_enum_get(op->ptr, "mode")); + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + if (BKE_pbvh_type(ss.pbvh) == PBVH_BMESH) { /* Dyntopo not supported. */ return OPERATOR_CANCELLED; @@ -780,6 +787,12 @@ static int sculpt_face_set_init_exec(bContext *C, wmOperator *op) const InitMode mode = InitMode(RNA_enum_get(op->ptr, "mode")); + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + BKE_sculpt_update_object_for_edit(depsgraph, ob, false); /* Dyntopo not supported. */ @@ -1126,6 +1139,12 @@ static int sculpt_face_set_change_visibility_invoke(bContext *C, Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + /* Update the active vertex and Face Set using the cursor position to avoid relying on the paint * cursor updates. */ SculptCursorGeometryInfo sgi; @@ -1174,6 +1193,12 @@ static int sculpt_face_sets_randomize_colors_exec(bContext *C, wmOperator * /*op Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + /* Dyntopo not supported. */ if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) { return OPERATOR_CANCELLED; @@ -1546,6 +1571,12 @@ static int sculpt_face_set_edit_invoke(bContext *C, wmOperator *op, const wmEven Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + BKE_sculpt_update_object_for_edit(depsgraph, ob, false); /* Update the current active Face Set and Vertex as the operator can be used directly from the diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_color.cc b/source/blender/editors/sculpt_paint/sculpt_filter_color.cc index 2d6c0285f45..9876e011184 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_color.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_color.cc @@ -18,6 +18,7 @@ #include "DNA_userdef_types.h" #include "BKE_context.hh" +#include "BKE_layer.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" @@ -330,6 +331,11 @@ static int sculpt_color_filter_init(bContext *C, wmOperator *op) SculptSession *ss = ob->sculpt; View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + int mval[2]; RNA_int_get_array(op->ptr, "start_mouse", mval); float mval_fl[2] = {float(mval[0]), float(mval[1])}; diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mask.cc b/source/blender/editors/sculpt_paint/sculpt_filter_mask.cc index 143c72e109f..d9e3d9f7ba3 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mask.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mask.cc @@ -11,6 +11,7 @@ #include "BLI_task.h" #include "BKE_context.hh" +#include "BKE_layer.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" @@ -160,6 +161,12 @@ static int sculpt_mask_filter_exec(bContext *C, wmOperator *op) const Scene *scene = CTX_data_scene(C); int filter_type = RNA_enum_get(op->ptr, "filter_type"); + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob); BKE_sculpt_mask_layers_ensure(CTX_data_depsgraph_pointer(C), CTX_data_main(C), ob, mmd); diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc index cc0adff706e..a4d5e7308fc 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc @@ -24,6 +24,8 @@ #include "BKE_brush.hh" #include "BKE_context.hh" +#include "BKE_layer.hh" +#include "BKE_modifier.hh" #include "BKE_object_types.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" @@ -948,6 +950,13 @@ static int sculpt_mesh_filter_start(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + int mval[2]; RNA_int_get_array(op->ptr, "start_mouse", mval); diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_init.cc b/source/blender/editors/sculpt_paint/sculpt_mask_init.cc index 0d80b2f1205..0efd49e3877 100644 --- a/source/blender/editors/sculpt_paint/sculpt_mask_init.cc +++ b/source/blender/editors/sculpt_paint/sculpt_mask_init.cc @@ -16,6 +16,7 @@ #include "BKE_ccg.h" #include "BKE_context.hh" +#include "BKE_layer.hh" #include "BKE_multires.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" @@ -80,6 +81,12 @@ static int sculpt_mask_init_exec(bContext *C, wmOperator *op) SculptSession *ss = ob->sculpt; Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + const int mode = RNA_enum_get(op->ptr, "mode"); MultiresModifierData *mmd = BKE_sculpt_multires_active(CTX_data_scene(C), ob); diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.cc b/source/blender/editors/sculpt_paint/sculpt_ops.cc index 113e67997d7..7c4366fe819 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/sculpt_ops.cc @@ -638,6 +638,12 @@ static int sculpt_sample_color_invoke(bContext *C, wmOperator *op, const wmEvent return OPERATOR_CANCELLED; } + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + BKE_sculpt_update_object_for_edit(CTX_data_depsgraph_pointer(C), ob, false); /* No color attribute? Set color to white. */ @@ -902,14 +908,19 @@ static int sculpt_mask_by_color_invoke(bContext *C, wmOperator *op, const wmEven Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; + View3D *v3d = CTX_wm_view3d(C); { - View3D *v3d = CTX_wm_view3d(C); if (v3d && v3d->shading.type == OB_SOLID) { v3d->shading.color_type = V3D_SHADING_VERTEX_COLOR; } } + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + /* Color data is not available in multi-resolution or dynamic topology. */ if (!SCULPT_handles_colors_report(ss, op->reports)) { return OPERATOR_CANCELLED; @@ -1067,6 +1078,12 @@ static int sculpt_bake_cavity_exec(bContext *C, wmOperator *op) Sculpt *sd = CTX_data_tool_settings(C)->sculpt; const Brush *brush = BKE_paint_brush(&sd->paint); + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + MultiresModifierData *mmd = BKE_sculpt_multires_active(CTX_data_scene(C), ob); BKE_sculpt_mask_layers_ensure(depsgraph, CTX_data_main(C), ob, mmd); diff --git a/source/blender/editors/sculpt_paint/sculpt_transform.cc b/source/blender/editors/sculpt_paint/sculpt_transform.cc index a0469ba689a..c61eebcaf05 100644 --- a/source/blender/editors/sculpt_paint/sculpt_transform.cc +++ b/source/blender/editors/sculpt_paint/sculpt_transform.cc @@ -16,6 +16,7 @@ #include "BKE_brush.hh" #include "BKE_context.hh" #include "BKE_kelvinlet.h" +#include "BKE_layer.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" @@ -385,6 +386,12 @@ static int sculpt_set_pivot_position_exec(bContext *C, wmOperator *op) int mode = RNA_enum_get(op->ptr, "mode"); + const View3D *v3d = CTX_wm_view3d(C); + const Base *base = CTX_data_active_base(C); + if (!BKE_base_is_visible(v3d, base)) { + return OPERATOR_CANCELLED; + } + BKE_sculpt_update_object_for_edit(depsgraph, ob, false); /* Pivot to center. */ diff --git a/source/blender/editors/transform/transform.cc b/source/blender/editors/transform/transform.cc index cc1c3c70166..9640a9e8c21 100644 --- a/source/blender/editors/transform/transform.cc +++ b/source/blender/editors/transform/transform.cc @@ -1492,7 +1492,20 @@ static void drawTransformView(const bContext * /*C*/, ARegion *region, void *arg GPU_line_width(1.0f); drawConstraint(t); - drawPropCircle(t); + + switch (t->spacetype) { + case SPACE_GRAPH: + case SPACE_ACTION: + /* Different visualization because the proportional editing in these editors only looks at + * the x-axis. */ + drawPropRange(t); + break; + + default: + drawPropCircle(t); + break; + } + drawSnapping(t); if (region == t->region && t->mode_info && t->mode_info->draw_fn) { diff --git a/source/blender/editors/transform/transform_constraints.cc b/source/blender/editors/transform/transform_constraints.cc index b9e152fd661..d124aa0bd64 100644 --- a/source/blender/editors/transform/transform_constraints.cc +++ b/source/blender/editors/transform/transform_constraints.cc @@ -904,15 +904,6 @@ void drawPropCircle(TransInfo *t) else if (t->spacetype == SPACE_IMAGE) { GPU_matrix_scale_2f(1.0f / t->aspect[0], 1.0f / t->aspect[1]); } - else if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_ACTION)) { - /* only scale y */ - float xscale, yscale; - UI_view2d_scale_get(&t->region->v2d, &xscale, &yscale); - - const float fac_scale = xscale / yscale; - GPU_matrix_scale_2f(1.0f, fac_scale); - GPU_matrix_translate_2f(0.0f, (t->center_global[1] / fac_scale) - t->center_global[1]); - } eGPUDepthTest depth_test_enabled = GPU_depth_test_get(); if (depth_test_enabled) { @@ -947,6 +938,40 @@ void drawPropCircle(TransInfo *t) } } +void drawPropRange(TransInfo *t) +{ + if ((t->flag & T_PROP_EDIT) == 0) { + return; + } + + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + + immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR); + + float viewport[4]; + GPU_viewport_size_get_f(viewport); + GPU_blend(GPU_BLEND_ALPHA); + + immUniform2fv("viewportSize", &viewport[2]); + + View2D *v2d = &t->region->v2d; + const float x1 = t->center_global[0] - t->prop_size; + const float y1 = v2d->cur.ymin; + const float x2 = t->center_global[0] + t->prop_size; + const float y2 = v2d->cur.ymax; + + immUniform1f("lineWidth", 3.0f * U.pixelsize); + immUniformThemeColorShadeAlpha(TH_GRID, -20, 255); + imm_draw_box_wire_3d(pos, x1, y1, x2, y2); + + immUniform1f("lineWidth", 1.0f * U.pixelsize); + immUniformThemeColorShadeAlpha(TH_GRID, 20, 255); + imm_draw_box_wire_3d(pos, x1, y1, x2, y2); + + immUnbindProgram(); + GPU_blend(GPU_BLEND_NONE); +} + static void drawObjectConstraint(TransInfo *t) { /* Draw the first one lighter because that's the one who controls the others. diff --git a/source/blender/editors/transform/transform_constraints.hh b/source/blender/editors/transform/transform_constraints.hh index 1dc224df693..2a55fc5487a 100644 --- a/source/blender/editors/transform/transform_constraints.hh +++ b/source/blender/editors/transform/transform_constraints.hh @@ -41,6 +41,10 @@ void drawConstraint(TransInfo *t); * Called from drawview.c, as an extra per-window draw option. */ void drawPropCircle(TransInfo *t); +/** + * Draws two lines to indicate a proportional editing range that is only defined in one axis. + */ +void drawPropRange(TransInfo *t); void startConstraint(TransInfo *t); void stopConstraint(TransInfo *t); void initSelectConstraint(TransInfo *t); diff --git a/source/blender/nodes/shader/nodes/node_shader_output_material.cc b/source/blender/nodes/shader/nodes/node_shader_output_material.cc index 7e3c0aecaf4..9cc7144f6c1 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_material.cc +++ b/source/blender/nodes/shader/nodes/node_shader_output_material.cc @@ -11,7 +11,9 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_input("Surface"); b.add_input("Volume").translation_context(BLT_I18NCONTEXT_ID_ID); b.add_input("Displacement").hide_value(); - b.add_input("Thickness").hide_value(); + b.add_input("Thickness") + .hide_value() + .unavailable() /* EEVEE-Next only. Does nothing in 4.1. */; } static int node_shader_gpu_output_material(GPUMaterial *mat,