[Bf-blender-cvs] [fd49a114244] greasepencil-object: Revert "GPencil: Several changes in Input Samples algorithm"

Antonio Vazquez noreply at git.blender.org
Sun Aug 18 11:40:35 CEST 2019


Commit: fd49a11424440ae1269b73abec49f6efa6ba2fda
Author: Antonio Vazquez
Date:   Sat Aug 17 20:24:18 2019 +0200
Branches: greasepencil-object
https://developer.blender.org/rBfd49a11424440ae1269b73abec49f6efa6ba2fda

Revert "GPencil: Several changes in Input Samples algorithm"

This reverts commit d78e3bfb33968f3b535e54029f54911018a535db.

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

M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/makesdna/DNA_gpencil_types.h

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

diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 665b16c5752..3984a256c10 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -3338,9 +3338,7 @@ static void gpencil_add_missing_events(bContext *C,
 
   RegionView3D *rv3d = p->ar->regiondata;
   float defaultpixsize = rv3d->pixsize * 1000.0f;
-  /* Use square values to keep UI in a reasonable range. */
-  int samples = ((GP_MAX_INPUT_SAMPLES * GP_MAX_INPUT_SAMPLES) - (input_samples * input_samples) +
-                 1);
+  int samples = (GP_MAX_INPUT_SAMPLES - input_samples + 1);
   float thickness = (float)brush->size;
 
   float pt[2], a[2], b[2];
@@ -3358,8 +3356,25 @@ static void gpencil_add_missing_events(bContext *C,
   }
 
   /* The thickness of the brush is reduced of thickness to get overlap dots */
-  float dot_factor = 0.05f;
-  float factor = (((thickness * dot_factor) / scale) * samples) * 0.25f;
+  float dot_factor = 0.50f;
+  if (samples < 2) {
+    dot_factor = 0.05f;
+  }
+  else if (samples < 4) {
+    dot_factor = 0.10f;
+  }
+  else if (samples < 7) {
+    dot_factor = 0.3f;
+  }
+  else if (samples < 10) {
+    dot_factor = 0.4f;
+  }
+  float factor = ((thickness * dot_factor) / scale) * samples;
+
+  /* If samples are more than 33%, divide the factor. */
+  if (input_samples > (GP_MAX_INPUT_SAMPLES / 3)) {
+    factor *= 0.5f;
+  }
 
   copy_v2_v2(a, p->mvalo);
   b[0] = (float)event->mval[0] + 1.0f;
@@ -3376,7 +3391,7 @@ static void gpencil_add_missing_events(bContext *C,
     gpencil_draw_apply_event(C, op, event, depsgraph, pt[0], pt[1]);
   }
   else if (dist >= factor) {
-    int slices = 2 + (int)(dist / factor);
+    int slices = 2 + (int)((dist - 1.0) / factor);
     float n = 1.0f / slices;
     for (int i = 1; i < slices; i++) {
       interp_v2_v2v2(pt, a, b, n * i);
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 0de7d8bdd16..64a5b6e7091 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -36,7 +36,7 @@ struct MDeformVert;
 
 #define GP_DEFAULT_PIX_FACTOR 1.0f
 #define GP_DEFAULT_GRID_LINES 4
-#define GP_MAX_INPUT_SAMPLES 10
+#define GP_MAX_INPUT_SAMPLES 100
 
 /* ***************************************** */
 /* GP Stroke Points */



More information about the Bf-blender-cvs mailing list