[Bf-blender-cvs] [62ef1c08af9] blender-v3.2-release: GPencil: Fix envelope modifier deform mode thickness
Henrik Dick
noreply at git.blender.org
Mon May 2 22:17:29 CEST 2022
Commit: 62ef1c08af9a62104201e062f2b9a374c056e53b
Author: Henrik Dick
Date: Mon May 2 22:13:38 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB62ef1c08af9a62104201e062f2b9a374c056e53b
GPencil: Fix envelope modifier deform mode thickness
The thickness in the deform mode was just correct if the radius when
drawing a stroke was set to 20. Now all factors that influence the
stroke thickness are considered in deform mode.
Differential Revision: https://developer.blender.org/D14691
===================================================================
M source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
===================================================================
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
index 8b0a6ee84a2..e5604005240 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilenvelope.c
@@ -152,8 +152,12 @@ static float calc_radius_limit(
return radius_limit;
}
-static void apply_stroke_envelope(
- bGPDstroke *gps, int spread, const int def_nr, const bool invert_vg, const float thickness)
+static void apply_stroke_envelope(bGPDstroke *gps,
+ int spread,
+ const int def_nr,
+ const bool invert_vg,
+ const float thickness,
+ const float pixfactor)
{
const bool is_cyclic = (gps->flag & GP_STROKE_CYCLIC) != 0;
if (is_cyclic) {
@@ -282,9 +286,7 @@ static void apply_stroke_envelope(
}
float fac = use_dist * weight;
- /* The 50 is an internal constant for the default pixel size. The result can be messed up if
- * #bGPdata.pixfactor is not default, but I think modifiers shouldn't access that. */
- point->pressure += fac * 50.0f * GP_DEFAULT_PIX_FACTOR;
+ point->pressure += fac * pixfactor;
interp_v3_v3v3(&point->x, &point->x, new_center, fac / len_v3v3(closest, closest2));
}
@@ -326,8 +328,14 @@ static void deformStroke(GpencilModifierData *md,
return;
}
- apply_stroke_envelope(
- gps, mmd->spread, def_nr, (mmd->flag & GP_ENVELOPE_INVERT_VGROUP) != 0, mmd->thickness);
+ bGPdata *gpd = (bGPdata *)ob->data;
+ const float pixfactor = 1000.0f / ((gps->thickness + gpl->line_change) * gpd->pixfactor);
+ apply_stroke_envelope(gps,
+ mmd->spread,
+ def_nr,
+ (mmd->flag & GP_ENVELOPE_INVERT_VGROUP) != 0,
+ mmd->thickness,
+ pixfactor);
}
static void add_stroke(Object *ob,
More information about the Bf-blender-cvs
mailing list