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

Brecht Van Lommel brechtvanlommel at pandora.be
Tue Apr 1 13:08:51 CEST 2008


Revision: 14305
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14305
Author:   blendix
Date:     2008-04-01 13:08:48 +0200 (Tue, 01 Apr 2008)

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

Bugfix: the defocus node "no zbuffer" settings was automatically set
if there was no zbuffer input. However this means a user settings can
be permanently changed without a user knowing. Now it just runs as if
this option is set if there is no zbuffer, but doesn't change the
setting.

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

Modified: trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c	2008-04-01 10:15:39 UTC (rev 14304)
+++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c	2008-04-01 11:08:48 UTC (rev 14305)
@@ -235,7 +235,7 @@
 #undef YVV
 }
 
-static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf, float inpval)
+static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf, float inpval, int no_zbuf)
 {
 	NodeDefocus *nqd = node->storage;
 	CompBuf *wts;		// weights buffer
@@ -283,7 +283,7 @@
 
 	// if 'no_zbuf' flag set (which is always set if input is not an image),
 	// values are instead interpreted directly as blur radius values
-	if (nqd->no_zbuf) {
+	if (no_zbuf) {
 		// to prevent *reaaallly* big radius values and impossible calculation times,
 		// limit the maximum to half the image width or height, whichever is smaller
 		float maxr = 0.5f*(float)MIN2(img->x, img->y);
@@ -700,7 +700,7 @@
 				// sampled, simple rejection sampling here, good enough
 				unsigned int maxsam, s, ui = BLI_rand()*BLI_rand();
 				float wcor, cpr = BLI_frand();
-				if (nqd->no_zbuf)
+				if (no_zbuf)
 					maxsam = nqd->samples;	// no zbuffer input, use sample value directly
 				else {
 					// depth adaptive sampling hack, the more out of focus, the more samples taken, 16 minimum.
@@ -774,11 +774,12 @@
 {
 	CompBuf *new, *old, *zbuf_use = NULL, *img = in[0]->data, *zbuf = in[1]->data;
 	NodeDefocus *nqd = node->storage;
+	int no_zbuf = nqd->no_zbuf;
 	
 	if ((img==NULL) || (out[0]->hasoutput==0)) return;
 	
 	// if image not valid type or fstop==infinite (128), nothing to do, pass in to out
-	if (((img->type!=CB_RGBA) && (img->type!=CB_VAL)) || ((nqd->no_zbuf==0) && (nqd->fstop==128.f))) {
+	if (((img->type!=CB_RGBA) && (img->type!=CB_VAL)) || ((no_zbuf==0) && (nqd->fstop==128.f))) {
 		out[0]->data = pass_on_compbuf(img);
 		return;
 	}
@@ -793,7 +794,7 @@
 		}
 		zbuf_use = typecheck_compbuf(zbuf, CB_VAL);
 	}
-	else nqd->no_zbuf = 1;	// no zbuffer input
+	else no_zbuf = 1;	// no zbuffer input
 		
 	// ok, process
 	old = img;
@@ -808,7 +809,7 @@
 	}
 	
 	new = alloc_compbuf(old->x, old->y, old->type, 1);
-	defocus_blur(node, new, old, zbuf_use, in[1]->vec[0]*nqd->scale);
+	defocus_blur(node, new, old, zbuf_use, in[1]->vec[0]*nqd->scale, no_zbuf);
 	
 	if (nqd->gamco) {
 		premul_compbuf(new, 1);





More information about the Bf-blender-cvs mailing list