[Bf-blender-cvs] [e4c81a0a2b2] temp-gpencil-bezier-stroke-type: GPencil: Initial bezier support for smooth modifier
Falk David
noreply at git.blender.org
Thu May 6 10:43:29 CEST 2021
Commit: e4c81a0a2b2243e54c1f7a9f8590e66729f943a9
Author: Falk David
Date: Thu May 6 09:26:58 2021 +0200
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rBe4c81a0a2b2243e54c1f7a9f8590e66729f943a9
GPencil: Initial bezier support for smooth modifier
This adds the `deformBezier` callback for the smooth modifier.
At the moment this does not support vertex group influence and
custom curve falloff.
===================================================================
M source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
M source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
===================================================================
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
index 2dc00079f91..6529f236e2b 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
@@ -34,6 +34,7 @@
#include "DNA_object_types.h"
#include "BKE_deform.h"
+#include "BKE_gpencil_curve.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_material.h"
@@ -136,8 +137,15 @@ bool is_stroke_affected_by_modifier(Object *ob,
}
}
/* need to have a minimum number of points */
- if ((minpoints > 0) && (gps->totpoints < minpoints)) {
- return false;
+ if (GPENCIL_STROKE_TYPE_BEZIER(gps)) {
+ if ((minpoints > 0) && (gps->editcurve->tot_curve_points < minpoints)) {
+ return false;
+ }
+ }
+ else {
+ if ((minpoints > 0) && (gps->totpoints < minpoints)) {
+ return false;
+ }
}
return true;
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
index 55f3276c84c..28091df01c5 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
@@ -39,6 +39,7 @@
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_deform.h"
+#include "BKE_gpencil_curve.h"
#include "BKE_gpencil_geom.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_lib_query.h"
@@ -151,6 +152,51 @@ static void deformPolyline(GpencilModifierData *md,
}
}
+static void deformBezier(GpencilModifierData *md,
+ Depsgraph *UNUSED(depsgraph),
+ Object *ob,
+ bGPDlayer *gpl,
+ bGPDframe *UNUSED(gpf),
+ bGPDstroke *gps)
+{
+ SmoothGpencilModifierData *mmd = (SmoothGpencilModifierData *)md;
+
+ if (!is_stroke_affected_by_modifier(ob,
+ mmd->layername,
+ mmd->material,
+ mmd->pass_index,
+ mmd->layer_pass,
+ 3,
+ gpl,
+ gps,
+ mmd->flag & GP_SMOOTH_INVERT_LAYER,
+ mmd->flag & GP_SMOOTH_INVERT_PASS,
+ mmd->flag & GP_SMOOTH_INVERT_LAYERPASS,
+ mmd->flag & GP_SMOOTH_INVERT_MATERIAL)) {
+ return;
+ }
+
+ if (mmd->factor <= 0.0f) {
+ return;
+ }
+ bGPdata *gpd = ob->data;
+ const int def_nr = BKE_object_defgroup_name_index(ob, mmd->vgname);
+ const bool use_curve = (mmd->flag & GP_SMOOTH_CUSTOM_CURVE) != 0 && mmd->curve_intensity;
+
+ BKE_gpencil_editcurve_smooth(gps,
+ mmd->factor,
+ 2,
+ mmd->step,
+ false,
+ false,
+ mmd->flag & GP_SMOOTH_MOD_LOCATION,
+ mmd->flag & GP_SMOOTH_MOD_THICKNESS,
+ mmd->flag & GP_SMOOTH_MOD_STRENGTH);
+
+ BKE_gpencil_editcurve_recalculate_handles(gps);
+ BKE_gpencil_stroke_geometry_update(gpd, gps, GP_GEO_UPDATE_POLYLINE_REGENERATE_ALL);
+}
+
static void bakeModifier(struct Main *UNUSED(bmain),
Depsgraph *depsgraph,
GpencilModifierData *md,
@@ -161,7 +207,12 @@ static void bakeModifier(struct Main *UNUSED(bmain),
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
- deformPolyline(md, depsgraph, ob, gpl, gpf, gps);
+ if (GPENCIL_STROKE_TYPE_BEZIER(gps)) {
+ deformBezier(md, depsgraph, ob, gpl, gpf, gps);
+ }
+ else {
+ deformPolyline(md, depsgraph, ob, gpl, gpf, gps);
+ }
}
}
}
@@ -233,7 +284,7 @@ GpencilModifierTypeInfo modifierType_Gpencil_Smooth = {
/* copyData */ copyData,
/* deformPolyline */ deformPolyline,
- /* deformBezier */ NULL,
+ /* deformBezier */ deformBezier,
/* generateStrokes */ NULL,
/* bakeModifier */ bakeModifier,
/* remapTime */ NULL,
More information about the Bf-blender-cvs
mailing list