[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43595] trunk/blender/source/blender/ editors/sculpt_paint/paint_vertex.c: fix for own error in recent paint refactor, subtract mode was broken.
Campbell Barton
ideasman42 at gmail.com
Sun Jan 22 05:30:23 CET 2012
Revision: 43595
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43595
Author: campbellbarton
Date: 2012-01-22 04:30:11 +0000 (Sun, 22 Jan 2012)
Log Message:
-----------
fix for own error in recent paint refactor, subtract mode was broken.
Modified Paths:
--------------
trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c 2012-01-22 04:12:30 UTC (rev 43594)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c 2012-01-22 04:30:11 UTC (rev 43595)
@@ -497,7 +497,7 @@
}
*/
-static unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac)
+BM_INLINE unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac)
{
char *cp1, *cp2, *cp;
int mfac;
@@ -520,7 +520,7 @@
return col;
}
-static unsigned int mcol_add(unsigned int col1, unsigned int col2, int fac)
+BM_INLINE unsigned int mcol_add(unsigned int col1, unsigned int col2, int fac)
{
char *cp1, *cp2, *cp;
int temp;
@@ -543,7 +543,7 @@
return col;
}
-static unsigned int mcol_sub(unsigned int col1, unsigned int col2, int fac)
+BM_INLINE unsigned int mcol_sub(unsigned int col1, unsigned int col2, int fac)
{
char *cp1, *cp2, *cp;
int temp;
@@ -566,7 +566,7 @@
return col;
}
-static unsigned int mcol_mul(unsigned int col1, unsigned int col2, int fac)
+BM_INLINE unsigned int mcol_mul(unsigned int col1, unsigned int col2, int fac)
{
char *cp1, *cp2, *cp;
int mfac;
@@ -590,7 +590,7 @@
return col;
}
-static unsigned int mcol_lighten(unsigned int col1, unsigned int col2, int fac)
+BM_INLINE unsigned int mcol_lighten(unsigned int col1, unsigned int col2, int fac)
{
char *cp1, *cp2, *cp;
int mfac;
@@ -618,7 +618,7 @@
return col;
}
-static unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac)
+BM_INLINE unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac)
{
char *cp1, *cp2, *cp;
int mfac;
@@ -651,18 +651,12 @@
{
switch (tool) {
case PAINT_BLEND_MIX:
- case PAINT_BLEND_BLUR:
- return mcol_blend(col, paintcol, alpha_i);
- case PAINT_BLEND_ADD:
- return mcol_add(col, paintcol, alpha_i);
- case PAINT_BLEND_SUB:
- return mcol_sub(col, paintcol, alpha_i);
- case PAINT_BLEND_MUL:
- return mcol_mul(col, paintcol, alpha_i);
- case PAINT_BLEND_LIGHTEN:
- return mcol_lighten(col, paintcol, alpha_i);
- case PAINT_BLEND_DARKEN:
- return mcol_darken(col, paintcol, alpha_i);
+ case PAINT_BLEND_BLUR: return mcol_blend(col, paintcol, alpha_i);
+ case PAINT_BLEND_ADD: return mcol_add(col, paintcol, alpha_i);
+ case PAINT_BLEND_SUB: return mcol_sub(col, paintcol, alpha_i);
+ case PAINT_BLEND_MUL: return mcol_mul(col, paintcol, alpha_i);
+ case PAINT_BLEND_LIGHTEN: return mcol_lighten(col, paintcol, alpha_i);
+ case PAINT_BLEND_DARKEN: return mcol_darken(col, paintcol, alpha_i);
default:
BLI_assert(0);
return 0;
@@ -797,6 +791,33 @@
return 0.0f;
}
+
+BM_INLINE float wval_blend(const float weight, const float paintval, const float alpha)
+{
+ return (paintval * alpha) + (weight * (1.0f - alpha));
+}
+BM_INLINE float wval_add(const float weight, const float paintval, const float alpha)
+{
+ return weight + (paintval * alpha);
+}
+BM_INLINE float wval_sub(const float weight, const float paintval, const float alpha)
+{
+ return weight - (paintval * alpha);
+}
+BM_INLINE float wval_mul(const float weight, const float paintval, const float alpha)
+{ /* first mul, then blend the fac */
+ return ((1.0f - alpha) + (alpha * paintval)) * weight;
+}
+BM_INLINE float wval_lighten(const float weight, const float paintval, const float alpha)
+{
+ return (weight < paintval) ? wval_blend(weight, paintval, alpha) : weight;
+}
+BM_INLINE float wval_darken(const float weight, const float paintval, const float alpha)
+{
+ return (weight > paintval) ? wval_blend(weight, paintval, alpha) : weight;
+}
+
+
/* vpaint has 'vpaint_blend_tool' */
/* result is not clamped from [0-1] */
static float wpaint_blend_tool(const int tool,
@@ -806,19 +827,12 @@
{
switch (tool) {
case PAINT_BLEND_MIX:
- case PAINT_BLEND_BLUR:
- return (paintval * alpha) + (weight * (1.0f - alpha));
- case PAINT_BLEND_ADD:
- return (paintval * alpha) + weight;
- case PAINT_BLEND_SUB:
- return (paintval * alpha) - weight;
- case PAINT_BLEND_MUL:
- /* first mul, then blend the fac */
- return ((1.0f - alpha) + alpha * paintval) * weight;
- case PAINT_BLEND_LIGHTEN:
- return (weight < paintval) ? (paintval * alpha) + (weight * (1.0f - alpha)) : weight;
- case PAINT_BLEND_DARKEN:
- return (weight > paintval) ? (paintval * alpha) + (weight * (1.0f - alpha)) : weight;
+ case PAINT_BLEND_BLUR: return wval_blend(weight, paintval, alpha);
+ case PAINT_BLEND_ADD: return wval_add(weight, paintval, alpha);
+ case PAINT_BLEND_SUB: return wval_sub(weight, paintval, alpha);
+ case PAINT_BLEND_MUL: return wval_mul(weight, paintval, alpha);
+ case PAINT_BLEND_LIGHTEN: return wval_lighten(weight, paintval, alpha);
+ case PAINT_BLEND_DARKEN: return wval_darken(weight, paintval, alpha);
default:
BLI_assert(0);
return 0.0f;
More information about the Bf-blender-cvs
mailing list