diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2020-08-12 11:47:47 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2020-08-12 23:47:38 +0300 |
commit | 19cef4073dd7b17a156fbb0feb1838417bf7ff30 (patch) | |
tree | cb890c336ccfdea862c08b0333e99ec74ad6f9fb /source | |
parent | 54b3168c4ad07bb2d3c7aade342b45c0dec34181 (diff) |
GPencil: Interpolate thickness when convert Curve to GPencil
The curve was using only the last point radius of the segment. Now, the value is interpolated between start and end points.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/gpencil_curve.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c index 6db5eaf28e0..988ae05e323 100644 --- a/source/blender/blenkernel/intern/gpencil_curve.c +++ b/source/blender/blenkernel/intern/gpencil_curve.c @@ -118,13 +118,18 @@ static Material *gpencil_add_from_curve_material(Main *bmain, /* Helper: Create new stroke section. */ static void gpencil_add_new_points(bGPDstroke *gps, - float *coord_array, - float pressure, - int init, - int totpoints, + const float *coord_array, + const float pressure_start, + const float pressure_end, + const int init, + const int totpoints, const float init_co[3], - bool last) + const bool last) { + BLI_assert(totpoints > 0); + + const float step = 1.0f / ((float)totpoints - 1.0f); + float factor = 0.0f; for (int i = 0; i < totpoints; i++) { bGPDspoint *pt = &gps->points[i + init]; copy_v3_v3(&pt->x, &coord_array[3 * i]); @@ -139,8 +144,9 @@ static void gpencil_add_new_points(bGPDstroke *gps, } } - pt->pressure = pressure; pt->strength = 1.0f; + pt->pressure = interpf(pressure_end, pressure_start, factor); + factor += step; } } @@ -336,7 +342,8 @@ static void gpencil_convert_spline(Main *bmain, copy_v3_v3(init_co, &coord_array[0]); } /* Add points to the stroke */ - gpencil_add_new_points(gps, coord_array, bezt->radius, init, resolu, init_co, last); + gpencil_add_new_points( + gps, coord_array, prevbezt->radius, bezt->radius, init, resolu, init_co, last); /* Free memory. */ MEM_SAFE_FREE(coord_array); @@ -367,7 +374,7 @@ static void gpencil_convert_spline(Main *bmain, gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); /* Add points. */ - gpencil_add_new_points(gps, coord_array, 1.0f, 0, gps->totpoints, init_co, false); + gpencil_add_new_points(gps, coord_array, 1.0f, 1.0f, 0, gps->totpoints, init_co, false); MEM_SAFE_FREE(coord_array); } |