GOOENGINE: Add autoclose stroke option for gpencil strokes
Update for GPv3
This commit is contained in:
@@ -230,7 +230,7 @@ class VIEW3D_HT_tool_header(Header):
|
||||
layout.prop(tool_settings, "use_gpencil_automerge_strokes", text="")
|
||||
layout.prop(tool_settings, "use_gpencil_weight_data_add", text="", icon='WPAINT_HLT')
|
||||
layout.prop(tool_settings, "use_gpencil_draw_onback", text="", icon='MOD_OPACITY')
|
||||
|
||||
layout.prop(tool_settings, "use_gpencil_autoclose_strokes", text="")
|
||||
|
||||
class _draw_tool_settings_context_mode:
|
||||
@staticmethod
|
||||
|
||||
@@ -1488,6 +1488,13 @@ void PaintOperation::on_stroke_done(const bContext &C)
|
||||
bke::AttrDomain::Point);
|
||||
screen_space_positions.span.slice(points).copy_from(this->screen_space_final_coords_);
|
||||
screen_space_positions.finish();
|
||||
|
||||
if ((scene->toolsettings->gpencil_flags & GP_TOOL_FLAG_AUTOCLOSE_STROKE) != 0) {
|
||||
bke::SpanAttributeWriter<bool> cyclic = attributes.lookup_or_add_for_write_span<bool>(
|
||||
"cyclic", bke::AttrDomain::Curve);
|
||||
cyclic.span[active_curve] = true;
|
||||
cyclic.finish();
|
||||
}
|
||||
|
||||
/* Remove trailing points with radii close to zero. */
|
||||
trim_end_points(drawing, 1e-5f, on_back, active_curve);
|
||||
@@ -1496,6 +1503,7 @@ void PaintOperation::on_stroke_done(const bContext &C)
|
||||
deselect_stroke(C, drawing, active_curve);
|
||||
|
||||
if (do_post_processing) {
|
||||
|
||||
if (settings->draw_smoothfac > 0.0f) {
|
||||
smooth_stroke(drawing, settings->draw_smoothfac, settings->draw_smoothlvl, active_curve);
|
||||
}
|
||||
|
||||
@@ -2775,6 +2775,8 @@ typedef enum eGPencil_Flags {
|
||||
GP_TOOL_FLAG_CREATE_WEIGHTS = (1 << 4),
|
||||
/** Auto-merge with last stroke. */
|
||||
GP_TOOL_FLAG_AUTOMERGE_STROKE = (1 << 5),
|
||||
/* Autoclose last stroke */
|
||||
GP_TOOL_FLAG_AUTOCLOSE_STROKE = (1 << 6),
|
||||
} eGPencil_Flags;
|
||||
|
||||
/** #Scene::r.simplify_gpencil */
|
||||
|
||||
@@ -3807,6 +3807,17 @@ static void rna_def_tool_settings(BlenderRNA *brna)
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, nullptr);
|
||||
|
||||
prop = RNA_def_property(srna, "use_gpencil_autoclose_strokes", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_AUTOCLOSE_STROKE);
|
||||
RNA_def_property_boolean_default(prop, false);
|
||||
RNA_def_property_ui_icon(prop, ICON_AUTOMERGE_OFF, 1);
|
||||
RNA_def_property_ui_text(
|
||||
prop,
|
||||
"Autoclose",
|
||||
"Close the last drawn stroke before post processing");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "gpencil_sculpt", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_pointer_sdna(prop, nullptr, "gp_sculpt");
|
||||
RNA_def_property_flag(prop, PROP_DEG_SYNC_ONLY);
|
||||
|
||||
Reference in New Issue
Block a user