[Bf-blender-cvs] [260b747d33b] greasepencil-object: GP Build Modifier: Fix "Concurrent" Mode
Joshua Leung
noreply at git.blender.org
Thu Nov 23 15:33:11 CET 2017
Commit: 260b747d33b5128e89e0faad251e08297b5de1f6
Author: Joshua Leung
Date: Fri Nov 24 02:57:30 2017 +1300
Branches: greasepencil-object
https://developer.blender.org/rB260b747d33b5128e89e0faad251e08297b5de1f6
GP Build Modifier: Fix "Concurrent" Mode
The last segment of shorter strokes was always suddenly appearing.
it turns out the at the formulations for those factors was off.
===================================================================
M source/blender/modifiers/intern/MOD_gpencilbuild.c
===================================================================
diff --git a/source/blender/modifiers/intern/MOD_gpencilbuild.c b/source/blender/modifiers/intern/MOD_gpencilbuild.c
index 6715dc333e3..39814eef5a5 100644
--- a/source/blender/modifiers/intern/MOD_gpencilbuild.c
+++ b/source/blender/modifiers/intern/MOD_gpencilbuild.c
@@ -320,7 +320,7 @@ static void build_concurrent(GpencilBuildModifierData *mmd, bGPDlayer *gpl, bGPD
/* Relative Length of Stroke - Relative to the longest stroke,
* what proportion of the available time should this stroke use
*/
- const float relative_len = (float)gps->totpoints / max_points;
+ const float relative_len = (float)gps->totpoints / (float)max_points;
/* Determine how many points should be left in the stroke */
int num_points = 0;
@@ -329,13 +329,16 @@ static void build_concurrent(GpencilBuildModifierData *mmd, bGPDlayer *gpl, bGPD
case GP_BUILD_TIMEALIGN_START: /* all start on frame 1 */
{
/* Build effect occurs over when fac = 0, to fac = relative_len */
- if (fac < relative_len) {
- /* Use fac directly */
+ if (fac <= relative_len) {
+ /* Scale fac to fit relative_len */
+ /* FIXME: prevent potential div by zero (e.g. very short stroke vs one very long one) */
+ const float scaled_fac = fac / relative_len;
+
if (reverse) {
- num_points = (int)roundf((1.0f - fac) * gps->totpoints);
+ num_points = (int)roundf((1.0f - scaled_fac) * gps->totpoints);
}
else {
- num_points = (int)roundf(fac * gps->totpoints);
+ num_points = (int)roundf(scaled_fac * gps->totpoints);
}
}
else {
@@ -357,12 +360,13 @@ static void build_concurrent(GpencilBuildModifierData *mmd, bGPDlayer *gpl, bGPD
if (fac >= start_fac) {
/* FIXME: prevent potential div by zero (e.g. very short stroke vs one very long one) */
- float f = fac - start_fac / relative_len;
+ const float scaled_fac = (fac - start_fac) / relative_len;
+
if (reverse) {
- num_points = (int)roundf((1.0f - f) * gps->totpoints);
+ num_points = (int)roundf((1.0f - scaled_fac) * gps->totpoints);
}
else {
- num_points = (int)roundf(f * gps->totpoints);
+ num_points = (int)roundf(scaled_fac * gps->totpoints);
}
}
else {
@@ -382,7 +386,7 @@ static void build_concurrent(GpencilBuildModifierData *mmd, bGPDlayer *gpl, bGPD
}
/* Modify the stroke geometry */
- if (num_points == 0) {
+ if (num_points <= 0) {
/* Nothing Left - Delete the stroke */
clear_stroke(gpf, gps, modifier_index);
}
More information about the Bf-blender-cvs
mailing list