[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46091] trunk/blender/source/blender: Fixed UI bug in distance, chroma, and difference nodes that caused the threshold to be limited by the falloff value .

Robert Holcomb bob_holcomb at hotmail.com
Sun Apr 29 22:07:29 CEST 2012


Revision: 46091
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46091
Author:   scourage
Date:     2012-04-29 20:07:29 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
Fixed UI bug in distance, chroma, and difference nodes that caused the threshold to be limited by the falloff value.  These should be independent.  Cleaned up how falloff works in keying nodes.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_node/drawnode.c
    trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
    trunk/blender/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c
    trunk/blender/source/blender/nodes/composite/nodes/node_composite_diffMatte.c
    trunk/blender/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c

Modified: trunk/blender/source/blender/editors/space_node/drawnode.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/drawnode.c	2012-04-29 20:04:25 UTC (rev 46090)
+++ trunk/blender/source/blender/editors/space_node/drawnode.c	2012-04-29 20:07:29 UTC (rev 46091)
@@ -1635,9 +1635,14 @@
 
 static void node_composit_buts_distance_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
-	uiLayout *col;
+	uiLayout *col, *row;
 	
 	col = uiLayoutColumn(layout, 1);
+   
+   uiItemL(layout, "Color Space:", ICON_NONE);
+	row= uiLayoutRow(layout, 0);
+	uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+
 	uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
 	uiItemR(col, ptr, "falloff", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
 }

Modified: trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_nodetree.c	2012-04-29 20:04:25 UTC (rev 46090)
+++ trunk/blender/source/blender/makesrna/intern/rna_nodetree.c	2012-04-29 20:07:29 UTC (rev 46091)
@@ -328,6 +328,39 @@
 	chroma->t2 = value;
 }
 
+static void rna_distance_matte_t1_set(PointerRNA *ptr, float value)
+{
+    bNode *node = (bNode*)ptr->data;
+    NodeChroma *chroma = node->storage;
+
+    chroma->t1 = value;
+}
+
+static void rna_distance_matte_t2_set(PointerRNA *ptr, float value)
+{
+    bNode *node = (bNode*)ptr->data;
+    NodeChroma *chroma = node->storage;
+
+    chroma->t2 = value;
+}
+
+static void rna_difference_matte_t1_set(PointerRNA *ptr, float value)
+{
+    bNode *node = (bNode*)ptr->data;
+    NodeChroma *chroma = node->storage;
+
+    chroma->t1 = value;
+}
+
+static void rna_difference_matte_t2_set(PointerRNA *ptr, float value)
+{
+    bNode *node = (bNode*)ptr->data;
+    NodeChroma *chroma = node->storage;
+
+    chroma->t2 = value;
+}
+
+
 static void rna_Node_scene_set(PointerRNA *ptr, PointerRNA value)
 {
 	bNode *node = (bNode*)ptr->data;
@@ -1891,14 +1924,14 @@
 	
 	prop = RNA_def_property(srna, "tolerance", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "t1");
-	RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t1_set", NULL);
+	RNA_def_property_float_funcs(prop, NULL, "rna_difference_matte_t1_set", NULL);
 	RNA_def_property_range(prop, 0.0f, 1.0f);
 	RNA_def_property_ui_text(prop, "Tolerance", "Color distances below this threshold are keyed");
 	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 	
 	prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "t2");
-	RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t2_set", NULL);
+	RNA_def_property_float_funcs(prop, NULL, "rna_difference_matte_t2_set", NULL);
 	RNA_def_property_range(prop, 0.0f, 1.0f);
 	RNA_def_property_ui_text(prop, "Falloff", "Color distances below this additional threshold are partially keyed");
 	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
@@ -1933,18 +1966,30 @@
 {
 	PropertyRNA *prop;
 	
-	RNA_def_struct_sdna_from(srna, "NodeChroma", "storage");
+   static EnumPropertyItem color_space_items[] = {
+		{1, "RGB", 0, "RGB", "RGB color space"},
+		{2, "YCC", 0, "YCC", "YCbCr Suppression"},
+		{0, NULL, 0, NULL, NULL}};
+
+   RNA_def_struct_sdna_from(srna, "NodeChroma", "storage");
+
+   prop = RNA_def_property(srna, "channel", PROP_ENUM, PROP_NONE);  
+	RNA_def_property_enum_sdna(prop, NULL, "channel");
+	RNA_def_property_enum_items(prop, color_space_items);
+	RNA_def_property_ui_text(prop, "Channel", "");
+	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
 	
 	prop = RNA_def_property(srna, "tolerance", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "t1");
-	RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t1_set", NULL);
+	RNA_def_property_float_funcs(prop, NULL, "rna_distance_matte_t1_set", NULL);
 	RNA_def_property_range(prop, 0.0f, 1.0f);
 	RNA_def_property_ui_text(prop, "Tolerance", "Color distances below this threshold are keyed");
 	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 	
 	prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "t2");
-	RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t2_set", NULL);
+	RNA_def_property_float_funcs(prop, NULL, "rna_distance_matte_t2_set", NULL);
 	RNA_def_property_range(prop, 0.0f, 1.0f);
 	RNA_def_property_ui_text(prop, "Falloff", "Color distances below this additional threshold are partially keyed");
 	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
@@ -2071,7 +2116,7 @@
 	prop = RNA_def_property(srna, "gain", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "fstrength");
 	RNA_def_property_range(prop, 0.0f, 1.0f);
