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-05-12 13:14:13 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-05-12 13:14:13 +0400
commit70eaf2fe44934da315753df30aff450333082630 (patch)
treea3dd92ddd4989a586fb64b475047fd645b148f2e /source/blender/blenkernel/intern/brush.c
parent698f1b56037ea9c6eec170a0f3b74b7a46eaae1d (diff)
Image paint: 2D painting now supports texture masks and does masking more
consistent with projection painting. Also did some refactoring of this code, moving the brush image creation code out of brush.c and making it consistent with image updating code.
Diffstat (limited to 'source/blender/blenkernel/intern/brush.c')
-rw-r--r--source/blender/blenkernel/intern/brush.c116
1 files changed, 0 insertions, 116 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 621c41c3df7..a8c78b430be 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -758,122 +758,6 @@ float BKE_brush_sample_masktex(const Scene *scene, Brush *br,
return intensity;
}
-static void brush_imbuf_tex_co(rctf *mapping, int x, int y, float texco[3])
-{
- texco[0] = mapping->xmin + x * mapping->xmax;
- texco[1] = mapping->ymin + y * mapping->ymax;
- texco[2] = 0.0f;
-}
-
-/* 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)
-{
- ImBuf *ibuf;
- float xy[2], texco[3], rgba[4], *dstf;
- int x, y, rowbytes, xoff, yoff, imbflag;
- const int radius = BKE_brush_size_get(scene, brush);
- unsigned char *dst, crgb[3];
- const float alpha = (use_brush_alpha)? BKE_brush_alpha_get(scene, brush): 1.0f;
- float brush_rgb[3] = {1.0f, 1.0f, 1.0f};
- int thread = 0;
-
- imbflag = (use_float) ? IB_rectfloat : IB_rect;
- xoff = -bufsize / 2.0f + 0.5f;
- yoff = -bufsize / 2.0f + 0.5f;
- rowbytes = bufsize * 4;
-
- if (*outbuf)
- ibuf = *outbuf;
- else
- ibuf = IMB_allocImBuf(bufsize, bufsize, 32, imbflag);
-
- if (use_float) {
- if (brush->imagepaint_tool == PAINT_TOOL_DRAW) {
- copy_v3_v3(brush_rgb, brush->rgb);
- if (use_color_correction) {
- srgb_to_linearrgb_v3_v3(brush_rgb, brush_rgb);
- }
- }
-
- for (y = 0; y < ibuf->y; y++) {
- dstf = ibuf->rect_float + y * rowbytes;
-
- for (x = 0; x < ibuf->x; x++, dstf += 4) {
- xy[0] = x + xoff;
- xy[1] = y + yoff;
-
- 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 (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 (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);
- }
-
- /* output premultiplied alpha image */
- dstf[0] *= dstf[3];
- dstf[1] *= dstf[3];
- dstf[2] *= dstf[3];
- }
- }
- }
- else {
- float alpha_f; /* final float alpha to convert to char */
-
- if (brush->imagepaint_tool == PAINT_TOOL_DRAW)
- 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;
-
- for (x = 0; x < ibuf->x; x++, dst += 4) {
- xy[0] = x + xoff;
- xy[1] = y + yoff;
-
- if (fill == BRUSH_IMBUF_MASK) {
- alpha_f = alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius);
-
- dst[0] = crgb[0];
- dst[1] = crgb[1];
- dst[2] = crgb[2];
- dst[3] = FTOCHAR(alpha_f);
- }
- 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 (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);
- }
- }
- }
- }
-
- *outbuf = ibuf;
-}
-
/* Unified Size and Strength */
/* XXX: be careful about setting size and unprojected radius