GPv3: Draw tool: Only create caps attributes if needed

This is to stop unneeded attributes from been created.

Pull Request: https://projects.blender.org/blender/blender/pulls/118985
This commit is contained in:
Casey Bianco-Davis
2024-03-04 10:55:42 +01:00
committed by Falk David
parent 38caa87b09
commit bb26c3d82f

View File

@@ -238,21 +238,28 @@ struct PaintOperationExecutor {
"hardness",
bke::AttrDomain::Curve,
bke::AttributeInitVArray(VArray<float>::ForSingle(1.0f, curves.curves_num())));
bke::SpanAttributeWriter<int8_t> start_caps = attributes.lookup_or_add_for_write_span<int8_t>(
"start_cap", bke::AttrDomain::Curve);
bke::SpanAttributeWriter<int8_t> end_caps = attributes.lookup_or_add_for_write_span<int8_t>(
"end_cap", bke::AttrDomain::Curve);
cyclic.span.last() = false;
materials.span.last() = material_index;
hardnesses.span.last() = hardness_;
start_caps.span.last() = settings_->caps_type;
end_caps.span.last() = settings_->caps_type;
/* Only set the attribute if the type is not the default or if it already exists. */
if (settings_->caps_type != GP_STROKE_CAP_TYPE_ROUND || attributes.contains("start_cap")) {
bke::SpanAttributeWriter<int8_t> start_caps =
attributes.lookup_or_add_for_write_span<int8_t>("start_cap", bke::AttrDomain::Curve);
start_caps.span.last() = settings_->caps_type;
start_caps.finish();
}
if (settings_->caps_type != GP_STROKE_CAP_TYPE_ROUND || attributes.contains("end_cap")) {
bke::SpanAttributeWriter<int8_t> end_caps = attributes.lookup_or_add_for_write_span<int8_t>(
"end_cap", bke::AttrDomain::Curve);
end_caps.span.last() = settings_->caps_type;
end_caps.finish();
}
cyclic.finish();
materials.finish();
hardnesses.finish();
start_caps.finish();
end_caps.finish();
curves.curve_types_for_write().last() = CURVE_TYPE_POLY;
curves.update_curve_types();