From 2283bdc09b48033c4de0e98e1bfd53b7fb382e25 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 19 Feb 2008 20:35:19 +0000 Subject: Possible fix for bug #6922: crash in displace compositor node, possibly because it didn't handle the vector input correct if it was translated. --- source/blender/nodes/intern/CMP_nodes/CMP_displace.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'source/blender/nodes') diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_displace.c b/source/blender/nodes/intern/CMP_nodes/CMP_displace.c index 0ec15d9eb77..67b04750056 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_displace.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_displace.c @@ -47,7 +47,7 @@ static bNodeSocketType cmp_node_displace_out[]= { static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float *veccol, float *xscale, float *yscale) { ImBuf *ibuf; - int x, y, sx, sy; + int x, y, vx, vy, sx, sy; float dx=0.0, dy=0.0; float dspx, dspy; float uv[2]; @@ -72,16 +72,21 @@ static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float /* the x-xrad stuff is a bit weird, but i seem to need it otherwise * my returned pixels are offset weirdly */ vp = compbuf_get_pixel(vecbuf, veccol, x-vecbuf->xrad, y-vecbuf->yrad, vecbuf->xrad, vecbuf->yrad); + + /* this happens in compbuf_get_pixel, need to make sure the following + * check takes them into account */ + vx= x-vecbuf->xof; + vy= y-vecbuf->yof; /* find the new displaced co-ords, also correcting for translate offset */ - dspx = x - (*xscale * vp[0]); - dspy = y - (*yscale * vp[1]); + dspx = vx - (*xscale * vp[0]); + dspy = vy - (*yscale * vp[1]); /* convert image space to 0.0-1.0 UV space for sampling, correcting for translate offset */ uv[0] = dspx / (float)sx; uv[1] = dspy / (float)sy; - - if(x>0 && x< vecbuf->x-1 && y>0 && y< vecbuf->y-1) { + + if(vx>0 && vx< vecbuf->x-1 && vy>0 && vy< vecbuf->y-1) { vpnext = vp+row; vpprev = vp-row; -- cgit v1.2.3