[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27357] trunk/blender/source/blender: Fix [#21188] HueCorrection Node, when reseting Curve, it goes to a incline instead of flat/straight

Matt Ebb matt at mke3.net
Tue Mar 9 08:41:28 CET 2010


Revision: 27357
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27357
Author:   broken
Date:     2010-03-09 08:41:27 +0100 (Tue, 09 Mar 2010)

Log Message:
-----------
Fix [#21188] HueCorrection Node, when reseting Curve, it goes to a incline instead of flat/straight

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_colortools.h
    trunk/blender/source/blender/blenkernel/intern/brush.c
    trunk/blender/source/blender/blenkernel/intern/colortools.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/editors/interface/interface_templates.c
    trunk/blender/source/blender/makesdna/DNA_color_types.h
    trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c

Modified: trunk/blender/source/blender/blenkernel/BKE_colortools.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_colortools.h	2010-03-09 07:41:04 UTC (rev 27356)
+++ trunk/blender/source/blender/blenkernel/BKE_colortools.h	2010-03-09 07:41:27 UTC (rev 27357)
@@ -45,13 +45,6 @@
 #   define DO_INLINE static inline
 #endif
 
-typedef enum CurveMappingPreset {
-	CURVE_PRESET_LINE,
-	CURVE_PRESET_SHARP,
-	CURVE_PRESET_SMOOTH,
-	CURVE_PRESET_MAX
-} CurveMappingPreset;
-
 void				floatbuf_to_srgb_byte(float *rectf, unsigned char *rectc, int x1, int x2, int y1, int y2, int w);
 void				floatbuf_to_byte(float *rectf, unsigned char *rectc, int x1, int x2, int y1, int y2, int w);
 
@@ -62,7 +55,7 @@
 
 void				curvemap_remove(struct CurveMap *cuma, int flag);
 void				curvemap_insert(struct CurveMap *cuma, float x, float y);
-void				curvemap_reset(struct CurveMap *cuma, struct rctf *clipr, CurveMappingPreset preset);
+void				curvemap_reset(struct CurveMap *cuma, struct rctf *clipr, int preset);
 void				curvemap_sethandle(struct CurveMap *cuma, int type);
 
 void				curvemapping_changed(struct CurveMapping *cumap, int rem_doubles);

Modified: trunk/blender/source/blender/blenkernel/intern/brush.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/brush.c	2010-03-09 07:41:04 UTC (rev 27356)
+++ trunk/blender/source/blender/blenkernel/intern/brush.c	2010-03-09 07:41:27 UTC (rev 27357)
@@ -237,7 +237,8 @@
 	cm = b->curve->cm;
 	cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
 
-	curvemap_reset(cm, &b->curve->clipr, preset);
+	b->curve->preset = preset;
+	curvemap_reset(cm, &b->curve->clipr, b->curve->preset);
 	curvemapping_changed(b->curve, 0);
 }
 

Modified: trunk/blender/source/blender/blenkernel/intern/colortools.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/colortools.c	2010-03-09 07:41:04 UTC (rev 27356)
+++ trunk/blender/source/blender/blenkernel/intern/colortools.c	2010-03-09 07:41:27 UTC (rev 27357)
@@ -239,7 +239,7 @@
 	cuma->curve= cmp;
 }
 
-void curvemap_reset(CurveMap *cuma, rctf *clipr, CurveMappingPreset preset)
+void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset)
 {
 	if(cuma->curve)
 		MEM_freeN(cuma->curve);
@@ -249,6 +249,7 @@
 		case CURVE_PRESET_SHARP: cuma->totpoint= 3; break;
 		case CURVE_PRESET_SMOOTH: cuma->totpoint= 4; break;
 		case CURVE_PRESET_MAX: cuma->totpoint= 2; break;
+		case CURVE_PRESET_MID9: cuma->totpoint= 9;
 	}
 
 	cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points");
@@ -286,6 +287,15 @@
 			cuma->curve[1].x= 1;
 			cuma->curve[1].y= 1;
 			break;
