Merge branch 'master' of https://github.com/DigitalPulseSoftware/NazaraEngine
This commit is contained in:
@@ -130,8 +130,6 @@ namespace Nz
|
||||
* \brief Returns the number of elements in a C-array
|
||||
* \return The number of elements
|
||||
*
|
||||
* \param name C-array
|
||||
*
|
||||
* \see CountOf
|
||||
*/
|
||||
template<typename T, std::size_t N>
|
||||
|
||||
@@ -815,7 +815,7 @@ namespace Nz
|
||||
for (std::size_t i = 0; i < m_blocks.size(); ++i)
|
||||
{
|
||||
Block mask = (i == m_blocks.size() - 1) ? lastBlockMask : fullBitMask;
|
||||
if (m_blocks[i] == mask) // The extra bits are set to zero, thus we can't test without proceeding with a mask
|
||||
if (m_blocks[i] != mask) // The extra bits are set to zero, thus we can't test without proceeding with a mask
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -421,7 +421,6 @@ namespace Nz
|
||||
|
||||
/*!
|
||||
* \brief Resizes the string
|
||||
* \return A reference to this
|
||||
*
|
||||
* \param newSize Target size
|
||||
*/
|
||||
@@ -433,7 +432,6 @@ namespace Nz
|
||||
|
||||
/*!
|
||||
* \brief Resizes the string
|
||||
* \return A reference to this
|
||||
*
|
||||
* \param newSize Target size
|
||||
* \param byte Byte to add if newSize is greather than actual size
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Nz
|
||||
void SetStream(void* ptr, Nz::UInt64 size);
|
||||
void SetStream(const void* ptr, Nz::UInt64 size);
|
||||
|
||||
inline void Write(const void* data, std::size_t size);
|
||||
inline std::size_t Write(const void* data, std::size_t size);
|
||||
|
||||
template<typename T>
|
||||
ByteStream& operator>>(T& value);
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Nz
|
||||
* \brief Reads data
|
||||
* \return Number of data read
|
||||
*
|
||||
* \param buffer Preallocated buffer to contain information read
|
||||
* \param ptr Preallocated buffer to contain information read
|
||||
* \param size Size of the read and thus of the buffer
|
||||
*/
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Nz
|
||||
/*!
|
||||
* \brief Sets the stream endianness
|
||||
*
|
||||
* \param Type of the endianness
|
||||
* \param endiannes Type of the endianness
|
||||
*/
|
||||
|
||||
inline void ByteStream::SetDataEndianness(Endianness endiannes)
|
||||
@@ -154,13 +154,13 @@ namespace Nz
|
||||
* \remark Produces a NazaraAssert if buffer is nullptr
|
||||
*/
|
||||
|
||||
inline void ByteStream::Write(const void* data, std::size_t size)
|
||||
inline std::size_t ByteStream::Write(const void* data, std::size_t size)
|
||||
{
|
||||
if (!m_context.stream)
|
||||
OnEmptyStream();
|
||||
|
||||
FlushBits();
|
||||
m_context.stream->Write(data, size);
|
||||
return m_context.stream->Write(data, size);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Nz
|
||||
inline explicit Color(UInt8 lightness);
|
||||
inline Color(UInt8 color[3], UInt8 alpha = 255);
|
||||
inline Color(const Color& color) = default;
|
||||
inline Color(Color&& color) = default;
|
||||
inline ~Color() = default;
|
||||
|
||||
inline bool IsOpaque() const;
|
||||
@@ -32,6 +33,9 @@ namespace Nz
|
||||
inline Color operator+(const Color& angles) const;
|
||||
inline Color operator*(const Color& angles) const;
|
||||
|
||||
inline Color& operator=(const Color& other) = default;
|
||||
inline Color& operator=(Color&& other) = default;
|
||||
|
||||
inline Color operator+=(const Color& angles);
|
||||
inline Color operator*=(const Color& angles);
|
||||
|
||||
@@ -40,13 +44,13 @@ namespace Nz
|
||||
|
||||
static inline Color FromCMY(float cyan, float magenta, float yellow);
|
||||
static inline Color FromCMYK(float cyan, float magenta, float yellow, float black);
|
||||
static inline Color FromHSL(UInt8 hue, UInt8 saturation, UInt8 lightness);
|
||||
static inline Color FromHSL(float hue, float saturation, float lightness);
|
||||
static inline Color FromHSV(float hue, float saturation, float value);
|
||||
static inline Color FromXYZ(const Vector3f& vec);
|
||||
static inline Color FromXYZ(float x, float y, float z);
|
||||
static inline void ToCMY(const Color& color, float* cyan, float* magenta, float* yellow);
|
||||
static inline void ToCMYK(const Color& color, float* cyan, float* magenta, float* yellow, float* black);
|
||||
static inline void ToHSL(const Color& color, UInt8* hue, UInt8* saturation, UInt8* lightness);
|
||||
static inline void ToHSL(const Color& color, float* hue, float* saturation, float* lightness);
|
||||
static inline void ToHSV(const Color& color, float* hue, float* saturation, float* value);
|
||||
static inline void ToXYZ(const Color& color, Vector3f* vec);
|
||||
static inline void ToXYZ(const Color& color, float* x, float* y, float* z);
|
||||
|
||||
@@ -219,35 +219,29 @@ namespace Nz
|
||||
* \brief Converts HSL representation to RGB
|
||||
* \return Color resulting
|
||||
*
|
||||
* \param hue Hue component
|
||||
* \param saturation Saturation component
|
||||
* \param lightness Lightness component
|
||||
* \param hue Hue component in [0, 360]
|
||||
* \param saturation Saturation component [0, 1]
|
||||
* \param lightness Lightness component [0, 1]
|
||||
*/
|
||||
|
||||
inline Color Color::FromHSL(UInt8 hue, UInt8 saturation, UInt8 lightness)
|
||||
inline Color Color::FromHSL(float hue, float saturation, float lightness)
|
||||
{
|
||||
if (saturation == 0)
|
||||
if (NumberEquals(saturation, 0.f))
|
||||
{
|
||||
// RGB results from 0 to 255
|
||||
return Color(lightness * 255,
|
||||
lightness * 255,
|
||||
lightness * 255);
|
||||
return Color(static_cast<UInt8>(lightness * 255.f));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Norme Windows
|
||||
float l = lightness/240.f;
|
||||
float h = hue/240.f;
|
||||
float s = saturation/240.f;
|
||||
|
||||
float v2;
|
||||
if (l < 0.5f)
|
||||
v2 = l * (1.f + s);
|
||||
if (lightness < 0.5f)
|
||||
v2 = lightness * (1.f + saturation);
|
||||
else
|
||||
v2 = (l + s) - (s*l);
|
||||
v2 = (lightness + saturation) - (saturation * lightness);
|
||||
|
||||
float v1 = 2.f * l - v2;
|
||||
float v1 = 2.f * lightness - v2;
|
||||
|
||||
float h = hue / 360.f;
|
||||
return Color(static_cast<UInt8>(255.f * Hue2RGB(v1, v2, h + (1.f/3.f))),
|
||||
static_cast<UInt8>(255.f * Hue2RGB(v1, v2, h)),
|
||||
static_cast<UInt8>(255.f * Hue2RGB(v1, v2, h - (1.f/3.f))));
|
||||
@@ -258,9 +252,9 @@ namespace Nz
|
||||
* \brief Converts HSV representation to RGB
|
||||
* \return Color resulting
|
||||
*
|
||||
* \param hue Hue component
|
||||
* \param saturation Saturation component
|
||||
* \param value Value component
|
||||
* \param hue Hue component in [0, 360]
|
||||
* \param saturation Saturation component in [0, 1]
|
||||
* \param value Value component in [0, 1]
|
||||
*/
|
||||
|
||||
inline Color Color::FromHSV(float hue, float saturation, float value)
|
||||
@@ -269,16 +263,15 @@ namespace Nz
|
||||
return Color(static_cast<UInt8>(value * 255.f));
|
||||
else
|
||||
{
|
||||
float h = hue/360.f * 6.f;
|
||||
float s = saturation/360.f;
|
||||
float h = (hue / 360.f) * 6.f;
|
||||
|
||||
if (NumberEquals(h, 6.f))
|
||||
h = 0; // hue must be < 1
|
||||
if (NumberEquals(h , 6.f))
|
||||
h = 0.f; // hue must be < 1
|
||||
|
||||
int i = static_cast<unsigned int>(h);
|
||||
float v1 = value * (1.f - s);
|
||||
float v2 = value * (1.f - s * (h - i));
|
||||
float v3 = value * (1.f - s * (1.f - (h - i)));
|
||||
int i = static_cast<int>(h);
|
||||
float v1 = value * (1.f - saturation);
|
||||
float v2 = value * (1.f - saturation * (h - i));
|
||||
float v3 = value * (1.f - saturation * (1.f - (h - i)));
|
||||
|
||||
float r, g, b;
|
||||
switch (i)
|
||||
@@ -321,7 +314,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
// RGB results from 0 to 255
|
||||
return Color(static_cast<UInt8>(r*255.f), static_cast<UInt8>(g*255.f), static_cast<UInt8>(b*255.f));
|
||||
return Color(static_cast<UInt8>(r * 255.f), static_cast<UInt8>(g * 255.f), static_cast<UInt8>(b * 255.f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,7 +331,7 @@ namespace Nz
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Converts XYZ representation to RGB
|
||||
* \brief Converts XYZ representation (D65/2°) to RGB
|
||||
* \return Color resulting
|
||||
*
|
||||
* \param x X component
|
||||
@@ -362,12 +355,12 @@ namespace Nz
|
||||
r *= 12.92f;
|
||||
|
||||
if (g > 0.0031308f)
|
||||
g = 1.055f * (std::pow(r, 1.f/2.4f)) - 0.055f;
|
||||
g = 1.055f * (std::pow(g, 1.f/2.4f)) - 0.055f;
|
||||
else
|
||||
g *= 12.92f;
|
||||
|
||||
if (b > 0.0031308f)
|
||||
b = 1.055f * (std::pow(r, 1.f/2.4f)) - 0.055f;
|
||||
b = 1.055f * (std::pow(b, 1.f/2.4f)) - 0.055f;
|
||||
else
|
||||
b *= 12.92f;
|
||||
|
||||
@@ -427,12 +420,12 @@ namespace Nz
|
||||
* \brief Converts RGB representation to HSL
|
||||
*
|
||||
* \param color Color to transform
|
||||
* \param hue Hue component
|
||||
* \param saturation Saturation component
|
||||
* \param lightness Lightness component
|
||||
* \param hue Hue component [0, 360]
|
||||
* \param saturation Saturation component in [0, 1]
|
||||
* \param lightness Lightness component in [0, 1]
|
||||
*/
|
||||
|
||||
inline void Color::ToHSL(const Color& color, UInt8* hue, UInt8* saturation, UInt8* lightness)
|
||||
inline void Color::ToHSL(const Color& color, float* hue, float* saturation, float* lightness)
|
||||
{
|
||||
float r = color.r / 255.f;
|
||||
float g = color.g / 255.f;
|
||||
@@ -443,42 +436,41 @@ namespace Nz
|
||||
|
||||
float deltaMax = max - min; //Delta RGB value
|
||||
|
||||
float l = (max + min)/2.f;
|
||||
float l = (max + min) / 2.f;
|
||||
*lightness = l;
|
||||
|
||||
if (NumberEquals(deltaMax, 0.f))
|
||||
{
|
||||
//This is a gray, no chroma...
|
||||
*hue = 0; //HSL results from 0 to 1
|
||||
*saturation = 0;
|
||||
*hue = 0.f;
|
||||
*saturation = 0.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Chromatic data...
|
||||
if (l < 0.5f)
|
||||
*saturation = static_cast<UInt8>(deltaMax/(max+min)*240.f);
|
||||
if (l <= 0.5f)
|
||||
*saturation = deltaMax / (max + min);
|
||||
else
|
||||
*saturation = static_cast<UInt8>(deltaMax/(2.f-max-min)*240.f);
|
||||
*saturation = (deltaMax / (2.f - max - min));
|
||||
|
||||
*lightness = static_cast<UInt8>(l*240.f);
|
||||
|
||||
float deltaR = ((max - r)/6.f + deltaMax/2.f)/deltaMax;
|
||||
float deltaG = ((max - g)/6.f + deltaMax/2.f)/deltaMax;
|
||||
float deltaB = ((max - b)/6.f + deltaMax/2.f)/deltaMax;
|
||||
float deltaR = ((max - r) / 6.f + deltaMax / 2.f) / deltaMax;
|
||||
float deltaG = ((max - g) / 6.f + deltaMax / 2.f) / deltaMax;
|
||||
float deltaB = ((max - b) / 6.f + deltaMax / 2.f) / deltaMax;
|
||||
|
||||
float h;
|
||||
|
||||
if (NumberEquals(r, max))
|
||||
h = deltaB - deltaG;
|
||||
else if (NumberEquals(g, max))
|
||||
h = (1.f/3.f) + deltaR - deltaB;
|
||||
h = (1.f / 3.f) + deltaR - deltaB;
|
||||
else
|
||||
h = (2.f/3.f) + deltaG - deltaR;
|
||||
h = (2.f / 3.f) + deltaG - deltaR;
|
||||
|
||||
if (h < 0.f)
|
||||
h += 1.f;
|
||||
else if (h > 1.f)
|
||||
h -= 1.f;
|
||||
|
||||
*hue = static_cast<UInt8>(h*240.f);
|
||||
*hue = h * 360.f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,33 +499,33 @@ namespace Nz
|
||||
if (NumberEquals(deltaMax, 0.f))
|
||||
{
|
||||
//This is a gray, no chroma...
|
||||
*hue = 0; //HSV results from 0 to 1
|
||||
*saturation = 0;
|
||||
*hue = 0.f;
|
||||
*saturation = 0.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Chromatic data...
|
||||
*saturation = deltaMax/max*360.f;
|
||||
*saturation = deltaMax / max;
|
||||
|
||||
float deltaR = ((max - r)/6.f + deltaMax/2.f)/deltaMax;
|
||||
float deltaG = ((max - g)/6.f + deltaMax/2.f)/deltaMax;
|
||||
float deltaB = ((max - b)/6.f + deltaMax/2.f)/deltaMax;
|
||||
float deltaR = ((max - r) / 6.f + deltaMax / 2.f) / deltaMax;
|
||||
float deltaG = ((max - g) / 6.f + deltaMax / 2.f) / deltaMax;
|
||||
float deltaB = ((max - b) / 6.f + deltaMax / 2.f) / deltaMax;
|
||||
|
||||
float h;
|
||||
|
||||
if (NumberEquals(r, max))
|
||||
h = deltaB - deltaG;
|
||||
else if (NumberEquals(g, max))
|
||||
h = (1.f/3.f) + deltaR - deltaB;
|
||||
h = (1.f / 3.f) + deltaR - deltaB;
|
||||
else
|
||||
h = (2.f/3.f) + deltaG - deltaR;
|
||||
h = (2.f / 3.f) + deltaG - deltaR;
|
||||
|
||||
if (h < 0.f)
|
||||
h += 1.f;
|
||||
else if (h > 1.f)
|
||||
h -= 1.f;
|
||||
|
||||
*hue = h*360.f;
|
||||
*hue = h * 360.f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Nz
|
||||
/*!
|
||||
* \brief Constructs a Flags object using an Enum value
|
||||
*
|
||||
* \param value enumVal
|
||||
* \param enumVal enumVal
|
||||
*
|
||||
* Setup a Flags object with only one flag active (corresponding to the enum value passed as argument).
|
||||
*/
|
||||
|
||||
@@ -484,16 +484,17 @@ namespace Nz
|
||||
|
||||
namespace std
|
||||
{
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \brief Gives a hash representation of the object, specialisation of std
|
||||
* \return Hash of the ObjectRef
|
||||
*
|
||||
* \param object Object to hash
|
||||
*/
|
||||
template<typename T>
|
||||
struct hash<Nz::ObjectRef<T>>
|
||||
{
|
||||
/*!
|
||||
* \ingroup core
|
||||
* \brief Gives a hash representation of the object, specialisation of std
|
||||
* \return Hash of the ObjectRef
|
||||
*
|
||||
* \param object Object to hash
|
||||
*/
|
||||
|
||||
size_t operator()(const Nz::ObjectRef<T>& object) const
|
||||
{
|
||||
hash<T*> h;
|
||||
|
||||
@@ -385,7 +385,7 @@ namespace Nz
|
||||
*
|
||||
* \param size (Width, Depth)
|
||||
* \param subdivision Number of subdivision for the axis
|
||||
* \param planeInfo Information for the plane
|
||||
* \param plane Information for the plane
|
||||
* \param uvCoords Coordinates for texture
|
||||
*/
|
||||
inline Primitive Primitive::Plane(const Vector2f& size, const Vector2ui& subdivision, const Planef& plane, const Rectf& uvCoords)
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace std
|
||||
const char* ptr = str.GetConstBuffer();
|
||||
|
||||
do
|
||||
h = ((h << 5) + h) + *ptr;
|
||||
h = ((h << 5) + h) + static_cast<size_t>(*ptr);
|
||||
while (*++ptr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user