Commit: e486461f23d1eacf009a097c890181304428edee Author: Darshan Kadu Date: Sat Jul 8 00:39:24 2017 +0530 Branches: soc-2017-vertex_paint https://developer.blender.org/rBe486461f23d1eacf009a097c890181304428edee
added the alpha channel in vpaint a slider and change in ply exporter =================================================================== M release/scripts/startup/bl_ui/space_view3d_toolbar.py M source/blender/editors/sculpt_paint/paint_vertex.c M source/blender/makesdna/DNA_brush_types.h M source/blender/makesrna/intern/rna_brush.c M source/blender/makesrna/intern/rna_mesh.c =================================================================== diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index b54557250fd..e8f764afe47 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1167,6 +1167,10 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): col.separator() col.prop(brush, "vertex_tool", text="Blend") col.prop(brush,"use_accumulate") + col.prop(brush,"use_alpha_vpaint") + sub = col.column() + sub.active = brush.use_alpha_vpaint + sub.prop(brush, "alpha_vpaint", text="Alpha", slider=True) col.separator() col.template_ID(settings, "palette", new="palette.new") diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 7be6a18e4d8..ce67cf87ea6 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -568,7 +568,8 @@ void vpaint_dogamma(Scene *scene) } #endif -BLI_INLINE unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac) +BLI_INLINE unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac, + const bool use_alpha, const unsigned char alpha_value) { unsigned char *cp1, *cp2, *cp; int mfac; @@ -600,12 +601,13 @@ BLI_INLINE unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac cp[0] = (unsigned char)round(sqrt(divide_round_i((mfac * r1 + fac * r2), 255))); cp[1] = (unsigned char)round(sqrt(divide_round_i((mfac * g1 + fac * g2), 255))); cp[2] = (unsigned char)round(sqrt(divide_round_i((mfac * b1 + fac * b2), 255))); - cp[3] = 255; + cp[3] = use_alpha ? alpha_value : 255; return col; } -BLI_INLINE unsigned int mcol_add(unsigned int col1, unsigned int col2, int fac) +BLI_INLINE unsigned int mcol_add(unsigned int col1, unsigned int col2, int fac, + const bool use_alpha, const unsigned char alpha_value) { unsigned char *cp1, *cp2, *cp; int temp; @@ -625,12 +627,13 @@ BLI_INLINE unsigned int mcol_add(unsigned int col1, unsigned int col2, int fac) cp[1] = (temp > 254) ? 255 : temp; temp = cp1[2] + divide_round_i((fac * cp2[2]), 255); cp[2] = (temp > 254) ? 255 : temp; - cp[3] = 255; + cp[3] = use_alpha ? alpha_value : 255; return col; } -BLI_INLINE unsigned int mcol_sub(unsigned int col1, unsigned int col2, int fac) +BLI_INLINE unsigned int mcol_sub(unsigned int col1, unsigned int col2, int fac, + const bool use_alpha, const unsigned char alpha_value) { unsigned char *cp1, *cp2, *cp; int temp; @@ -650,12 +653,13 @@ BLI_INLINE unsigned int mcol_sub(unsigned int col1, unsigned int col2, int fac) cp[1] = (temp < 0) ? 0 : temp; temp = cp1[2] - divide_round_i((fac * cp2[2]), 255); cp[2] = (temp < 0) ? 0 : temp; - cp[3] = 255; + cp[3] = use_alpha ? alpha_value : 255; return col; } -BLI_INLINE unsigned int mcol_mul(unsigned int col1, unsigned int col2, int fac) +BLI_INLINE unsigned int mcol_mul(unsigned int col1, unsigned int col2, int fac, + const bool use_alpha, const unsigned char alpha_value) { unsigned char *cp1, *cp2, *cp; int mfac; @@ -675,12 +679,13 @@ BLI_INLINE unsigned int mcol_mul(unsigned int col1, unsigned int col2, int fac) cp[0] = divide_round_i(mfac * cp1[0] * 255 + fac * cp2[0] * cp1[0], 255 * 255); cp[1] = divide_round_i(mfac * cp1[1] * 255 + fac * cp2[1] * cp1[1], 255 * 255); cp[2] = divide_round_i(mfac * cp1[2] * 255 + fac * cp2[2] * cp1[2], 255 * 255); - cp[3] = 255; + cp[3] = use_alpha ? alpha_value : 255; return col; } -BLI_INLINE unsigned int mcol_lighten(unsigned int col1, unsigned int col2, int fac) +BLI_INLINE unsigned int mcol_lighten(unsigned int col1, unsigned int col2, int fac, + const bool use_alpha, const unsigned char alpha_value) { unsigned char *cp1, *cp2, *cp; int mfac; @@ -708,12 +713,13 @@ BLI_INLINE unsigned int mcol_lighten(unsigned int col1, unsigned int col2, int f cp[0] = divide_round_i(mfac * cp1[0] + fac * cp2[0], 255); cp[1] = divide_round_i(mfac * cp1[1] + fac * cp2[1], 255); cp[2] = divide_round_i(mfac * cp1[2] + fac * cp2[2], 255); - cp[3] = 255; + cp[3] = use_alpha ? alpha_value : 255; return col; } -BLI_INLINE unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac) +BLI_INLINE unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac, + const bool use_alpha, const unsigned char alpha_value) { unsigned char *cp1, *cp2, *cp; int mfac; @@ -741,11 +747,12 @@ BLI_INLINE unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fa cp[0] = divide_round_i((mfac * cp1[0] + fac * cp2[0]), 255); cp[1] = divide_round_i((mfac * cp1[1] + fac * cp2[1]), 255); cp[2] = divide_round_i((mfac * cp1[2] + fac * cp2[2]), 255); - cp[3] = 255; + cp[3] = use_alpha ? alpha_value : 255; return col; } -BLI_INLINE unsigned int mcol_colordodge(unsigned int col1, unsigned int col2, int fac) +BLI_INLINE unsigned int mcol_colordodge(unsigned int col1, unsigned int col2, int fac, + const bool use_alpha, const unsigned char alpha_value) { unsigned char *cp1, *cp2, *cp; int mfac,temp; @@ -767,10 +774,12 @@ BLI_INLINE unsigned int mcol_colordodge(unsigned int col1, unsigned int col2, in cp[1] = (mfac * cp1[1] + temp * fac) / 255; temp = (cp2[2] == 255) ? 255 : min_ii((cp1[2] * 225 )/ (255 - cp2[2]), 255); cp[2] = (mfac * cp1[2] + temp * fac) / 255; + cp[3] = use_alpha ? alpha_value : 255; return col; } -BLI_INLINE unsigned int mcol_difference(unsigned int col1, unsigned int col2, int fac) +BLI_INLINE unsigned int mcol_difference(unsigned int col1, unsigned int col2, int fac, + const bool use_alpha, const unsigned char alpha_value) { unsigned char *cp1, *cp2, *cp; int mfac, temp; @@ -792,10 +801,12 @@ BLI_INLINE unsigned int mcol_difference(unsigned int col1, unsigned int col2, in cp[1] = (mfac * cp1[1] + temp * fac) / 255; temp = abs(cp1[2] - cp2[2]); cp[2] = (mfac * cp1[2] + temp * fac) / 255; + cp[3] = use_alpha ? alpha_value : 255; return col; } -BLI_INLINE unsigned int mcol_screen(unsigned int col1, unsigned int col2, int fac) +BLI_INLINE unsigned int mcol_screen(unsigned int col1, unsigned int col2, int fac, + const bool use_alpha, const unsigned char alpha_value) { unsigned char *cp1, *cp2, *cp; int mfac, temp; @@ -817,10 +828,12 @@ BLI_INLINE unsigned int mcol_screen(unsigned int col1, unsigned int col2, int fa cp[1] = (mfac * cp1[1] + temp * fac) / 255; temp = max_ii(255 - (((255 - cp1[2]) * (255 - cp2[2])) / 255), 0); cp[2] = (mfac * cp1[2] + temp * fac) / 255; + cp[3] = use_alpha ? alpha_value : 255; return col; } -BLI_INLINE unsigned int mcol_hardlight(unsigned int col1, unsigned int col2, int fac) +BLI_INLINE unsigned int mcol_hardlight(unsigned int col1, unsigned int col2, int fac, + const bool use_alpha, const unsigned char alpha_value) { unsigned char *cp1, *cp2, *cp; int mfac, temp; @@ -848,10 +861,12 @@ BLI_INLINE unsigned int mcol_hardlight(unsigned int col1, unsigned int col2, int } cp[i] = min_ii((mfac * cp1[i] + temp * fac) / 255, 255); } + cp[3] = use_alpha ? alpha_value : 255; return col; } -BLI_INLINE unsigned int mcol_overlay(unsigned int col1, unsigned int col2, int fac) +BLI_INLINE unsigned int mcol_overlay(unsigned int col1, unsigned int col2, int fac, + const bool use_alpha, const unsigned char alpha_value) { unsigned char *cp1, *cp2, *cp; int mfac, temp; @@ -879,10 +894,12 @@ BLI_INLINE unsigned int mcol_overlay(unsigned int col1, unsigned int col2, int f } cp[i] = min_ii((mfac * cp1[i] + temp * fac) / 255, 255); } + cp[3] = use_alpha ? alpha_value : 255; return col; } -BLI_INLINE unsigned int mcol_softlight(unsigned int col1, unsigned int col2, int fac) +BLI_INLINE unsigned int mcol_softlight(unsigned int col1, unsigned int col2, int fac, + const bool use_alpha, const unsigned char alpha_value) { unsigned char *cp1, *cp2, *cp; int mfac, temp; @@ -910,10 +927,12 @@ BLI_INLINE unsigned int mcol_softlight(unsigned int col1, unsigned int col2, int } cp[i] = (temp * fac + cp1[i] * mfac) / 255; } + cp[3] = use_alpha ? alpha_value : 255; return col; } -BLI_INLINE unsigned int mcol_exclusion(unsigned int col1, unsigned int col2, int fac) +BLI_INLINE unsigned int mcol_exclusion(unsigned int col1, unsigned int col2, int fac, + const bool use_alpha, const unsigned char alpha_value) { unsigned char *cp1, *cp2, *cp; int mfac, temp; @@ -935,10 +954,12 @@ BLI_INLINE unsigned int mcol_exclusion(unsigned int col1, unsigned int col2, int temp = 127 - ((2 * (cp1[i] - 127) * (cp2[i] - 127)) / 255); cp[i] = (temp * fac + cp1[i] * mfac) / 255; } + cp[3] = use_alpha ? alpha_value : 255; return col; } -BLI_INLINE unsigned int mcol_luminocity(unsigned int col1, unsigned int col2, int fac) +BLI_INLINE unsigned int mcol_luminocity(unsigned int col1, unsigned int col2, int fac, + const bool use_alpha, const unsigned char alpha_value) { unsigned char *cp1, *cp2, *cp; int mfac; @@ -967,10 +988,12 @@ BLI_INLINE unsigned int mcol_luminocity(unsigned int col1, unsigned int col2, in cp[0] = ((int)(r * 255.0f) * fac + mfac * cp1[0]) / 255; cp[1] = ((int)(g * 255.0f) * fac + mfac * cp1[1]) / 255; cp[2] = ((int)(b * 255.0f) * fac + mfac * cp1[2]) / 255; + cp[3] = use_alpha ? alpha_value : 255; return col; } -BLI_INLINE unsigned int mcol_saturation(unsigned int col1, unsigned int col2, int fac) +BLI_INLINE unsigned int mcol_saturation(unsigned int col1, unsigned int col2, int fac, + const bool use_alpha, const unsigned char alpha_value) { unsigned char *cp1, *cp2, *cp; int mfac; @@ -1001,10 +1024,12 @@ BLI_INLINE unsigned int mcol_saturation(unsigned int col1, unsigned int col2, in cp[0] = ((int)(r * 255.0f) * fac + mfac * cp1[0]) / 255; cp[1] = ((int)(g * 255.0f) * fac + mfac * cp1[1]) / 255; cp[2] = ((int)(b * 255.0f) * fac + mfac * cp1[2]) / 255; + cp[3] = use_alpha ? alpha_value : 255; return col; } -BLI_INLINE unsigned int mcol_hue( @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs