[Bf-blender-cvs] [34024c7] master: FCurve Auto Colours: "XYZ to RGB" works for Quaternions too now

Joshua Leung noreply at git.blender.org
Mon Jun 27 14:28:53 CEST 2016


Commit: 34024c7cd8b3e7e90754c80d60ac5cd02de87a85
Author: Joshua Leung
Date:   Tue Jun 28 00:25:48 2016 +1200
Branches: master
https://developer.blender.org/rB34024c7cd8b3e7e90754c80d60ac5cd02de87a85

FCurve Auto Colours: "XYZ to RGB" works for Quaternions too now

The "W" channel will get a yellowish colour (i.e. a blend between the X/R and
Y/G axis colours), while the XYZ will behave as they do for other transforms.

===================================================================

M	source/blender/editors/animation/keyframing.c
M	source/blender/editors/space_graph/space_graph.c
M	source/blender/makesdna/DNA_anim_types.h
M	source/blender/makesrna/intern/rna_fcurve.c

===================================================================

diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 66b3a63..0c0f54f 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1069,6 +1069,9 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
 				if (ELEM(RNA_property_subtype(prop), PROP_TRANSLATION, PROP_XYZ, PROP_EULER, PROP_COLOR, PROP_COORDS)) {
 					fcu->color_mode = FCURVE_COLOR_AUTO_RGB;
 				}
+				else if (RNA_property_subtype(prop), PROP_QUATERNION) {
+					fcu->color_mode = FCURVE_COLOR_AUTO_YRGB;
+				}
 			}
 			
 			/* insert keyframe */
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index a728469..8ae5932 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -611,6 +611,51 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
 					}
 					break;
 				}
+				case FCURVE_COLOR_AUTO_YRGB:
+				{
+					/* Like FCURVE_COLOR_AUTO_RGB, except this is for quaternions... */
+					float *col = fcu->color;
+					
+					switch (fcu->array_index) {
+						case 1:
+							UI_GetThemeColor3fv(TH_AXIS_X, col);
+							break;
+						case 2:
+							UI_GetThemeColor3fv(TH_AXIS_Y, col);
+							break;
+						case 3:
+							UI_GetThemeColor3fv(TH_AXIS_Z, col);
+							break;
+						
+						case 0:
+						{
+							/* Special Case: "W" channel should be yellowish, so blend X and Y channel colors... */
+							float c1[3], c2[3];
+							float h1[3], h2[3];
+							float hresult[3];
+							
+							/* - get colors (rgb) */
+							UI_GetThemeColor3fv(TH_AXIS_X, c1);
+							UI_GetThemeColor3fv(TH_AXIS_Y, c2);
+							
+							/* - perform blending in HSV space (to keep brightness similar) */
+							rgb_to_hsv_v(c1, h1);
+							rgb_to_hsv_v(c2, h2);
+							
+							interp_v3_v3v3(hresult, h1, h2, 0.5f);
+							
+							/* - convert back to RGB for display */
+							hsv_to_rgb_v(hresult, col);
+							break;
+						}
+						
+						default:
+							/* 'unknown' color - bluish so as to not conflict with handles */
+							col[0] = 0.3f; col[1] = 0.8f; col[2] = 1.0f;
+							break;
+					}
+					break;
+				}
 				case FCURVE_COLOR_AUTO_RAINBOW:
 				default:
 				{
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index 4c12834..6bd7b3a 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -537,8 +537,9 @@ typedef enum eFCurve_Extend {
 /* curve coloring modes */
 typedef enum eFCurve_Coloring {
 	FCURVE_COLOR_AUTO_RAINBOW = 0,		/* automatically determine color using rainbow (calculated at drawtime) */
-	FCURVE_COLOR_AUTO_RGB,				/* automatically determine color using XYZ (array index) <-> RGB */
-	FCURVE_COLOR_CUSTOM					/* custom color */
+	FCURVE_COLOR_AUTO_RGB     = 1,		/* automatically determine color using XYZ (array index) <-> RGB */
+	FCURVE_COLOR_AUTO_YRGB    = 3,		/* automatically determine color where XYZ <-> RGB, but index(X) != 0 */
+	FCURVE_COLOR_CUSTOM       = 2,		/* custom color */
 } eFCurve_Coloring;
 
 /* ************************************************ */
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index 1487dfa..3043c54 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -1844,6 +1844,8 @@ static void rna_def_fcurve(BlenderRNA *brna)
 		                            "Cycle through the rainbow, trying to give each curve a unique color"},
 		{FCURVE_COLOR_AUTO_RGB, "AUTO_RGB", 0, "Auto XYZ to RGB",
 		                        "Use axis colors for transform and color properties, and auto-rainbow for the rest"},
+		{FCURVE_COLOR_AUTO_YRGB, "AUTO_YRGB", 0, "Auto WXYZ to YRGB",
+		                         "Use axis colors for XYZ parts of transform, and yellow for the 'W' channel"},
 		{FCURVE_COLOR_CUSTOM, "CUSTOM", 0, "User Defined",
 		                      "Use custom hand-picked color for F-Curve"},
 		{0, NULL, 0, NULL, NULL}




More information about the Bf-blender-cvs mailing list