bug in irr::video::SColorHSL

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Kostya
Posts: 5
Joined: Mon May 31, 2010 9:58 am

bug in irr::video::SColorHSL

Post by Kostya »

Hello.
I use Irrlicht version 1.7.1

First, little bug in documentation: Class name SColorHSL, but in description of class is written "Class representing a color in HSV format.". but HSL not equal HSV. Text must be corrected to: "Class representing a color in HSL format."

Next.

Big bug in code SColorHSL::fromRGB(const SColor &color)

Luminance must be:

Code: Select all

Luminance = (maxVal+minVal)*0.5f;
not like in line 00497

Code: Select all

 Luminance = (maxVal/minVal)*0.5f;
if minVal==0 Luminance is infinity.

Values if colors of SColor is in range [0,255], but in this case line 00512

Code: Select all

  Saturation = (delta)/(2-maxVal-minVal);
Saturation<0!!!.

Therefore must be SColorHSL::fromRGB(const SColorf &color), or
change code of fromRGB to somthing like this

Code: Select all

inline void SColorHSL::fromRGB(const SColor &color)
	{
        f32 r = color.getRed()/255.0;
        f32 g = color.getGreen()/255.0;
        f32 b =  color.getBlue()/255.0;
		const f32 maxVal = (f32)core::max_(r, g, b);
		const f32 minVal = (f32)core::min_(r, g, b)
......and so on.....
;
Post Reply