Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-30 20:07:52 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-30 20:07:52 +0400
commit576e579925d205a44dd347fca3646f5c749a60a6 (patch)
tree3184282505f00cb7514384d2f1b6bdfc433ede6e /source/blender/blenkernel/intern/brush.c
parent7a0bdbc55016d287278b6818f26dc096eeb9c098 (diff)
More painting fixes:
* 2D image painting with textures that contained alpha did not work correctly, had been broken for a while. * 2D image panels texture (mask) panels showed wrong buttons for texture overlay. * Texture map mode 3D now also uses masking, like Tiled and Stencil the texture does not move along with the brush so it works fine. * 2D image paint View mapping did not work correct, especially noticeable with Rake rotation. * Masking is now disabled for the smear tool, this can't really work because the original image is constantly changing and gave artifacts.
Diffstat (limited to 'source/blender/blenkernel/intern/brush.c')
-rw-r--r--source/blender/blenkernel/intern/brush.c49
1 files changed, 17 insertions, 32 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 5ddc215dc2c..feb6a961596 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -765,9 +765,10 @@ static void brush_imbuf_tex_co(rctf *mapping, int x, int y, float texco[3])
texco[2] = 0.0f;
}
-/* TODO, use define for 'texfall' arg
- * NOTE: only used for 2d brushes currently! */
-void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall, int bufsize,
+/* NOTE: only used for 2d brushes currently! and needs to stay in sync
+ * with brush_painter_2d_do_partial */
+void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, bool use_float,
+ enum BrushImBufFill fill, int bufsize,
ImBuf **outbuf, bool use_color_correction, bool use_brush_alpha,
struct ImagePool *pool, rctf *mapping)
{
@@ -780,7 +781,7 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf
float brush_rgb[3] = {1.0f, 1.0f, 1.0f};
int thread = 0;
- imbflag = (flt) ? IB_rectfloat : IB_rect;
+ imbflag = (use_float) ? IB_rectfloat : IB_rect;
xoff = -bufsize / 2.0f + 0.5f;
yoff = -bufsize / 2.0f + 0.5f;
rowbytes = bufsize * 4;
@@ -790,7 +791,7 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf
else
ibuf = IMB_allocImBuf(bufsize, bufsize, 32, imbflag);
- if (flt) {
+ if (use_float) {
if (brush->imagepaint_tool == PAINT_TOOL_DRAW) {
copy_v3_v3(brush_rgb, brush->rgb);
if (use_color_correction) {
@@ -805,27 +806,21 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf
xy[0] = x + xoff;
xy[1] = y + yoff;
- if (texfall == 0) {
+ if (fill == BRUSH_IMBUF_MASK) {
copy_v3_v3(dstf, brush_rgb);
dstf[3] = alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius);
}
- else if (texfall == 1) {
+ else if (fill == BRUSH_IMBUF_TEX) {
brush_imbuf_tex_co(mapping, x, y, texco);
BKE_brush_sample_tex_3D(scene, brush, texco, dstf, thread, pool);
}
- else if (texfall == 2) {
+ else { /* if (fill == BRUSH_IMBUF_TEX_MASK) */
brush_imbuf_tex_co(mapping, x, y, texco);
BKE_brush_sample_tex_3D(scene, brush, texco, rgba, thread, pool);
mul_v3_v3v3(dstf, rgba, brush_rgb);
dstf[3] = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius);
}
- else {
- brush_imbuf_tex_co(mapping, x, y, texco);
- BKE_brush_sample_tex_3D(scene, brush, texco, rgba, thread, pool);
- copy_v3_v3(dstf, brush_rgb);
- dstf[3] = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius);
- }
/* output premultiplied alpha image */
dstf[0] *= dstf[3];
@@ -838,9 +833,9 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf
float alpha_f; /* final float alpha to convert to char */
if (brush->imagepaint_tool == PAINT_TOOL_DRAW)
- rgb_float_to_uchar(crgb, brush->rgb);
- else
- rgb_float_to_uchar(crgb, brush_rgb);
+ copy_v3_v3(brush_rgb, brush->rgb);
+
+ rgb_float_to_uchar(crgb, brush->rgb);
for (y = 0; y < ibuf->y; y++) {
dst = (unsigned char *)ibuf->rect + y * rowbytes;
@@ -849,7 +844,7 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf
xy[0] = x + xoff;
xy[1] = y + yoff;
- if (texfall == 0) {
+ if (fill == BRUSH_IMBUF_MASK) {
alpha_f = alpha * BKE_brush_curve_strength(brush, len_v2(xy), radius);
dst[0] = crgb[0];
@@ -857,29 +852,19 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf
dst[2] = crgb[2];
dst[3] = FTOCHAR(alpha_f);
}
- else if (texfall == 1) {
+ else if (fill == BRUSH_IMBUF_TEX) {
brush_imbuf_tex_co(mapping, x, y, texco);
BKE_brush_sample_tex_3D(scene, brush, texco, rgba, thread, pool);
rgba_float_to_uchar(dst, rgba);
}
- else if (texfall == 2) {
+ else { /* if (fill == BRUSH_IMBUF_TEX_MASK) */
brush_imbuf_tex_co(mapping, x, y, texco);
BKE_brush_sample_tex_3D(scene, brush, texco, rgba, thread, pool);
- mul_v3_v3(rgba, brush->rgb);
- alpha_f = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius);
-
- rgb_float_to_uchar(dst, rgba);
- dst[3] = FTOCHAR(alpha_f);
- }
- else {
- brush_imbuf_tex_co(mapping, x, y, texco);
- BKE_brush_sample_tex_3D(scene, brush, texco, rgba, thread, pool);
+ mul_v3_v3(rgba, brush_rgb);
alpha_f = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius);
- dst[0] = crgb[0];
- dst[1] = crgb[1];
- dst[2] = crgb[2];
+ rgb_float_to_uchar(dst, rgba);
dst[3] = FTOCHAR(alpha_f);
}
}