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.
This commit is contained in:
Joshua Leung 2016-06-28 00:25:48 +12:00
parent f4e492ad71
commit 34024c7cd8
4 changed files with 53 additions and 2 deletions

View 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 */

View 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:
{

View 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;
/* ************************************************ */

View 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}