GPv3: Lock material layer property #119913
|
@ -600,7 +600,7 @@ static int grease_pencil_dissolve_exec(bContext *C, wmOperator *op)
|
|||
|
||||
IndexMaskMemory memory;
|
||||
const IndexMask points = ed::greasepencil::retrieve_editable_and_selected_points(
|
||||
*object, info.drawing, memory);
|
||||
*object, info, memory);
|
||||
if (points.is_empty()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -306,7 +306,7 @@ static int select_ends_exec(bContext *C, wmOperator *op)
|
|||
curves, selectable_strokes, amount_start, amount_end, true, memory);
|
||||
|
||||
const IndexMask selectable_points = ed::greasepencil::retrieve_editable_points(
|
||||
*object, info.drawing, memory);
|
||||
*object, info.drawing, info.layer_index, memory);
|
||||
const bool was_anything_selected = ed::curves::has_anything_selected(curves,
|
||||
selectable_points);
|
||||
bke::GSpanAttributeWriter selection = ed::curves::ensure_selection_attribute(
|
||||
|
|
|
@ -486,6 +486,7 @@ IndexMask retrieve_editable_strokes_by_material(Object &object,
|
|||
|
||||
IndexMask retrieve_editable_points(Object &object,
|
||||
const bke::greasepencil::Drawing &drawing,
|
||||
int layer_index,
|
||||
IndexMaskMemory &memory)
|
||||
{
|
||||
/* Get all the editable material indices */
|
||||
|
@ -497,6 +498,8 @@ IndexMask retrieve_editable_points(Object &object,
|
|||
const bke::CurvesGeometry &curves = drawing.strokes();
|
||||
const IndexRange points_range = drawing.strokes().points_range();
|
||||
const bke::AttributeAccessor attributes = curves.attributes();
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object.data);
|
||||
const bke::greasepencil::Layer &layer = *grease_pencil.layers()[layer_index];
|
||||
|
||||
/* Propagate the material index to the points. */
|
||||
const VArray<int> materials = *attributes.lookup<int>("material_index", bke::AttrDomain::Point);
|
||||
|
@ -511,7 +514,8 @@ IndexMask retrieve_editable_points(Object &object,
|
|||
return IndexMask::from_predicate(
|
||||
points_range, GrainSize(4096), memory, [&](const int64_t point_i) {
|
||||
const int material_index = materials[point_i];
|
||||
return editable_material_indices.contains(material_index);
|
||||
return editable_material_indices.contains(material_index) ||
|
||||
!(layer.as_node().flag & GP_LAYER_TREE_NODE_LOCK_MATERIAL);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -526,7 +530,7 @@ IndexMask retrieve_editable_elements(Object &object,
|
|||
return ed::greasepencil::retrieve_editable_strokes(object, drawing, info.layer_index, memory);
|
||||
}
|
||||
else if (selection_domain == bke::AttrDomain::Point) {
|
||||
return ed::greasepencil::retrieve_editable_points(object, drawing, memory);
|
||||
return ed::greasepencil::retrieve_editable_points(object, drawing, info.layer_index, memory);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -581,13 +585,14 @@ IndexMask retrieve_editable_and_selected_strokes(Object &object,
|
|||
}
|
||||
|
||||
IndexMask retrieve_editable_and_selected_points(Object &object,
|
||||
const bke::greasepencil::Drawing &drawing,
|
||||
const MutableDrawingInfo &info,
|
||||
IndexMaskMemory &memory)
|
||||
{
|
||||
const bke::greasepencil::Drawing &drawing = info.drawing;
|
||||
const bke::CurvesGeometry &curves = drawing.strokes();
|
||||
const IndexRange points_range = drawing.strokes().points_range();
|
||||
|
||||
const IndexMask editable_points = retrieve_editable_points(object, drawing, memory);
|
||||
const IndexMask editable_points = retrieve_editable_points(object, drawing, info.layer_index, memory);
|
||||
const IndexMask selected_points = ed::curves::retrieve_selected_points(curves, memory);
|
||||
|
||||
BitVector<> editable_points_bits(curves.points_num(), false);
|
||||
|
@ -604,12 +609,11 @@ IndexMask retrieve_editable_and_selected_elements(Object &object,
|
|||
const bke::AttrDomain selection_domain,
|
||||
IndexMaskMemory &memory)
|
||||
{
|
||||
const bke::greasepencil::Drawing &drawing = info.drawing;
|
||||
if (selection_domain == bke::AttrDomain::Curve) {
|
||||
return ed::greasepencil::retrieve_editable_and_selected_strokes(object, info, memory);
|
||||
}
|
||||
else if (selection_domain == bke::AttrDomain::Point) {
|
||||
return ed::greasepencil::retrieve_editable_and_selected_points(object, drawing, memory);
|
||||
return ed::greasepencil::retrieve_editable_and_selected_points(object, info, memory);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -204,6 +204,7 @@ IndexMask retrieve_editable_strokes_by_material(Object &object,
|
|||
IndexMaskMemory &memory);
|
||||
IndexMask retrieve_editable_points(Object &object,
|
||||
const bke::greasepencil::Drawing &drawing,
|
||||
int layer_index,
|
||||
filedescriptor marked this conversation as resolved
Outdated
|
||||
IndexMaskMemory &memory);
|
||||
IndexMask retrieve_editable_elements(Object &object,
|
||||
const MutableDrawingInfo &info,
|
||||
|
@ -218,7 +219,7 @@ IndexMask retrieve_editable_and_selected_strokes(Object &grease_pencil_object,
|
|||
const MutableDrawingInfo &info,
|
||||
IndexMaskMemory &memory);
|
||||
IndexMask retrieve_editable_and_selected_points(Object &object,
|
||||
const bke::greasepencil::Drawing &drawing,
|
||||
const MutableDrawingInfo &info,
|
||||
IndexMaskMemory &memory);
|
||||
IndexMask retrieve_editable_and_selected_elements(Object &object,
|
||||
const MutableDrawingInfo &info,
|
||||
|
|
|
@ -55,12 +55,12 @@ static void createTransGreasePencilVerts(bContext *C, TransInfo *t)
|
|||
for (ed::greasepencil::MutableDrawingInfo info : drawings) {
|
||||
if (use_proportional_edit) {
|
||||
points_per_layer_per_object[layer_offset] = ed::greasepencil::retrieve_editable_points(
|
||||
*object, info.drawing, memory);
|
||||
*object, info.drawing, info.layer_index, memory);
|
||||
tc.data_len += points_per_layer_per_object[layer_offset].size();
|
||||
}
|
||||
else {
|
||||
points_per_layer_per_object[layer_offset] =
|
||||
ed::greasepencil::retrieve_editable_and_selected_points(*object, info.drawing, memory);
|
||||
ed::greasepencil::retrieve_editable_and_selected_points(*object, info, memory);
|
||||
tc.data_len += points_per_layer_per_object[layer_offset].size();
|
||||
}
|
||||
|
||||
|
|
|
@ -474,7 +474,7 @@ static void rna_def_grease_pencil_layer(BlenderRNA *brna)
|
|||
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_grease_pencil_update");
|
||||
|
||||
prop = RNA_def_property(srna, "lock_material", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(
|
||||
RNA_def_property_boolean_negative_sdna(
|
||||
filedescriptor marked this conversation as resolved
Outdated
Falk David
commented
Seems incorrect to use Seems incorrect to use `RNA_def_property_boolean_negative_sdna` for `GP_LAYER_TREE_NODE_LOCK_MATERIAL` when the property is also `lock_material`
Pratik Borhade
commented
Thanks for the review. Done, renamed the property/flag. Now by default this property will be off for each layer. Thanks for the review. Done, renamed the property/flag. Now by default this property will be off for each layer.
|
||||
prop, "GreasePencilLayerTreeNode", "flag", GP_LAYER_TREE_NODE_LOCK_MATERIAL);
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_ui_text(
|
||||
|
|
Loading…
Reference in New Issue
This should be
const bke::greasepencil::Layer &layer
instead.