+		case CURVE_PRESET_MID9:
+			{
+				int i;
+				for (i=0; i < cuma->totpoint; i++)
+				{
+					cuma->curve[i].x= i / ((float)cuma->totpoint-1);
+					cuma->curve[i].y= 0.5;
+				}
+			}
 	}
 	
 	if(cuma->table) {

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2010-03-09 07:41:04 UTC (rev 27356)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2010-03-09 07:41:27 UTC (rev 27357)
@@ -10647,6 +10647,11 @@
 
 	/* put 2.50 compatibility code here until next subversion bump */
 	{
+		Brush *brush;
+		
+		for (brush= main->brush.first; brush; brush= brush->id.next) {
+			if (brush->curve) brush->curve->preset = CURVE_PRESET_SMOOTH;
+		}
 	}
 
 	/* WATCH IT!!!: pointers from libdata have not been converted yet here! */

Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c	2010-03-09 07:41:04 UTC (rev 27356)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c	2010-03-09 07:41:27 UTC (rev 27357)
@@ -1707,7 +1707,7 @@
 
 	switch(event) {
 		case 0: /* reset */
-			curvemap_reset(cuma, &cumap->clipr, CURVE_PRESET_LINE);
+			curvemap_reset(cuma, &cumap->clipr,	cumap->preset);
 			curvemapping_changed(cumap, 0);
 			break;
 		case 1:
@@ -1729,10 +1729,6 @@
 			cuma->flag |= CUMA_EXTEND_EXTRAPOLATE;
 			curvemapping_changed(cumap, 0);
 			break;
-		case 6: /* reset smooth */
-			curvemap_reset(cuma, &cumap->clipr, CURVE_PRESET_SMOOTH);
-			curvemapping_changed(cumap, 0);
-			break;
 	}
 	ED_region_tag_redraw(CTX_wm_region(C));
 }
@@ -1770,7 +1766,7 @@
 	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View",				0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
 	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle",			0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
 	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle",			0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
-	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve",			0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
+	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve",			0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
 
 	uiBlockSetDirection(block, UI_RIGHT);
 	uiTextBoundsBlock(block, 50);
@@ -1789,8 +1785,9 @@
 	CurveMapping *cumap = cumap_v;
 	int a;
 	
+	cumap->preset = CURVE_PRESET_LINE;
 	for(a=0; a<CM_TOT; a++)
-		curvemap_reset(cumap->cm+a, &cumap->clipr, CURVE_PRESET_LINE);
+		curvemap_reset(cumap->cm+a, &cumap->clipr, cumap->preset);
 	
 	cumap->black[0]=cumap->black[1]=cumap->black[2]= 0.0f;
 	cumap->white[0]=cumap->white[1]=cumap->white[2]= 1.0f;

Modified: trunk/blender/source/blender/makesdna/DNA_color_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_color_types.h	2010-03-09 07:41:04 UTC (rev 27356)
+++ trunk/blender/source/blender/makesdna/DNA_color_types.h	2010-03-09 07:41:27 UTC (rev 27357)
@@ -64,6 +64,7 @@
 
 typedef struct CurveMapping {
 	int flag, cur;					/* cur; for buttons, to show active curve */
+	int preset, pad;
 	
 	rctf curr, clipr;				/* current rect, clip rect (is default rect too) */
 	
@@ -80,6 +81,15 @@
 #define CUMA_DRAW_CFRA			4
 #define CUMA_DRAW_SAMPLE		8
 
+/* cumapping->preset */
+typedef enum CurveMappingPreset {
+	CURVE_PRESET_LINE,
+	CURVE_PRESET_SHARP,
+	CURVE_PRESET_SMOOTH,
+	CURVE_PRESET_MAX,
+	CURVE_PRESET_MID9
+} CurveMappingPreset;
+
 typedef struct Histogram {
 	int channels;
 	int x_resolution;

Modified: trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c	2010-03-09 07:41:04 UTC (rev 27356)
+++ trunk/blender/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c	2010-03-09 07:41:27 UTC (rev 27357)
@@ -137,28 +137,13 @@
 static void node_composit_init_huecorrect(bNode* node)
 {
 	CurveMapping *cumapping = node->storage= curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
-	int c, i;
+	int c;
 	
+	cumapping->preset = CURVE_PRESET_MID9;
+	
 	for (c=0; c<3; c++) {
 		CurveMap *cuma = &cumapping->cm[c];
-		
-		/* set default horizontal curve */
-		if(cuma->curve)
-			MEM_freeN(cuma->curve);
-		
-		cuma->totpoint= 9;
-		cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points");
-		
-		for (i=0; i < cuma->totpoint; i++)
-		{
-			cuma->curve[i].x= i / ((float)cuma->totpoint-1);
-			cuma->curve[i].y= 0.5;
-		}
-		
-		if(cuma->table) {
-			MEM_freeN(cuma->table);
-			cuma->table= NULL;
-		}
+		curvemap_reset(cuma, &cumapping->clipr, cumapping->preset);
 	}
 	
 	/* default to showing Saturation */





More information about the Bf-blender-cvs mailing list