diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc index 26bc0f0fbf6..2bf2e69222a 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc @@ -301,14 +301,16 @@ Array retrieve_visible_drawings(const Scene &scene, const GreasePen return visible_drawings.as_span(); } -static VectorSet get_locked_material_indices(Object &object) +static VectorSet get_editable_material_indices(Object &object) { BLI_assert(object.type == OB_GREASE_PENCIL); VectorSet locked_material_indices; for (const int mat_i : IndexRange(object.totcol)) { Material *material = BKE_object_material_get(&object, mat_i + 1); + /* The editable materials are unlocked and not hidden. */ if (material != nullptr && material->gp_style != nullptr && - (material->gp_style->flag & GP_MATERIAL_LOCKED) != 0) + (material->gp_style->flag & GP_MATERIAL_LOCKED) == 0 && + (material->gp_style->flag & GP_MATERIAL_HIDE) == 0) { locked_material_indices.add(mat_i); } @@ -322,8 +324,8 @@ IndexMask retrieve_editable_strokes(Object &object, { using namespace blender; - /* Get all the locked material indices */ - VectorSet locked_material_indices = get_locked_material_indices(object); + /* Get all the editable material indices */ + VectorSet editable_material_indices = get_editable_material_indices(object); const bke::CurvesGeometry &curves = drawing.strokes(); const IndexRange curves_range = drawing.strokes().curves_range(); @@ -335,7 +337,7 @@ IndexMask retrieve_editable_strokes(Object &object, return IndexMask::from_predicate( curves_range, GrainSize(4096), memory, [&](const int64_t curve_i) { const int material_index = materials[curve_i]; - return !locked_material_indices.contains(material_index); + return editable_material_indices.contains(material_index); }); } @@ -343,8 +345,8 @@ IndexMask retrieve_editable_points(Object &object, const bke::greasepencil::Drawing &drawing, IndexMaskMemory &memory) { - /* Get all the locked material indices */ - VectorSet locked_material_indices = get_locked_material_indices(object); + /* Get all the editable material indices */ + VectorSet editable_material_indices = get_editable_material_indices(object); const bke::CurvesGeometry &curves = drawing.strokes(); const IndexRange points_range = drawing.strokes().points_range(); @@ -357,7 +359,7 @@ 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 !locked_material_indices.contains(material_index); + return editable_material_indices.contains(material_index); }); } @@ -381,9 +383,6 @@ IndexMask retrieve_editable_and_selected_strokes(Object &object, { using namespace blender; - /* Get all the locked material indices */ - VectorSet locked_material_indices = get_locked_material_indices(object); - const bke::CurvesGeometry &curves = drawing.strokes(); const IndexRange curves_range = drawing.strokes().curves_range(); @@ -403,9 +402,6 @@ IndexMask retrieve_editable_and_selected_points(Object &object, const bke::greasepencil::Drawing &drawing, IndexMaskMemory &memory) { - /* Get all the locked material indices */ - VectorSet locked_material_indices = get_locked_material_indices(object); - const bke::CurvesGeometry &curves = drawing.strokes(); const IndexRange points_range = drawing.strokes().points_range();