From f4894c098f3b0269b85004cdebb583862e9a5568 Mon Sep 17 00:00:00 2001 From: Pratik Borhade Date: Mon, 22 Apr 2024 13:04:15 +0200 Subject: [PATCH] Fix #120920: Can not edit strokes/points when materials array is empty Return entire points/curves range if object has no material. Pull Request: https://projects.blender.org/blender/blender/pulls/120923 --- .../grease_pencil/intern/grease_pencil_utils.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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 4baaba6a30c..75534792ec2 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc @@ -544,6 +544,12 @@ IndexMask retrieve_editable_strokes(Object &object, IndexMaskMemory &memory) { using namespace blender; + const bke::CurvesGeometry &curves = drawing.strokes(); + const IndexRange curves_range = drawing.strokes().curves_range(); + + if (object.totcol == 0) { + return IndexMask(curves_range); + } /* Get all the editable material indices */ VectorSet editable_material_indices = get_editable_material_indices(object); @@ -551,8 +557,6 @@ IndexMask retrieve_editable_strokes(Object &object, return {}; } - const bke::CurvesGeometry &curves = drawing.strokes(); - const IndexRange curves_range = drawing.strokes().curves_range(); const bke::AttributeAccessor attributes = curves.attributes(); const VArray materials = *attributes.lookup("material_index", bke::AttrDomain::Curve); @@ -611,14 +615,19 @@ IndexMask retrieve_editable_points(Object &object, const bke::greasepencil::Drawing &drawing, IndexMaskMemory &memory) { + const bke::CurvesGeometry &curves = drawing.strokes(); + const IndexRange points_range = drawing.strokes().points_range(); + + if (object.totcol == 0) { + return IndexMask(points_range); + } + /* Get all the editable material indices */ VectorSet editable_material_indices = get_editable_material_indices(object); if (editable_material_indices.is_empty()) { return {}; } - const bke::CurvesGeometry &curves = drawing.strokes(); - const IndexRange points_range = drawing.strokes().points_range(); const bke::AttributeAccessor attributes = curves.attributes(); /* Propagate the material index to the points. */