[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28487] trunk/blender/source/blender/ editors/interface/interface_templates.c: patch 21737 by Elia Sarti (vekoon)

Daniel Salazar zanqdo at gmail.com
Wed Apr 28 11:29:17 CEST 2010


Revision: 28487
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28487
Author:   zanqdo
Date:     2010-04-28 11:29:17 +0200 (Wed, 28 Apr 2010)

Log Message:
-----------
patch 21737 by Elia Sarti (vekoon)

Currently for ColorBands, when pressing the Add button, new elements are
set with a medium gray in a medium position which often is not desired
behaviour.
 
This patch when possible sets new elements as averaged values between
the current element and its preceding neighbour

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_templates.c

Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c	2010-04-28 08:50:49 UTC (rev 28486)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c	2010-04-28 09:29:17 UTC (rev 28487)
@@ -39,6 +39,7 @@
 #include "BKE_global.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
+#include "BKE_texture.h"
 #include "BKE_utildefines.h"
 
 #include "ED_screen.h"
@@ -1438,6 +1439,33 @@
 {
 	ColorBand *coba= coba_v;
 
+	if(coba->tot > 0) {
+		CBData *xnew, *x1, *x2;
+		float col[4];
+
+		xnew= &coba->data[coba->tot];
+
+		if(coba->tot > 1) {
+			if(coba->cur > 0) {
+				x1= &coba->data[coba->cur-1];
+				x2= &coba->data[coba->cur];
+			}
+			else {
+				x1= &coba->data[coba->cur];
+				x2= &coba->data[coba->cur+1];
+			}
+
+			xnew->pos = x1->pos + ((x2->pos - x1->pos) / 2);
+		}
+
+		do_colorband(coba, xnew->pos, col);
+
+		xnew->r= col[0];
+		xnew->g= col[1];
+		xnew->b= col[2];
+		xnew->a= col[3];
+	}
+
 	if(coba->tot < MAXCOLORBAND-1) coba->tot++;
 	coba->cur= coba->tot-1;
 





More information about the Bf-blender-cvs mailing list