GPv3: Handle UVs in Smooth Modifier #120032

Merged
Falk David merged 2 commits from casey-bianco-davis/blender:GPv3-uv-smooth-modifier into main 2024-03-29 11:18:17 +01:00
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");
casey-bianco-davis marked this conversation as resolved Outdated

I'd include the expected type in the attribute lookup, since it's not guaranteed and the smoothing currently only supports float, float2, and float3

I'd include the expected type in the attribute lookup, since it's not guaranteed and the smoothing currently only supports float, float2, and float3
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);