Commit: d5b64198782db8bbf8a3e66626b7c4b0da2c0a93
Author: Antonio Vazquez
Date:   Mon Apr 23 19:55:48 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rBd5b64198782db8bbf8a3e66626b7c4b0da2c0a93

Create new fields in material for moving palettecolor

===================================================================

M       source/blender/makesdna/DNA_material_types.h
M       source/blender/makesrna/intern/rna_material.c
M       source/tools

===================================================================

diff --git a/source/blender/makesdna/DNA_material_types.h 
b/source/blender/makesdna/DNA_material_types.h
index 564e6aee3fc..0a54bd71838 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -64,6 +64,54 @@ typedef struct TexPaintSlot {
 #define CLAY_MATCAP_SIMPLE             1
 #define CLAY_MATCAP_COMPLETE   2
 
+typedef struct GpencilColorData {
+       struct Image *sima;      /* Texture image for strokes */
+       struct Image *ima;       /* Texture image for filling */
+       float rgb[4];            /* color for paint and strokes (alpha 
included) */
+       float fill[4];           /* color that should be used for drawing 
"fills" for strokes (alpha included) */
+       float scolor[4];         /* secondary color used for gradients and 
other stuff */
+       short flag;              /* settings for palette color */
+       short index;             /* custom index for passes */
+       short stroke_style;      /* style for drawing strokes (used to select 
shader type) */
+       short fill_style;        /* style for filling areas (used to select 
shader type) */
+       float mix_factor;        /* factor used to define shader behavior 
(several uses) */
+       float g_angle;           /* angle used for gradients orientation */
+       float g_radius;          /* radius for radial gradients */
+       float g_boxsize;         /* cheesboard size */
+       float g_scale[2];        /* uv coordinates scale */
+       float g_shift[2];        /* factor to shift filling in 2d space */
+       float t_angle;           /* angle used for texture orientation */
+       float t_scale[2];        /* texture scale (separated of uv scale) */
+       float t_offset[2];       /* factor to shift texture in 2d space */
+       float t_opacity;         /* texture opacity */
+       float t_pixsize;         /* pixel size for uv along the stroke */
+       int mode;                /* drawing mode (line or dots) */
+} GpencilColorData;
+
+/* GpencilColor->flag */
+typedef enum eGpencilColorData_Flag {
+       /* don't display color */
+       GPC_COLOR_HIDE = (1 << 1),
+       /* protected from further editing */
+       GPC_COLOR_LOCKED = (1 << 2),
+       /* do onion skinning */
+       GPC_COLOR_ONIONSKIN = (1 << 3),
+       /* clamp texture */
+       GPC_COLOR_TEX_CLAMP = (1 << 4),
+       /* mix texture */
+       GPC_COLOR_TEX_MIX = (1 << 5),
+       /* Flip fill colors */
+       GPC_COLOR_FLIP_FILL = (1 << 6),
+       /* Texture is a pattern */
+       GPC_COLOR_PATTERN = (1 << 7)
+} eGpencilColorData_Flag;
+
+typedef enum eGpencilColorData_Mode {
+       GPC_MODE_LINE = 0, /* line */
+       GPC_MODE_DOTS = 1, /* dots */
+       GPC_MODE_BOX = 2, /* rectangles */
+} eGpencilColorData_Mode;
+
 typedef struct Material {
        ID id;
        struct AnimData *adt;   /* animation data (must be immediately after id 
for utilities to use it) */ 
@@ -111,6 +159,9 @@ typedef struct Material {
 
        /* Runtime cache for GLSL materials. */
        ListBase gpumaterial;
+
+       /* grease pencil color */
+       struct GpencilColorData *gpcolor;
 } Material;
 
 /* **************** MATERIAL ********************* */
@@ -233,5 +284,21 @@ enum {
        MA_BS_HASHED,
 };
 
+/* Grease Pencil Stroke styles */
+enum {
+       GPC_STROKE_STYLE_SOLID = 0,
+       GPC_STROKE_STYLE_TEXTURE
+};
+
+/* Grease Pencil Fill styles */
+enum {
+       GPC_FILL_STYLE_SOLID = 0,
+       GPC_FILL_STYLE_GRADIENT,
+       GPC_FILL_STYLE_RADIAL,
+       GPC_FILL_STYLE_CHESSBOARD,
+       GPC_FILL_STYLE_TEXTURE,
+       GPC_FILL_STYLE_PATTERN,
+};
+
 #endif
 
diff --git a/source/blender/makesrna/intern/rna_material.c 
b/source/blender/makesrna/intern/rna_material.c
index 0621c1e1ad6..ed88fe0e619 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -72,6 +72,7 @@ const EnumPropertyItem rna_enum_ramp_blend_items[] = {
 #include "BKE_colorband.h"
 #include "BKE_context.h"
 #include "BKE_main.h"
+#include "BKE_gpencil.h"
 #include "BKE_material.h"
 #include "BKE_texture.h"
 #include "BKE_node.h"
@@ -248,6 +249,62 @@ void rna_mtex_texture_slots_clear(ID *self_id, struct 
bContext *C, ReportList *r
        WM_event_add_notifier(C, NC_TEXTURE, CTX_data_scene(C));
 }
 
+static void rna_gpcolordata_uv_update(Main *bmain, Scene *scene, PointerRNA 
*ptr)
+{
+       /* update all uv strokes of this color */
+       GpencilColorData *gpcolor = (GpencilColorData *)ptr->data;
+       //ED_gpencil_update_color_uv(bmain, palette, gpcolor);
+
+       rna_Material_update(bmain, scene, ptr);
+}
+
+static char *rna_GpencilColorData_path(PointerRNA *ptr)
+{
+       Material *ma = ptr->id.data;
+       GpencilColorData *gpcolor = (GpencilColorData *)ptr->data;
+       char name_esc[sizeof(ma->id.name) * 2];
+
+       BLI_strescape(name_esc, ma->id.name, sizeof(name_esc));
+
+       return BLI_sprintfN("grease_pencil[\"%s\"]", name_esc);
+
+}
+static int rna_GpencilColorData_is_stroke_visible_get(PointerRNA *ptr)
+{
+       GpencilColorData *pcolor = (GpencilColorData *)ptr->data;
+       return (pcolor->rgb[3] > GPENCIL_ALPHA_OPACITY_THRESH);
+}
+
+static int rna_GpencilColorData_is_fill_visible_get(PointerRNA *ptr)
+{
+       GpencilColorData *pcolor = (GpencilColorData *)ptr->data;
+       return ((pcolor->fill[3] > GPENCIL_ALPHA_OPACITY_THRESH) || 
(pcolor->fill_style > 0));
+}
+
+static void rna_GpencilColorData_stroke_image_set(PointerRNA *ptr, PointerRNA 
value)
+{
+       GpencilColorData *pcolor = (GpencilColorData *)ptr->data;
+       ID *id = value.data;
+
+       if (id) {
+               /* enable fake user */
+               id_fake_user_set(id);
+       }
+       pcolor->sima = (struct Image *)id;
+}
+
+static void rna_GpencilColorData_fill_image_set(PointerRNA *ptr, PointerRNA 
value)
+{
+       GpencilColorData *pcolor = (GpencilColorData *)ptr->data;
+       ID *id = value.data;
+
+       if (id) {
+               /* enable fake user */
+               id_fake_user_set(id);
+       }
+       pcolor->ima = (struct Image *)id;
+}
+
 #else
 
 static void rna_def_material_colors(StructRNA *srna)
@@ -316,6 +373,263 @@ static void rna_def_material_raymirror(BlenderRNA *brna)
        RNA_def_property_update(prop, 0, "rna_Material_update");
 }
 
+static void rna_def_material_greasepencil(BlenderRNA *brna)
+{
+       StructRNA *srna;
+       PropertyRNA *prop;
+
+       /* mode type styles */
+       static EnumPropertyItem gpcolordata_mode_types_items[] = {
+               { GPC_MODE_LINE, "LINE", 0, "Line", "Draw strokes using a 
continuous line" },
+               { GPC_MODE_DOTS, "DOTS", 0, "Dots", "Draw strokes using 
separated dots" },
+               { GPC_MODE_BOX, "BOX", 0, "Boxes", "Draw strokes using 
separated rectangle boxes" },
+               { 0, NULL, 0, NULL, NULL }
+       };
+
+       /* stroke styles */
+       static EnumPropertyItem stroke_style_items[] = {
+               { GPC_STROKE_STYLE_SOLID, "SOLID", 0, "Solid", "Draw strokes 
with solid color" },
+               { GPC_STROKE_STYLE_TEXTURE, "TEXTURE", 0, "Texture", "Draw 
strokes using texture" },
+               { 0, NULL, 0, NULL, NULL }
+       };
+
+       /* fill styles */
+       static EnumPropertyItem fill_style_items[] = {
+               { GPC_FILL_STYLE_SOLID, "SOLID", 0, "Solid", "Fill area with 
solid color" },
+               { GPC_FILL_STYLE_GRADIENT, "GRADIENT", 0, "Gradient", "Fill 
area with gradient color" },
+               { GPC_FILL_STYLE_RADIAL, "RADIAL", 0, "Radial", "Fill area with 
radial gradient" },
+               { GPC_FILL_STYLE_CHESSBOARD, "CHESSBOARD", 0, "Checker Board", 
"Fill area with chessboard pattern" },
+               { GPC_FILL_STYLE_TEXTURE, "TEXTURE", 0, "Texture", "Fill area 
with image texture" },
+               { GPC_FILL_STYLE_PATTERN, "PATTERN", 0, "Pattern", "Fill area 
with color but use image texture as pattern to distribute color" },
+               { 0, NULL, 0, NULL, NULL }
+       };
+
+       srna = RNA_def_struct(brna, "GpencilColorData", NULL);
+       RNA_def_struct_sdna(srna, "GpencilColorData");
+       RNA_def_struct_ui_text(srna, "Grease Pencil Color", "");
+       /* TODO (antoniov): add animation path */
+       //RNA_def_struct_path_func(srna, "rna_GpencilColorData_path");
+
+       prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
+       RNA_def_property_range(prop, 0.0, 1.0);
+       RNA_def_property_float_sdna(prop, NULL, "rgb");
+       RNA_def_property_array(prop, 3);
+       RNA_def_property_ui_text(prop, "Color", "");
+       RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | 
ND_DATA | NC_GPENCIL, "rna_Material_update");
+
+       prop = RNA_def_property(srna, "color_rgba", PROP_FLOAT, 
PROP_COLOR_GAMMA);
+       RNA_def_property_range(prop, 0.0, 1.0);
+       RNA_def_property_float_sdna(prop, NULL, "rgb");
+       RNA_def_property_array(prop, 4);
+       RNA_def_property_ui_text(prop, "Color", "");
+       RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | 
ND_DATA | NC_GPENCIL, "rna_Material_update");
+
+       prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "rgb[3]");
+       RNA_def_property_range(prop, 0.0, 1.0f);
+       RNA_def_property_ui_text(prop, "Opacity", "Color Opacity");
+       RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | 
NC_GPENCIL, "rna_Material_update");
+
+       /* Fill Drawing Color */
+       prop = RNA_def_property(srna, "fill_color", PROP_FLOAT, 
PROP_COLOR_GAMMA);
+       RNA_def_property_float_sdna(prop, NULL, "fill");
+       RNA_def_property_array(prop, 3);
+       RNA_def_property_range(prop, 0.0f, 1.0f);
+       RNA_def_property_ui_text(prop, "Fill Color", "Color for filling region 
bounded by each stroke");
+       RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | 
ND_DATA | NC_GPENCIL, "rna_Material_update");
+
+       prop = RNA_def_property(srna, "fill_rgba", PROP_FLOAT, 
PROP_COLOR_GAMMA);
+       RNA_def_property_float_sdna(prop, NULL, "fill");
+       RNA_def_property_array(prop, 4);
+       RNA_def_property_range(prop, 0.0f, 1.0f);
+       RNA_def_property_ui_text(prop, "Fill Color", "Color for filling region 
bounded by each stroke");
+       RNA_def_property_update(prop, NC_SCREEN | NC_SCENE | ND_TOOLSETTINGS | 
ND_DATA | NC_GPENCIL, "rna_Material_update");
+
+       /* Fill alpha */
+       prop = RNA_def_property(srna, "fill_alpha", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "fill[3]");
+       RNA_def_property_range(prop, 0.0, 1.0f);
+       RNA_def_property_ui_text(prop, "Fill Opacity", "Opacity for filling 
region bounded by each stroke");
+       RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | 
NC_GPENCIL, "rna_Material_update");
+
+       /* Secondary Drawing Color */
+       prop = RNA_def_property(srna, "mix_color", PROP_FLOAT, 
PROP_COLOR_GAMMA);
+       RNA_def_property_float_sdna(prop, NULL, "scolor");
+       RNA_def_property_array(prop, 4);
+       RNA_def_property_range(prop, 0.0f, 1.0f);
+       RNA_def_property_ui_text(prop, "Mix Color", "Color for mixing with 
primary filling color");
+       RNA_def_property_update(prop, NC_SCENE | ND

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to