[Bf-blender-cvs] [9c91e6c857d] greasepencil-object: GP: Primitive: Fix randomness bias

Charlie Jolly noreply at git.blender.org
Fri Dec 21 13:21:43 CET 2018


Commit: 9c91e6c857d61efdd435ac259ccb47d4cbf46b82
Author: Charlie Jolly
Date:   Fri Dec 21 12:19:41 2018 +0000
Branches: greasepencil-object
https://developer.blender.org/rB9c91e6c857d61efdd435ac259ccb47d4cbf46b82

GP: Primitive: Fix randomness bias

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

M	source/blender/editors/gpencil/gpencil_primitive.c
M	source/blender/editors/include/ED_gpencil.h

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

diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index c9cdc542bd0..8385274802c 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -864,9 +864,10 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
 		tGPspoint *p2d = &points2D[i];
 
 		/* set rnd value for reuse */
-		if (p2d->rnd_dirty != true) {
+		if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_RANDOM) && (p2d->rnd_dirty != true)) {
 			p2d->rnd[0] = BLI_rng_get_float(tgpi->rng);
 			p2d->rnd[1] = BLI_rng_get_float(tgpi->rng);
+			p2d->rnd[2] = BLI_rng_get_float(tgpi->rng);
 			p2d->rnd_dirty = true;
 		}
 
@@ -920,7 +921,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
 			svec[0] = -mvec[1];
 			svec[1] = mvec[0];
 
-			if (p2d->rnd[0] > 0.5f) {
+			if (p2d->rnd[1] > 0.5f) {
 				mul_v2_fl(svec, -fac);
 			}
 			else {
@@ -934,10 +935,10 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
 		    (brush->gpencil_settings->draw_random_press > 0.0f))
 		{
 			if (p2d->rnd[0] > 0.5f) {
-				pressure -= brush->gpencil_settings->draw_random_press * p2d->rnd[0];
+				pressure -= brush->gpencil_settings->draw_random_press * p2d->rnd[1];
 			}
 			else {
-				pressure += brush->gpencil_settings->draw_random_press * p2d->rnd[0];
+				pressure += brush->gpencil_settings->draw_random_press * p2d->rnd[2];
 			}
 		}
 
@@ -954,8 +955,8 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
 		if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_RANDOM) &&
 		    (brush->gpencil_settings->draw_random_strength > 0.0f))
 		{
-			if (p2d->rnd[1] > 0.5f) {
-				strength -= strength * brush->gpencil_settings->draw_random_strength * p2d->rnd[1];
+			if (p2d->rnd[2] > 0.5f) {
+				strength -= strength * brush->gpencil_settings->draw_random_strength * p2d->rnd[0];
 			}
 			else {
 				strength += strength * brush->gpencil_settings->draw_random_strength * p2d->rnd[1];
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index 4b419263a37..fb216a8c9a9 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -79,7 +79,7 @@ typedef struct tGPspoint {
 	float time;             /* Time relative to stroke start (used when converting to path) */
 	float uv_fac;           /* factor of uv along the stroke */
 	float uv_rot;           /* uv rotation for dor mode */
-	float rnd[2];           /* rnd value */
+	float rnd[3];           /* rnd value */
 	bool rnd_dirty;         /* rnd flag */
 } tGPspoint;



More information about the Bf-blender-cvs mailing list