diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-03-05 23:22:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-03-05 23:22:17 +0300 |
commit | 0d9cb646248c11f052a6523e49269eb097c1d659 (patch) | |
tree | cb7efe74f906e4f9c56f5463384aaf55fb97153a /source/blender/editors/sculpt_paint/paint_image.c | |
parent | 6fd13b904cc2bd7cde48dbd9334d1a9ececc1480 (diff) |
reprojection
- blend in the projected image by its alpha rather then copy its alpha. this way you can easily mask out areas not to touch.
- undo was crashing.
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_image.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 3e0d5fdb2fa..cfac7fcf13c 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -3534,6 +3534,18 @@ static void blend_color_mix_float(float *cp, const float *cp1, const float *cp2, cp[3]= mfac*cp1[3] + fac*cp2[3]; } +static void blend_color_mix_rgb(unsigned char *cp, const unsigned char *cp1, const unsigned char *cp2, const int fac) +{ + /* this and other blending modes previously used >>8 instead of /255. both + are not equivalent (>>8 is /256), and the former results in rounding + errors that can turn colors black fast after repeated blending */ + const int mfac= 255-fac; + + cp[0]= (mfac*cp1[0]+fac*cp2[0])/255; + cp[1]= (mfac*cp1[1]+fac*cp2[1])/255; + cp[2]= (mfac*cp1[2]+fac*cp2[2])/255; +} + static void do_projectpaint_clone(ProjPaintState *ps, ProjPixel *projPixel, float *rgba, float alpha, float mask) { if (ps->is_airbrush==0 && mask < 1.0f) { @@ -3785,7 +3797,8 @@ static void *do_projectpaint_thread(void *ph_v) else { /* reprojection! */ bicubic_interpolation_color(ps->reproject_ibuf, projPixel->newColor.ch, NULL, projPixel->projCoSS[0], projPixel->projCoSS[1]); - blend_color_mix(projPixel->pixel.ch_pt, projPixel->origColor.ch, projPixel->newColor.ch, (int)(mask*255)); + if(projPixel->newColor.ch[3]) + blend_color_mix_rgb(projPixel->pixel.ch_pt, projPixel->origColor.ch, projPixel->newColor.ch, (mask*projPixel->newColor.ch[3])); } } /* done painting */ @@ -5353,6 +5366,11 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) ps.source= PROJ_SRC_CAM; + scene->toolsettings->imapaint.flag |= IMAGEPAINT_DRAWING; + + undo_paint_push_begin(UNDO_PAINT_IMAGE, "Image Paint", + image_undo_restore, image_undo_free); + /* allocate and initialize spacial data structures */ project_paint_begin(&ps); @@ -5379,6 +5397,8 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) project_paint_end(&ps); + scene->toolsettings->imapaint.flag &= ~IMAGEPAINT_DRAWING; + return OPERATOR_FINISHED; } |