[Bf-blender-cvs] [32d2d5a21d4] greasepencil-object: GPencil: Fix Vertex Color modifier
Antonio Vazquez
noreply at git.blender.org
Sun Feb 23 18:24:58 CET 2020
Commit: 32d2d5a21d4f13732ad164a8d986595fbff61e7d
Author: Antonio Vazquez
Date: Sun Feb 23 18:24:46 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rB32d2d5a21d4f13732ad164a8d986595fbff61e7d
GPencil: Fix Vertex Color modifier
Solved belnding problems and code cleanup
===================================================================
M release/scripts/startup/bl_ui/properties_data_modifier.py
M source/blender/gpencil_modifiers/intern/MOD_gpencilvertexcolor.c
M source/blender/makesdna/DNA_gpencil_modifier_types.h
M source/blender/makesrna/intern/rna_gpencil_modifier.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 147c3d320d9..2955964e228 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -2138,21 +2138,21 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
def GP_VERTEXCOLOR(self, layout, ob, md):
col = layout.column()
- col.prop(md, "vertex_mode")
-
- col.separator()
col.label(text="Object:")
col.prop(md, "object", text="")
col.separator()
- col.prop(md, "radius")
- col.prop(md, "factor", slider=True)
- col.prop(md, "use_decay_color", text="Decay color with distance")
+ row = col.row(align=True)
+ row.prop(md, "radius")
+ row.prop(md, "factor", text="Strength", slider=True)
col.separator()
col.label(text="Colors:")
col.template_color_ramp(md, "colors")
+ col.separator()
+ col.prop(md, "vertex_mode")
+
self.gpencil_masking(layout, ob, md, True)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilvertexcolor.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilvertexcolor.c
index c29bb41e33a..d2f76181f42 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilvertexcolor.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilvertexcolor.c
@@ -141,31 +141,6 @@ static void gpencil_parent_location(const Depsgraph *depsgraph,
}
}
-/* Check if a point is inside a ellipsoid. */
-static bool gpencil_check_inside_ellipsoide(float co[3],
- float radius[3],
- float obmat[4][4],
- float inv_mat[4][4])
-{
- float fpt[3];
-
- /* Translate to Ellipsoid space. */
- sub_v3_v3v3(fpt, co, obmat[3]);
-
- /* Rotate point to ellipsoid rotation. */
- mul_mat3_m4_v3(inv_mat, fpt);
-
- /* Standard equation of an ellipsoid. */
- float r = ((fpt[0] / radius[0]) * (fpt[0] / radius[0])) +
- ((fpt[1] / radius[1]) * (fpt[1] / radius[1])) +
- ((fpt[2] / radius[2]) * (fpt[2] / radius[2]));
-
- if (r < 1.0f) {
- return true;
- }
- return false;
-}
-
/* deform stroke */
static void deformStroke(GpencilModifierData *md,
Depsgraph *depsgraph,
@@ -203,15 +178,6 @@ static void deformStroke(GpencilModifierData *md,
gpencil_parent_location(depsgraph, ob, gpl, mat);
- /* Radius and matrix for Ellipsoid. */
- float radius[3];
- float inv_mat[4][4];
- mul_v3_v3fl(radius, mmd->object->scale, mmd->radius);
- /* Clamp to avoid division by zero. */
- CLAMP3_MIN(radius, 0.0001f);
-
- invert_m4_m4(inv_mat, mmd->object->obmat);
-
/* loop points and apply deform */
bool doit = false;
for (int i = 0; i < gps->totpoints; i++) {
@@ -223,10 +189,6 @@ static void deformStroke(GpencilModifierData *md,
mul_v3_m4v3(pt_loc, mat, &pt->x);
float dist_sqr = len_squared_v3v3(pt_loc, mmd->object->loc);
- if (!gpencil_check_inside_ellipsoide(pt_loc, radius, mmd->object->obmat, inv_mat)) {
- continue;
- }
-
if (!doit) {
/* Apply to fill. */
if (mmd->mode != GPPAINT_MODE_STROKE) {
@@ -250,15 +212,10 @@ static void deformStroke(GpencilModifierData *md,
continue;
}
/* Calc the factor using the distance and get mix color. */
- float mix_factor = dist_sqr / radius_sqr;
+ float mix_factor = clamp_f(dist_sqr / radius_sqr, 0.0f, 1.0f);
BKE_colorband_evaluate(mmd->colorband, mix_factor, coba_res);
- interp_v3_v3v3(pt->vert_color, pt->vert_color, coba_res, mmd->factor * weight);
- pt->vert_color[3] = mmd->factor;
- /* Apply Decay. */
- if (mmd->flag & GP_VERTEXCOL_DECAY_COLOR) {
- pt->vert_color[3] *= (1.0f - mix_factor);
- }
+ interp_v3_v3v3(pt->vert_color, pt->vert_color, coba_res, mmd->factor * weight * coba_res[3]);
}
}
}
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index 79a7510c072..477ee8da734 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -712,7 +712,6 @@ typedef enum eVertexcolorGpencil_Flag {
GP_VERTEXCOL_UNIFORM_SPACE = (1 << 3),
GP_VERTEXCOL_INVERT_LAYERPASS = (1 << 4),
GP_VERTEXCOL_INVERT_MATERIAL = (1 << 5),
- GP_VERTEXCOL_DECAY_COLOR = (1 << 6),
} eVertexcolorGpencil_Flag;
#endif /* __DNA_GPENCIL_MODIFIER_TYPES_H__ */
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index 51f81c3e194..d92cf9baa97 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -2037,11 +2037,6 @@ static void rna_def_modifier_gpencilvertexcolor(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
- prop = RNA_def_property(srna, "use_decay_color", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_VERTEXCOL_DECAY_COLOR);
- RNA_def_property_ui_text(prop, "Decay", "The tinting decrease with the distance");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "factor");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -2050,8 +2045,8 @@ static void rna_def_modifier_gpencilvertexcolor(BlenderRNA *brna)
prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "radius");
- RNA_def_property_range(prop, 0, FLT_MAX);
- RNA_def_property_ui_range(prop, 0, 100, 100, 2);
+ RNA_def_property_range(prop, 1e-6f, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 1, 3);
RNA_def_property_ui_text(prop, "Radius", "Defines the maximum distance of the effect");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
More information about the Bf-blender-cvs
mailing list