FCurve Auto Colours: "XYZ to RGB" works for Quaternions too now
authorJoshua Leung <aligorith@gmail.com>
Mon, 27 Jun 2016 12:25:48 +0000 (00:25 +1200)
committerJoshua Leung <aligorith@gmail.com>
Mon, 27 Jun 2016 12:27:51 +0000 (00:27 +1200)
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.

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

index 66b3a63c6694055bab1d1669c53bfca6ffe3a5b2..0c0f54f01793fffb6099d684d45e2f8a39b0a7e5 100644 (file)
@@ -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 */
index a7284694f6407b33bad35edcb72474be66dfef54..8ae5932f3fd8bf39a7e94422c02c80e4b67bc8c1 100644 (file)
@@ -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:
                                {
index 4c1283452ff874e57066f5f025a2209d43e53420..6bd7b3a499906f6a181e4cfdbcacaf0b66c95353 100644 (file)
@@ -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;
 
 /* ************************************************ */
index 1487dfa074e3cb7de3bb609b12fc04b7ea7aea78..3043c5452c045c74c2fff4e426d11b2add516575 100644 (file)
@@ -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}