NDOF: fix for negative colors and flickering hue when picking with HSVCUBE
This commit is contained in:
parent
7bc577e9f7
commit
e2089e1406
@ -123,6 +123,7 @@ MINLINE void premul_float_to_straight_uchar(unsigned char *result, const float c
|
||||
|
||||
int constrain_rgb(float *r, float *g, float *b);
|
||||
void minmax_rgb(short c[3]);
|
||||
void hsv_clamp_v(float hsv[3], float v_max);
|
||||
|
||||
void rgb_float_set_hue_float_offset(float *rgb, float hue_offset);
|
||||
void rgb_byte_set_hue_float_offset(unsigned char *rgb, float hue_offset);
|
||||
|
@ -347,6 +347,16 @@ void rgb_to_hsv_compat_v(const float rgb[3], float r_hsv[3])
|
||||
rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], &r_hsv[0], &r_hsv[1], &r_hsv[2]);
|
||||
}
|
||||
|
||||
/* clamp hsv to usable values */
|
||||
void hsv_clamp_v(float hsv[3], float v_max)
|
||||
{
|
||||
if (UNLIKELY(hsv[0] < 0.0f || hsv[0] > 1.0f)) {
|
||||
hsv[0] = hsv[0] - floorf(hsv[0]);
|
||||
}
|
||||
CLAMP(hsv[1], 0.0f, 1.0f);
|
||||
CLAMP(hsv[2], 0.0f, v_max);
|
||||
}
|
||||
|
||||
/*http://brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html */
|
||||
|
||||
void xyz_to_rgb(float xc, float yc, float zc, float *r, float *g, float *b, int colorspace)
|
||||
|
@ -4380,6 +4380,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
|
||||
const enum eSnapType snap, const bool shift)
|
||||
{
|
||||
float *hsv = ui_block_hsv_get(but->block);
|
||||
const float hsv_v_max = max_ff(hsv[2], but->softmax);
|
||||
float rgb[3];
|
||||
float sensitivity = (shift ? 0.15f : 0.3f) * ndof->dt;
|
||||
bool use_display_colorspace = ui_hsvcube_use_display_colorspace(but);
|
||||
@ -4432,6 +4433,9 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
|
||||
}
|
||||
}
|
||||
|
||||
/* ndof specific: the changes above aren't clamping */
|
||||
hsv_clamp_v(hsv, hsv_v_max);
|
||||
|
||||
hsv_to_rgb_v(hsv, rgb);
|
||||
|
||||
if (use_display_colorspace)
|
||||
|
Loading…
Reference in New Issue
Block a user