GPv3: Opacity modifier #116946
|
@ -2511,6 +2511,14 @@ typedef struct GreasePencilModifierVertexGroupData {
|
|||
char _pad[4];
|
||||
} GreasePencilModifierVertexGroupData;
|
||||
|
||||
typedef struct GreasePencilModifierCustomCurveData {
|
||||
struct CurveMapping *curve;
|
||||
/** GreasePencilModifierFilterFlag */
|
||||
int flag;
|
||||
char _pad1[4];
|
||||
void *_pad2;
|
||||
} GreasePencilModifierCustomCurveData;
|
||||
|
||||
typedef enum GreasePencilModifierInfluenceFlag {
|
||||
GREASE_PENCIL_INFLUENCE_INVERT_LAYER_FILTER = (1 << 0),
|
||||
GREASE_PENCIL_INFLUENCE_USE_LAYER_PASS_FILTER = (1 << 1),
|
||||
|
@ -2519,6 +2527,7 @@ typedef enum GreasePencilModifierInfluenceFlag {
|
|||
GREASE_PENCIL_INFLUENCE_USE_MATERIAL_PASS_FILTER = (1 << 4),
|
||||
GREASE_PENCIL_INFLUENCE_INVERT_MATERIAL_PASS_FILTER = (1 << 5),
|
||||
GREASE_PENCIL_INFLUENCE_INVERT_VERTEX_GROUP = (1 << 6),
|
||||
GREASE_PENCIL_INFLUENCE_USE_CUSTOM_CURVE = (1 << 7),
|
||||
} GreasePencilModifierInfluenceFlag;
|
||||
/**
|
||||
* Combined generic influence data for grease pencil modifiers.
|
||||
|
@ -2528,4 +2537,5 @@ typedef struct GreasePencilModifierInfluenceData {
|
|||
GreasePencilModifierLayerFilter layer_filter;
|
||||
GreasePencilModifierMaterialFilter material_filter;
|
||||
GreasePencilModifierVertexGroupData vertex_group;
|
||||
GreasePencilModifierCustomCurveData custom_curve;
|
||||
} GreasePencilModifierInfluenceData;
|
||||
|
|
|
@ -7588,11 +7588,35 @@ static void rna_def_modifier_grease_pencil_vertex_group(BlenderRNA *brna)
|
|||
RNA_define_lib_overridable(false);
|
||||
}
|
||||
|
||||
static void rna_def_modifier_grease_pencil_custom_curve(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
srna = RNA_def_struct(brna, "GreasePencilModifierCustomCurveData", nullptr);
|
||||
RNA_def_struct_ui_text(srna,
|
||||
"Grease Pencil Modifier Custom Curve",
|
||||
"Custom curve settings for grease pencil modifiers");
|
||||
RNA_def_struct_sdna(srna, "GreasePencilModifierCustomCurveData");
|
||||
|
||||
prop = RNA_def_property(srna, "use_custom_curve", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", GREASE_PENCIL_INFLUENCE_USE_CUSTOM_CURVE);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Use Custom Curve", "Use a custom curve to define a factor along the strokes");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_pointer_sdna(prop, nullptr, "curve");
|
||||
RNA_def_property_ui_text(prop, "Curve", "Custom curve to apply effect");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
}
|
||||
|
||||
/** Utility function to register common influence properties for grease pencil modifiers. */
|
||||
static void rna_def_modifier_grease_pencil_influence_properties(StructRNA *srna,
|
||||
const char *layer_filter_sdna,
|
||||
const char *material_filter_sdna,
|
||||
const char *vertex_group_sdna)
|
||||
const char *vertex_group_sdna,
|
||||
const char *custom_curve_sdna)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
|
@ -7614,6 +7638,12 @@ static void rna_def_modifier_grease_pencil_influence_properties(StructRNA *srna,
|
|||
RNA_def_property_struct_type(prop, "GreasePencilModifierVertexGroupData");
|
||||
RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group settings");
|
||||
}
|
||||
if (custom_curve_sdna) {
|
||||
prop = RNA_def_property(srna, "custom_curve", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_pointer_sdna(prop, nullptr, custom_curve_sdna);
|
||||
RNA_def_property_struct_type(prop, "GreasePencilModifierCustomCurveData");
|
||||
RNA_def_property_ui_text(prop, "Custom Curve", "Custom curve settings");
|
||||
}
|
||||
}
|
||||
|
||||
void RNA_def_modifier(BlenderRNA *brna)
|
||||
|
@ -7779,6 +7809,7 @@ void RNA_def_modifier(BlenderRNA *brna)
|
|||
rna_def_modifier_grease_pencil_layer_filter(brna);
|
||||
rna_def_modifier_grease_pencil_material_filter(brna);
|
||||
rna_def_modifier_grease_pencil_vertex_group(brna);
|
||||
rna_def_modifier_grease_pencil_custom_curve(brna);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "DNA_modifier_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_colortools.hh"
|
||||
#include "BKE_curves.hh"
|
||||
#include "BKE_grease_pencil.hh"
|
||||
#include "BKE_lib_query.h"
|
||||
|
@ -36,16 +37,31 @@ namespace blender::greasepencil {
|
|||
using bke::greasepencil::Drawing;
|
||||
using bke::greasepencil::Layer;
|
||||
|
||||
void init_influence_data(GreasePencilModifierInfluenceData * /*influence_data*/) {}
|
||||
void init_influence_data(GreasePencilModifierInfluenceData *influence_data,
|
||||
const bool has_custom_curve)
|
||||
{
|
||||
if (has_custom_curve) {
|
||||
influence_data->custom_curve.curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
|
||||
BKE_curvemapping_init(influence_data->custom_curve.curve);
|
||||
}
|
||||
}
|
||||
|
||||
void copy_influence_data(const GreasePencilModifierInfluenceData *influence_data_src,
|
||||
GreasePencilModifierInfluenceData *influence_data_dst,
|
||||
const int /*flag*/)
|
||||
{
|
||||
memcpy(influence_data_dst, influence_data_src, sizeof(GreasePencilModifierInfluenceData));
|
||||
influence_data_dst->custom_curve.curve = BKE_curvemapping_copy(
|
||||
influence_data_src->custom_curve.curve);
|
||||
}
|
||||
|
||||
void free_influence_data(GreasePencilModifierInfluenceData * /*influence_data*/) {}
|
||||
void free_influence_data(GreasePencilModifierInfluenceData *influence_data)
|
||||
{
|
||||
if (influence_data->custom_curve.curve) {
|
||||
BKE_curvemapping_free(influence_data->custom_curve.curve);
|
||||
influence_data->custom_curve.curve = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void foreach_influence_ID_link(GreasePencilModifierInfluenceData *influence_data,
|
||||
Object *ob,
|
||||
|
@ -112,7 +128,7 @@ void draw_material_filter_settings(const bContext * /*C*/, uiLayout *layout, Poi
|
|||
void draw_vertex_group_settings(const bContext * /*C*/, uiLayout *layout, PointerRNA *ptr)
|
||||
{
|
||||
PointerRNA ob_ptr = RNA_pointer_create(ptr->owner_id, &RNA_Object, ptr->owner_id);
|
||||
bool has_vertex_group = RNA_string_length(ptr, "name") != 0;
|
||||
bool has_vertex_group = RNA_string_length(ptr, "vertex_group_name") != 0;
|
||||
uiLayout *row, *sub;
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
@ -125,6 +141,18 @@ void draw_vertex_group_settings(const bContext * /*C*/, uiLayout *layout, Pointe
|
|||
uiItemR(sub, ptr, "invert_vertex_group", UI_ITEM_NONE, "", ICON_ARROW_LEFTRIGHT);
|
||||
}
|
||||
|
||||
void draw_custom_curve_settings(const bContext * /*C*/, uiLayout *layout, PointerRNA *ptr)
|
||||
{
|
||||
bool use_custom_curve = RNA_boolean_get(ptr, "use_custom_curve");
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, ptr, "use_custom_curve", UI_ITEM_NONE, nullptr, ICON_NONE);
|
||||
if (use_custom_curve) {
|
||||
uiTemplateCurveMapping(layout, ptr, "curve", 0, false, false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of pass IDs used by grease pencil materials.
|
||||
* This way the material pass can be looked up by index instead of having to get the material for
|
||||
|
|
|
@ -31,7 +31,7 @@ class Drawing;
|
|||
|
||||
namespace blender::greasepencil {
|
||||
|
||||
void init_influence_data(GreasePencilModifierInfluenceData *influence_data);
|
||||
void init_influence_data(GreasePencilModifierInfluenceData *influence_data, bool has_custom_curve);
|
||||
void copy_influence_data(const GreasePencilModifierInfluenceData *influence_data_src,
|
||||
GreasePencilModifierInfluenceData *influence_data_dst,
|
||||
int flag);
|
||||
|
@ -43,7 +43,8 @@ void foreach_influence_ID_link(GreasePencilModifierInfluenceData *influence_data
|
|||
|
||||
void draw_layer_filter_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr);
|
||||
void draw_material_filter_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr);
|
||||
void draw_vertex_group_settings(const bContext * /*C*/, uiLayout *layout, PointerRNA *ptr);
|
||||
void draw_vertex_group_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr);
|
||||
void draw_custom_curve_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr);
|
||||
|
||||
IndexMask get_filtered_layer_mask(const GreasePencil &grease_pencil,
|
||||
const GreasePencilModifierLayerFilter &filter,
|
||||
|
|
Loading…
Reference in New Issue