[Bf-blender-cvs] [55f78da8abf] greasepencil-object: GPencil: Fix error using Random curve
Antonio Vazquez
noreply at git.blender.org
Wed Apr 22 15:59:01 CEST 2020
Commit: 55f78da8abfb7d00f63ebedaff33c2b6be720e4b
Author: Antonio Vazquez
Date: Wed Apr 22 15:58:55 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rB55f78da8abfb7d00f63ebedaff33c2b6be720e4b
GPencil: Fix error using Random curve
The curve must be used as factor.
===================================================================
M source/blender/editors/gpencil/gpencil_paint.c
M source/blender/editors/gpencil/gpencil_primitive.c
M source/blender/editors/gpencil/gpencil_utils.c
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 4330be01c06..006b1a5a631 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -711,9 +711,9 @@ static void gp_apply_randomness(tGPsdata *p,
value = 1.0 + random_settings.pressure * brush_settings->draw_random_press;
}
- /* Apply random curve with point pressure. */
+ /* Apply random curve. */
if (brush_settings->flag2 & GP_BRUSH_USE_PRESSURE_RAND_PRESS) {
- value = BKE_curvemapping_evaluateF(brush_settings->curve_rand_pressure, 0, pt->pressure);
+ value *= BKE_curvemapping_evaluateF(brush_settings->curve_rand_pressure, 0, pt->strength);
}
pt->pressure *= value;
@@ -730,9 +730,9 @@ static void gp_apply_randomness(tGPsdata *p,
value = 1.0 + random_settings.strength * brush_settings->draw_random_strength;
}
- /* Apply random curve with point pressure. */
+ /* Apply random curve. */
if (brush_settings->flag2 & GP_BRUSH_USE_STRENGTH_RAND_PRESS) {
- value = BKE_curvemapping_evaluateF(brush_settings->curve_rand_pressure, 0, pt->pressure);
+ value *= BKE_curvemapping_evaluateF(brush_settings->curve_rand_pressure, 0, pt->strength);
}
pt->strength *= value;
@@ -750,9 +750,9 @@ static void gp_apply_randomness(tGPsdata *p,
value = random_settings.uv * M_PI_2 * brush_settings->uv_random;
}
- /* Apply random curve with point pressure. */
+ /* Apply random curve. */
if (brush_settings->flag2 & GP_BRUSH_USE_UV_RAND_PRESS) {
- value = BKE_curvemapping_evaluateF(brush_settings->curve_rand_uv, 0, pt->pressure);
+ value *= BKE_curvemapping_evaluateF(brush_settings->curve_rand_uv, 0, pt->strength);
}
pt->uv_rot += value;
@@ -817,14 +817,6 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
return GP_STROKEADD_INVALID;
}
- /* Set vertex colors for buffer. */
- ED_gpencil_sbuffer_vertex_color_set(p->depsgraph,
- p->ob,
- p->scene->toolsettings,
- p->brush,
- p->material,
- p->random_settings.hsv);
-
/* get pointer to destination point */
pt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_used);
@@ -845,6 +837,14 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
}
+ /* Set vertex colors for buffer. */
+ ED_gpencil_sbuffer_vertex_color_set(p->depsgraph,
+ p->ob,
+ p->scene->toolsettings,
+ p->brush,
+ p->material,
+ p->random_settings.hsv);
+
if (brush_settings->flag & GP_BRUSH_GROUP_RANDOM) {
/* Apply jitter to position */
if (brush_settings->draw_jitter > 0.0f) {
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index 50d1fe1680c..060c0abdc46 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -925,7 +925,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
pressure *= 1.0 + random_settings.pressure * brush_settings->draw_random_press;
}
- /* Apply random curve with point pressure. */
+ /* Apply random curve. */
if (brush_settings->flag2 & GP_BRUSH_USE_PRESSURE_RAND_PRESS) {
pressure *= BKE_curvemapping_evaluateF(brush_settings->curve_rand_pressure, 0, pressure);
}
@@ -943,7 +943,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
strength *= 1.0 + random_settings.strength * brush_settings->draw_random_strength;
}
- /* Apply random curve with point pressure. */
+ /* Apply random curve. */
if (brush_settings->flag2 & GP_BRUSH_USE_STRENGTH_RAND_PRESS) {
strength *= BKE_curvemapping_evaluateF(brush_settings->curve_rand_strength, 0, pressure);
}
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 33210713834..d9b1f8a5e60 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -2787,10 +2787,10 @@ void ED_gpencil_sbuffer_vertex_color_random(bGPdata *gpd,
factor_value[0] = random_color[0];
}
- /* Apply random curve with point pressure. */
+ /* Apply random curve. */
if (brush_settings->flag2 & GP_BRUSH_USE_HUE_RAND_PRESS) {
- factor_value[0] = BKE_curvemapping_evaluateF(
- brush_settings->curve_rand_hue, 0, tpt->pressure);
+ factor_value[0] *= BKE_curvemapping_evaluateF(
+ brush_settings->curve_rand_hue, 0, tpt->strength);
}
}
@@ -2804,10 +2804,10 @@ void ED_gpencil_sbuffer_vertex_color_random(bGPdata *gpd,
factor_value[1] = random_color[1];
}
- /* Apply random curve with point pressure. */
+ /* Apply random curve. */
if (brush_settings->flag2 & GP_BRUSH_USE_SAT_RAND_PRESS) {
- factor_value[1] = BKE_curvemapping_evaluateF(
- brush_settings->curve_rand_saturation, 0, tpt->pressure);
+ factor_value[1] *= BKE_curvemapping_evaluateF(
+ brush_settings->curve_rand_saturation, 0, tpt->strength);
}
}
@@ -2821,10 +2821,10 @@ void ED_gpencil_sbuffer_vertex_color_random(bGPdata *gpd,
factor_value[2] = random_color[2];
}
- /* Apply random curve with point pressure. */
+ /* Apply random curve. */
if (brush_settings->flag2 & GP_BRUSH_USE_VAL_RAND_PRESS) {
- factor_value[2] = BKE_curvemapping_evaluateF(
- brush_settings->curve_rand_value, 0, tpt->pressure);
+ factor_value[2] *= BKE_curvemapping_evaluateF(
+ brush_settings->curve_rand_value, 0, tpt->strength);
}
}
More information about the Bf-blender-cvs
mailing list