Commit: ca0ecfc234aa38967dcbe46dd2a0c573c2b0eec9
Author: Antonio Vazquez
Date:   Thu Mar 1 16:29:21 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rBca0ecfc234aa38967dcbe46dd2a0c573c2b0eec9

Fast mouse event capture afected by zoom factor

Before, the number of points was not equal at different zoom levels.

To get this work, the pixel size is calculated and the distance is relative to 
30% of the brush thickness multiplied by the number of samples.

The number of samples has been reduced too, because the new method doesn't need 
big values.

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

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 e22762827ee..9220d51cd30 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -2651,12 +2651,32 @@ static void gpencil_add_missing_events(bContext *C, 
wmOperator *op, const wmEven
        if (brush->input_samples == 0) {
                return;
        }
+       RegionView3D *rv3d = p->ar->regiondata;
+       float defaultpixsize = rv3d->pixsize * 1000.0f;
+       int samples = (GP_MAX_INPUT_SAMPLES - brush->input_samples + 1);
+       float thickness = (float)brush->thickness;
 
-       int factor = GP_MAX_INPUT_SAMPLES - brush->input_samples + 1;
        float pt[2], a[2], b[2];
+       float vec[3];
+       float scale = 1.0f;
+
+       /* get pixel scale */
+       gp_get_3d_reference(p, vec);
+       mul_m4_v3(rv3d->persmat, vec);
+       if (rv3d->is_persp) {
+               scale = vec[2] * defaultpixsize;
+       }
+       else {
+               scale = defaultpixsize;
+       }
+       float factor = ((thickness * 0.30f) / scale) * samples;
+
+       /* get distance to generate new points. The thickness of the brush ir 
deduced at 30% of
+        * thickness to get overlap dots */
        copy_v2fl_v2i(a, p->mvalo);
        b[0] = event->mval[0] + 1;
        b[1] = event->mval[1] + 1;
+
        float dist = len_v2v2(a, b);
        if (dist >= factor) {
                int slices = 2 + (int)((dist - 1.0) / factor);
diff --git a/source/blender/makesdna/DNA_gpencil_types.h 
b/source/blender/makesdna/DNA_gpencil_types.h
index 9c863a666de..ed6ff4be7c7 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -42,7 +42,7 @@ struct GHash;
 #define GP_OBGPENCIL_DEFAULT_SIZE  0.2f 
 #define GP_DEFAULT_PIX_FACTOR 1.0f
 #define GP_DEFAULT_GRID_SIZE 100 
-#define GP_MAX_INPUT_SAMPLES 30
+#define GP_MAX_INPUT_SAMPLES 10
 
 /* ***************************************** */
 /* GP Point Weights */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to