[Bf-blender-cvs] [663e918b097] greasepencil-object: Cleanup: rename color members in gpencil style
Campbell Barton
noreply at git.blender.org
Mon May 28 20:19:50 CEST 2018
Commit: 663e918b09778ec353122342607e903772eb1ce5
Author: Campbell Barton
Date: Mon May 28 19:58:37 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB663e918b09778ec353122342607e903772eb1ce5
Cleanup: rename color members in gpencil style
It reads like a bug to store alpha in variables named 'rgb'
Also remove some redundant casts.
===================================================================
M source/blender/blenkernel/intern/material.c
M source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M source/blender/editors/gpencil/drawgpencil.c
M source/blender/editors/gpencil/gpencil_add_monkey.c
M source/blender/editors/gpencil/gpencil_colorpick.c
M source/blender/editors/gpencil/gpencil_data.c
M source/blender/editors/gpencil/gpencil_fill.c
M source/blender/editors/gpencil/gpencil_paint.c
M source/blender/editors/gpencil/gpencil_utils.c
M source/blender/makesdna/DNA_gpencil_types.h
M source/blender/makesdna/DNA_material_types.h
M source/blender/makesrna/intern/rna_material.c
M source/blender/modifiers/intern/MOD_gpencilcolor.c
M source/blender/modifiers/intern/MOD_gpencilopacity.c
M source/blender/modifiers/intern/MOD_gpenciltint.c
===================================================================
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 45abee90542..dd9f03cbf72 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -118,10 +118,10 @@ void BKE_material_init_gpencil_settings(Material *ma)
MaterialGPencilStyle *gp_style = ma->gp_style;
/* set basic settings */
- gp_style->rgb[3] = 1.0f;
+ gp_style->stroke_rgba[3] = 1.0f;
gp_style->gradient_boxsize = 0.1f;
gp_style->gradient_radius = 0.5f;
- ARRAY_SET_ITEMS(gp_style->scolor, 1.0f, 1.0f, 1.0f, 0.2f);
+ ARRAY_SET_ITEMS(gp_style->mix_rgba, 1.0f, 1.0f, 1.0f, 0.2f);
ARRAY_SET_ITEMS(gp_style->gradient_scale, 1.0f, 1.0f);
ARRAY_SET_ITEMS(gp_style->texture_scale, 1.0f, 1.0f);
gp_style->texture_opacity = 1.0f;
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index d990d1045ad..dec93db121b 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -515,7 +515,7 @@ Gwn_Batch *DRW_gpencil_get_edit_geom(bGPDstroke *gps, float alpha, short dflag)
fsize = vsize;
}
else {
- copy_v4_v4(fcolor, gps->runtime.tmp_rgb);
+ copy_v4_v4(fcolor, gps->runtime.tmp_stroke_rgba);
fsize = bsize;
}
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 1ef111c6642..d2ac45e9c8d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -639,7 +639,7 @@ static void gpencil_draw_onion_strokes(GpencilBatchCache *cache, GPENCIL_e_data
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
- copy_v4_v4(gps->runtime.tmp_rgb, gp_style->rgb);
+ copy_v4_v4(gps->runtime.tmp_rgb, gp_style->stroke_rgba);
copy_v4_v4(gps->runtime.tmp_fill, gp_style->fill);
int id = stl->storage->shgroup_id;
@@ -768,7 +768,7 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
strokegrp = stl->shgroups[id].shgrps_stroke;
/* copy color to temp fields to apply temporal changes in the stroke */
- copy_v4_v4(gps->runtime.tmp_rgb, gp_style->rgb);
+ copy_v4_v4(gps->runtime.tmp_rgb, gp_style->stroke_rgba);
copy_v4_v4(gps->runtime.tmp_fill, gp_style->fill);
/* apply modifiers (only modify geometry, but not create ) */
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 491dedf2727..9ae6dc7b2b0 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -640,7 +640,7 @@ static void gp_draw_stroke_fill(
immBindBuiltinProgram(GPU_SHADER_GPENCIL_FILL);
immUniformColor4fv(color);
- immUniform4fv("color2", gp_style->scolor);
+ immUniform4fv("color2", gp_style->mix_rgba);
immUniform1i("fill_type", gp_style->fill_style);
immUniform1f("mix_factor", gp_style->mix_factor);
@@ -1038,9 +1038,9 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
}
/* if disable fill, the colors with fill must be omitted too except fill boundary strokes */
- if ((tgpw->disable_fill == 1) &&
- (gp_style->fill[3] > 0.0f) &&
- ((gps->flag & GP_STROKE_NOFILL) == 0))
+ if ((tgpw->disable_fill == 1) &&
+ (gp_style->fill_rgba[3] > 0.0f) &&
+ ((gps->flag & GP_STROKE_NOFILL) == 0))
{
continue;
}
@@ -1071,8 +1071,8 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
//if ((dflag & GP_DRAWDATA_FILL) && (gps->totpoints >= 3)) {
if ((gps->totpoints >= 3) && (tgpw->disable_fill != 1)) {
/* set color using material, tint color and opacity */
- interp_v3_v3v3(tfill, gp_style->fill, tgpw->tintcolor, tgpw->tintcolor[3]);
- tfill[3] = gp_style->fill[3] * tgpw->opacity;
+ interp_v3_v3v3(tfill, gp_style->fill_rgba, tgpw->tintcolor, tgpw->tintcolor[3]);
+ tfill[3] = gp_style->fill_rgba[3] * tgpw->opacity;
if ((tfill[3] > GPENCIL_ALPHA_OPACITY_THRESH) || (gp_style->fill_style > 0)) {
const float *color;
if (!tgpw->onion) {
@@ -1083,7 +1083,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
color = tgpw->tintcolor;
}
else {
- ARRAY_SET_ITEMS(tfill, UNPACK3(gp_style->fill), tgpw->tintcolor[3]);
+ ARRAY_SET_ITEMS(tfill, UNPACK3(gp_style->fill_rgba), tgpw->tintcolor[3]);
color = tfill;
}
}
@@ -1094,8 +1094,8 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
/* 3D Stroke */
/* set color using material tint color and opacity */
if (!tgpw->onion) {
- interp_v3_v3v3(tcolor, gp_style->rgb, tgpw->tintcolor, tgpw->tintcolor[3]);
- tcolor[3] = gp_style->rgb[3] * tgpw->opacity;
+ interp_v3_v3v3(tcolor, gp_style->stroke_rgba, tgpw->tintcolor, tgpw->tintcolor[3]);
+ tcolor[3] = gp_style->stroke_rgba[3] * tgpw->opacity;
copy_v4_v4(ink, tcolor);
}
else {
@@ -1103,7 +1103,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
copy_v4_v4(ink, tgpw->tintcolor);
}
else {
- ARRAY_SET_ITEMS(tcolor, gp_style->rgb[0], gp_style->rgb[1], gp_style->rgb[2], tgpw->opacity);
+ ARRAY_SET_ITEMS(tcolor, UNPACK3(gp_style->stroke_rgba), tgpw->opacity);
copy_v4_v4(ink, tcolor);
}
}
@@ -1138,8 +1138,8 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
/* 2D - Fill */
if (gps->totpoints >= 3) {
/* set color using material, tint color and opacity */
- interp_v3_v3v3(tfill, gp_style->fill, tgpw->tintcolor, tgpw->tintcolor[3]);
- tfill[3] = gp_style->fill[3] * tgpw->opacity;
+ interp_v3_v3v3(tfill, gp_style->fill_rgba, tgpw->tintcolor, tgpw->tintcolor[3]);
+ tfill[3] = gp_style->fill_rgba[3] * tgpw->opacity;
if ((tfill[3] > GPENCIL_ALPHA_OPACITY_THRESH) || (gp_style->fill_style > 0)) {
const float *color;
if (!tgpw->onion) {
@@ -1150,8 +1150,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
color = tgpw->tintcolor;
}
else {
- ARRAY_SET_ITEMS(tfill, gp_style->fill[0], gp_style->fill[1], gp_style->fill[2],
- tgpw->tintcolor[3]);
+ ARRAY_SET_ITEMS(tfill, UNPACK3(gp_style->fill_rgba), tgpw->tintcolor[3]);
color = tfill;
}
}
@@ -1162,8 +1161,8 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
/* 2D Strokes... */
/* set color using material, tint color and opacity */
if (!tgpw->onion) {
- interp_v3_v3v3(tcolor, gp_style->rgb, tgpw->tintcolor, tgpw->tintcolor[3]);
- tcolor[3] = gp_style->rgb[3] * tgpw->opacity;
+ interp_v3_v3v3(tcolor, gp_style->stroke_rgba, tgpw->tintcolor, tgpw->tintcolor[3]);
+ tcolor[3] = gp_style->stroke_rgba[3] * tgpw->opacity;
copy_v4_v4(ink, tcolor);
}
else {
@@ -1171,7 +1170,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
copy_v4_v4(ink, tgpw->tintcolor);
}
else {
- ARRAY_SET_ITEMS(tcolor, gp_style->rgb[0], gp_style->rgb[1], gp_style->rgb[2], tgpw->opacity);
+ ARRAY_SET_ITEMS(tcolor, UNPACK3(gp_style->stroke_rgba), tgpw->opacity);
copy_v4_v4(ink, tcolor);
}
}
@@ -1315,7 +1314,7 @@ static void gp_draw_strokes_edit(
immAttrib1f(size, vsize);
}
else {
- immAttrib3fv(color, gp_style->rgb);
+ immAttrib3fv(color, gp_style->stroke_rgba);
immAttrib1f(size, bsize);
}
diff --git a/source/blender/editors/gpencil/gpencil_add_monkey.c b/source/blender/editors/gpencil/gpencil_add_monkey.c
index c994dbd0833..d2ff8d65d9c 100644
--- a/source/blender/editors/gpencil/gpencil_add_monkey.c
+++ b/source/blender/editors/gpencil/gpencil_add_monkey.c
@@ -70,9 +70,9 @@ static int gpencil_monkey_color(Main *bmain, Object *ob, const ColorTemplate *pc
ma = BKE_material_add_gpencil(bmain, pct->name);
assign_material(ob, ma, ob->totcol, BKE_MAT_ASSIGN_EXISTING);
- copy_v4_v4(ma->gp_style->rgb, pct->line);
- copy_v4_v4(ma->gp_style->fill, pct->fill);
-
+ copy_v4_v4(ma->gp_style->stroke_rgba, pct->line);
+ copy_v4_v4(ma->gp_style->fill_rgba, pct->fill);
+
return BKE_object_material_slot_find_index(ob, ma) - 1;
}
diff --git a/source/blender/editors/gpencil/gpencil_colorpick.c b/source/blender/editors/gpencil/gpencil_colorpick.c
index bf6ab13c839..1ba8a0806a7 100644
--- a/source/blender/editors/gpencil/gpencil_colorpick.c
+++ b/source/blender/editors/gpencil/gpencil_colorpick.c
@@ -405,8 +405,8 @@ static tGPDpick *gpencil_colorpick_init(bContext *C, wmOperator *op, const wmEve
MaterialGPencilStyle *gp_style = mat->gp_style;
tcolor->index = idx;
tcolor->mat = mat;
- copy_v4_v4(tcolor->rgba, gp_style->rgb);
- copy_v4_v4(tcolor->fill, gp_style->fill);
+ copy_v4_v4(tcolor->rgba, gp_style->stroke_rgba);
+ copy_v4_v4(tcolor->fill, gp_style->fill_rgba);
/* box position */
tcolor->rect.xmin = tgpk->panel.xmin + (tgpk->boxsize[0] * col) + (GP_BOX_GAP * (col + 1)) - (GP_BOX_GAP / 2);
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index bb8423e18a4..4a1d73fc240 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -2434,16 +2434,16 @@ static int gpencil_convert_old_files_exec(bContext *C, wmOperator *UNUSED(op))
/* copy color settings */
MaterialGPencilStyle *gp_style = ma->gp_style;
- copy_v4_v4(gp_style->rgb, palcolor->color);
- copy_v4_v4(gp_style->fill, palcolor->fill);
+ copy_v4_v4(gp_style->stroke_rgba, palcolor->color);
+ copy_v4_v4(gp_style->fill_rgba, palcolor->fill);
gp_style->flag = palcolor->flag;
/* fix strokes */
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
- if ((gps->colorname[0] != '\0') &&
- (STREQ(gps->colorname, palcolor->info)))
+ if ((gps->colorname[0] != '\0') &&
+ (STREQ(gps->colorname, palcolor->info)))
{
gps->mat_nr = ob->totcol - 1;
gps->colorname[0] = '\0';
diff --
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list