GPv3: Opacity modifier #116946

Merged
Lukas Tönne merged 52 commits from LukasTonne/blender:gp3-opacity-modifier into main 2024-01-16 16:56:22 +01:00
5 changed files with 45 additions and 32 deletions
Showing only changes of commit a3109b6e82 - Show all commits

View File

@ -2511,6 +2511,13 @@ typedef enum GreasePencilModifierFilterFlag {
typedef struct GreasePencilOpacityModifierData {
ModifierData modifier;
/** GreasePencilOpacityModifierFlag */
int flag;
char _pad1[4];
GreasePencilModifierFilterData filter;
void *_pad;
void *_pad2;
} GreasePencilOpacityModifierData;
typedef enum GreasePencilOpacityModifierFlag {
MOD_GREASE_PENCIL_OPACITY_OPEN_INFLUENCE_PANEL = (1 << 0),
} GreasePencilOpacityModifierFlag;

View File

@ -7548,6 +7548,13 @@ static void rna_def_modifier_grease_pencil_opacity(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "GreasePencilModifierFilter");
RNA_def_property_ui_text(prop, "Filter", "Filter settings");
prop = RNA_def_property(srna, "open_influence_panel", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(
prop, nullptr, "flag", MOD_GREASE_PENCIL_OPACITY_OPEN_INFLUENCE_PANEL);
RNA_def_property_ui_text(prop, "Open Influence Panel", "Open the influence panel");
RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, nullptr);
RNA_define_lib_overridable(true);
// TODO

View File

@ -139,13 +139,20 @@ static void modify_geometry_set(ModifierData *md,
}
}
static void panel_draw(const bContext * /*C*/, Panel *panel)
static void panel_draw(const bContext *C, Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ob_ptr;
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
if (uiLayout *influence_panel = uiLayoutPanel(
C, layout, "Influence", ptr, "open_influence_panel"))
{
PointerRNA filter_ptr = RNA_pointer_get(ptr, "filter");
greasepencil::draw_influence_settings(C, influence_panel, &filter_ptr);
}
uiLayoutSetPropSep(layout, true);
// TODO
@ -155,9 +162,7 @@ static void panel_draw(const bContext * /*C*/, Panel *panel)
static void panel_register(ARegionType *region_type)
{
PanelType *panel_type = modifier_panel_register(
region_type, eModifierType_GreasePencilOpacity, panel_draw);
greasepencil::filter_subpanel_register(region_type, panel_type);
modifier_panel_register(region_type, eModifierType_GreasePencilOpacity, panel_draw);
LukasTonne marked this conversation as resolved
Review

points_range -> points is the cononical variable name here. "range" is already described by the type

`points_range` -> `points` is the cononical variable name here. "range" is already described by the type
}
LukasTonne marked this conversation as resolved
Review

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
Review

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.
Review

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.
static void blend_write(BlendWriter *writer, const ID * /*id_owner*/, const ModifierData *md)

View File

@ -27,6 +27,7 @@
#include "MOD_ui_common.hh"
#include "RNA_access.hh"
#include "RNA_prototypes.h"
#include "UI_interface.hh"
@ -54,60 +55,49 @@ void foreach_ID_link_filter(GreasePencilModifierFilterData *filter_data,
walk(user_data, ob, (ID **)&filter_data->material, IDWALK_CB_USER);
}
static void filter_panel_draw(const bContext * /*C*/, Panel *panel)
void draw_influence_settings(const bContext * /*C*/, uiLayout *layout, PointerRNA *ptr)
{
uiLayout *row, *col, *sub;
uiLayout *layout = panel->layout;
PointerRNA ob_ptr;
PointerRNA *modifier_ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
PointerRNA ptr = RNA_pointer_get(modifier_ptr, "filter");
PointerRNA ob_ptr = RNA_pointer_create(ptr->owner_id, &RNA_Object, ptr->owner_id);
PointerRNA obj_data_ptr = RNA_pointer_get(&ob_ptr, "data");
const bool use_layer_pass = RNA_boolean_get(&ptr, "use_layer_pass");
const bool use_material_pass = RNA_boolean_get(&ptr, "use_material_pass");
const bool use_layer_pass = RNA_boolean_get(ptr, "use_layer_pass");
const bool use_material_pass = RNA_boolean_get(ptr, "use_material_pass");
uiLayout *row, *col, *sub;
uiLayoutSetPropSep(layout, true);
col = uiLayoutColumn(layout, true);
row = uiLayoutRow(col, true);
uiItemPointerR(row, &ptr, "layer", &obj_data_ptr, "layers", nullptr, ICON_GREASEPENCIL);
uiItemPointerR(row, ptr, "layer", &obj_data_ptr, "layers", nullptr, ICON_GREASEPENCIL);
sub = uiLayoutRow(row, true);
uiLayoutSetPropDecorate(sub, false);
uiItemR(sub, &ptr, "invert_layer", UI_ITEM_NONE, "", ICON_ARROW_LEFTRIGHT);
uiItemR(sub, ptr, "invert_layer", UI_ITEM_NONE, "", ICON_ARROW_LEFTRIGHT);
/* TODO Would be nice to have the checkbox in the same line as the pass button. */
row = uiLayoutRow(col, true);
uiItemR(row, &ptr, "use_layer_pass", UI_ITEM_NONE, "Filter by layer pass", ICON_NONE);
uiItemR(row, ptr, "use_layer_pass", UI_ITEM_NONE, "Filter by layer pass", ICON_NONE);
row = uiLayoutRow(col, true);
uiLayoutSetActive(row, use_layer_pass);
uiItemR(row, &ptr, "layer_pass", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(row, ptr, "layer_pass", UI_ITEM_NONE, nullptr, ICON_NONE);
sub = uiLayoutRow(row, true);
uiLayoutSetPropDecorate(sub, false);
uiItemR(sub, &ptr, "invert_layer_pass", UI_ITEM_NONE, "", ICON_ARROW_LEFTRIGHT);
uiItemR(sub, ptr, "invert_layer_pass", UI_ITEM_NONE, "", ICON_ARROW_LEFTRIGHT);
col = uiLayoutColumn(layout, true);
row = uiLayoutRow(col, true);
uiItemPointerR(row, &ptr, "material", &obj_data_ptr, "materials", nullptr, ICON_SHADING_TEXTURE);
uiItemPointerR(row, ptr, "material", &obj_data_ptr, "materials", nullptr, ICON_SHADING_TEXTURE);
sub = uiLayoutRow(row, true);
uiLayoutSetPropDecorate(sub, false);
uiItemR(sub, &ptr, "invert_material", UI_ITEM_NONE, "", ICON_ARROW_LEFTRIGHT);
uiItemR(sub, ptr, "invert_material", UI_ITEM_NONE, "", ICON_ARROW_LEFTRIGHT);
/* TODO Would be nice to have the checkbox in the same line as the pass button. */
row = uiLayoutRow(col, true);
uiItemR(row, &ptr, "use_material_pass", UI_ITEM_NONE, "Filter by material pass", ICON_NONE);
uiItemR(row, ptr, "use_material_pass", UI_ITEM_NONE, "Filter by material pass", ICON_NONE);
row = uiLayoutRow(col, true);
uiLayoutSetActive(row, use_material_pass);
uiItemR(row, &ptr, "material_pass", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(row, ptr, "material_pass", UI_ITEM_NONE, nullptr, ICON_NONE);
sub = uiLayoutRow(row, true);
uiLayoutSetPropDecorate(sub, false);
uiItemR(sub, &ptr, "invert_material_pass", UI_ITEM_NONE, "", ICON_ARROW_LEFTRIGHT);
}
void filter_subpanel_register(ARegionType *region_type, PanelType *panel_type)
{
modifier_subpanel_register(
region_type, "influence", "Influence", nullptr, filter_panel_draw, panel_type);
uiItemR(sub, ptr, "invert_material_pass", UI_ITEM_NONE, "", ICON_ARROW_LEFTRIGHT);
}
/**

View File

@ -14,9 +14,12 @@
#include "BKE_modifier.hh"
struct ARegionType;
struct bContext;
struct GreasePencil;
struct GreasePencilModifierFilterData;
struct PanelType;
struct PointerRNA;
struct uiLayout;
namespace blender::bke {
class CurvesGeometry;
namespace greasepencil {
@ -35,7 +38,8 @@ void foreach_ID_link_filter(GreasePencilModifierFilterData *filter_data,
Object *ob,
IDWalkFunc walk,
void *user_data);
void filter_subpanel_register(ARegionType *region_type, PanelType *panel_type);
void draw_influence_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr);
IndexMask get_filtered_layer_mask(const GreasePencil &grease_pencil,
const GreasePencilModifierFilterData &filter_data,