Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
index 357e36a06b2..8ab72716f4d 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
@@ -102,16 +102,41 @@ static void deformStroke(GpencilModifierData *md,
return;
}
- /* if normalize, set stroke thickness */
+ /* Check to see if we normalize the whole stroke or only certain points along it. */
+ bool gps_has_affected_points = false;
+ bool gps_has_unaffected_points = false;
+
if (mmd->flag & GP_THICK_NORMALIZE) {
+ for (int i = 0; i < gps->totpoints; i++) {
+ MDeformVert *dvert = gps->dvert != NULL ? &gps->dvert[i] : NULL;
+ const float weight = get_modifier_point_weight(
+ dvert, (mmd->flag & GP_THICK_INVERT_VGROUP) != 0, def_nr);
+ if (weight < 0.0f) {
+ gps_has_unaffected_points = true;
+ }
+ else {
+ gps_has_affected_points = true;
+ }
+
+ /* If both checks are true, we have what we need so we can stop looking. */
+ if (gps_has_affected_points && gps_has_unaffected_points) {
+ break;
+ }
+ }
+ }
+
+ /* If we are normalizing and all points of the stroke are affected, it's safe to reset thickness
+ */
+ if (mmd->flag & GP_THICK_NORMALIZE && gps_has_affected_points && !gps_has_unaffected_points) {
gps->thickness = mmd->thickness;
}
+ /* Without this check, modifier alters the thickness of strokes which have no points in scope */
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
MDeformVert *dvert = gps->dvert != NULL ? &gps->dvert[i] : NULL;
float curvef = 1.0f;
- /* verify vertex group */
+ /* Verify point is part of vertex group. */
const float weight = get_modifier_point_weight(
dvert, (mmd->flag & GP_THICK_INVERT_VGROUP) != 0, def_nr);
if (weight < 0.0f) {
@@ -119,11 +144,21 @@ static void deformStroke(GpencilModifierData *md,
}
if (mmd->flag & GP_THICK_NORMALIZE) {
- pt->pressure = 1.0f;
+ if (gps_has_unaffected_points) {
+ /* Clamp value for very weird situations when stroke thickness can be zero. */
+ CLAMP_MIN(gps->thickness, 0.001f);
+ /* Calculate pressure value to match the width of strokes with reset thickness and 1.0
+ * pressure. */
+ pt->pressure = (float)mmd->thickness / (float)gps->thickness;
+ }
+ else {
+ /* Reset point pressure values so only stroke thickness counts. */
+ pt->pressure = 1.0f;
+ }
}
else {
if ((mmd->flag & GP_THICK_CUSTOM_CURVE) && (mmd->curve_thickness)) {
- /* normalize value to evaluate curve */
+ /* Normalize value to evaluate curve. */
float value = (float)i / (gps->totpoints - 1);
curvef = BKE_curvemapping_evaluateF(mmd->curve_thickness, 0, value);
}