-	RNA_def_property_ui_text(prop, "Gain", "Alpha gain");
+	RNA_def_property_ui_text(prop, "Falloff", "Alpha falloff");
 	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 	
 	prop = RNA_def_property(srna, "shadow_adjust", PROP_FLOAT, PROP_NONE);

Modified: trunk/blender/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c
===================================================================
--- trunk/blender/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c	2012-04-29 20:04:25 UTC (rev 46090)
+++ trunk/blender/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c	2012-04-29 20:07:29 UTC (rev 46091)
@@ -1,33 +1,33 @@
 /*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. 
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2006 Blender Foundation.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
+* ***** BEGIN GPL LICENSE BLOCK *****
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version. 
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+* The Original Code is Copyright (C) 2006 Blender Foundation.
+* All rights reserved.
+*
+* The Original Code is: all of this file.
+*
+* Contributor(s): none yet.
+*
+* ***** END GPL LICENSE BLOCK *****
+*/
 
 /** \file blender/nodes/composite/nodes/node_composite_chromaMatte.c
- *  \ingroup cmpnodes
- */
+*  \ingroup cmpnodes
+*/
 
 
 #include "node_composite_util.h"
@@ -59,9 +59,9 @@
 	out[1]=(out[1]*2.0f)-1.0f;
 	out[2]=(out[2]*2.0f)-1.0f;
 
-//	out[0]=((out[0])-16)/255.0;
-//	out[1]=((out[1])-128)/255.0;
-//	out[2]=((out[2])-128)/255.0;
+	//	out[0]=((out[0])-16)/255.0;
+	//	out[1]=((out[1])-128)/255.0;
+	//	out[2]=((out[2])-128)/255.0;
 	out[3]=in[3];
 }
 
@@ -77,8 +77,8 @@
 	in[2]=(in[2]*255.0f);
 
 	//	in[0]=(in[0]*255.0)+16;
-//	in[1]=(in[1]*255.0)+128;
-//	in[2]=(in[2]*255.0)+128;
+	//	in[1]=(in[1]*255.0)+128;
+	//	in[2]=(in[2]*255.0)+128;
 	ycc_to_rgb(in[0], in[1], in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601);
 	out[3]=in[3];
 }
@@ -94,7 +94,7 @@
 
 	/* Algorithm from book "Video Demistified," does not include the spill reduction part */
 
-	/* find theta, the angle that the color space should be rotated based on key*/
+	/* find theta, the angle that the color space should be rotated based on key chroma values*/
 	theta=atan2(c->key[2], c->key[1]);
 
 	/*rotate the cb and cr into x/z space */
@@ -107,13 +107,9 @@
 	/* if kfg is <0 then the pixel is outside of the key color */
 	kfg= x-(fabsf(z)/tanf(angle/2.0f));
 
-	out[0]=in[0];
-	out[1]=in[1];
-	out[2]=in[2];
+	copy_v3_v3(out, in);
 
 	if (kfg>0.0f) {  /* found a pixel that is within key color */
-		alpha=(1.0f-kfg)*(c->fstrength);
-
 		beta=atan2(z, x);
 		angle2=c->t2; /* t2 is radians. */
 
@@ -121,6 +117,9 @@
 		if (fabsf(beta) < (angle2/2.0f)) {
 			alpha=0.0;
 		}
+		else {
+			alpha=1.0f-(kfg/c->fstrength);
+		}
 
 		/* don't make something that was more transparent less transparent */
 		if (alpha<in[3]) {
@@ -130,11 +129,8 @@
 			out[3]=in[3];
 		}
 	}
-	else { /*pixel is outside key color */
-		out[0]=in[0];
-		out[1]=in[1];
-		out[2]=in[2];
-		out[3]=in[3]; /* make pixel just as transparent as it was before */
+	else { /* make pixel just as transparent as it was before */
+		out[3]=in[3];
 	}
 }
 
@@ -143,32 +139,32 @@
 	CompBuf *cbuf;
 	CompBuf *chromabuf;
 	NodeChroma *c;
-	
+
 	if (in[0]->hasinput==0) return;
 	if (in[0]->data==NULL) return;
 	if (out[0]->hasoutput==0 && out[1]->hasoutput==0) return;
-	
+
 	cbuf= typecheck_compbuf(in[0]->data, CB_RGBA);
-	
+
 	chromabuf= dupalloc_compbuf(cbuf);
-	
+
 	c=node->storage;
-	
+
 	/*convert rgbbuf to normalized chroma space*/
 	composit1_pixel_processor(node, chromabuf, cbuf, in[0]->vec, do_rgba_to_ycca_normalized, CB_RGBA);
 	/*convert key to normalized chroma color space */
 	do_rgba_to_ycca_normalized(node, c->key, in[1]->vec);
-	
+
 	/*per pixel chroma key*/
 	composit1_pixel_processor(node, chromabuf, chromabuf, in[0]->vec, do_chroma_key, CB_RGBA);
-	
+
 	/*convert back*/
 	composit1_pixel_processor(node, chromabuf, chromabuf, in[0]->vec, do_ycca_to_rgba_normalized, CB_RGBA);
-	
+
 	out[0]->data= chromabuf;
 	if (out[1]->hasoutput)
 		out[1]->data= valbuf_from_rgbabuf(chromabuf, CHAN_A);
-	
+

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list