From 027277fce0565f8518cf1fc3a0b3b34b8d0b3cda Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 Mar 2008 21:35:38 +0000 Subject: * Bakeing fix for apricot, stop pixels being extended for parts of the image that are not being baked (useful for multiple objects) * Added support for baking alpha, as well as extending alpha margins. --- source/blender/imbuf/intern/filter.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'source/blender/imbuf/intern/filter.c') diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index 156e26fd5d6..1be5cf99e19 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -240,13 +240,16 @@ void IMB_filter(struct ImBuf *ibuf) imb_filterx(ibuf); } -#define EXTEND_PIXEL(a, w) if((a)[3]) {r+= w*(a)[0]; g+= w*(a)[1]; b+= w*(a)[2]; tot+=w;} +#define EXTEND_PIXEL(color, w) if((color)[3]) {r+= w*(color)[0]; g+= w*(color)[1]; b+= w*(color)[2]; a+= w*(color)[3]; tot+=w;} -/* if alpha is zero, it checks surrounding pixels and averages color. sets new alphas to 1.0 */ -void IMB_filter_extend(struct ImBuf *ibuf) +/* if alpha is zero, it checks surrounding pixels and averages color. sets new alphas to 1.0 + * + * When a mask is given, only effect pixels with a mask value of 1, defined as BAKE_MASK_MARGIN in rendercore.c + * */ +void IMB_filter_extend(struct ImBuf *ibuf, char *mask) { register char *row1, *row2, *row3; - register char *cp; + register char *cp; int rowlen, x, y; rowlen= ibuf->x; @@ -269,11 +272,11 @@ void IMB_filter_extend(struct ImBuf *ibuf) row3f= row2f; fp= (float *)(ibuf->rect_float + (y-1)*rowlen*4); - + for(x=0; xrect + (y-1)*rowlen); for(x=0; x