[Bf-blender-cvs] [84d85f963fc] blender2.8: GP: Fix strange pressure values when drawing
Antonioya
noreply at git.blender.org
Sun Sep 9 14:08:26 CEST 2018
Commit: 84d85f963fc140f42501670527d579e683ab4fb1
Author: Antonioya
Date: Sun Sep 9 14:08:18 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB84d85f963fc140f42501670527d579e683ab4fb1
GP: Fix strange pressure values when drawing
This strange values produced an "explosion" of the stoke and it was very annoying.
===================================================================
M source/blender/blenkernel/intern/gpencil.c
M source/blender/editors/gpencil/gpencil_paint.c
===================================================================
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index b5230afa0bb..45163de559e 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -1350,7 +1350,7 @@ bool BKE_gpencil_smooth_stroke_thickness(bGPDstroke *gps, int point_index, float
bGPDspoint *ptb = &gps->points[point_index];
/* Do nothing if not enough points */
- if (gps->totpoints <= 2) {
+ if ((gps->totpoints <= 2) || (point_index < 1)) {
return false;
}
@@ -1369,6 +1369,7 @@ bool BKE_gpencil_smooth_stroke_thickness(bGPDstroke *gps, int point_index, float
* at the distance of point b
*/
float fac = line_point_factor_v3(&ptb->x, &pta->x, &ptc->x);
+ CLAMP(fac, 0.0f, 1.0f);
float optimal = interpf(ptc->pressure, pta->pressure, fac);
/* Based on influence factor, blend between original and optimal */
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 27eba6581db..4ce3899e288 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1199,7 +1199,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
{
float reduce = 0.0f;
for (int r = 0; r < brush->gpencil_settings->draw_smoothlvl; r++) {
- for (i = 0; i < gps->totpoints; i++) {
+ for (i = 0; i < gps->totpoints - 1; i++) {
BKE_gpencil_smooth_stroke(gps, i, brush->gpencil_settings->draw_smoothfac - reduce);
BKE_gpencil_smooth_stroke_strength(gps, i, brush->gpencil_settings->draw_smoothfac);
}
@@ -1211,7 +1211,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
(brush->gpencil_settings->thick_smoothfac > 0.0f))
{
for (int r = 0; r < brush->gpencil_settings->thick_smoothlvl * 2; r++) {
- for (i = 0; i < gps->totpoints; i++) {
+ for (i = 0; i < gps->totpoints - 1; i++) {
BKE_gpencil_smooth_stroke_thickness(gps, i, brush->gpencil_settings->thick_smoothfac);
}
}
More information about the Bf-blender-cvs
mailing list