From be9a3c247d034c78f9d1e9f8cae6bc5f508ba4ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 24 Apr 2023 17:25:45 +0200 Subject: [PATCH] Math: change all assertions to debug-only. The perf cost is just too great for these to be enabled always. The only place where the assertions are kept always is in the batch APIs -- there it's assumed the function is called on large enough data to offset this overhead, plus since it's often dealing with large blocks of data the memory safety is more important than various FP drifts which were the usual case why other assertions were firing. --- doc/changelog.dox | 3 +++ src/Magnum/Math/Algorithms/GaussJordan.h | 2 +- src/Magnum/Math/Algorithms/Svd.h | 4 ++-- src/Magnum/Math/Color.h | 2 +- src/Magnum/Math/Complex.h | 12 +++++----- src/Magnum/Math/CubicHermite.h | 6 ++--- src/Magnum/Math/Distance.h | 2 +- src/Magnum/Math/DualComplex.h | 2 +- src/Magnum/Math/DualQuaternion.h | 10 ++++---- src/Magnum/Math/Frustum.h | 4 ++-- src/Magnum/Math/Functions.cpp | 9 +++---- src/Magnum/Math/Functions.h | 4 ++-- src/Magnum/Math/Intersection.h | 2 +- src/Magnum/Math/Matrix.h | 2 +- src/Magnum/Math/Matrix3.h | 10 ++++---- src/Magnum/Math/Matrix4.h | 12 +++++----- src/Magnum/Math/Quaternion.h | 24 +++++++++---------- src/Magnum/Math/Test/ComplexTest.cpp | 10 ++++---- src/Magnum/Math/Test/CubicHermiteTest.cpp | 16 ++++++------- src/Magnum/Math/Test/DistanceTest.cpp | 2 +- src/Magnum/Math/Test/DualComplexTest.cpp | 4 ++-- src/Magnum/Math/Test/DualQuaternionTest.cpp | 10 ++++---- src/Magnum/Math/Test/FrustumTest.cpp | 2 +- src/Magnum/Math/Test/FunctionsTest.cpp | 8 +++---- src/Magnum/Math/Test/IntersectionTest.cpp | 2 +- src/Magnum/Math/Test/Matrix3Test.cpp | 10 ++++---- src/Magnum/Math/Test/Matrix4Test.cpp | 12 +++++----- src/Magnum/Math/Test/MatrixTest.cpp | 2 +- src/Magnum/Math/Test/QuaternionTest.cpp | 22 ++++++++--------- src/Magnum/Math/Test/VectorTest.cpp | 4 ++-- src/Magnum/Math/Vector.h | 6 ++--- .../Shaders/Implementation/lineMiterLimit.h | 2 ++ src/Magnum/Trade/LightData.cpp | 2 ++ src/Magnum/Trade/ObjectData2D.cpp | 1 + src/Magnum/Trade/ObjectData3D.cpp | 1 + 35 files changed, 118 insertions(+), 108 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 0f2ddc21c..c95130de0 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -539,6 +539,9 @@ See also: @subsubsection changelog-latest-changes-math Math library +- Assertions in all @ref Math APIs except for batch functions in + @ref Magnum/Math/PackingBatch.h and @ref Magnum/Math/FunctionsBatch.h + were changed to debug-only for better performance in release builds - Added @ref Math::BitVector::set(std::size_t) and @ref Math::BitVector::reset(std::size_t) for branchless bit setting - Added @ref Math::castInto() overloads for casting between @ref UnsignedByte diff --git a/src/Magnum/Math/Algorithms/GaussJordan.h b/src/Magnum/Math/Algorithms/GaussJordan.h index 00a322611..4aac2066a 100644 --- a/src/Magnum/Math/Algorithms/GaussJordan.h +++ b/src/Magnum/Math/Algorithms/GaussJordan.h @@ -122,7 +122,7 @@ returning the inverted matrix. Expects that the matrix is invertible. */ template Matrix gaussJordanInverted(Matrix matrix) { Matrix inverted{Math::IdentityInit}; - CORRADE_INTERNAL_ASSERT_OUTPUT(gaussJordanInPlaceTransposed(matrix, inverted)); + CORRADE_INTERNAL_DEBUG_ASSERT_OUTPUT(gaussJordanInPlaceTransposed(matrix, inverted)); return inverted; } diff --git a/src/Magnum/Math/Algorithms/Svd.h b/src/Magnum/Math/Algorithms/Svd.h index bae79f18f..4c63e4fa0 100644 --- a/src/Magnum/Math/Algorithms/Svd.h +++ b/src/Magnum/Math/Algorithms/Svd.h @@ -223,7 +223,7 @@ template std::tuple std::tuple typename std::enable_if::value, Color3>: case 3: return {p, q, hsv.value}; case 4: return {t, p, hsv.value}; case 5: return {hsv.value, p, q}; - default: CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + default: CORRADE_INTERNAL_DEBUG_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } } template inline typename std::enable_if::value, Color3>::type fromHsv(const ColorHsv::FloatingPointType>& hsv) { diff --git a/src/Magnum/Math/Complex.h b/src/Magnum/Math/Complex.h index c0554338d..6f8f3bd11 100644 --- a/src/Magnum/Math/Complex.h +++ b/src/Magnum/Math/Complex.h @@ -29,10 +29,10 @@ * @brief Class @ref Magnum::Math::Complex, function @ref Magnum::Math::dot(), @ref Magnum::Math::angle() */ -#include #ifndef CORRADE_NO_DEBUG #include #endif +#include #include "Magnum/Math/Matrix.h" #include "Magnum/Math/Vector2.h" @@ -76,7 +76,7 @@ passed to @f$ \arccos @f$. @ref angle(const Vector&, const Vector&) */ template inline Rad angle(const Complex& normalizedA, const Complex& normalizedB) { - CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), + CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), "Math::angle(): complex numbers" << normalizedA << "and" << normalizedB << "are not normalized", {}); return Rad(std::acos(clamp(dot(normalizedA, normalizedB), T(-1), T(1)))); } @@ -522,7 +522,7 @@ template class Complex { * @see @ref isNormalized(), @ref inverted() */ Complex invertedNormalized() const { - CORRADE_ASSERT(isNormalized(), + CORRADE_DEBUG_ASSERT(isNormalized(), "Math::Complex::invertedNormalized():" << *this << "is not normalized", {}); return conjugated(); } @@ -608,7 +608,7 @@ Expects that both complex numbers are normalized. @f[ @ref lerp(const CubicHermiteQuaternion&, const CubicHermiteQuaternion&, T) */ template inline Complex lerp(const Complex& normalizedA, const Complex& normalizedB, T t) { - CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), + CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), "Math::lerp(): complex numbers" << normalizedA << "and" << normalizedB << "are not normalized", {}); return ((T(1) - t)*normalizedA + t*normalizedB).normalized(); } @@ -630,7 +630,7 @@ the same, returns the first argument. @f[ @ref slerp(const Quaternion&, const Quaternion&, T) */ template inline Complex slerp(const Complex& normalizedA, const Complex& normalizedB, T t) { - CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), + CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), "Math::slerp(): complex numbers" << normalizedA << "and" << normalizedB << "are not normalized", {}); const T cosAngle = dot(normalizedA, normalizedB); @@ -652,7 +652,7 @@ template inline Complex Complex::fromMatrix(const Matrix2x2& m fuzzy comparison should be 1 ± 2ε. This is similar to Vector::isNormalized(), which compares the dot product (length squared) to 1 ± 2ε. */ - CORRADE_ASSERT(std::abs(matrix.determinant() - T(1)) < T(2)*TypeTraits::epsilon(), + CORRADE_DEBUG_ASSERT(std::abs(matrix.determinant() - T(1)) < T(2)*TypeTraits::epsilon(), "Math::Complex::fromMatrix(): the matrix is not a rotation:" << Corrade::Utility::Debug::newline << matrix, {}); return Implementation::complexFromMatrix(matrix); } diff --git a/src/Magnum/Math/CubicHermite.h b/src/Magnum/Math/CubicHermite.h index 8878c0b9c..c190a3278 100644 --- a/src/Magnum/Math/CubicHermite.h +++ b/src/Magnum/Math/CubicHermite.h @@ -94,7 +94,7 @@ template class CubicHermite { typename std::enable_if, T>::value, CubicHermite>::type #endif fromBezier(const CubicBezier& a, const CubicBezier& b) { - return CORRADE_CONSTEXPR_ASSERT(a[3] == b[0], + return CORRADE_CONSTEXPR_DEBUG_ASSERT(a[3] == b[0], "Math::CubicHermite::fromBezier(): segments are not adjacent"), CubicHermite{3*(a[3] - a[2]), a[3], 3*(b[1] - a[3])}; } @@ -512,7 +512,7 @@ Expects that @ref CubicHermite::point() is a normalized complex number in both @ref slerp(const CubicHermiteComplex&, const CubicHermiteComplex&, T) */ template Complex splerp(const CubicHermiteComplex& a, const CubicHermiteComplex& b, T t) { - CORRADE_ASSERT(a.point().isNormalized() && b.point().isNormalized(), + CORRADE_DEBUG_ASSERT(a.point().isNormalized() && b.point().isNormalized(), "Math::splerp(): complex spline points" << a.point() << "and" << b.point() << "are not normalized", {}); return ((T(2)*t*t*t - T(3)*t*t + T(1))*a.point() + (t*t*t - T(2)*t*t + t)*a.outTangent() + @@ -542,7 +542,7 @@ and @p b. @ref slerp(const CubicHermiteQuaternion&, const CubicHermiteQuaternion&, T) */ template Quaternion splerp(const CubicHermiteQuaternion& a, const CubicHermiteQuaternion& b, T t) { - CORRADE_ASSERT(a.point().isNormalized() && b.point().isNormalized(), + CORRADE_DEBUG_ASSERT(a.point().isNormalized() && b.point().isNormalized(), "Math::splerp(): quaternion spline points" << a.point() << "and" << b.point() << "are not normalized", {}); return ((T(2)*t*t*t - T(3)*t*t + T(1))*a.point() + (t*t*t - T(2)*t*t + t)*a.outTangent() + diff --git a/src/Magnum/Math/Distance.h b/src/Magnum/Math/Distance.h index 5109b5e3f..31015a4f2 100644 --- a/src/Magnum/Math/Distance.h +++ b/src/Magnum/Math/Distance.h @@ -275,7 +275,7 @@ top. @see @ref planeEquation() */ template inline T pointPlaneNormalized(const Vector3& point, const Vector4& plane) { - CORRADE_ASSERT(plane.xyz().isNormalized(), + CORRADE_DEBUG_ASSERT(plane.xyz().isNormalized(), "Math::Distance::pointPlaneNormalized(): plane normal" << plane.xyz() << "is not normalized", {}); return pointPlaneScaled(point, plane); } diff --git a/src/Magnum/Math/DualComplex.h b/src/Magnum/Math/DualComplex.h index 76f229c81..3ae3db7e1 100644 --- a/src/Magnum/Math/DualComplex.h +++ b/src/Magnum/Math/DualComplex.h @@ -102,7 +102,7 @@ template class DualComplex: public Dual> { * @ref Matrix3::isRigidTransformation() */ static DualComplex fromMatrix(const Matrix3& matrix) { - CORRADE_ASSERT(matrix.isRigidTransformation(), + CORRADE_DEBUG_ASSERT(matrix.isRigidTransformation(), "Math::DualComplex::fromMatrix(): the matrix doesn't represent rigid transformation:" << Corrade::Utility::Debug::newline << matrix, {}); return {Implementation::complexFromMatrix(matrix.rotationScaling()), Complex(matrix.translation())}; } diff --git a/src/Magnum/Math/DualQuaternion.h b/src/Magnum/Math/DualQuaternion.h index 417c99f67..84448aee3 100644 --- a/src/Magnum/Math/DualQuaternion.h +++ b/src/Magnum/Math/DualQuaternion.h @@ -79,7 +79,7 @@ Note that this function does not check for shortest path interpolation, see @ref slerp(const Quaternion&, const Quaternion&, T) */ template inline DualQuaternion sclerp(const DualQuaternion& normalizedA, const DualQuaternion& normalizedB, const T t) { - CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), + CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), "Math::sclerp(): dual quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {}); const T cosHalfAngle = dot(normalizedA.real(), normalizedB.real()); @@ -145,7 +145,7 @@ otherwise, the interpolation is performed as: @f[ @ref slerpShortestPath() */ template inline DualQuaternion sclerpShortestPath(const DualQuaternion& normalizedA, const DualQuaternion& normalizedB, const T t) { - CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), + CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), "Math::sclerp(): dual quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {}); const T cosHalfAngle = dot(normalizedA.real(), normalizedB.real()); @@ -240,7 +240,7 @@ template class DualQuaternion: public Dual> { * @ref Matrix4::isRigidTransformation() */ static DualQuaternion fromMatrix(const Matrix4& matrix) { - CORRADE_ASSERT(matrix.isRigidTransformation(), + CORRADE_DEBUG_ASSERT(matrix.isRigidTransformation(), "Math::DualQuaternion::fromMatrix(): the matrix doesn't represent a rigid transformation:" << Corrade::Utility::Debug::newline << matrix, {}); Quaternion q = Implementation::quaternionFromMatrix(matrix.rotationScaling()); @@ -501,7 +501,7 @@ template class DualQuaternion: public Dual> { * @see @ref isNormalized(), @ref inverted() */ DualQuaternion invertedNormalized() const { - CORRADE_ASSERT(isNormalized(), + CORRADE_DEBUG_ASSERT(isNormalized(), "Math::DualQuaternion::invertedNormalized():" << *this << "is not normalized", {}); return quaternionConjugated(); } @@ -556,7 +556,7 @@ template class DualQuaternion: public Dual> { * @ref DualComplex::transformPoint() */ Vector3 transformPointNormalized(const Vector3& vector) const { - CORRADE_ASSERT(isNormalized(), + CORRADE_DEBUG_ASSERT(isNormalized(), "Math::DualQuaternion::transformPointNormalized():" << *this << "is not normalized", {}); return ((*this)*DualQuaternion(vector)*conjugated()).dual().vector(); } diff --git a/src/Magnum/Math/Frustum.h b/src/Magnum/Math/Frustum.h index 744275e8b..3423c9fd6 100644 --- a/src/Magnum/Math/Frustum.h +++ b/src/Magnum/Math/Frustum.h @@ -175,7 +175,7 @@ template class Frustum { * Expects that @p i is less than @cpp 6 @ce. */ Vector4& operator[](std::size_t i) { - CORRADE_ASSERT(i < 6, "Math::Frustum::operator[](): index" << i << "out of range", + CORRADE_DEBUG_ASSERT(i < 6, "Math::Frustum::operator[](): index" << i << "out of range", _data[i]); return _data[i]; } @@ -183,7 +183,7 @@ template class Frustum { /** @overload */ /* returns const& so [][] operations are also constexpr */ constexpr const Vector4& operator[](std::size_t i) const { - return CORRADE_CONSTEXPR_ASSERT(i < 6, "Math::Frustum::operator[](): index" << i << "out of range"), _data[i]; + return CORRADE_CONSTEXPR_DEBUG_ASSERT(i < 6, "Math::Frustum::operator[](): index" << i << "out of range"), _data[i]; } /** diff --git a/src/Magnum/Math/Functions.cpp b/src/Magnum/Math/Functions.cpp index 819cf3001..0968ae353 100644 --- a/src/Magnum/Math/Functions.cpp +++ b/src/Magnum/Math/Functions.cpp @@ -24,10 +24,10 @@ DEALINGS IN THE SOFTWARE. */ -#include - #include "Functions.h" +#include + namespace Magnum { namespace Math { #if !defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) @@ -69,7 +69,7 @@ UnsignedInt log2(UnsignedInt number) { } UnsignedLong binomialCoefficient(const UnsignedInt n, UnsignedInt k) { - CORRADE_ASSERT(n >= k, + CORRADE_DEBUG_ASSERT(n >= k, "Math::binomialCoefficient(): k can't be greater than n in (" << Corrade::Utility::Debug::nospace << n << "choose" << k << Corrade::Utility::Debug::nospace << ")", {}); /* k and n - k gives the same value, optimize the calculation to do fewer @@ -80,7 +80,8 @@ UnsignedLong binomialCoefficient(const UnsignedInt n, UnsignedInt k) { UnsignedLong result = n; for(UnsignedInt i = 2; i <= k; ++i) { - CORRADE_ASSERT(result < ~UnsignedLong{} / (n-i+1), "Math::binomialCoefficient(): overflow for (" << Corrade::Utility::Debug::nospace << n << "choose" << k << Corrade::Utility::Debug::nospace << ")", {}); + CORRADE_DEBUG_ASSERT(result < ~UnsignedLong{} / (n-i+1), + "Math::binomialCoefficient(): overflow for (" << Corrade::Utility::Debug::nospace << n << "choose" << k << Corrade::Utility::Debug::nospace << ")", {}); result *= n - i + 1; result /= i; diff --git a/src/Magnum/Math/Functions.h b/src/Magnum/Math/Functions.h index 34328e704..06fe1dc07 100644 --- a/src/Magnum/Math/Functions.h +++ b/src/Magnum/Math/Functions.h @@ -763,7 +763,7 @@ calculated as: @f[ @ref Matrix4::reflection() */ template inline Vector reflect(const Vector& vector, const Vector& normal) { - CORRADE_ASSERT(normal.isNormalized(), + CORRADE_DEBUG_ASSERT(normal.isNormalized(), "Math::reflect(): normal" << normal << "is not normalized", {}); return vector - T(2.0)*dot(vector, normal)*normal; } @@ -792,7 +792,7 @@ Wikipedia has a [List of refractive indices](https://en.wikipedia.org/wiki/List_ @ref Vector::isNormalized() */ template inline Vector refract(const Vector& vector, const Vector& normal, T eta) { - CORRADE_ASSERT(vector.isNormalized() && normal.isNormalized(), + CORRADE_DEBUG_ASSERT(vector.isNormalized() && normal.isNormalized(), "Math::refract(): vectors" << vector << "and" << normal << "are not normalized", {}); const T dot = Math::dot(vector, normal); const T k = T(1.0) - eta*eta*(T(1.0) - dot*dot); diff --git a/src/Magnum/Math/Intersection.h b/src/Magnum/Math/Intersection.h index 14ae37433..6e5f5dd4a 100644 --- a/src/Magnum/Math/Intersection.h +++ b/src/Magnum/Math/Intersection.h @@ -572,7 +572,7 @@ template bool sphereConeView(const Vector3& sphereCenter, const T sp } template bool sphereConeView(const Vector3& sphereCenter, const T sphereRadius, const Matrix4& coneView, const T sinAngle, const T tanAngle) { - CORRADE_ASSERT(coneView.isRigidTransformation(), + CORRADE_DEBUG_ASSERT(coneView.isRigidTransformation(), "Math::Intersection::sphereConeView(): coneView does not represent a rigid transformation:" << Corrade::Utility::Debug::newline << coneView, false); /* Transform the sphere so that we can test against Z axis aligned origin diff --git a/src/Magnum/Math/Matrix.h b/src/Magnum/Math/Matrix.h index c92e7fec6..275c94d12 100644 --- a/src/Magnum/Math/Matrix.h +++ b/src/Magnum/Math/Matrix.h @@ -274,7 +274,7 @@ template class Matrix: public RectangularMatrix invertedOrthogonal() const { - CORRADE_ASSERT(isOrthogonal(), + CORRADE_DEBUG_ASSERT(isOrthogonal(), "Math::Matrix::invertedOrthogonal(): the matrix is not orthogonal:" << Corrade::Utility::Debug::Debug::newline << *this, {}); return RectangularMatrix::transposed(); } diff --git a/src/Magnum/Math/Matrix3.h b/src/Magnum/Math/Matrix3.h index 681ab9636..22211a3f1 100644 --- a/src/Magnum/Math/Matrix3.h +++ b/src/Magnum/Math/Matrix3.h @@ -161,7 +161,7 @@ template class Matrix3: public Matrix3x3 { * @ref reflect() */ static Matrix3 reflection(const Vector2& normal) { - CORRADE_ASSERT(normal.isNormalized(), + CORRADE_DEBUG_ASSERT(normal.isNormalized(), "Math::Matrix3::reflection(): normal" << normal << "is not normalized", {}); return from(Matrix2x2() - T(2)*normal*RectangularMatrix<1, 2, T>(normal).transposed(), {}); } @@ -764,7 +764,7 @@ template Matrix3 Matrix3::projection(const Vector2& bottomLeft template Matrix2x2 Matrix3::rotation() const { Matrix2x2 rotation{(*this)[0].xy().normalized(), (*this)[1].xy().normalized()}; - CORRADE_ASSERT(rotation.isOrthogonal(), + CORRADE_DEBUG_ASSERT(rotation.isOrthogonal(), "Math::Matrix3::rotation(): the normalized rotation part is not orthogonal:" << Corrade::Utility::Debug::newline << rotation, {}); return rotation; } @@ -772,20 +772,20 @@ template Matrix2x2 Matrix3::rotation() const { template Matrix2x2 Matrix3::rotationNormalized() const { Matrix2x2 rotation{(*this)[0].xy(), (*this)[1].xy()}; - CORRADE_ASSERT(rotation.isOrthogonal(), + CORRADE_DEBUG_ASSERT(rotation.isOrthogonal(), "Math::Matrix3::rotationNormalized(): the rotation part is not orthogonal:" << Corrade::Utility::Debug::newline << rotation, {}); return rotation; } template T Matrix3::uniformScalingSquared() const { const T scalingSquared = (*this)[0].xy().dot(); - CORRADE_ASSERT(TypeTraits::equals((*this)[1].xy().dot(), scalingSquared), + CORRADE_DEBUG_ASSERT(TypeTraits::equals((*this)[1].xy().dot(), scalingSquared), "Math::Matrix3::uniformScaling(): the matrix doesn't have uniform scaling:" << Corrade::Utility::Debug::newline << rotationScaling(), {}); return scalingSquared; } template inline Matrix3 Matrix3::invertedRigid() const { - CORRADE_ASSERT(isRigidTransformation(), + CORRADE_DEBUG_ASSERT(isRigidTransformation(), "Math::Matrix3::invertedRigid(): the matrix doesn't represent a rigid transformation:" << Corrade::Utility::Debug::newline << *this, {}); Matrix2x2 inverseRotation = rotationScaling().transposed(); diff --git a/src/Magnum/Math/Matrix4.h b/src/Magnum/Math/Matrix4.h index 1472cb663..2797f7804 100644 --- a/src/Magnum/Math/Matrix4.h +++ b/src/Magnum/Math/Matrix4.h @@ -1087,7 +1087,7 @@ MAGNUM_MATRIXn_OPERATOR_IMPLEMENTATION(4, Matrix4) #endif template Matrix4 Matrix4::rotation(const Rad angle, const Vector3& normalizedAxis) { - CORRADE_ASSERT(normalizedAxis.isNormalized(), + CORRADE_DEBUG_ASSERT(normalizedAxis.isNormalized(), "Math::Matrix4::rotation(): axis" << normalizedAxis << "is not normalized", {}); const T sine = std::sin(T(angle)); @@ -1149,7 +1149,7 @@ template Matrix4 Matrix4::rotationZ(const Rad angle) { } template Matrix4 Matrix4::reflection(const Vector3& normal) { - CORRADE_ASSERT(normal.isNormalized(), + CORRADE_DEBUG_ASSERT(normal.isNormalized(), "Math::Matrix4::reflection(): normal" << normal << "is not normalized", {}); return from(Matrix3x3() - T(2)*normal*RectangularMatrix<1, 3, T>(normal).transposed(), {}); } @@ -1226,7 +1226,7 @@ template Matrix3x3 Matrix4::rotation() const { Matrix3x3 rotation{(*this)[0].xyz().normalized(), (*this)[1].xyz().normalized(), (*this)[2].xyz().normalized()}; - CORRADE_ASSERT(rotation.isOrthogonal(), + CORRADE_DEBUG_ASSERT(rotation.isOrthogonal(), "Math::Matrix4::rotation(): the normalized rotation part is not orthogonal:" << Corrade::Utility::Debug::newline << rotation, {}); return rotation; } @@ -1235,21 +1235,21 @@ template Matrix3x3 Matrix4::rotationNormalized() const { Matrix3x3 rotation{(*this)[0].xyz(), (*this)[1].xyz(), (*this)[2].xyz()}; - CORRADE_ASSERT(rotation.isOrthogonal(), + CORRADE_DEBUG_ASSERT(rotation.isOrthogonal(), "Math::Matrix4::rotationNormalized(): the rotation part is not orthogonal:" << Corrade::Utility::Debug::newline << rotation, {}); return rotation; } template T Matrix4::uniformScalingSquared() const { const T scalingSquared = (*this)[0].xyz().dot(); - CORRADE_ASSERT(TypeTraits::equals((*this)[1].xyz().dot(), scalingSquared) && + CORRADE_DEBUG_ASSERT(TypeTraits::equals((*this)[1].xyz().dot(), scalingSquared) && TypeTraits::equals((*this)[2].xyz().dot(), scalingSquared), "Math::Matrix4::uniformScaling(): the matrix doesn't have uniform scaling:" << Corrade::Utility::Debug::newline << rotationScaling(), {}); return scalingSquared; } template Matrix4 Matrix4::invertedRigid() const { - CORRADE_ASSERT(isRigidTransformation(), + CORRADE_DEBUG_ASSERT(isRigidTransformation(), "Math::Matrix4::invertedRigid(): the matrix doesn't represent a rigid transformation:" << Corrade::Utility::Debug::newline << *this, {}); Matrix3x3 inverseRotation = rotationScaling().transposed(); diff --git a/src/Magnum/Math/Quaternion.h b/src/Magnum/Math/Quaternion.h index ae90afea1..15c4c3c7b 100644 --- a/src/Magnum/Math/Quaternion.h +++ b/src/Magnum/Math/Quaternion.h @@ -30,10 +30,10 @@ * @brief Class @ref Magnum::Math::Quaternion, function @ref Magnum::Math::dot(), @ref Magnum::Math::angle(), @ref Magnum::Math::lerp(), @ref Magnum::Math::slerp() */ -#include #ifndef CORRADE_NO_DEBUG #include #endif +#include #include #include "Magnum/Math/Matrix.h" @@ -73,7 +73,7 @@ passed to @f$ \arccos @f$. @ref angle(const Vector&, const Vector&) */ template inline Rad angle(const Quaternion& normalizedA, const Quaternion& normalizedB) { - CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), + CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), "Math::angle(): quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {}); return Rad{std::acos(clamp(dot(normalizedA, normalizedB), T(-1), T(1)))}; } @@ -100,7 +100,7 @@ alternative. @ref lerp(const CubicHermiteQuaternion&, const CubicHermiteQuaternion&, T) */ template inline Quaternion lerp(const Quaternion& normalizedA, const Quaternion& normalizedB, T t) { - CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), + CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), "Math::lerp(): quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {}); return ((T(1) - t)*normalizedA + t*normalizedB).normalized(); } @@ -169,7 +169,7 @@ alternative. @ref slerp(const CubicHermiteQuaternion&, const CubicHermiteQuaternion&, T) */ template inline Quaternion slerp(const Quaternion& normalizedA, const Quaternion& normalizedB, T t) { - CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), + CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), "Math::slerp(): quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {}); const T cosHalfAngle = dot(normalizedA, normalizedB); @@ -240,7 +240,7 @@ Otherwise, the interpolation is performed as: @f[ @ref sclerpShortestPath() */ template inline Quaternion slerpShortestPath(const Quaternion& normalizedA, const Quaternion& normalizedB, T t) { - CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), + CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), "Math::slerpShortestPath(): quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {}); const T cosHalfAngle = dot(normalizedA, normalizedB); @@ -781,7 +781,7 @@ template Quaternion quaternionFromMatrix(const Matrix3x3& m) { } template inline Quaternion Quaternion::rotation(const Rad angle, const Vector3& normalizedAxis) { - CORRADE_ASSERT(normalizedAxis.isNormalized(), + CORRADE_DEBUG_ASSERT(normalizedAxis.isNormalized(), "Math::Quaternion::rotation(): axis" << normalizedAxis << "is not normalized", {}); return {normalizedAxis*std::sin(T(angle)/2), std::cos(T(angle)/2)}; } @@ -796,19 +796,19 @@ template inline Quaternion Quaternion::fromMatrix(const Matrix3x3 unrepresentable, the fuzzy comparison should be 1 ± 3ε. This is similar to Vector::isNormalized(), which compares the dot product (length squared) to 1 ± 2ε. */ - CORRADE_ASSERT(std::abs(matrix.determinant() - T(1)) < T(3)*TypeTraits::epsilon(), + CORRADE_DEBUG_ASSERT(std::abs(matrix.determinant() - T(1)) < T(3)*TypeTraits::epsilon(), "Math::Quaternion::fromMatrix(): the matrix is not a rotation:" << Corrade::Utility::Debug::newline << matrix, {}); return Implementation::quaternionFromMatrix(matrix); } template inline Rad Quaternion::angle() const { - CORRADE_ASSERT(isNormalized(), + CORRADE_DEBUG_ASSERT(isNormalized(), "Math::Quaternion::angle():" << *this << "is not normalized", {}); return Rad(T(2)*std::acos(_scalar)); } template inline Vector3 Quaternion::axis() const { - CORRADE_ASSERT(isNormalized(), + CORRADE_DEBUG_ASSERT(isNormalized(), "Math::Quaternion::axis():" << *this << "is not normalized", {}); return _vector/std::sqrt(1-pow2(_scalar)); } @@ -830,7 +830,7 @@ template Matrix3x3 Quaternion::toMatrix() const { /* Algorithm from: https://github.com/mrdoob/three.js/blob/6892dd0aba1411d35c5e2b44dc6ff280b24d6aa2/src/math/Euler.js#L197 */ template Vector3> Quaternion::toEuler() const { - CORRADE_ASSERT(isNormalized(), + CORRADE_DEBUG_ASSERT(isNormalized(), "Math::Quaternion::toEuler():" << *this << "is not normalized", {}); Vector3> euler{Magnum::NoInit}; @@ -864,13 +864,13 @@ template inline Quaternion Quaternion::operator*(const Quaternion } template inline Quaternion Quaternion::invertedNormalized() const { - CORRADE_ASSERT(isNormalized(), + CORRADE_DEBUG_ASSERT(isNormalized(), "Math::Quaternion::invertedNormalized():" << *this << "is not normalized", {}); return conjugated(); } template inline Vector3 Quaternion::transformVectorNormalized(const Vector3& vector) const { - CORRADE_ASSERT(isNormalized(), + CORRADE_DEBUG_ASSERT(isNormalized(), "Math::Quaternion::transformVectorNormalized():" << *this << "is not normalized", {}); const Vector3 t = T(2)*Math::cross(_vector, vector); return vector + _scalar*t + Math::cross(_vector, t); diff --git a/src/Magnum/Math/Test/ComplexTest.cpp b/src/Magnum/Math/Test/ComplexTest.cpp index a41b1ec47..a43385ff4 100644 --- a/src/Magnum/Math/Test/ComplexTest.cpp +++ b/src/Magnum/Math/Test/ComplexTest.cpp @@ -437,7 +437,7 @@ void ComplexTest::invertedNormalized() { } void ComplexTest::invertedNormalizedNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -476,7 +476,7 @@ void ComplexTest::angleNormalizedButOver1() { } void ComplexTest::angleNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -516,7 +516,7 @@ void ComplexTest::matrix() { } void ComplexTest::matrixNotRotation() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -551,7 +551,7 @@ void ComplexTest::lerp() { } void ComplexTest::lerpNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -579,7 +579,7 @@ void ComplexTest::slerp() { } void ComplexTest::slerpNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; diff --git a/src/Magnum/Math/Test/CubicHermiteTest.cpp b/src/Magnum/Math/Test/CubicHermiteTest.cpp index 03684d199..b4bba7787 100644 --- a/src/Magnum/Math/Test/CubicHermiteTest.cpp +++ b/src/Magnum/Math/Test/CubicHermiteTest.cpp @@ -890,7 +890,7 @@ void CubicHermiteTest::lerpComplex() { } void CubicHermiteTest::lerpComplexNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -933,7 +933,7 @@ void CubicHermiteTest::lerpQuaternion() { } void CubicHermiteTest::lerpQuaternionNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -975,7 +975,7 @@ void CubicHermiteTest::lerpQuaternionShortestPath() { } void CubicHermiteTest::lerpQuaternionShortestPathNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -1013,7 +1013,7 @@ void CubicHermiteTest::slerpComplex() { } void CubicHermiteTest::slerpComplexNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -1056,7 +1056,7 @@ void CubicHermiteTest::slerpQuaternion() { } void CubicHermiteTest::slerpQuaternionNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -1099,7 +1099,7 @@ void CubicHermiteTest::slerpQuaternionShortestPath() { } void CubicHermiteTest::slerpQuaternionShortestPathNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -1173,7 +1173,7 @@ void CubicHermiteTest::splerpComplex() { } void CubicHermiteTest::splerpComplexNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -1212,7 +1212,7 @@ void CubicHermiteTest::splerpQuaternion() { } void CubicHermiteTest::splerpQuaternionNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; diff --git a/src/Magnum/Math/Test/DistanceTest.cpp b/src/Magnum/Math/Test/DistanceTest.cpp index e21fea367..402f5d253 100644 --- a/src/Magnum/Math/Test/DistanceTest.cpp +++ b/src/Magnum/Math/Test/DistanceTest.cpp @@ -234,7 +234,7 @@ void DistanceTest::pointPlaneNormalized() { } void DistanceTest::pointPlaneNormalizedNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; diff --git a/src/Magnum/Math/Test/DualComplexTest.cpp b/src/Magnum/Math/Test/DualComplexTest.cpp index 36884ef8b..7649d64d4 100644 --- a/src/Magnum/Math/Test/DualComplexTest.cpp +++ b/src/Magnum/Math/Test/DualComplexTest.cpp @@ -402,7 +402,7 @@ void DualComplexTest::invertedNormalized() { } void DualComplexTest::invertedNormalizedNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -464,7 +464,7 @@ void DualComplexTest::matrix() { } void DualComplexTest::matrixNotOrthogonal() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream o; Error redirectError{&o}; diff --git a/src/Magnum/Math/Test/DualQuaternionTest.cpp b/src/Magnum/Math/Test/DualQuaternionTest.cpp index 381cd8d01..4e63a4a1b 100644 --- a/src/Magnum/Math/Test/DualQuaternionTest.cpp +++ b/src/Magnum/Math/Test/DualQuaternionTest.cpp @@ -439,7 +439,7 @@ void DualQuaternionTest::invertedNormalized() { } void DualQuaternionTest::invertedNormalizedNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -467,7 +467,7 @@ void DualQuaternionTest::rotation() { } void DualQuaternionTest::rotationNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -521,7 +521,7 @@ void DualQuaternionTest::matrix() { } void DualQuaternionTest::matrixNotOrthogonal() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -558,7 +558,7 @@ void DualQuaternionTest::transformVectorNormalized() { } void DualQuaternionTest::transformVectorNormalizedNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -602,7 +602,7 @@ void DualQuaternionTest::transformPointNormalized() { } void DualQuaternionTest::transformPointNormalizedNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; diff --git a/src/Magnum/Math/Test/FrustumTest.cpp b/src/Magnum/Math/Test/FrustumTest.cpp index 334da7eee..b6bf5fb2a 100644 --- a/src/Magnum/Math/Test/FrustumTest.cpp +++ b/src/Magnum/Math/Test/FrustumTest.cpp @@ -354,7 +354,7 @@ void FrustumTest::data() { } void FrustumTest::dataOutOfRange() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); Frustum a; constexpr Frustum ca; diff --git a/src/Magnum/Math/Test/FunctionsTest.cpp b/src/Magnum/Math/Test/FunctionsTest.cpp index e642a0787..3d395da2a 100644 --- a/src/Magnum/Math/Test/FunctionsTest.cpp +++ b/src/Magnum/Math/Test/FunctionsTest.cpp @@ -323,7 +323,7 @@ void FunctionsTest::binomialCoefficient() { } void FunctionsTest::binomialCoefficientInvalidInput() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -332,7 +332,7 @@ void FunctionsTest::binomialCoefficientInvalidInput() { } void FunctionsTest::binomialCoefficientOverflow() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -516,7 +516,7 @@ void FunctionsTest::reflect() { } void FunctionsTest::reflectNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -543,7 +543,7 @@ void FunctionsTest::refract() { } void FunctionsTest::refractNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; diff --git a/src/Magnum/Math/Test/IntersectionTest.cpp b/src/Magnum/Math/Test/IntersectionTest.cpp index a66fbc7f1..81e66edd3 100644 --- a/src/Magnum/Math/Test/IntersectionTest.cpp +++ b/src/Magnum/Math/Test/IntersectionTest.cpp @@ -460,7 +460,7 @@ void IntersectionTest::sphereConeView() { } void IntersectionTest::sphereConeViewNotRigid() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; diff --git a/src/Magnum/Math/Test/Matrix3Test.cpp b/src/Magnum/Math/Test/Matrix3Test.cpp index 1ab0edc1e..de028f91e 100644 --- a/src/Magnum/Math/Test/Matrix3Test.cpp +++ b/src/Magnum/Math/Test/Matrix3Test.cpp @@ -377,7 +377,7 @@ void Matrix3Test::reflection() { } void Matrix3Test::reflectionNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -505,7 +505,7 @@ void Matrix3Test::rotationPart() { } void Matrix3Test::rotationPartNotOrthogonal() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -557,7 +557,7 @@ void Matrix3Test::rotationNormalizedPart() { } void Matrix3Test::rotationNormalizedPartNotOrthogonal() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -619,7 +619,7 @@ void Matrix3Test::uniformScalingPart() { } void Matrix3Test::uniformScalingPartNotUniform() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -665,7 +665,7 @@ void Matrix3Test::invertedRigid() { } void Matrix3Test::invertedRigidNotRigid() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; diff --git a/src/Magnum/Math/Test/Matrix4Test.cpp b/src/Magnum/Math/Test/Matrix4Test.cpp index e1b00d435..c8f77a571 100644 --- a/src/Magnum/Math/Test/Matrix4Test.cpp +++ b/src/Magnum/Math/Test/Matrix4Test.cpp @@ -426,7 +426,7 @@ void Matrix4Test::rotation() { } void Matrix4Test::rotationNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -476,7 +476,7 @@ void Matrix4Test::reflection() { } void Matrix4Test::reflectionNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -738,7 +738,7 @@ void Matrix4Test::rotationPart() { } void Matrix4Test::rotationPartNotOrthogonal() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -798,7 +798,7 @@ void Matrix4Test::rotationNormalizedPart() { } void Matrix4Test::rotationNormalizedPartNotOrthogonal() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -861,7 +861,7 @@ void Matrix4Test::uniformScalingPart() { } void Matrix4Test::uniformScalingPartNotUniform() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; Matrix4::scaling(Vector3::yScale(3.0f)).uniformScaling(); @@ -1032,7 +1032,7 @@ void Matrix4Test::invertedRigid() { } void Matrix4Test::invertedRigidNotRigid() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; diff --git a/src/Magnum/Math/Test/MatrixTest.cpp b/src/Magnum/Math/Test/MatrixTest.cpp index 33592e71d..80d0085bb 100644 --- a/src/Magnum/Math/Test/MatrixTest.cpp +++ b/src/Magnum/Math/Test/MatrixTest.cpp @@ -412,7 +412,7 @@ void MatrixTest::invertedOrthogonal() { } void MatrixTest::invertedOrthogonalNotOrthogonal() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream o; Error redirectError{&o}; diff --git a/src/Magnum/Math/Test/QuaternionTest.cpp b/src/Magnum/Math/Test/QuaternionTest.cpp index 0b931645b..3116a4455 100644 --- a/src/Magnum/Math/Test/QuaternionTest.cpp +++ b/src/Magnum/Math/Test/QuaternionTest.cpp @@ -375,7 +375,7 @@ void QuaternionTest::axisAngle() { } void QuaternionTest::axisAngleNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -478,7 +478,7 @@ void QuaternionTest::invertedNormalized() { } void QuaternionTest::invertedNormalizedNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -508,7 +508,7 @@ void QuaternionTest::rotation() { } void QuaternionTest::rotationNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -550,7 +550,7 @@ void QuaternionTest::angleNormalizedButOver1() { } void QuaternionTest::angleNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -613,7 +613,7 @@ void QuaternionTest::matrix() { } void QuaternionTest::matrixNotRotation() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -657,7 +657,7 @@ void QuaternionTest::euler() { } void QuaternionTest::eulerNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -694,7 +694,7 @@ void QuaternionTest::lerp2D() { } void QuaternionTest::lerpNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -726,7 +726,7 @@ void QuaternionTest::lerpShortestPath() { } void QuaternionTest::lerpShortestPathNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -811,7 +811,7 @@ void QuaternionTest::slerpNormalizedButOver1() { } void QuaternionTest::slerpNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -872,7 +872,7 @@ template void QuaternionTest::slerpShortestPathLinearFallbackIsNormaliz } void QuaternionTest::slerpShortestPathNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; @@ -906,7 +906,7 @@ void QuaternionTest::transformVectorNormalized() { } void QuaternionTest::transformVectorNormalizedNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; diff --git a/src/Magnum/Math/Test/VectorTest.cpp b/src/Magnum/Math/Test/VectorTest.cpp index 34411ac9e..a389ead7a 100644 --- a/src/Magnum/Math/Test/VectorTest.cpp +++ b/src/Magnum/Math/Test/VectorTest.cpp @@ -578,7 +578,7 @@ void VectorTest::projectedOntoNormalized() { } void VectorTest::projectedOntoNormalizedNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); Vector3 vector(1.0f, 2.0f, 3.0f); Vector3 line(1.0f, -1.0f, 0.5f); @@ -623,7 +623,7 @@ void VectorTest::angleNormalizedButOver1() { } void VectorTest::angleNotNormalized() { - CORRADE_SKIP_IF_NO_ASSERT(); + CORRADE_SKIP_IF_NO_DEBUG_ASSERT(); std::ostringstream out; Error redirectError{&out}; diff --git a/src/Magnum/Math/Vector.h b/src/Magnum/Math/Vector.h index f6752ad51..cd39d3271 100644 --- a/src/Magnum/Math/Vector.h +++ b/src/Magnum/Math/Vector.h @@ -30,10 +30,10 @@ */ #include -#include #ifndef CORRADE_NO_DEBUG #include #endif +#include #include #include "Magnum/visibility.h" @@ -130,7 +130,7 @@ Rad typename std::enable_if::value, Rad>::type #endif angle(const Vector& normalizedA, const Vector& normalizedB) { - CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), + CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), "Math::angle(): vectors" << normalizedA << "and" << normalizedB << "are not normalized", {}); return Rad(std::acos(clamp(dot(normalizedA, normalizedB), FloatingPoint(-1), FloatingPoint(1)))); } @@ -1510,7 +1510,7 @@ inline Vector template inline typename std::enable_if::value, Vector>::type #endif Vector::projectedOntoNormalized(const Vector& line) const { - CORRADE_ASSERT(line.isNormalized(), + CORRADE_DEBUG_ASSERT(line.isNormalized(), "Math::Vector::projectedOntoNormalized(): line" << line << "is not normalized", {}); return line*Math::dot(*this, line); } diff --git a/src/Magnum/Shaders/Implementation/lineMiterLimit.h b/src/Magnum/Shaders/Implementation/lineMiterLimit.h index 87ee4dfb0..67b8d82e8 100644 --- a/src/Magnum/Shaders/Implementation/lineMiterLimit.h +++ b/src/Magnum/Shaders/Implementation/lineMiterLimit.h @@ -25,6 +25,8 @@ DEALINGS IN THE SOFTWARE. */ +#include + #include "Magnum/Math/Functions.h" namespace Magnum { namespace Shaders { namespace Implementation { diff --git a/src/Magnum/Trade/LightData.cpp b/src/Magnum/Trade/LightData.cpp index 724256453..bb7e1de3f 100644 --- a/src/Magnum/Trade/LightData.cpp +++ b/src/Magnum/Trade/LightData.cpp @@ -25,6 +25,8 @@ #include "LightData.h" +#include + namespace Magnum { namespace Trade { using namespace Math::Literals; diff --git a/src/Magnum/Trade/ObjectData2D.cpp b/src/Magnum/Trade/ObjectData2D.cpp index 1099ff1c7..83c207a40 100644 --- a/src/Magnum/Trade/ObjectData2D.cpp +++ b/src/Magnum/Trade/ObjectData2D.cpp @@ -28,6 +28,7 @@ #include "ObjectData2D.h" #include +#include namespace Magnum { namespace Trade { diff --git a/src/Magnum/Trade/ObjectData3D.cpp b/src/Magnum/Trade/ObjectData3D.cpp index f8e20cca6..a3408d169 100644 --- a/src/Magnum/Trade/ObjectData3D.cpp +++ b/src/Magnum/Trade/ObjectData3D.cpp @@ -28,6 +28,7 @@ #include "ObjectData3D.h" #include +#include namespace Magnum { namespace Trade {