Fix potentially incorrect index when looking up layer hints for GP crazyspace

The layer mask used by the armature modifier can be incomplete, in which case
the indices may not match the edit hints list of layer data. The actual
layer index must be used instead.

Also fixes a build error on Win64 ARM which cannot compile a parallel_for_each
over an index range.

Pull Request: https://projects.blender.org/blender/blender/pulls/131620
This commit is contained in:
Lukas Tönne
2024-12-09 17:05:42 +01:00
parent 7f6058c1fb
commit c77933e748

View File

@@ -187,6 +187,8 @@ static void modify_geometry_set(ModifierData *md,
const ModifierEvalContext *ctx,
bke::GeometrySet *geometry_set)
{
using namespace modifier::greasepencil;
const auto *amd = reinterpret_cast<GreasePencilArmatureModifierData *>(md);
if (!geometry_set->has_grease_pencil()) {
@@ -211,17 +213,15 @@ static void modify_geometry_set(ModifierData *md,
}
IndexMaskMemory mask_memory;
const IndexMask layer_mask = modifier::greasepencil::get_filtered_layer_mask(
grease_pencil, amd->influence, mask_memory);
const Vector<Drawing *> drawings = modifier::greasepencil::get_drawings_for_write(
const IndexMask layer_mask = get_filtered_layer_mask(grease_pencil, amd->influence, mask_memory);
const Vector<LayerDrawingInfo> drawings = get_drawing_infos_by_layer(
grease_pencil, layer_mask, frame);
threading::parallel_for_each(drawings.index_range(), [&](const int index) {
Drawing *drawing = drawings[index];
threading::parallel_for_each(drawings, [&](const LayerDrawingInfo &info) {
if (edit_hints.is_empty()) {
modify_curves(*md, *ctx, *drawing, nullptr);
modify_curves(*md, *ctx, *info.drawing, nullptr);
}
else {
modify_curves(*md, *ctx, *drawing, &edit_hints[index]);
modify_curves(*md, *ctx, *info.drawing, &edit_hints[info.layer_index]);
}
});
}