GPv3: Draw tool set caps types

Adds functionally to sets the cap type of the drawn stroke.

Pull Request: https://projects.blender.org/blender/blender/pulls/118950
This commit is contained in:
Casey Bianco-Davis
2024-03-01 10:45:02 +01:00
committed by Falk David
parent 68c12fe0ec
commit bf6f9ea2da
2 changed files with 13 additions and 6 deletions

View File

@@ -1444,8 +1444,6 @@ def brush_basic_grease_pencil_paint_settings(layout, context, brush, *, compact=
row.prop(gp_settings, "caps_type", text="", expand=True)
else:
row.prop(gp_settings, "caps_type", text="Caps Type")
# TODO: Remove this when caps work.
row.enabled = False
elif grease_pencil_tool == 'ERASE':
layout.prop(gp_settings, "eraser_mode", expand=True)
if gp_settings.eraser_mode == "HARD":

View File

@@ -238,13 +238,21 @@ 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;
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();
@@ -254,10 +262,11 @@ struct PaintOperationExecutor {
bke::AttrDomain::Point,
{"position", "radius", "opacity", "vertex_color"},
curves.points_range().take_back(1));
bke::fill_attribute_range_default(attributes,
bke::AttrDomain::Curve,
{"curve_type", "material_index", "cyclic", "hardness"},
curves.curves_range().take_back(1));
bke::fill_attribute_range_default(
attributes,
bke::AttrDomain::Curve,
{"curve_type", "material_index", "cyclic", "hardness", "start_cap", "end_cap"},
curves.curves_range().take_back(1));
drawing_->tag_topology_changed();
}