GPv3: Opacity modifier #116946
|
@ -2543,7 +2543,7 @@ typedef enum GreasePencilModifierColorMode {
|
|||
typedef enum GreasePencilOpacityModifierFlag {
|
||||
MOD_GREASE_PENCIL_OPACITY_OPEN_INFLUENCE_PANEL = (1 << 0),
|
||||
/* Use vertex group as opacity factors instead of influence. */
|
||||
MOD_GREASE_PENCIL_OPACITY_USE_VERTEX_GROUP = (1 << 1),
|
||||
MOD_GREASE_PENCIL_OPACITY_USE_WEIGHT_AS_FACTOR = (1 << 1),
|
||||
/* Set the opacity for every point in a stroke, otherwise multiply existing opacity. */
|
||||
MOD_GREASE_PENCIL_OPACITY_USE_UNIFORM_OPACITY = (1 << 2),
|
||||
} GreasePencilOpacityModifierFlag;
|
||||
|
|
|
@ -1764,6 +1764,26 @@ static void rna_GreasePencilModifier_material_set(PointerRNA *ptr,
|
|||
RNA_MOD_GREASE_PENCIL_MATERIAL_FILTER_SET(GreasePencilOpacity);
|
||||
RNA_MOD_GREASE_PENCIL_VERTEX_GROUP_SET(GreasePencilOpacity);
|
||||
|
||||
static void rna_GreasePencilOpacityModifier_opacity_factor_range(
|
||||
PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
|
||||
{
|
||||
GreasePencilOpacityModifierData *omd = static_cast<GreasePencilOpacityModifierData *>(ptr->data);
|
||||
|
||||
*min = 0.0f;
|
||||
*softmin = 0.0f;
|
||||
*softmax = (omd->flag & MOD_GREASE_PENCIL_OPACITY_USE_UNIFORM_OPACITY) ? 1.0f : 2.0f;
|
||||
*max = *softmax;
|
||||
}
|
||||
|
||||
static void rna_GreasePencilOpacityModifier_opacity_factor_max_set(PointerRNA *ptr, float value)
|
||||
{
|
||||
GreasePencilOpacityModifierData *omd = static_cast<GreasePencilOpacityModifierData *>(ptr->data);
|
||||
|
||||
omd->color_factor = (omd->flag & MOD_GREASE_PENCIL_OPACITY_USE_UNIFORM_OPACITY) ?
|
||||
std::min(value, 1.0f) :
|
||||
value;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void rna_def_modifier_panel_open_prop(StructRNA *srna, const char *identifier, const int id)
|
||||
|
@ -7615,7 +7635,36 @@ static void rna_def_modifier_grease_pencil_opacity(BlenderRNA *brna)
|
|||
|
||||
RNA_define_lib_overridable(true);
|
||||
|
||||
// TODO
|
||||
prop = RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "color_factor");
|
||||
RNA_def_property_ui_range(prop, 0, 2.0, 0.1, 2);
|
||||
RNA_def_property_float_funcs(prop,
|
||||
nullptr,
|
||||
"rna_GreasePencilOpacityModifier_opacity_factor_max_set",
|
||||
"rna_GreasePencilOpacityModifier_opacity_factor_range");
|
||||
RNA_def_property_ui_text(prop, "Opacity Factor", "Factor of opacity");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "hardness_factor", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "hardness_factor");
|
||||
RNA_def_property_range(prop, 0.0, FLT_MAX);
|
||||
RNA_def_property_ui_range(prop, 0.0, FLT_MAX, 0.1, 2);
|
||||
RNA_def_property_ui_text(prop, "Hardness Factor", "Factor of stroke hardness");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_weight_as_factor", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(
|
||||
prop, nullptr, "flag", MOD_GREASE_PENCIL_OPACITY_USE_WEIGHT_AS_FACTOR);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Use Weight as Factor", "Use vertex group weight as factor instead of influence");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_uniform_opacity", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(
|
||||
prop, nullptr, "flag", MOD_GREASE_PENCIL_OPACITY_USE_UNIFORM_OPACITY);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Uniform Opacity", "Replace the stroke opacity instead of modulating each point");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
RNA_define_lib_overridable(false);
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ static void modify_stroke_color(const GreasePencilOpacityModifierData &omd,
|
|||
const IndexMask &curves_mask)
|
||||
{
|
||||
const bool use_uniform_opacity = (omd.flag & MOD_GREASE_PENCIL_OPACITY_USE_UNIFORM_OPACITY);
|
||||
const bool use_vgroup_opacity = (omd.flag & MOD_GREASE_PENCIL_OPACITY_USE_VERTEX_GROUP);
|
||||
const bool use_weight_as_factor = (omd.flag & MOD_GREASE_PENCIL_OPACITY_USE_WEIGHT_AS_FACTOR);
|
||||
const bool invert_vertex_group = (omd.influence.flag &
|
||||
GREASE_PENCIL_INFLUENCE_INVERT_VERTEX_GROUP);
|
||||
const bool use_curve = (omd.influence.flag & GREASE_PENCIL_INFLUENCE_USE_CUSTOM_CURVE);
|
||||
|
@ -135,7 +135,7 @@ static void modify_stroke_color(const GreasePencilOpacityModifierData &omd,
|
|||
if (use_uniform_opacity) {
|
||||
opacities.span[point_i] = std::clamp(curve_factor, 0.0f, 1.0f);
|
||||
}
|
||||
else if (use_vgroup_opacity) {
|
||||
else if (use_weight_as_factor) {
|
||||
/* Use vertex group weights as opacity factors. */
|
||||
const float vgroup_weight = vgroup_weights[point_i];
|
||||
const float point_factor = vgroup_weight;
|
||||
|
@ -162,7 +162,7 @@ static void modify_fill_color(const GreasePencilOpacityModifierData &omd,
|
|||
bke::CurvesGeometry &curves,
|
||||
const IndexMask &curves_mask)
|
||||
{
|
||||
const bool use_vgroup_opacity = (omd.flag & MOD_GREASE_PENCIL_OPACITY_USE_VERTEX_GROUP);
|
||||
const bool use_vgroup_opacity = (omd.flag & MOD_GREASE_PENCIL_OPACITY_USE_WEIGHT_AS_FACTOR);
|
||||
LukasTonne marked this conversation as resolved
|
||||
const bool invert_vertex_group = (omd.influence.flag &
|
||||
LukasTonne marked this conversation as resolved
Hans Goudey
commented
You can count on the fact that curves always have at least one point You can count on the fact that curves always have at least one point
Lukas Tönne
commented
At least one or at least two? I need two for this length factor calculation. At least one or at least two? I need two for this length factor calculation.
Lukas Tönne
commented
Falk says curves can have 1 point only, so i still need to check. Falk says curves can have 1 point only, so i still need to check.
|
||||
GREASE_PENCIL_INFLUENCE_INVERT_VERTEX_GROUP);
|
||||
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
|
||||
|
|
Loading…
Reference in New Issue
points_range
->points
is the cononical variable name here. "range" is already described by the type