Merge branch 'blender-v4.5-release'

This commit is contained in:
Falk David
2025-06-10 15:46:46 +02:00
3 changed files with 26 additions and 22 deletions

View File

@@ -1303,6 +1303,17 @@ IndexMask retrieve_editable_and_selected_elements(Object &object,
return {};
}
bool has_editable_layer(const GreasePencil &grease_pencil)
{
using namespace blender::bke::greasepencil;
for (const Layer *layer : grease_pencil.layers()) {
if (layer->is_editable()) {
return true;
}
}
return false;
}
Array<PointTransferData> compute_topology_change(
const bke::CurvesGeometry &src,
bke::CurvesGeometry &dst,

View File

@@ -432,6 +432,7 @@ IndexMask retrieve_editable_and_selected_elements(Object &object,
int layer_index,
bke::AttrDomain selection_domain,
IndexMaskMemory &memory);
bool has_editable_layer(const GreasePencil &grease_pencil);
void create_blank(Main &bmain, Object &object, int frame_number);
void create_stroke(Main &bmain, Object &object, const float4x4 &matrix, int frame_number);

View File

@@ -350,8 +350,8 @@ static wmOperatorStatus grease_pencil_sculpt_paint_invoke(bContext *C,
}
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
if (!grease_pencil.has_active_layer()) {
BKE_report(op->reports, RPT_ERROR, "No active Grease Pencil layer");
if (!ed::greasepencil::has_editable_layer(grease_pencil)) {
BKE_report(op->reports, RPT_ERROR, "No editable Grease Pencil layer");
return OPERATOR_CANCELLED;
}
@@ -361,12 +361,6 @@ static wmOperatorStatus grease_pencil_sculpt_paint_invoke(bContext *C,
return OPERATOR_CANCELLED;
}
bke::greasepencil::Layer &active_layer = *grease_pencil.get_active_layer();
if (!active_layer.is_editable()) {
BKE_report(op->reports, RPT_ERROR, "Active layer is locked or hidden");
return OPERATOR_CANCELLED;
}
/* Ensure a drawing at the current keyframe. */
bool inserted_keyframe = false;
/* For the sculpt tools, we don't want the auto-key to create an empty keyframe, so we duplicate
@@ -557,14 +551,8 @@ static wmOperatorStatus grease_pencil_vertex_brush_stroke_invoke(bContext *C,
}
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
if (!grease_pencil.has_active_layer()) {
BKE_report(op->reports, RPT_ERROR, "No active Grease Pencil layer");
return OPERATOR_CANCELLED;
}
bke::greasepencil::Layer &active_layer = *grease_pencil.get_active_layer();
if (!active_layer.is_editable()) {
BKE_report(op->reports, RPT_ERROR, "Active layer is locked or hidden");
if (!ed::greasepencil::has_editable_layer(grease_pencil)) {
BKE_report(op->reports, RPT_ERROR, "No editable Grease Pencil layer");
return OPERATOR_CANCELLED;
}
@@ -579,15 +567,19 @@ static wmOperatorStatus grease_pencil_vertex_brush_stroke_invoke(bContext *C,
/* For the vertex paint tools, we don't want the auto-key to create an empty keyframe, so we
* duplicate the previous key. */
const bool use_duplicate_previous_key = true;
if (!ed::greasepencil::ensure_active_keyframe(
*scene, grease_pencil, active_layer, use_duplicate_previous_key, inserted_keyframe))
{
for (bke::greasepencil::Layer *layer : grease_pencil.layers_for_write()) {
if (layer->is_editable() &&
ed::greasepencil::ensure_active_keyframe(
*scene, grease_pencil, *layer, use_duplicate_previous_key, inserted_keyframe))
{
inserted_keyframe = true;
}
}
if (!inserted_keyframe) {
BKE_report(op->reports, RPT_ERROR, "No Grease Pencil frame to draw on");
return OPERATOR_CANCELLED;
}
if (inserted_keyframe) {
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, nullptr);
}
WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, nullptr);
op->customdata = paint_stroke_new(C,
op,