[Bf-blender-cvs] [26793d619cb] master: GPencil: Cleanup Build modifier and fix potential div by zero errors

Antonio Vazquez noreply at git.blender.org
Tue Jul 14 10:26:33 CEST 2020


Commit: 26793d619cbe399ba505ab4daeea1f6ed2eaa6a1
Author: Antonio Vazquez
Date:   Tue Jul 14 10:26:19 2020 +0200
Branches: master
https://developer.blender.org/rB26793d619cbe399ba505ab4daeea1f6ed2eaa6a1

GPencil: Cleanup Build modifier and fix potential div by zero errors

===================================================================

M	source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c

===================================================================

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
index 54ed2ffafe1..56d94611b5d 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
@@ -119,7 +119,6 @@ static void gpf_clear_all_strokes(bGPDframe *gpf)
 /* Reduce the number of points in the stroke
  *
  * Note: This won't be called if all points are present/removed
- * TODO: Allow blending of growing/shrinking tip (e.g. for more gradual transitions)
  */
 static void reduce_stroke_points(bGPDstroke *gps,
                                  const int num_points,
@@ -132,7 +131,6 @@ static void reduce_stroke_points(bGPDstroke *gps,
   }
 
   /* Which end should points be removed from */
-  // TODO: free stroke weights
   switch (transition) {
     case GP_BUILD_TRANSITION_GROW:   /* Show in forward order =
                                       * Remove ungrown-points from end of stroke. */
@@ -279,7 +277,6 @@ static void build_sequential(BuildGpencilModifierData *mmd, bGPDframe *gpf, floa
     }
     else {
       /* Some proportion of stroke is visible */
-      /* XXX: Will the transition settings still be valid now? */
       if ((first_visible <= cell->start_idx) && (last_visible >= cell->end_idx)) {
         /* Do nothing - whole stroke is visible */
       }
@@ -303,8 +300,6 @@ static void build_sequential(BuildGpencilModifierData *mmd, bGPDframe *gpf, floa
 /* --------------------------------------------- */
 
 /* Concurrent - Show multiple strokes at once */
-// TODO: Allow random offsets to start times
-// TODO: Allow varying speeds? Scaling of progress?
 static void build_concurrent(BuildGpencilModifierData *mmd, bGPDframe *gpf, float fac)
 {
   bGPDstroke *gps, *gps_next;
@@ -342,8 +337,7 @@ static void build_concurrent(BuildGpencilModifierData *mmd, bGPDframe *gpf, floa
         /* Build effect occurs over when fac = 0, to fac = relative_len */
         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;
+          const float scaled_fac = fac / MAX2(relative_len, PSEUDOINVERSE_EPSILON);
 
           if (reverse) {
             num_points = (int)roundf((1.0f - scaled_fac) * gps->totpoints);
@@ -371,8 +365,7 @@ static void build_concurrent(BuildGpencilModifierData *mmd, bGPDframe *gpf, floa
         const float start_fac = 1.0f - relative_len;
 
         if (fac >= start_fac) {
-          /* FIXME: prevent potential div by zero (e.g. very short stroke vs one very long one) */
-          const float scaled_fac = (fac - start_fac) / relative_len;
+          const float scaled_fac = (fac - start_fac) / MAX2(relative_len, PSEUDOINVERSE_EPSILON);
 
           if (reverse) {
             num_points = (int)roundf((1.0f - scaled_fac) * gps->totpoints);
@@ -393,8 +386,6 @@ static void build_concurrent(BuildGpencilModifierData *mmd, bGPDframe *gpf, floa
 
         break;
       }
-
-        /* TODO... */
     }
 
     /* Modify the stroke geometry */



More information about the Bf-blender-cvs mailing list