[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36202] trunk/blender/source/blender/nodes /intern/CMP_nodes/CMP_displace.c: Fix [#26896] Displace Node crashes Blender when connected to Z-Buffer
Matt Ebb
matt at mke3.net
Mon Apr 18 00:47:24 CEST 2011
Revision: 36202
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36202
Author: broken
Date: 2011-04-17 22:47:23 +0000 (Sun, 17 Apr 2011)
Log Message:
-----------
Fix [#26896] Displace Node crashes Blender when connected to Z-Buffer
Clamped the maximum displacement distance to 4 x the input image dimensions - prevents hanging when vary large values are mistakenly plugged in, such as Z buffers,
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 2011-04-17 22:11:23 UTC (rev 36201)
+++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_displace.c 2011-04-17 22:47:23 UTC (rev 36202)
@@ -53,7 +53,7 @@
* in order to take effect */
#define DISPLACE_EPSILON 0.01
-static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float *UNUSED(veccol), CompBuf *xbuf, CompBuf *ybuf, float *xscale, float *yscale)
+static void do_displace(bNode *node, CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float *UNUSED(veccol), CompBuf *xbuf, CompBuf *ybuf, float *xscale, float *yscale)
{
ImBuf *ibuf;
int x, y;
@@ -83,6 +83,10 @@
else
ys = yscale[0];
+ /* clamp x and y displacement to triple image resolution -
+ * to prevent hangs from huge values mistakenly plugged in eg. z buffers */
+ CLAMP(xs, -stackbuf->x*4, stackbuf->x*4);
+ CLAMP(ys, -stackbuf->y*4, stackbuf->y*4);
p_dx = vec[0] * xs;
p_dy = vec[1] * ys;
@@ -114,7 +118,11 @@
ibuf_sample(ibuf, u, v, dxt, dyt, col);
qd_setPixel(stackbuf, x, y, col);
+
+ if(node->exec & NODE_BREAK) break;
}
+
+ if(node->exec & NODE_BREAK) break;
}
IMB_freeImBuf(ibuf);
@@ -145,7 +153,7 @@
}
-static void node_composit_exec_displace(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **in, bNodeStack **out)
+static void node_composit_exec_displace(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
{
if(out[0]->hasoutput==0)
return;
@@ -164,7 +172,7 @@
stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */
- do_displace(stackbuf, cbuf, vecbuf, in[1]->vec, xbuf, ybuf, in[2]->vec, in[3]->vec);
+ do_displace(node, stackbuf, cbuf, vecbuf, in[1]->vec, xbuf, ybuf, in[2]->vec, in[3]->vec);
out[0]->data= stackbuf;
More information about the Bf-blender-cvs
mailing list