Allow error message to be formatted

This commit is contained in:
SirLynix
2023-08-14 23:16:37 +02:00
committed by Jérôme Leclercq
parent 25957c4b7f
commit a741672a51
119 changed files with 707 additions and 490 deletions

View File

@@ -363,7 +363,7 @@ namespace Nz
}
// If we arrive here, the extent is invalid
NazaraError("Invalid extent type (From) (0x" + NumberToString(UnderlyingCast(from.extent), 16) + ')');
NazaraError("Invalid extent type (From) ({0:#x})", UnderlyingCast(from.extent));
return Null();
}
@@ -390,13 +390,13 @@ namespace Nz
}
// If we arrive here, the extent is invalid
NazaraError("Invalid extent type (From) (0x" + NumberToString(UnderlyingCast(from.extent), 16) + ')');
NazaraError("Invalid extent type (From) ({0:#x})", UnderlyingCast(from.extent));
return Null();
}
}
// If we arrive here, the extent is invalid
NazaraError("Invalid extent type (To) (0x" + NumberToString(UnderlyingCast(to.extent), 16) + ')');
NazaraError("Invalid extent type (To) ({0:#x})", UnderlyingCast(to.extent));
return Null();
}

View File

@@ -7,12 +7,12 @@
#ifndef NAZARA_MATH_BOX_HPP
#define NAZARA_MATH_BOX_HPP
#include <NazaraUtils/EnumArray.hpp>
#include <Nazara/Math/Enums.hpp>
#include <Nazara/Math/Matrix4.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Math/Sphere.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <NazaraUtils/EnumArray.hpp>
#include <string>
namespace Nz

View File

@@ -305,7 +305,7 @@ namespace Nz
return Vector3<T>(x + width, y + height, z + depth);
}
NazaraError("Corner not handled (0x" + NumberToString(UnderlyingCast(corner), 16) + ')');
NazaraError("Corner not handled ({0:#x})", UnderlyingCast(corner));
return Vector3<T>();
}

View File

@@ -116,7 +116,7 @@ namespace Nz
return false;
}
NazaraError("Invalid intersection side (0x" + NumberToString(UnderlyingCast(side), 16) + ')');
NazaraError("Invalid intersection side ({0:#x})", UnderlyingCast(side));
return false;
}
@@ -127,7 +127,7 @@ namespace Nz
return false;
}
NazaraError("Invalid extent type (0x" + NumberToString(UnderlyingCast(volume.extent), 16) + ')');
NazaraError("Invalid extent type ({0:#x})", UnderlyingCast(volume.extent));
return false;
}
@@ -281,7 +281,7 @@ namespace Nz
return IntersectionSide::Outside;
}
NazaraError("Invalid intersection side (0x" + NumberToString(UnderlyingCast(side), 16) + ')');
NazaraError("Invalid intersection side ({0:#x})", UnderlyingCast(side));
return IntersectionSide::Outside;
}
@@ -292,7 +292,7 @@ namespace Nz
return IntersectionSide::Outside;
}
NazaraError("Invalid extent type (0x" + NumberToString(UnderlyingCast(volume.extent), 16) + ')');
NazaraError("Invalid extent type ({0:#x})", UnderlyingCast(volume.extent));
return IntersectionSide::Outside;
}

View File

@@ -221,22 +221,11 @@ namespace Nz
* \param to Target plane
* \param interpolation Factor of interpolation
*
* \remark interpolation is meant to be between 0 and 1, other values are potentially undefined behavior
* \remark With NAZARA_DEBUG, a NazaraError is thrown and Plane() is returned
*
* \see Lerp
*/
template<typename T>
constexpr Plane<T> Plane<T>::Lerp(const Plane& from, const Plane& to, T interpolation)
{
#ifdef NAZARA_DEBUG
if (interpolation < T(0.0) || interpolation > T(1.0))
{
NazaraError("Interpolation must be in range [0..1] (Got " + NumberToString(interpolation) + ')');
return Plane();
}
#endif
Plane plane;
plane.distance = Nz::Lerp(from.distance, to.distance, interpolation);
plane.normal = Vector3<T>::Lerp(from.normal, to.normal, interpolation);

View File

@@ -603,14 +603,6 @@ namespace Nz
template<typename T>
constexpr Quaternion<T> Quaternion<T>::Lerp(const Quaternion& from, const Quaternion& to, T interpolation)
{
#ifdef NAZARA_DEBUG
if (interpolation < T(0.0) || interpolation > T(1.0))
{
NazaraError("Interpolation must be in range [0..1] (Got " + NumberToString(interpolation) + ')');
return Zero();
}
#endif
Quaternion interpolated;
interpolated.w = Nz::Lerp(from.w, to.w, interpolation);
interpolated.x = Nz::Lerp(from.x, to.x, interpolation);
@@ -717,22 +709,11 @@ namespace Nz
* \param to Target quaternion
* \param interpolation Factor of interpolation
*
* \remark interpolation is meant to be between 0 and 1, other values are potentially undefined behavior
* \remark With NAZARA_DEBUG, a NazaraError is thrown and Zero() is returned
*
* \see Lerp
*/
template<typename T>
Quaternion<T> Quaternion<T>::Slerp(const Quaternion& from, const Quaternion& to, T interpolation)
{
#ifdef NAZARA_DEBUG
if (interpolation < T(0.0) || interpolation > T(1.0))
{
NazaraError("Interpolation must be in range [0..1] (Got " + std::to_string(interpolation) + ')');
return Zero();
}
#endif
Quaternion q;
T cosOmega = from.DotProduct(to);

View File

@@ -200,7 +200,7 @@ namespace Nz
return false;
}
NazaraError("Invalid extent type (0x" + NumberToString(UnderlyingCast(volume.extent), 16) + ')');
NazaraError("Invalid extent type ({0:#x})", UnderlyingCast(volume.extent));
return false;
}

View File

@@ -7,9 +7,9 @@
#ifndef NAZARA_MATH_RECT_HPP
#define NAZARA_MATH_RECT_HPP
#include <NazaraUtils/EnumArray.hpp>
#include <Nazara/Math/Enums.hpp>
#include <Nazara/Math/Vector2.hpp>
#include <NazaraUtils/EnumArray.hpp>
#include <string>
namespace Nz

View File

@@ -246,7 +246,7 @@ namespace Nz
return Vector2<T>(x + width, y);
}
NazaraError("Corner not handled (0x" + NumberToString(UnderlyingCast(corner), 16) + ')');
NazaraError("Corner not handled ({0:#x})", UnderlyingCast(corner));
return Vector2<T>();
}

View File

@@ -478,22 +478,11 @@ namespace Nz
* \param to Target sphere
* \param interpolation Factor of interpolation
*
* \remark interpolation is meant to be between 0 and 1, other values are potentially undefined behavior
* \remark With NAZARA_DEBUG, a NazaraError is thrown and Zero() is returned
*
* \see Lerp
*/
template<typename T>
constexpr Sphere<T> Sphere<T>::Lerp(const Sphere& from, const Sphere& to, T interpolation)
{
#ifdef NAZARA_DEBUG
if (interpolation < T(0.0) || interpolation > T(1.0))
{
NazaraError("Interpolation must be in range [0..1] (Got " + NumberToString(interpolation) + ')');
return Zero();
}
#endif
Sphere sphere;
sphere.x = Nz::Lerp(from.x, to.x, interpolation);
sphere.y = Nz::Lerp(from.y, to.y, interpolation);