GPv3: Handle UVs in Smooth Modifier

The smooth modifier was made before UVs were implemented.
This adds smoothing to the UV rotations.

Pull Request: https://projects.blender.org/blender/blender/pulls/120032
This commit is contained in:
casey bianco-davis 2024-03-29 11:18:06 +01:00 committed by Falk David
parent 4365d0496a
commit 7669ba7a5c
1 changed files with 18 additions and 3 deletions

View File

@ -99,12 +99,13 @@ static void deform_drawing(const ModifierData &md,
const bool smooth_position = (mmd.flag & MOD_GREASE_PENCIL_SMOOTH_MOD_LOCATION);
const bool smooth_radius = (mmd.flag & MOD_GREASE_PENCIL_SMOOTH_MOD_THICKNESS);
const bool smooth_opacity = (mmd.flag & MOD_GREASE_PENCIL_SMOOTH_MOD_STRENGTH);
const bool smooth_uv = (mmd.flag & MOD_GREASE_PENCIL_SMOOTH_MOD_UV);
if (iterations <= 0 || influence <= 0.0f) {
return;
}
if (!(smooth_position || smooth_radius || smooth_opacity)) {
if (!(smooth_position || smooth_radius || smooth_opacity || smooth_uv)) {
return;
}
@ -166,6 +167,21 @@ static void deform_drawing(const ModifierData &md,
radii.span);
radii.finish();
}
if (smooth_uv) {
bke::SpanAttributeWriter<float> rotation = attributes.lookup_for_write_span<float>("rotation");
if (rotation) {
geometry::smooth_curve_attribute(strokes,
points_by_curve,
point_selection,
cyclic,
iterations,
influence,
smooth_ends,
false,
rotation.span);
}
rotation.finish();
}
}
static void modify_geometry_set(ModifierData *md,
@ -203,8 +219,7 @@ static void panel_draw(const bContext *C, Panel *panel)
uiItemR(row, ptr, "use_edit_strength", UI_ITEM_R_TOGGLE, IFACE_("Strength"), ICON_NONE);
uiItemR(row, ptr, "use_edit_thickness", UI_ITEM_R_TOGGLE, IFACE_("Thickness"), ICON_NONE);
/* TODO: UV not implemented yet in GPv3. */
// uiItemR(row, ptr, "use_edit_uv", UI_ITEM_R_TOGGLE, IFACE_("UV"), ICON_NONE);
uiItemR(row, ptr, "use_edit_uv", UI_ITEM_R_TOGGLE, IFACE_("UV"), ICON_NONE);
uiLayoutSetPropSep(layout, true);