Grease Pencil: Fix zero default hardness created by the opacity modifier

Opacity modifier can also change hardness. It was creating the curve
"hardness" attribute but using the default zero value. Hardness should
be 1.0 by default.

Pull Request: https://projects.blender.org/blender/blender/pulls/118000
This commit is contained in:
Lukas Tönne
2024-02-08 16:45:38 +01:00
parent 7b44c2ffb3
commit 1f35dc9d48

View File

@@ -161,10 +161,10 @@ static void modify_hardness(const GreasePencilOpacityModifierData &omd,
const IndexMask &curves_mask)
{
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
bke::SpanAttributeWriter<float> hardnesses = attributes.lookup_for_write_span<float>("hardness");
if (!hardnesses) {
return;
}
bke::SpanAttributeWriter<float> hardnesses = attributes.lookup_or_add_for_write_span<float>(
"hardness",
bke::AttrDomain::Curve,
bke::AttributeInitVArray(VArray<float>::ForSingle(1.0f, curves.curve_num)));
curves_mask.foreach_index(GrainSize(512), [&](int64_t curve_i) {
hardnesses.span[curve_i] = std::clamp(