[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13772] trunk/blender/source/blender/nodes /intern/CMP_nodes/CMP_displace.c:

Brecht Van Lommel brechtvanlommel at pandora.be
Tue Feb 19 21:35:20 CET 2008


Revision: 13772
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13772
Author:   blendix
Date:     2008-02-19 21:35:19 +0100 (Tue, 19 Feb 2008)

Log Message:
-----------

Possible fix for bug #6922: crash in displace compositor node,
possibly because it didn't handle the vector input correct if
it was translated.

Modified Paths:
--------------
    trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_displace.c

Modified: trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_displace.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_displace.c	2008-02-19 19:26:49 UTC (rev 13771)
+++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_displace.c	2008-02-19 20:35:19 UTC (rev 13772)
@@ -47,7 +47,7 @@
 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 @@
 			/* 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;
 			





More information about the Bf-blender-cvs mailing list