Changed: #825 Remove all warnings when compiling Ryzom

This commit is contained in:
kervala 2010-12-22 14:15:50 +01:00
parent e53a439e7f
commit fcd7edc6b3

View file

@ -615,25 +615,26 @@ bool CRGBA::convertToHLS(float &h, float &l, float &s) const
float maxV = NLMISC::maxof(r, g, b); float maxV = NLMISC::maxof(r, g, b);
float minV = NLMISC::minof(r, g, b); float minV = NLMISC::minof(r, g, b);
/// get lightness // all composants are equals -> achromatique
l = 0.5f * (maxV + minV); if (minV == maxV)
/// Get saturation
if (minV == maxV) // all composants are equals -> achromatique
{ {
h = 0; h = 0.f;
s = 0; l = minV;
s = 0.f;
return true; return true;
} }
// get lightness
l = 0.5f * (maxV + minV);
float diff = maxV - minV; float diff = maxV - minV;
/// compute saturation // get saturation
s = l > 0.5f ? /*are we in the top of the double-hexcone ? */ s = l > 0.5f ? /*are we in the top of the double-hexcone ? */
diff / (2.f - maxV - minV) : diff / (2.f - maxV - minV) :
diff / (maxV + minV); diff / (maxV + minV);
// Get hue // get hue
if (maxV == r) if (maxV == r)
{ {
h = (g - b) / diff; h = (g - b) / diff;
@ -691,10 +692,10 @@ static float HLSValue(float h, float v1, float v2)
// *************************************************************************** // ***************************************************************************
void CRGBA::buildFromHLS(float h, float l, float s) void CRGBA::buildFromHLS(float h, float l, float s)
{ {
clamp(l, 0, 1); clamp(l, 0.f, 1.f);
clamp(s, 0, 1); clamp(s, 0.f, 1.f);
float v2 = (l <= 0.5f) ? (l * (1 + s)) : (l + s - l * s); float v2 = (l <= 0.5f) ? (l * (1.f + s)) : (l + s - l * s);
float v1 = 2.f * l - v2; float v1 = 2.f * l - v2;
if (s == 0) // achromatic ? if (s == 0) // achromatic ?