48 bool is_selected =
false;
57 bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
59 if ((gpf == gpl->actframe) || ((gpf->flag &
GP_FRAME_SELECT) && (is_multiedit))) {
70 if (gps->editcurve ==
NULL) {
129 brightness /= 100.0f;
130 float delta = contrast / 200.0f;
137 gain = 1.0f - delta * 2.0f;
138 gain = 1.0f /
max_ff(gain, FLT_EPSILON);
139 offset = gain * (brightness - delta);
143 gain =
max_ff(1.0f - delta * 2.0f, 0.0f);
144 offset = gain * brightness + delta;
149 bool changed =
false;
151 bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
154 if ((gpf == gpl->actframe) || ((gpf->flag &
GP_FRAME_SELECT) && (is_multiedit))) {
168 if (gps->vert_color_fill[3] > 0.0f) {
170 for (
int i2 = 0; i2 < 3; i2++) {
171 gps->vert_color_fill[i2] = gain * gps->vert_color_fill[i2] +
offset;
180 for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
183 for (
int i2 = 0; i2 < 3; i2++) {
214 ot->
name =
"Vertex Paint Brightness/Contrast";
215 ot->
idname =
"GPENCIL_OT_vertex_color_brightness_contrast";
228 const float min = -100,
max = +100;
246 bool changed =
false;
248 bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
251 if ((gpf == gpl->actframe) || ((gpf->flag &
GP_FRAME_SELECT) && (is_multiedit))) {
267 if (gps->vert_color_fill[3] > 0.0f) {
272 hsv[0] += (
hue - 0.5f);
276 else if (hsv[0] < 0.0f) {
291 for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
296 hsv[0] += (
hue - 0.5f);
300 else if (hsv[0] < 0.0f) {
334 ot->
name =
"Vertex Paint Hue Saturation Value";
335 ot->
idname =
"GPENCIL_OT_vertex_color_hsv";
362 bool changed =
false;
364 bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
367 if ((gpf == gpl->actframe) || ((gpf->flag &
GP_FRAME_SELECT) && (is_multiedit))) {
381 if (gps->vert_color_fill[3] > 0.0f) {
383 for (
int i2 = 0; i2 < 3; i2++) {
384 gps->vert_color_fill[i2] = 1.0f - gps->vert_color_fill[i2];
395 for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
398 for (
int i2 = 0; i2 < 3; i2++) {
427 ot->
name =
"Vertex Paint Invert";
428 ot->
idname =
"GPENCIL_OT_vertex_color_invert";
454 bool changed =
false;
456 bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
459 if ((gpf == gpl->actframe) || ((gpf->flag &
GP_FRAME_SELECT) && (is_multiedit))) {
473 if (gps->vert_color_fill[3] > 0.0f) {
475 for (
int i2 = 0; i2 < 3; i2++) {
476 gps->vert_color_fill[i2] = gain * (gps->vert_color_fill[i2] +
offset);
486 for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
489 for (
int i2 = 0; i2 < 3; i2++) {
519 ot->
name =
"Vertex Paint Levels";
520 ot->
idname =
"GPENCIL_OT_vertex_color_levels";
535 ot->
srna,
"offset", 0.0f, -1.0f, 1.0f,
"Offset",
"Value to add to colors", -1.0f, 1.0f);
537 ot->
srna,
"gain", 1.0f, 0.0f, FLT_MAX,
"Gain",
"Value to multiply colors by", 0.0f, 10.0f);
546 Brush *brush = paint->brush;
553 bool changed =
false;
555 bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
558 if ((gpf == gpl->actframe) || ((gpf->flag &
GP_FRAME_SELECT) && (is_multiedit))) {
574 gps->vert_color_fill[3] = factor;
588 for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
618 ot->
name =
"Vertex Paint Set Color";
619 ot->
idname =
"GPENCIL_OT_vertex_color_set";
632 RNA_def_float(
ot->
srna,
"factor", 1.0f, 0.001f, 1.0f,
"Factor",
"Mix Factor", 0.001f, 1.0f);
659 if (gp_style ==
NULL) {
671 if ((!use_fill) && (!use_stroke)) {
687 if (gps->vert_color_fill[3] > 0.0f) {
688 col[0] = truncf(gps->vert_color_fill[0] * range) / range;
689 col[1] = truncf(gps->vert_color_fill[1] * range) / range;
690 col[2] = truncf(gps->vert_color_fill[2] * range) / range;
702 for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
739 if ((use_stroke) && (use_fill)) {
740 switch (gp_style->
mode) {
743 strcpy(name,
"Line Stroke-Fill");
748 strcpy(name,
"Dots Stroke-Fill");
753 strcpy(name,
"Squares Stroke-Fill");
760 else if (use_stroke) {
761 switch (gp_style->
mode) {
764 strcpy(name,
"Line Stroke");
769 strcpy(name,
"Dots Stroke");
774 strcpy(name,
"Squares Stroke");
783 strcpy(name,
"Solid Fill");
822 bool changed =
false;
830 int totmat = *totcol;
849 if (gp_style ==
NULL) {
860 if ((!use_fill) && (!use_stroke)) {
883 for (i = 0; i < totmat; i++) {
884 mat_elm = &mat_table[i];
885 if (mat_elm->
ma ==
NULL) {
888 if (key == mat_elm->
key) {
922 mat_elm = &mat_table[i];
926 gps->mat_nr = mat_elm->
index;
931 gps->vert_color_fill[3] = 1.0f;
936 for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
971 ot->
name =
"Convert Stroke Materials to Vertex Color";
972 ot->
idname =
"GPENCIL_OT_material_to_vertex_color";
973 ot->
description =
"Replace materials in strokes with Vertex Color";
986 "Remove Unused Materials",
987 "Remove any unused material after the conversion");
1023 ot->
name =
"Extract Palette from Vertex Color";
1024 ot->
idname =
"GPENCIL_OT_extract_palette_vertex";
1025 ot->
description =
"Extract all colors used in Grease Pencil Vertex and create a Palette";
1036 ot->
srna,
"selected",
false,
"Only Selected",
"Convert only selected strokes");
1052 for (
int i = 0; i < gps->
totpoints; i++) {
1071 bool changed =
false;
1073 bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
1076 if ((gpf == gpl->actframe) || ((gpf->flag &
GP_FRAME_SELECT) && (is_multiedit))) {
1087 if (is_curve_edit) {
1088 if (gps->editcurve ==
NULL) {
1105 if (!is_multiedit) {
1129 {
GPPAINT_MODE_BOTH,
"BOTH", 0,
"Stroke & Fill",
"Reset Vertex Color to Stroke and Fill"},
1134 ot->
name =
"Reset Vertex Color";
1135 ot->
idname =
"GPENCIL_OT_stroke_reset_vertex_color";
1136 ot->
description =
"Reset vertex color for all or selected strokes";
#define CTX_DATA_BEGIN(C, Type, instance, member)
struct Object * CTX_data_active_object(const bContext *C)
struct Main * CTX_data_main(const bContext *C)
struct ToolSettings * CTX_data_tool_settings(const bContext *C)
General operations, lookup, etc. for materials.
struct MaterialGPencilStyle * BKE_gpencil_material_settings(struct Object *ob, short act)
struct Material * BKE_gpencil_material_add(struct Main *bmain, const char *name)
void BKE_object_material_assign(struct Main *bmain, struct Object *ob, struct Material *ma, short act, int assign_type)
bool BKE_object_material_slot_add(struct Main *bmain, struct Object *ob)
short * BKE_object_material_len_p(struct Object *ob)
@ BKE_MAT_ASSIGN_USERPREF
bool BKE_palette_from_hash(struct Main *bmain, struct GHash *color_table, const char *name, bool linear)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
bool BLI_ghash_haskey(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
GHash * BLI_ghash_int_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
#define LISTBASE_FOREACH(type, var, list)
MINLINE float max_ff(float a, float b)
void hsv_to_rgb_v(const float hsv[3], float r_rgb[3])
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
unsigned int rgb_to_cpack(float r, float g, float b)
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v4(float r[4])
#define POINTER_FROM_INT(i)
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_COPY_ON_WRITE
#define GPENCIL_ANY_VERTEX_MASK(flag)
#define GPENCIL_VERTEX_MODE(gpd)
#define GPENCIL_MULTIEDIT_SESSIONS_ON(gpd)
#define GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)
@ GP_MATERIAL_FILL_STYLE_SOLID
@ GP_MATERIAL_STROKE_STYLE_TEXTURE
@ GP_MATERIAL_STROKE_PATTERN
@ GP_MATERIAL_STROKE_SHOW
@ GP_MATERIAL_MODE_SQUARE
Read Guarded memory(de)allocation.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its hue
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
@ WM_OP_INVOKE_REGION_WIN
bool ED_gpencil_stroke_material_editable(Object *ob, const bGPDlayer *gpl, const bGPDstroke *gps)
bool ED_gpencil_stroke_can_use(const bContext *C, const bGPDstroke *gps)
static int gpencil_material_to_vertex_exec(bContext *C, wmOperator *op)
static bool gpencil_vertexpaint_mode_poll(bContext *C)
static int gpencil_vertexpaint_hsv_exec(bContext *C, wmOperator *op)
static int gpencil_vertexpaint_set_exec(bContext *C, wmOperator *op)
static int gpencil_vertexpaint_brightness_contrast_exec(bContext *C, wmOperator *op)
static const EnumPropertyItem gpencil_modesEnumPropertyItem_mode[]
static int gpencil_stroke_reset_vertex_color_exec(bContext *C, wmOperator *op)
static bool gpencil_extract_palette_vertex_poll(bContext *C)
static int gpencil_vertexpaint_invert_exec(bContext *C, wmOperator *op)
void GPENCIL_OT_stroke_reset_vertex_color(wmOperatorType *ot)
static uint get_material_type(MaterialGPencilStyle *gp_style, bool use_stroke, bool use_fill, char *name)
static int gpencil_vertexpaint_levels_exec(bContext *C, wmOperator *op)
static void gpencil_reset_vertex(bGPDstroke *gps, eGp_Vertex_Mode mode)
void GPENCIL_OT_vertex_color_levels(wmOperatorType *ot)
static bool gpencil_material_to_vertex_poll(bContext *C)
void GPENCIL_OT_vertex_color_invert(wmOperatorType *ot)
void GPENCIL_OT_vertex_color_hsv(wmOperatorType *ot)
void GPENCIL_OT_vertex_color_brightness_contrast(wmOperatorType *ot)
static bool gpencil_extract_palette_from_vertex(bContext *C, const bool selected, const int threshold)
static bool is_any_stroke_selected(bContext *C, const bool is_multiedit, const bool is_curve_edit)
void GPENCIL_OT_vertex_color_set(wmOperatorType *ot)
struct GPMatArray GPMatArray
void GPENCIL_OT_material_to_vertex_color(wmOperatorType *ot)
static int gpencil_extract_palette_vertex_exec(bContext *C, wmOperator *op)
void GPENCIL_OT_extract_palette_vertex(wmOperatorType *ot)
ccl_gpu_kernel_postfix ccl_global float int int int int float threshold
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
ccl_device_inline float3 pow(float3 v, float e)
bool remove(void *owner, const AttributeIDRef &attribute_id)
int RNA_int_get(PointerRNA *ptr, const char *name)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
struct MaterialGPencilStyle * gp_style
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
int WM_operator_name_call(bContext *C, const char *opstring, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)