Sculpt: Disable set pivot and select color for invisible objects

This PR disables the `SCULPT_OT_sample_color` and `SCULPT_OT_set_pivot_position` operators and the following actions that correspond to them when attempting to operate on invisible objects:
* Set Pivot
* Sample Color

| Set Pivot | Sample Color |
| --- | --- |
| ![invisible_set_pivot.gif](/attachments/0dd23857-abdf-4214-a08d-ce986f15e16f) | ![invisible_set_color.gif](/attachments/84950810-1c3d-4f02-8e84-67425d80754d) |

### Limitations
* All of the operators invoked by a menu option do not indicate to the user that they are currently invalid or will not operate due to the mesh being invisible, potentially leading to a confusing user experience.

Addresses part of #112371

Pull Request: https://projects.blender.org/blender/blender/pulls/118306
This commit is contained in:
Sean Kim
2024-02-15 16:30:31 +01:00
committed by Raul Fernandez Hernandez
parent 1e3e5c5ac2
commit a2f49b05f8
2 changed files with 13 additions and 0 deletions

View File

@@ -640,6 +640,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. */

View File

@@ -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"
@@ -387,6 +388,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. */