From 8db8533300cf837e75e7969e44a8dd0a9ac3bc2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 19 Aug 2021 20:27:20 +0200 Subject: [PATCH] Fixes a lot of warnings and move math enums to enum classes --- examples/GraphicsTest/main.cpp | 6 +- include/Nazara/Graphics/CullingList.inl | 18 +- include/Nazara/Graphics/MaterialPipeline.inl | 2 + include/Nazara/Math/BoundingVolume.inl | 88 ++++----- include/Nazara/Math/Box.inl | 24 +-- include/Nazara/Math/Enums.hpp | 78 ++++---- include/Nazara/Math/Frustum.hpp | 6 +- include/Nazara/Math/Frustum.inl | 178 +++++++++---------- include/Nazara/Math/OrientedBox.hpp | 2 +- include/Nazara/Math/OrientedBox.inl | 42 ++--- include/Nazara/Math/Ray.inl | 22 +-- include/Nazara/Math/Rect.inl | 16 +- include/Nazara/Utility/Algorithm.hpp | 24 +-- src/Nazara/Shader/GlslWriter.cpp | 4 +- src/Nazara/Shader/LangWriter.cpp | 2 +- src/Nazara/Utility/AlgorithmUtility.cpp | 38 ++-- src/Nazara/Utility/Mesh.cpp | 24 +-- src/Nazara/Utility/RichTextDrawer.cpp | 8 +- src/Nazara/Utility/SimpleTextDrawer.cpp | 8 +- src/Nazara/Utility/StaticMesh.cpp | 4 +- tests/Engine/Core/SerializationTest.cpp | 4 +- tests/Engine/Math/BoundingVolumeTest.cpp | 4 +- tests/Engine/Math/BoxTest.cpp | 2 +- tests/Engine/Math/FrustumTest.cpp | 26 +-- tests/Engine/Math/OrientedBoxTest.cpp | 2 +- tests/Engine/Math/RayTest.cpp | 4 +- tests/Engine/Math/RectTest.cpp | 2 +- 27 files changed, 323 insertions(+), 315 deletions(-) diff --git a/examples/GraphicsTest/main.cpp b/examples/GraphicsTest/main.cpp index 92aafb1f2..0abb250b4 100644 --- a/examples/GraphicsTest/main.cpp +++ b/examples/GraphicsTest/main.cpp @@ -148,9 +148,9 @@ int main() case Nz::WindowEventType::Resized: { - Nz::Vector2ui windowSize = window.GetSize(); - viewerInstance.UpdateProjectionMatrix(Nz::Matrix4f::Perspective(Nz::DegreeAnglef(70.f), float(windowSize.x) / windowSize.y, 0.1f, 1000.f)); - viewerInstance.UpdateTargetSize(Nz::Vector2f(windowSize)); + Nz::Vector2ui newWindowSize = window.GetSize(); + viewerInstance.UpdateProjectionMatrix(Nz::Matrix4f::Perspective(Nz::DegreeAnglef(70.f), float(newWindowSize.x) / newWindowSize.y, 0.1f, 1000.f)); + viewerInstance.UpdateTargetSize(Nz::Vector2f(newWindowSize)); break; } diff --git a/include/Nazara/Graphics/CullingList.inl b/include/Nazara/Graphics/CullingList.inl index aa94bc995..8088ff0c8 100644 --- a/include/Nazara/Graphics/CullingList.inl +++ b/include/Nazara/Graphics/CullingList.inl @@ -33,7 +33,7 @@ namespace Nz { switch (frustum.Intersect(entry.box)) { - case IntersectionSide_Inside: + case IntersectionSide::Inside: m_fullyVisibleResults.push_back(entry.renderable); fullyVisibleHash = CombineHash(fullyVisibleHash, std::hash()(entry.renderable)); @@ -41,7 +41,7 @@ namespace Nz entry.forceInvalidation = false; break; - case IntersectionSide_Intersecting: + case IntersectionSide::Intersecting: m_partiallyVisibleResults.push_back(entry.renderable); partiallyVisibleHash = CombineHash(partiallyVisibleHash, std::hash()(entry.renderable)); @@ -49,7 +49,7 @@ namespace Nz entry.forceInvalidation = false; break; - case IntersectionSide_Outside: + case IntersectionSide::Outside: break; } } @@ -70,7 +70,7 @@ namespace Nz { switch (frustum.Intersect(entry.sphere)) { - case IntersectionSide_Inside: + case IntersectionSide::Inside: m_fullyVisibleResults.push_back(entry.renderable); fullyVisibleHash = CombineHash(fullyVisibleHash, std::hash()(entry.renderable)); @@ -78,7 +78,7 @@ namespace Nz entry.forceInvalidation = false; break; - case IntersectionSide_Intersecting: + case IntersectionSide::Intersecting: m_partiallyVisibleResults.push_back(entry.renderable); partiallyVisibleHash = CombineHash(partiallyVisibleHash, std::hash()(entry.renderable)); @@ -86,7 +86,7 @@ namespace Nz entry.forceInvalidation = false; break; - case IntersectionSide_Outside: + case IntersectionSide::Outside: break; } } @@ -95,7 +95,7 @@ namespace Nz { switch (frustum.Intersect(entry.volume)) { - case IntersectionSide_Inside: + case IntersectionSide::Inside: m_fullyVisibleResults.push_back(entry.renderable); fullyVisibleHash = CombineHash(fullyVisibleHash, std::hash()(entry.renderable)); @@ -103,7 +103,7 @@ namespace Nz entry.forceInvalidation = false; break; - case IntersectionSide_Intersecting: + case IntersectionSide::Intersecting: m_partiallyVisibleResults.push_back(entry.renderable); partiallyVisibleHash = CombineHash(partiallyVisibleHash, std::hash()(entry.renderable)); @@ -111,7 +111,7 @@ namespace Nz entry.forceInvalidation = false; break; - case IntersectionSide_Outside: + case IntersectionSide::Outside: break; } } diff --git a/include/Nazara/Graphics/MaterialPipeline.inl b/include/Nazara/Graphics/MaterialPipeline.inl index 928230f9c..b4ef58c6a 100644 --- a/include/Nazara/Graphics/MaterialPipeline.inl +++ b/include/Nazara/Graphics/MaterialPipeline.inl @@ -77,6 +77,8 @@ namespace std Nz::HashCombine(seed, shader.uberShader.get()); } + NazaraUnused(parameterIndex); + #undef NazaraPipelineMember #undef NazaraPipelineBoolMember diff --git a/include/Nazara/Math/BoundingVolume.inl b/include/Nazara/Math/BoundingVolume.inl index 2600897e2..f6074fb6e 100644 --- a/include/Nazara/Math/BoundingVolume.inl +++ b/include/Nazara/Math/BoundingVolume.inl @@ -24,12 +24,12 @@ namespace Nz /*! * \brief Constructs a BoundingVolume object by default * - * \remark extend is set to Extend_Null, aabb and obb are uninitialized + * \remark extend is set to Extend::Null, aabb and obb are uninitialized */ template BoundingVolume::BoundingVolume() : - extend(Extend_Null) + extend(Extend::Null) { } @@ -136,31 +136,31 @@ namespace Nz { switch (extend) { - case Extend_Finite: + case Extend::Finite: { switch (volume.extend) { - case Extend_Finite: + case Extend::Finite: { // Extend the OBB local box obb.localBox.ExtendTo(volume.obb.localBox); break; } - case Extend_Infinite: + case Extend::Infinite: MakeInfinite(); break; - case Extend_Null: + case Extend::Null: break; } break; } - case Extend_Infinite: + case Extend::Infinite: break; //< We already contain the bounding volume - case Extend_Null: + case Extend::Null: Set(volume); break; } @@ -170,40 +170,40 @@ namespace Nz /*! * \brief Checks whether the volume is finite - * \return true if extend is Extend_Finite + * \return true if extend is Extend::Finite */ template bool BoundingVolume::IsFinite() const { - return extend == Extend_Finite; + return extend == Extend::Finite; } /*! * \brief Checks whether the volume is infinite - * \return true if extend is Extend_Infinite + * \return true if extend is Extend::Infinite */ template bool BoundingVolume::IsInfinite() const { - return extend == Extend_Infinite; + return extend == Extend::Infinite; } /*! * \brief Checks whether the volume is null - * \return true if extend is Extend_Null + * \return true if extend is Extend::Null */ template bool BoundingVolume::IsNull() const { - return extend == Extend_Null; + return extend == Extend::Null; } /*! * \brief Makes the bounding volume infinite - * \return A reference to this bounding volume with Extend_Infinite for extend + * \return A reference to this bounding volume with Extend::Infinite for extend * * \see Infinite */ @@ -211,14 +211,14 @@ namespace Nz template BoundingVolume& BoundingVolume::MakeInfinite() { - extend = Extend_Infinite; + extend = Extend::Infinite; return *this; } /*! * \brief Makes the bounding volume null - * \return A reference to this bounding volume with Extend_Null for extend + * \return A reference to this bounding volume with Extend::Null for extend * * \see Null */ @@ -226,7 +226,7 @@ namespace Nz template BoundingVolume& BoundingVolume::MakeNull() { - extend = Extend_Null; + extend = Extend::Null; return *this; } @@ -237,7 +237,7 @@ namespace Nz * * \param Extend New extend * - * \remark This method is meant to be called with Extend_Infinite or Extend_Null + * \remark This method is meant to be called with Extend::Infinite or Extend::Null */ template @@ -264,7 +264,7 @@ namespace Nz BoundingVolume& BoundingVolume::Set(T X, T Y, T Z, T Width, T Height, T Depth) { obb.Set(X, Y, Z, Width, Height, Depth); - extend = Extend_Finite; + extend = Extend::Finite; return *this; } @@ -296,7 +296,7 @@ namespace Nz BoundingVolume& BoundingVolume::Set(const Box& box) { obb.Set(box); - extend = Extend_Finite; + extend = Extend::Finite; return *this; } @@ -312,7 +312,7 @@ namespace Nz BoundingVolume& BoundingVolume::Set(const OrientedBox& orientedBox) { obb.Set(orientedBox); - extend = Extend_Finite; + extend = Extend::Finite; return *this; } @@ -329,7 +329,7 @@ namespace Nz BoundingVolume& BoundingVolume::Set(const Vector3& vec1, const Vector3& vec2) { obb.Set(vec1, vec2); - extend = Extend_Finite; + extend = Extend::Finite; return *this; } @@ -441,7 +441,7 @@ namespace Nz bool BoundingVolume::operator==(const BoundingVolume& volume) const { if (extend == volume.extend) - if (extend == Extend_Finite) + if (extend == Extend::Finite) return obb == volume.obb; else return true; @@ -463,8 +463,8 @@ namespace Nz } /*! - * \brief Shorthand for the bounding volume (Extend_Infinite) - * \return A bounding volume with Extend_Infinite + * \brief Shorthand for the bounding volume (Extend::Infinite) + * \return A bounding volume with Extend::Infinite * * \see MakeInfinite */ @@ -512,11 +512,11 @@ namespace Nz switch (to.extend) { - case Extend_Finite: + case Extend::Finite: { switch (from.extend) { - case Extend_Finite: + case Extend::Finite: { BoundingVolume volume; volume.Set(OrientedBox::Lerp(from.obb, to.obb, interpolation)); @@ -524,49 +524,49 @@ namespace Nz return volume; } - case Extend_Infinite: + case Extend::Infinite: return Infinite(); - case Extend_Null: + case Extend::Null: return to.obb * interpolation; } // If we arrive here, the extend is invalid - NazaraError("Invalid extend type (From) (0x" + NumberToString(from.extend, 16) + ')'); + NazaraError("Invalid extend type (From) (0x" + NumberToString(UnderlyingCast(from.extend), 16) + ')'); return Null(); } - case Extend_Infinite: + case Extend::Infinite: return Infinite(); // A little bit of infinity is already too much ;) - case Extend_Null: + case Extend::Null: { switch (from.extend) { - case Extend_Finite: + case Extend::Finite: return from.obb * (T(1.0) - interpolation); - case Extend_Infinite: + case Extend::Infinite: return Infinite(); - case Extend_Null: + case Extend::Null: return Null(); } // If we arrive here, the extend is invalid - NazaraError("Invalid extend type (From) (0x" + NumberToString(from.extend, 16) + ')'); + NazaraError("Invalid extend type (From) (0x" + NumberToString(UnderlyingCast(from.extend), 16) + ')'); return Null(); } } // If we arrive here, the extend is invalid - NazaraError("Invalid extend type (To) (0x" + NumberToString(to.extend, 16) + ')'); + NazaraError("Invalid extend type (To) (0x" + NumberToString(UnderlyingCast(to.extend), 16) + ')'); return Null(); } /*! - * \brief Shorthand for the bounding volume (Extend_Null) - * \return A bounding volume with Extend_Null + * \brief Shorthand for the bounding volume (Extend::Null) + * \return A bounding volume with Extend::Null * * \see MakeNull */ @@ -620,7 +620,7 @@ namespace Nz if (!Unserialize(context, &extend)) return false; - if (extend > Extend_Max) + if (extend > UnderlyingCast(Extend::Max)) return false; boundingVolume->extend = static_cast(extend); @@ -648,15 +648,15 @@ std::ostream& operator<<(std::ostream& out, const Nz::BoundingVolume& volume) { switch (volume.extend) { - case Nz::Extend_Finite: + case Nz::Extend::Finite: out << "BoundingVolume(localBox=" << volume.obb.localBox << ')'; break; - case Nz::Extend_Infinite: + case Nz::Extend::Infinite: out << "BoundingVolume(Infinite)"; break; - case Nz::Extend_Null: + case Nz::Extend::Null: out << "BoundingVolume(Null)"; break; } diff --git a/include/Nazara/Math/Box.inl b/include/Nazara/Math/Box.inl index 9fedec598..fbeea4501 100644 --- a/include/Nazara/Math/Box.inl +++ b/include/Nazara/Math/Box.inl @@ -276,32 +276,32 @@ namespace Nz { switch (corner) { - case BoxCorner_FarLeftBottom: + case BoxCorner::FarLeftBottom: return Vector3(x, y, z); - case BoxCorner_FarLeftTop: + case BoxCorner::FarLeftTop: return Vector3(x, y + height, z); - case BoxCorner_FarRightBottom: + case BoxCorner::FarRightBottom: return Vector3(x + width, y, z); - case BoxCorner_FarRightTop: + case BoxCorner::FarRightTop: return Vector3(x + width, y + height, z); - case BoxCorner_NearLeftBottom: + case BoxCorner::NearLeftBottom: return Vector3(x, y, z + depth); - case BoxCorner_NearLeftTop: + case BoxCorner::NearLeftTop: return Vector3(x, y + height, z + depth); - case BoxCorner_NearRightBottom: + case BoxCorner::NearRightBottom: return Vector3(x + width, y, z + depth); - case BoxCorner_NearRightTop: + case BoxCorner::NearRightTop: return Vector3(x + width, y + height, z + depth); } - NazaraError("Corner not handled (0x" + NumberToString(corner, 16) + ')'); + NazaraError("Corner not handled (0x" + NumberToString(UnderlyingCast(corner), 16) + ')'); return Vector3(); } @@ -318,7 +318,7 @@ namespace Nz /*! * \brief Gets a Vector3 for the maximum point - * \return The BoxCorner_NearRightTop of the box + * \return The BoxCorner::NearRightTop of the box * * \see GetCorner */ @@ -331,7 +331,7 @@ namespace Nz /*! * \brief Gets a Vector3 for the minimum point - * \return The BoxCorner_FarLeftBottom of the box + * \return The BoxCorner::FarLeftBottom of the box * * \see GetCorner, GetPosition */ @@ -370,7 +370,7 @@ namespace Nz /*! * \brief Gets a Vector3 for the position - * \return The BoxCorner_FarLeftBottom of the box + * \return The BoxCorner::FarLeftBottom of the box * * \see GetCorner, GetMinimum */ diff --git a/include/Nazara/Math/Enums.hpp b/include/Nazara/Math/Enums.hpp index 2c51092b3..5ed60a81c 100644 --- a/include/Nazara/Math/Enums.hpp +++ b/include/Nazara/Math/Enums.hpp @@ -7,6 +7,8 @@ #ifndef NAZARA_ENUMS_MATH_HPP #define NAZARA_ENUMS_MATH_HPP +#include + namespace Nz { enum class AngleUnit @@ -15,58 +17,62 @@ namespace Nz Radian }; - enum BoxCorner + enum class BoxCorner { - BoxCorner_FarLeftBottom, - BoxCorner_FarLeftTop, - BoxCorner_FarRightBottom, - BoxCorner_FarRightTop, - BoxCorner_NearLeftBottom, - BoxCorner_NearLeftTop, - BoxCorner_NearRightBottom, - BoxCorner_NearRightTop, + FarLeftBottom, + FarLeftTop, + FarRightBottom, + FarRightTop, + NearLeftBottom, + NearLeftTop, + NearRightBottom, + NearRightTop, - BoxCorner_Max = BoxCorner_NearRightTop + Max = NearRightTop }; - enum Extend - { - Extend_Finite, - Extend_Infinite, - Extend_Null, + constexpr std::size_t BoxCornerCount = UnderlyingCast(BoxCorner::Max) + 1; - Extend_Max = Extend_Null + enum class Extend + { + Finite, + Infinite, + Null, + + Max = Null }; - enum FrustumPlane + enum class FrustumPlane { - FrustumPlane_Bottom, - FrustumPlane_Far, - FrustumPlane_Left, - FrustumPlane_Near, - FrustumPlane_Right, - FrustumPlane_Top, + Bottom, + Far, + Left, + Near, + Right, + Top, - FrustumPlane_Max = FrustumPlane_Top + Max = Top }; - enum IntersectionSide - { - IntersectionSide_Inside, - IntersectionSide_Intersecting, - IntersectionSide_Outside, + constexpr std::size_t FrustumPlaneCount = UnderlyingCast(FrustumPlane::Max) + 1; - IntersectionSide_Max = IntersectionSide_Outside + enum class IntersectionSide + { + Inside, + Intersecting, + Outside, + + Max = Outside }; - enum RectCorner + enum class RectCorner { - RectCorner_LeftBottom, - RectCorner_LeftTop, - RectCorner_RightBottom, - RectCorner_RightTop, + LeftBottom, + LeftTop, + RightBottom, + RightTop, - RectCorner_Max = RectCorner_RightTop + Max = RightTop }; } diff --git a/include/Nazara/Math/Frustum.hpp b/include/Nazara/Math/Frustum.hpp index f676603c7..eb72a0efe 100644 --- a/include/Nazara/Math/Frustum.hpp +++ b/include/Nazara/Math/Frustum.hpp @@ -49,7 +49,7 @@ namespace Nz IntersectionSide Intersect(const Box& box) const; IntersectionSide Intersect(const OrientedBox& orientedBox) const; IntersectionSide Intersect(const Sphere& sphere) const; - IntersectionSide Intersect(const Vector3* points, unsigned int pointCount) const; + IntersectionSide Intersect(const Vector3* points, std::size_t pointCount) const; Frustum& operator=(const Frustum& other) = default; @@ -64,8 +64,8 @@ namespace Nz friend bool Unserialize(SerializationContext& context, Frustum* frustum, TypeTag>); private: - Vector3 m_corners[BoxCorner_Max+1]; - Plane m_planes[FrustumPlane_Max+1]; + Vector3 m_corners[BoxCornerCount]; + Plane m_planes[FrustumPlaneCount]; }; using Frustumd = Frustum; diff --git a/include/Nazara/Math/Frustum.inl b/include/Nazara/Math/Frustum.inl index 80472e3db..ee060277e 100644 --- a/include/Nazara/Math/Frustum.inl +++ b/include/Nazara/Math/Frustum.inl @@ -16,7 +16,7 @@ namespace Nz { /*! - * \ingroup math + * \ingroup math * \class Nz::Frustum * \brief Math class that represents a frustum in the three dimensional vector space * @@ -69,23 +69,23 @@ namespace Nz Vector3 fc = eye + f * zFar; // Computing the frustum - m_corners[BoxCorner_FarLeftBottom] = fc - u * farH - s * farW; - m_corners[BoxCorner_FarLeftTop] = fc + u * farH - s * farW; - m_corners[BoxCorner_FarRightTop] = fc + u * farH + s * farW; - m_corners[BoxCorner_FarRightBottom] = fc - u * farH + s * farW; + m_corners[UnderlyingCast(BoxCorner::FarLeftBottom)] = fc - u * farH - s * farW; + m_corners[UnderlyingCast(BoxCorner::FarLeftTop)] = fc + u * farH - s * farW; + m_corners[UnderlyingCast(BoxCorner::FarRightTop)] = fc + u * farH + s * farW; + m_corners[UnderlyingCast(BoxCorner::FarRightBottom)] = fc - u * farH + s * farW; - m_corners[BoxCorner_NearLeftBottom] = nc - u * nearH - s * nearW; - m_corners[BoxCorner_NearLeftTop] = nc + u * nearH - s * nearW; - m_corners[BoxCorner_NearRightTop] = nc + u * nearH + s * nearW; - m_corners[BoxCorner_NearRightBottom] = nc - u * nearH + s * nearW; + m_corners[UnderlyingCast(BoxCorner::NearLeftBottom)] = nc - u * nearH - s * nearW; + m_corners[UnderlyingCast(BoxCorner::NearLeftTop)] = nc + u * nearH - s * nearW; + m_corners[UnderlyingCast(BoxCorner::NearRightTop)] = nc + u * nearH + s * nearW; + m_corners[UnderlyingCast(BoxCorner::NearRightBottom)] = nc - u * nearH + s * nearW; // Construction of frustum's planes - m_planes[FrustumPlane_Bottom].Set(m_corners[BoxCorner_NearLeftBottom], m_corners[BoxCorner_NearRightBottom], m_corners[BoxCorner_FarRightBottom]); - m_planes[FrustumPlane_Far].Set(m_corners[BoxCorner_FarRightTop], m_corners[BoxCorner_FarLeftTop], m_corners[BoxCorner_FarLeftBottom]); - m_planes[FrustumPlane_Left].Set(m_corners[BoxCorner_NearLeftTop], m_corners[BoxCorner_NearLeftBottom], m_corners[BoxCorner_FarLeftBottom]); - m_planes[FrustumPlane_Near].Set(m_corners[BoxCorner_NearLeftTop], m_corners[BoxCorner_NearRightTop], m_corners[BoxCorner_NearRightBottom]); - m_planes[FrustumPlane_Right].Set(m_corners[BoxCorner_NearRightBottom], m_corners[BoxCorner_NearRightTop], m_corners[BoxCorner_FarRightBottom]); - m_planes[FrustumPlane_Top].Set(m_corners[BoxCorner_NearRightTop], m_corners[BoxCorner_NearLeftTop], m_corners[BoxCorner_FarLeftTop]); + m_planes[UnderlyingCast(FrustumPlane::Bottom)].Set(m_corners[UnderlyingCast(BoxCorner::NearLeftBottom)], m_corners[UnderlyingCast(BoxCorner::NearRightBottom)], m_corners[UnderlyingCast(BoxCorner::FarRightBottom)]); + m_planes[UnderlyingCast(FrustumPlane::Far)].Set(m_corners[UnderlyingCast(BoxCorner::FarRightTop)], m_corners[UnderlyingCast(BoxCorner::FarLeftTop)], m_corners[UnderlyingCast(BoxCorner::FarLeftBottom)]); + m_planes[UnderlyingCast(FrustumPlane::Left)].Set(m_corners[UnderlyingCast(BoxCorner::NearLeftTop)], m_corners[UnderlyingCast(BoxCorner::NearLeftBottom)], m_corners[UnderlyingCast(BoxCorner::FarLeftBottom)]); + m_planes[UnderlyingCast(FrustumPlane::Near)].Set(m_corners[UnderlyingCast(BoxCorner::NearLeftTop)], m_corners[UnderlyingCast(BoxCorner::NearRightTop)], m_corners[UnderlyingCast(BoxCorner::NearRightBottom)]); + m_planes[UnderlyingCast(FrustumPlane::Right)].Set(m_corners[UnderlyingCast(BoxCorner::NearRightBottom)], m_corners[UnderlyingCast(BoxCorner::NearRightTop)], m_corners[UnderlyingCast(BoxCorner::FarRightBottom)]); + m_planes[UnderlyingCast(FrustumPlane::Top)].Set(m_corners[UnderlyingCast(BoxCorner::NearRightTop)], m_corners[UnderlyingCast(BoxCorner::NearLeftTop)], m_corners[UnderlyingCast(BoxCorner::FarLeftTop)]); return *this; } @@ -107,33 +107,33 @@ namespace Nz { switch (volume.extend) { - case Extend_Finite: + case Extend::Finite: { IntersectionSide side = Intersect(volume.aabb); switch (side) { - case IntersectionSide_Inside: + case IntersectionSide::Inside: return true; - case IntersectionSide_Intersecting: + case IntersectionSide::Intersecting: return Contains(volume.obb); - case IntersectionSide_Outside: + case IntersectionSide::Outside: return false; } - NazaraError("Invalid intersection side (0x" + NumberToString(side, 16) + ')'); + NazaraError("Invalid intersection side (0x" + NumberToString(UnderlyingCast(side), 16) + ')'); return false; } - case Extend_Infinite: + case Extend::Infinite: return true; - case Extend_Null: + case Extend::Null: return false; } - NazaraError("Invalid extend type (0x" + NumberToString(volume.extend, 16) + ')'); + NazaraError("Invalid extend type (0x" + NumberToString(UnderlyingCast(volume.extend), 16) + ')'); return false; } @@ -148,7 +148,7 @@ namespace Nz bool Frustum::Contains(const Box& box) const { // http://www.lighthouse3d.com/tutorials/view-frustum-culling/geometric-approach-testing-boxes-ii/ - for (unsigned int i = 0; i <= FrustumPlane_Max; i++) + for (unsigned int i = 0; i < FrustumPlaneCount; i++) { if (m_planes[i].Distance(box.GetPositiveVertex(m_planes[i].normal)) < T(0.0)) return false; @@ -180,7 +180,7 @@ namespace Nz template bool Frustum::Contains(const Sphere& sphere) const { - for (unsigned int i = 0; i <= FrustumPlane_Max; i++) + for (unsigned int i = 0; i < FrustumPlaneCount; i++) { if (m_planes[i].Distance(sphere.GetPosition()) < -sphere.radius) return false; @@ -199,7 +199,7 @@ namespace Nz template bool Frustum::Contains(const Vector3& point) const { - for (unsigned int i = 0; i <= FrustumPlane_Max; ++i) + for (unsigned int i = 0; i < FrustumPlaneCount; ++i) { if (m_planes[i].Distance(point) < T(0.0)) return false; @@ -219,7 +219,7 @@ namespace Nz template bool Frustum::Contains(const Vector3* points, unsigned int pointCount) const { - for (unsigned int i = 0; i <= FrustumPlane_Max; ++i) + for (unsigned int i = 0; i < FrustumPlaneCount; ++i) { unsigned int j; for (j = 0; j < pointCount; j++ ) @@ -264,7 +264,7 @@ namespace Nz plane[2] *= invLength; plane[3] *= -invLength; - m_planes[FrustumPlane_Right].Set(plane); + m_planes[FrustumPlane::Right].Set(plane); // Extract the numbers for the LEFT plane plane[0] = clipMatrix[ 3] + clipMatrix[ 0]; @@ -279,7 +279,7 @@ namespace Nz plane[2] *= invLength; plane[3] *= -invLength; - m_planes[FrustumPlane_Left].Set(plane); + m_planes[FrustumPlane::Left].Set(plane); // Extract the BOTTOM plane plane[0] = clipMatrix[ 3] + clipMatrix[ 1]; @@ -294,7 +294,7 @@ namespace Nz plane[2] *= invLength; plane[3] *= -invLength; - m_planes[FrustumPlane_Bottom].Set(plane); + m_planes[FrustumPlane::Bottom].Set(plane); // Extract the TOP plane plane[0] = clipMatrix[ 3] - clipMatrix[ 1]; @@ -309,7 +309,7 @@ namespace Nz plane[2] *= invLength; plane[3] *= -invLength; - m_planes[FrustumPlane_Top].Set(plane); + m_planes[FrustumPlane::Top].Set(plane); // Extract the FAR plane plane[0] = clipMatrix[ 3] - clipMatrix[ 2]; @@ -324,7 +324,7 @@ namespace Nz plane[2] *= invLength; plane[3] *= -invLength; - m_planes[FrustumPlane_Far].Set(plane); + m_planes[FrustumPlane::Far].Set(plane); // Extract the NEAR plane plane[0] = clipMatrix[ 3] + clipMatrix[ 2]; @@ -339,7 +339,7 @@ namespace Nz plane[2] *= invLength; plane[3] *= -invLength; - m_planes[FrustumPlane_Near].Set(plane); + m_planes[FrustumPlane::Near].Set(plane); // Once planes have been extracted, we must extract points of the frustum // Based on: http://www.gamedev.net/topic/393309-calculating-the-view-frustums-vertices/ @@ -354,56 +354,56 @@ namespace Nz corner = invClipMatrix.Transform(corner); corner.Normalize(); - m_corners[BoxCorner_FarLeftBottom] = Vector3(corner.x, corner.y, corner.z); + m_corners[BoxCorner::FarLeftBottom] = Vector3(corner.x, corner.y, corner.z); // FarLeftTop corner.Set(T(-1.0), T(1.0), T(1.0)); corner = invClipMatrix.Transform(corner); corner.Normalize(); - m_corners[BoxCorner_FarLeftTop] = Vector3(corner.x, corner.y, corner.z); + m_corners[BoxCorner::FarLeftTop] = Vector3(corner.x, corner.y, corner.z); // FarRightBottom corner.Set(T(1.0), T(-1.0), T(1.0)); corner = invClipMatrix.Transform(corner); corner.Normalize(); - m_corners[BoxCorner_FarRightBottom] = Vector3(corner.x, corner.y, corner.z); + m_corners[BoxCorner::FarRightBottom] = Vector3(corner.x, corner.y, corner.z); // FarRightTop corner.Set(T(1.0), T(1.0), T(1.0)); corner = invClipMatrix.Transform(corner); corner.Normalize(); - m_corners[BoxCorner_FarRightTop] = Vector3(corner.x, corner.y, corner.z); + m_corners[BoxCorner::FarRightTop] = Vector3(corner.x, corner.y, corner.z); // NearLeftBottom corner.Set(T(-1.0), T(-1.0), T(0.0)); corner = invClipMatrix.Transform(corner); corner.Normalize(); - m_corners[BoxCorner_NearLeftBottom] = Vector3(corner.x, corner.y, corner.z); + m_corners[BoxCorner::NearLeftBottom] = Vector3(corner.x, corner.y, corner.z); // NearLeftTop corner.Set(T(-1.0), T(1.0), T(0.0)); corner = invClipMatrix.Transform(corner); corner.Normalize(); - m_corners[BoxCorner_NearLeftTop] = Vector3(corner.x, corner.y, corner.z); + m_corners[BoxCorner::NearLeftTop] = Vector3(corner.x, corner.y, corner.z); // NearRightBottom corner.Set(T(1.0), T(-1.0), T(0.0)); corner = invClipMatrix.Transform(corner); corner.Normalize(); - m_corners[BoxCorner_NearRightBottom] = Vector3(corner.x, corner.y, corner.z); + m_corners[BoxCorner::NearRightBottom] = Vector3(corner.x, corner.y, corner.z); // NearRightTop corner.Set(T(1.0), T(1.0), T(0.0)); corner = invClipMatrix.Transform(corner); corner.Normalize(); - m_corners[BoxCorner_NearRightTop] = Vector3(corner.x, corner.y, corner.z); + m_corners[BoxCorner::NearRightTop] = Vector3(corner.x, corner.y, corner.z); } else NazaraWarning("Clip matrix is not invertible, failed to compute frustum corners"); @@ -440,7 +440,7 @@ namespace Nz const Vector3& Frustum::GetCorner(BoxCorner corner) const { #ifdef NAZARA_DEBUG - if (corner > BoxCorner_Max) + if (corner > BoxCornerCount) { NazaraError("Corner not handled (0x" + NumberToString(corner, 16) + ')'); @@ -449,7 +449,7 @@ namespace Nz } #endif - return m_corners[corner]; + return m_corners[UnderlyingCast(corner)]; } /*! @@ -465,7 +465,7 @@ namespace Nz const Plane& Frustum::GetPlane(FrustumPlane plane) const { #ifdef NAZARA_DEBUG - if (plane > FrustumPlane_Max) + if (plane > FrustumPlane::Max) { NazaraError("Frustum plane not handled (0x" + NumberToString(plane, 16) + ')'); @@ -474,7 +474,7 @@ namespace Nz } #endif - return m_planes[plane]; + return m_planes[UnderlyingCast(plane)]; } /*! @@ -483,10 +483,10 @@ namespace Nz * * \param volume Volume to check * - * \remark If volume is infinite, IntersectionSide_Intersecting is returned - * \remark If volume is null, IntersectionSide_Outside is returned - * \remark If enumeration of the volume is not defined in Extend, a NazaraError is thrown and IntersectionSide_Outside is returned - * \remark If enumeration of the intersection is not defined in IntersectionSide, a NazaraError is thrown and IntersectionSide_Outside is returned. This should not never happen for a user of the library + * \remark If volume is infinite, IntersectionSide::Intersecting is returned + * \remark If volume is null, IntersectionSide::Outside is returned + * \remark If enumeration of the volume is not defined in Extend, a NazaraError is thrown and IntersectionSide::Outside is returned + * \remark If enumeration of the intersection is not defined in IntersectionSide, a NazaraError is thrown and IntersectionSide::Outside is returned. This should not never happen for a user of the library */ template @@ -494,34 +494,34 @@ namespace Nz { switch (volume.extend) { - case Extend_Finite: + case Extend::Finite: { IntersectionSide side = Intersect(volume.aabb); switch (side) { - case IntersectionSide_Inside: - return IntersectionSide_Inside; + case IntersectionSide::Inside: + return IntersectionSide::Inside; - case IntersectionSide_Intersecting: + case IntersectionSide::Intersecting: return Intersect(volume.obb); - case IntersectionSide_Outside: - return IntersectionSide_Outside; + case IntersectionSide::Outside: + return IntersectionSide::Outside; } - NazaraError("Invalid intersection side (0x" + NumberToString(side, 16) + ')'); - return IntersectionSide_Outside; + NazaraError("Invalid intersection side (0x" + NumberToString(UnderlyingCast(side), 16) + ')'); + return IntersectionSide::Outside; } - case Extend_Infinite: - return IntersectionSide_Intersecting; // We can not contain infinity + case Extend::Infinite: + return IntersectionSide::Intersecting; // We can not contain infinity - case Extend_Null: - return IntersectionSide_Outside; + case Extend::Null: + return IntersectionSide::Outside; } - NazaraError("Invalid extend type (0x" + NumberToString(volume.extend, 16) + ')'); - return IntersectionSide_Outside; + NazaraError("Invalid extend type (0x" + NumberToString(UnderlyingCast(volume.extend), 16) + ')'); + return IntersectionSide::Outside; } /*! @@ -535,14 +535,14 @@ namespace Nz IntersectionSide Frustum::Intersect(const Box& box) const { // http://www.lighthouse3d.com/tutorials/view-frustum-culling/geometric-approach-testing-boxes-ii/ - IntersectionSide side = IntersectionSide_Inside; + IntersectionSide side = IntersectionSide::Inside; - for (unsigned int i = 0; i <= FrustumPlane_Max; i++) + for (std::size_t i = 0; i < FrustumPlaneCount; i++) { if (m_planes[i].Distance(box.GetPositiveVertex(m_planes[i].normal)) < T(0.0)) - return IntersectionSide_Outside; + return IntersectionSide::Outside; else if (m_planes[i].Distance(box.GetNegativeVertex(m_planes[i].normal)) < T(0.0)) - side = IntersectionSide_Intersecting; + side = IntersectionSide::Intersecting; } return side; @@ -572,15 +572,15 @@ namespace Nz IntersectionSide Frustum::Intersect(const Sphere& sphere) const { // http://www.lighthouse3d.com/tutorials/view-frustum-culling/geometric-approach-testing-points-and-spheres/ - IntersectionSide side = IntersectionSide_Inside; + IntersectionSide side = IntersectionSide::Inside; - for (unsigned int i = 0; i <= FrustumPlane_Max; i++) + for (std::size_t i = 0; i < FrustumPlaneCount; i++) { T distance = m_planes[i].Distance(sphere.GetPosition()); if (distance < -sphere.radius) - return IntersectionSide_Outside; + return IntersectionSide::Outside; else if (distance < sphere.radius) - side = IntersectionSide_Intersecting; + side = IntersectionSide::Intersecting; } return side; @@ -595,13 +595,13 @@ namespace Nz */ template - IntersectionSide Frustum::Intersect(const Vector3* points, unsigned int pointCount) const + IntersectionSide Frustum::Intersect(const Vector3* points, std::size_t pointCount) const { - unsigned int c = 0; + std::size_t c = 0; - for (unsigned int i = 0; i <= FrustumPlane_Max; ++i) + for (std::size_t i = 0; i < FrustumPlaneCount; ++i) { - unsigned int j; + std::size_t j; for (j = 0; j < pointCount; j++ ) { if (m_planes[i].Distance(points[j]) > T(0.0)) @@ -609,12 +609,12 @@ namespace Nz } if (j == pointCount) - return IntersectionSide_Outside; + return IntersectionSide::Outside; else c++; } - return (c == 6) ? IntersectionSide_Inside : IntersectionSide_Intersecting; + return (c == 6) ? IntersectionSide::Inside : IntersectionSide::Intersecting; } /*! @@ -628,10 +628,10 @@ namespace Nz template Frustum& Frustum::Set(const Frustum& frustum) { - for (unsigned int i = 0; i <= BoxCorner_Max; ++i) + for (unsigned int i = 0; i < BoxCornerCount; ++i) m_corners[i].Set(frustum.m_corners[i]); - for (unsigned int i = 0; i <= FrustumPlane_Max; ++i) + for (unsigned int i = 0; i < FrustumPlaneCount; ++i) m_planes[i].Set(frustum.m_planes[i]); return *this; @@ -661,13 +661,13 @@ namespace Nz template bool Serialize(SerializationContext& context, const Frustum& frustum, TypeTag>) { - for (unsigned int i = 0; i <= BoxCorner_Max; ++i) + for (unsigned int i = 0; i < BoxCornerCount; ++i) { if (!Serialize(context, frustum.m_corners[i])) return false; } - for (unsigned int i = 0; i <= FrustumPlane_Max; ++i) + for (unsigned int i = 0; i < FrustumPlaneCount; ++i) { if (!Serialize(context, frustum.m_planes[i])) return false; @@ -686,13 +686,13 @@ namespace Nz template bool Unserialize(SerializationContext& context, Frustum* frustum, TypeTag>) { - for (unsigned int i = 0; i <= BoxCorner_Max; ++i) + for (unsigned int i = 0; i < BoxCornerCount; ++i) { if (!Unserialize(context, &frustum->m_corners[i])) return false; } - for (unsigned int i = 0; i <= FrustumPlane_Max; ++i) + for (unsigned int i = 0; i < FrustumPlaneCount; ++i) { if (!Unserialize(context, &frustum->m_planes[i])) return false; @@ -713,12 +713,12 @@ namespace Nz template std::ostream& operator<<(std::ostream& out, const Nz::Frustum& frustum) { - return out << "Frustum(Bottom: " << frustum.GetPlane(Nz::FrustumPlane_Bottom) << ",\n" - << " Far: " << frustum.GetPlane(Nz::FrustumPlane_Far) << ",\n" - << " Left: " << frustum.GetPlane(Nz::FrustumPlane_Left) << ",\n" - << " Near: " << frustum.GetPlane(Nz::FrustumPlane_Near) << ",\n" - << " Right: " << frustum.GetPlane(Nz::FrustumPlane_Right) << ",\n" - << " Top: " << frustum.GetPlane(Nz::FrustumPlane_Top) << ")\n"; + return out << "Frustum(Bottom: " << frustum.GetPlane(Nz::FrustumPlane::Bottom) << ",\n" + << " Far: " << frustum.GetPlane(Nz::FrustumPlane::Far) << ",\n" + << " Left: " << frustum.GetPlane(Nz::FrustumPlane::Left) << ",\n" + << " Near: " << frustum.GetPlane(Nz::FrustumPlane::Near) << ",\n" + << " Right: " << frustum.GetPlane(Nz::FrustumPlane::Right) << ",\n" + << " Top: " << frustum.GetPlane(Nz::FrustumPlane::Top) << ")\n"; } #include diff --git a/include/Nazara/Math/OrientedBox.hpp b/include/Nazara/Math/OrientedBox.hpp index 4a73f1cb8..645ab0292 100644 --- a/include/Nazara/Math/OrientedBox.hpp +++ b/include/Nazara/Math/OrientedBox.hpp @@ -63,7 +63,7 @@ namespace Nz Box localBox; private: - Vector3 m_corners[BoxCorner_Max+1]; // Ne peuvent pas être modifiés directement + Vector3 m_corners[BoxCornerCount]; }; using OrientedBoxd = OrientedBox; diff --git a/include/Nazara/Math/OrientedBox.inl b/include/Nazara/Math/OrientedBox.inl index 5eae2124f..ca6400fe2 100644 --- a/include/Nazara/Math/OrientedBox.inl +++ b/include/Nazara/Math/OrientedBox.inl @@ -89,7 +89,7 @@ namespace Nz const Vector3& OrientedBox::GetCorner(BoxCorner corner) const { #ifdef NAZARA_DEBUG - if (corner > BoxCorner_Max) + if (corner > BoxCornerCount) { NazaraError("Corner not handled (0x" + NumberToString(corner, 16) + ')'); @@ -98,7 +98,7 @@ namespace Nz } #endif - return m_corners[corner]; + return m_corners[UnderlyingCast(corner)]; } template @@ -195,7 +195,7 @@ namespace Nz template OrientedBox& OrientedBox::Set(const OrientedBox& orientedBox) { - for (unsigned int i = 0; i <= BoxCorner_Max; ++i) + for (unsigned int i = 0; i < BoxCornerCount; ++i) m_corners[i].Set(orientedBox(i)); localBox.Set(orientedBox.localBox); @@ -226,7 +226,7 @@ namespace Nz template void OrientedBox::Update(const Matrix4& transformMatrix) { - for (unsigned int i = 0; i <= BoxCorner_Max; ++i) + for (unsigned int i = 0; i < BoxCornerCount; ++i) m_corners[i] = transformMatrix.Transform(localBox.GetCorner(static_cast(i))); } @@ -239,7 +239,7 @@ namespace Nz template void OrientedBox::Update(const Vector3& translation) { - for (unsigned int i = 0; i <= BoxCorner_Max; ++i) + for (unsigned int i = 0; i < BoxCornerCount; ++i) m_corners[i] = localBox.GetCorner(static_cast(i)) + translation; } @@ -247,18 +247,18 @@ namespace Nz * \brief Gets the ith corner of the oriented box * \return A reference to this corner * - * \remark Produce a NazaraError if you try to access to index greather than BoxCorner_Max with NAZARA_MATH_SAFE defined. If not, it is undefined behaviour - * \throw std::out_of_range if NAZARA_MATH_SAFE is defined and you try to acces to index greather than BoxCorner_Max + * \remark Produce a NazaraError if you try to access to index greather than BoxCorner::Max with NAZARA_MATH_SAFE defined. If not, it is undefined behaviour + * \throw std::out_of_range if NAZARA_MATH_SAFE is defined and you try to acces to index greather than BoxCorner::Max */ template Vector3& OrientedBox::operator()(unsigned int i) { #if NAZARA_MATH_SAFE - if (i > BoxCorner_Max) + if (i > BoxCornerCount) { std::ostringstream ss; - ss << "Index out of range: (" << i << " >= " << BoxCorner_Max << ")"; + ss << "Index out of range: (" << i << " >= " << BoxCornerCount << ")"; NazaraError(ss.str()); throw std::out_of_range(ss.str()); @@ -272,18 +272,18 @@ namespace Nz * \brief Gets the ith corner of the oriented box * \return A reference to this corner * - * \remark Produce a NazaraError if you try to access to index greather than BoxCorner_Max with NAZARA_MATH_SAFE defined. If not, it is undefined behaviour - * \throw std::out_of_range if NAZARA_MATH_SAFE is defined and you try to acces to index greather than BoxCorner_Max + * \remark Produce a NazaraError if you try to access to index greather than BoxCorner::Max with NAZARA_MATH_SAFE defined. If not, it is undefined behaviour + * \throw std::out_of_range if NAZARA_MATH_SAFE is defined and you try to acces to index greather than BoxCorner::Max */ template Vector3 OrientedBox::operator()(unsigned int i) const { #if NAZARA_MATH_SAFE - if (i > BoxCorner_Max) + if (i > BoxCornerCount) { std::ostringstream ss; - ss << "Index out of range: (" << i << " >= " << BoxCorner_Max << ")"; + ss << "Index out of range: (" << i << " >= " << BoxCornerCount << ")"; NazaraError(ss.str()); throw std::out_of_range(ss.str()); @@ -437,14 +437,14 @@ namespace Nz template std::ostream& operator<<(std::ostream& out, const Nz::OrientedBox& orientedBox) { - return out << "OrientedBox(FLB: " << orientedBox.GetCorner(Nz::BoxCorner_FarLeftBottom) << ",\n" - << " FLT: " << orientedBox.GetCorner(Nz::BoxCorner_FarLeftTop) << ",\n" - << " FRB: " << orientedBox.GetCorner(Nz::BoxCorner_FarRightBottom) << ",\n" - << " FRT: " << orientedBox.GetCorner(Nz::BoxCorner_FarRightTop) << ",\n" - << " NLB: " << orientedBox.GetCorner(Nz::BoxCorner_NearLeftBottom) << ",\n" - << " NLT: " << orientedBox.GetCorner(Nz::BoxCorner_NearLeftTop) << ",\n" - << " NRB: " << orientedBox.GetCorner(Nz::BoxCorner_NearRightBottom) << ",\n" - << " NRT: " << orientedBox.GetCorner(Nz::BoxCorner_NearRightTop) << ")\n"; + return out << "OrientedBox(FLB: " << orientedBox.GetCorner(Nz::BoxCorner::FarLeftBottom) << ",\n" + << " FLT: " << orientedBox.GetCorner(Nz::BoxCorner::FarLeftTop) << ",\n" + << " FRB: " << orientedBox.GetCorner(Nz::BoxCorner::FarRightBottom) << ",\n" + << " FRT: " << orientedBox.GetCorner(Nz::BoxCorner::FarRightTop) << ",\n" + << " NLB: " << orientedBox.GetCorner(Nz::BoxCorner::NearLeftBottom) << ",\n" + << " NLT: " << orientedBox.GetCorner(Nz::BoxCorner::NearLeftTop) << ",\n" + << " NRB: " << orientedBox.GetCorner(Nz::BoxCorner::NearRightBottom) << ",\n" + << " NRT: " << orientedBox.GetCorner(Nz::BoxCorner::NearRightTop) << ")\n"; } #include diff --git a/include/Nazara/Math/Ray.inl b/include/Nazara/Math/Ray.inl index f0c19fca3..27783b699 100644 --- a/include/Nazara/Math/Ray.inl +++ b/include/Nazara/Math/Ray.inl @@ -141,8 +141,8 @@ namespace Nz * \param closestHit Optional argument to get the closest parameter where the intersection is only if it happened * \param furthestHit Optional argument to get the furthest parameter where the intersection is only if it happened * - * \remark If BoundingVolume is Extend_Infinite, then closestHit and furthestHit are equal to 0 et infinity - * \remark If BoundingVolume is Extend_Null, then closestHit and furthestHit are unchanged + * \remark If BoundingVolume is Extend::Infinite, then closestHit and furthestHit are equal to 0 et infinity + * \remark If BoundingVolume is Extend::Null, then closestHit and furthestHit are unchanged * \remark If enumeration of BoundingVolume is not defined in Extend, a NazaraError is thrown and closestHit and furthestHit are unchanged * * \see Intersect @@ -153,7 +153,7 @@ namespace Nz { switch (volume.extend) { - case Extend_Finite: + case Extend::Finite: { if (Intersect(volume.aabb)) return Intersect(volume.obb, closestHit, furthestHit); @@ -161,7 +161,7 @@ namespace Nz return false; } - case Extend_Infinite: + case Extend::Infinite: { if (closestHit) *closestHit = T(0.0); @@ -172,11 +172,11 @@ namespace Nz return true; } - case Extend_Null: + case Extend::Null: return false; } - NazaraError("Invalid extend type (0x" + NumberToString(volume.extend, 16) + ')'); + NazaraError("Invalid extend type (0x" + NumberToString(UnderlyingCast(volume.extend), 16) + ')'); return false; } @@ -321,12 +321,12 @@ namespace Nz template bool Ray::Intersect(const OrientedBox& orientedBox, T* closestHit, T* furthestHit) const { - Vector3 corner = orientedBox.GetCorner(BoxCorner_FarLeftBottom); - Vector3 oppositeCorner = orientedBox.GetCorner(BoxCorner_NearRightTop); + Vector3 corner = orientedBox.GetCorner(BoxCorner::FarLeftBottom); + Vector3 oppositeCorner = orientedBox.GetCorner(BoxCorner::NearRightTop); - Vector3 width = (orientedBox.GetCorner(BoxCorner_NearLeftBottom) - corner); - Vector3 height = (orientedBox.GetCorner(BoxCorner_FarLeftTop) - corner); - Vector3 depth = (orientedBox.GetCorner(BoxCorner_FarRightBottom) - corner); + Vector3 width = (orientedBox.GetCorner(BoxCorner::NearLeftBottom) - corner); + Vector3 height = (orientedBox.GetCorner(BoxCorner::FarLeftTop) - corner); + Vector3 depth = (orientedBox.GetCorner(BoxCorner::FarRightBottom) - corner); // Construction de la matrice de transformation de l'OBB Matrix4 matrix(width.x, height.x, depth.x, corner.x, diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index f56aca63f..8e6ea4dcc 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -239,20 +239,20 @@ namespace Nz { switch (corner) { - case RectCorner_LeftBottom: + case RectCorner::LeftBottom: return Vector2(x, y + height); - case RectCorner_LeftTop: + case RectCorner::LeftTop: return Vector2(x, y); - case RectCorner_RightBottom: + case RectCorner::RightBottom: return Vector2(x + width, y + height); - case RectCorner_RightTop: + case RectCorner::RightTop: return Vector2(x + width, y); } - NazaraError("Corner not handled (0x" + NumberToString(corner, 16) + ')'); + NazaraError("Corner not handled (0x" + NumberToString(UnderlyingCast(corner), 16) + ')'); return Vector2(); } @@ -269,7 +269,7 @@ namespace Nz /*! * \brief Gets a Vector2 for the maximum point - * \return The RectCorner_RightBottom of the rectangle + * \return The RectCorner::RightBottom of the rectangle * * \see GetCorner */ @@ -282,7 +282,7 @@ namespace Nz /*! * \brief Gets a Vector2 for the minimum point - * \return The RectCorner_LeftTop of the rectangle + * \return The RectCorner::LeftTop of the rectangle * * \see GetCorner, GetPosition */ @@ -318,7 +318,7 @@ namespace Nz /*! * \brief Gets a Vector2 for the position - * \return The RectCorner_LeftTop of the rectangle + * \return The RectCorner::LeftTop of the rectangle * * \see GetCorner, GetMinimum */ diff --git a/include/Nazara/Utility/Algorithm.hpp b/include/Nazara/Utility/Algorithm.hpp index c2ae790ea..b7299da73 100644 --- a/include/Nazara/Utility/Algorithm.hpp +++ b/include/Nazara/Utility/Algorithm.hpp @@ -42,14 +42,14 @@ namespace Nz SparsePtr uvPtr; }; - NAZARA_UTILITY_API Boxf ComputeAABB(SparsePtr positionPtr, unsigned int vertexCount); - NAZARA_UTILITY_API void ComputeBoxIndexVertexCount(const Vector3ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount); - NAZARA_UTILITY_API unsigned int ComputeCacheMissCount(IndexIterator indices, unsigned int indexCount); - NAZARA_UTILITY_API void ComputeConeIndexVertexCount(unsigned int subdivision, unsigned int* indexCount, unsigned int* vertexCount); - NAZARA_UTILITY_API void ComputeCubicSphereIndexVertexCount(unsigned int subdivision, unsigned int* indexCount, unsigned int* vertexCount); - NAZARA_UTILITY_API void ComputeIcoSphereIndexVertexCount(unsigned int recursionLevel, unsigned int* indexCount, unsigned int* vertexCount); - NAZARA_UTILITY_API void ComputePlaneIndexVertexCount(const Vector2ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount); - NAZARA_UTILITY_API void ComputeUvSphereIndexVertexCount(unsigned int sliceCount, unsigned int stackCount, unsigned int* indexCount, unsigned int* vertexCount); + NAZARA_UTILITY_API Boxf ComputeAABB(SparsePtr positionPtr, std::size_t vertexCount); + NAZARA_UTILITY_API void ComputeBoxIndexVertexCount(const Vector3ui& subdivision, std::size_t* indexCount, std::size_t* vertexCount); + NAZARA_UTILITY_API unsigned int ComputeCacheMissCount(IndexIterator indices, std::size_t indexCount); + NAZARA_UTILITY_API void ComputeConeIndexVertexCount(unsigned int subdivision, std::size_t* indexCount, std::size_t* vertexCount); + NAZARA_UTILITY_API void ComputeCubicSphereIndexVertexCount(unsigned int subdivision, std::size_t* indexCount, std::size_t* vertexCount); + NAZARA_UTILITY_API void ComputeIcoSphereIndexVertexCount(unsigned int recursionLevel, std::size_t* indexCount, std::size_t* vertexCount); + NAZARA_UTILITY_API void ComputePlaneIndexVertexCount(const Vector2ui& subdivision, std::size_t* indexCount, std::size_t* vertexCount); + NAZARA_UTILITY_API void ComputeUvSphereIndexVertexCount(unsigned int sliceCount, unsigned int stackCount, std::size_t* indexCount, std::size_t* vertexCount); NAZARA_UTILITY_API void GenerateBox(const Vector3f& lengths, const Vector3ui& subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, unsigned int indexOffset = 0); NAZARA_UTILITY_API void GenerateCone(float length, float radius, unsigned int subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, unsigned int indexOffset = 0); @@ -60,11 +60,11 @@ namespace Nz NAZARA_UTILITY_API void OptimizeIndices(IndexIterator indices, unsigned int indexCount); - NAZARA_UTILITY_API void SkinPosition(const SkinningData& data, unsigned int startVertex, unsigned int vertexCount); - NAZARA_UTILITY_API void SkinPositionNormal(const SkinningData& data, unsigned int startVertex, unsigned int vertexCount); - NAZARA_UTILITY_API void SkinPositionNormalTangent(const SkinningData& data, unsigned int startVertex, unsigned int vertexCount); + NAZARA_UTILITY_API void SkinPosition(const SkinningData& data, std::size_t startVertex, std::size_t vertexCount); + NAZARA_UTILITY_API void SkinPositionNormal(const SkinningData& data, std::size_t startVertex, std::size_t vertexCount); + NAZARA_UTILITY_API void SkinPositionNormalTangent(const SkinningData& data, std::size_t startVertex, std::size_t vertexCount); - NAZARA_UTILITY_API void TransformVertices(VertexPointers vertexPointers, unsigned int vertexCount, const Matrix4f& matrix); + NAZARA_UTILITY_API void TransformVertices(VertexPointers vertexPointers, std::size_t vertexCount, const Matrix4f& matrix); template constexpr ComponentType ComponentTypeId(); template constexpr ComponentType GetComponentTypeOf(); diff --git a/src/Nazara/Shader/GlslWriter.cpp b/src/Nazara/Shader/GlslWriter.cpp index 5009ebe18..d01abcc78 100644 --- a/src/Nazara/Shader/GlslWriter.cpp +++ b/src/Nazara/Shader/GlslWriter.cpp @@ -46,12 +46,12 @@ namespace Nz currentFunction->calledFunctions.UnboundedSet(std::get(node.targetFunction)); } - void Visit(ShaderAst::ConditionalExpression& node) override + void Visit(ShaderAst::ConditionalExpression& /*node*/) override { throw std::runtime_error("unexpected conditional expression, is shader sanitized?"); } - void Visit(ShaderAst::ConditionalStatement& node) override + void Visit(ShaderAst::ConditionalStatement& /*node*/) override { throw std::runtime_error("unexpected conditional statement, is shader sanitized?"); } diff --git a/src/Nazara/Shader/LangWriter.cpp b/src/Nazara/Shader/LangWriter.cpp index 6b0c01686..866f001c8 100644 --- a/src/Nazara/Shader/LangWriter.cpp +++ b/src/Nazara/Shader/LangWriter.cpp @@ -94,7 +94,7 @@ namespace Nz unsigned int indentLevel = 0; }; - std::string LangWriter::Generate(ShaderAst::Statement& shader, const States& states) + std::string LangWriter::Generate(ShaderAst::Statement& shader, const States& /*states*/) { State state; m_currentState = &state; diff --git a/src/Nazara/Utility/AlgorithmUtility.cpp b/src/Nazara/Utility/AlgorithmUtility.cpp index 430c966c7..5fc3bb8ad 100644 --- a/src/Nazara/Utility/AlgorithmUtility.cpp +++ b/src/Nazara/Utility/AlgorithmUtility.cpp @@ -634,7 +634,7 @@ namespace Nz /**********************************Compute**********************************/ - Boxf ComputeAABB(SparsePtr positionPtr, unsigned int vertexCount) + Boxf ComputeAABB(SparsePtr positionPtr, std::size_t vertexCount) { Boxf aabb; if (vertexCount > 0) @@ -651,10 +651,10 @@ namespace Nz return aabb; } - void ComputeBoxIndexVertexCount(const Vector3ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount) + void ComputeBoxIndexVertexCount(const Vector3ui& subdivision, std::size_t* indexCount, std::size_t* vertexCount) { - unsigned int xIndexCount, yIndexCount, zIndexCount; - unsigned int xVertexCount, yVertexCount, zVertexCount; + std::size_t xIndexCount, yIndexCount, zIndexCount; + std::size_t xVertexCount, yVertexCount, zVertexCount; ComputePlaneIndexVertexCount(Vector2ui(subdivision.y, subdivision.z), &xIndexCount, &xVertexCount); ComputePlaneIndexVertexCount(Vector2ui(subdivision.x, subdivision.z), &yIndexCount, &yVertexCount); @@ -667,13 +667,13 @@ namespace Nz *vertexCount = xVertexCount*2 + yVertexCount*2 + zVertexCount*2; } - unsigned int ComputeCacheMissCount(IndexIterator indices, unsigned int indexCount) + unsigned int ComputeCacheMissCount(IndexIterator indices, std::size_t indexCount) { VertexCache cache(indices, indexCount); return cache.GetMissCount(); } - void ComputeConeIndexVertexCount(unsigned int subdivision, unsigned int* indexCount, unsigned int* vertexCount) + void ComputeConeIndexVertexCount(unsigned int subdivision, std::size_t* indexCount, std::size_t* vertexCount) { if (indexCount) *indexCount = (subdivision-1)*6; @@ -682,7 +682,7 @@ namespace Nz *vertexCount = subdivision + 2; } - void ComputeCubicSphereIndexVertexCount(unsigned int subdivision, unsigned int* indexCount, unsigned int* vertexCount) + void ComputeCubicSphereIndexVertexCount(unsigned int subdivision, std::size_t* indexCount, std::size_t* vertexCount) { // Comme tous nos plans sont identiques, on peut optimiser un peu ComputePlaneIndexVertexCount(Vector2ui(subdivision), indexCount, vertexCount); @@ -694,7 +694,7 @@ namespace Nz *vertexCount *= 6; } - void ComputeIcoSphereIndexVertexCount(unsigned int recursionLevel, unsigned int* indexCount, unsigned int* vertexCount) + void ComputeIcoSphereIndexVertexCount(unsigned int recursionLevel, std::size_t* indexCount, std::size_t* vertexCount) { if (indexCount) *indexCount = 3 * 20 * IntegralPow(4, recursionLevel); @@ -703,7 +703,7 @@ namespace Nz *vertexCount = IntegralPow(4, recursionLevel)*10 + 2; } - void ComputePlaneIndexVertexCount(const Vector2ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount) + void ComputePlaneIndexVertexCount(const Vector2ui& subdivision, std::size_t* indexCount, std::size_t* vertexCount) { // Le nombre de faces appartenant à un axe est équivalent à 2 exposant la subdivision (1,2,4,8,16,32,...) unsigned int horizontalFaceCount = (1 << subdivision.x); @@ -720,7 +720,7 @@ namespace Nz *vertexCount = horizontalVertexCount*verticalVertexCount; } - void ComputeUvSphereIndexVertexCount(unsigned int sliceCount, unsigned int stackCount, unsigned int* indexCount, unsigned int* vertexCount) + void ComputeUvSphereIndexVertexCount(unsigned int sliceCount, unsigned int stackCount, std::size_t* indexCount, std::size_t* vertexCount) { if (indexCount) *indexCount = (sliceCount-1) * (stackCount-1) * 6; @@ -733,8 +733,8 @@ namespace Nz void GenerateBox(const Vector3f& lengths, const Vector3ui& subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, unsigned int indexOffset) { - unsigned int xIndexCount, yIndexCount, zIndexCount; - unsigned int xVertexCount, yVertexCount, zVertexCount; + std::size_t xIndexCount, yIndexCount, zIndexCount; + std::size_t xVertexCount, yVertexCount, zVertexCount; ComputePlaneIndexVertexCount(Vector2ui(subdivision.y, subdivision.z), &xIndexCount, &xVertexCount); ComputePlaneIndexVertexCount(Vector2ui(subdivision.x, subdivision.z), &yIndexCount, &yVertexCount); @@ -901,7 +901,7 @@ namespace Nz void GenerateCubicSphere(float size, unsigned int subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, unsigned int indexOffset) { ///DOC: Cette fonction va accéder aux pointeurs en écriture ET en lecture - unsigned int vertexCount; + std::size_t vertexCount; ComputeBoxIndexVertexCount(Vector3ui(subdivision), nullptr, &vertexCount); // On envoie une matrice identité de sorte à ce que la boîte ne subisse aucune transformation (rendant plus facile l'étape suivante) @@ -1057,12 +1057,12 @@ namespace Nz const SkeletalMeshVertex* inputVertex = &skinningInfos.inputVertex[startVertex]; MeshVertex* outputVertex = &skinningInfos.outputVertex[startVertex]; - unsigned int endVertex = startVertex + vertexCount - 1; - for (unsigned int i = startVertex; i <= endVertex; ++i) + std::size_t endVertex = startVertex + vertexCount - 1; + for (std::size_t i = startVertex; i <= endVertex; ++i) { Vector3f finalPosition(Vector3f::Zero()); - for (int j = 0; j < inputVertex->weightCount; ++j) + for (Int32 j = 0; j < inputVertex->weightCount; ++j) { Matrix4f mat(skinningInfos.joints[inputVertex->jointIndexes[j]].GetSkinningMatrix()); mat *= inputVertex->weights[j]; @@ -1083,13 +1083,13 @@ namespace Nz const SkeletalMeshVertex* inputVertex = &skinningInfos.inputVertex[startVertex]; MeshVertex* outputVertex = &skinningInfos.outputVertex[startVertex]; - unsigned int endVertex = startVertex + vertexCount - 1; - for (unsigned int i = startVertex; i <= endVertex; ++i) + std::size_t endVertex = startVertex + vertexCount - 1; + for (std::size_t i = startVertex; i <= endVertex; ++i) { Vector3f finalPosition(Vector3f::Zero()); Vector3f finalNormal(Vector3f::Zero()); - for (int j = 0; j < inputVertex->weightCount; ++j) + for (Int32 j = 0; j < inputVertex->weightCount; ++j) { Matrix4f mat(skinningInfos.joints[inputVertex->jointIndexes[j]].GetSkinningMatrix()); mat *= inputVertex->weights[j]; diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index 23a1ba615..1480c6964 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -108,8 +108,8 @@ namespace Nz { case PrimitiveType::Box: { - unsigned int indexCount; - unsigned int vertexCount; + std::size_t indexCount; + std::size_t vertexCount; ComputeBoxIndexVertexCount(primitive.box.subdivision, &indexCount, &vertexCount); indexBuffer = std::make_shared(vertexCount > std::numeric_limits::max(), indexCount, params.storage, params.indexBufferFlags); @@ -130,8 +130,8 @@ namespace Nz case PrimitiveType::Cone: { - unsigned int indexCount; - unsigned int vertexCount; + std::size_t indexCount; + std::size_t vertexCount; ComputeConeIndexVertexCount(primitive.cone.subdivision, &indexCount, &vertexCount); indexBuffer = std::make_shared(vertexCount > std::numeric_limits::max(), indexCount, params.storage, params.indexBufferFlags); @@ -152,8 +152,8 @@ namespace Nz case PrimitiveType::Plane: { - unsigned int indexCount; - unsigned int vertexCount; + std::size_t indexCount; + std::size_t vertexCount; ComputePlaneIndexVertexCount(primitive.plane.subdivision, &indexCount, &vertexCount); indexBuffer = std::make_shared(vertexCount > std::numeric_limits::max(), indexCount, params.storage, params.indexBufferFlags); @@ -178,8 +178,8 @@ namespace Nz { case SphereType::Cubic: { - unsigned int indexCount; - unsigned int vertexCount; + std::size_t indexCount; + std::size_t vertexCount; ComputeCubicSphereIndexVertexCount(primitive.sphere.cubic.subdivision, &indexCount, &vertexCount); indexBuffer = std::make_shared(vertexCount > std::numeric_limits::max(), indexCount, params.storage, params.indexBufferFlags); @@ -200,8 +200,8 @@ namespace Nz case SphereType::Ico: { - unsigned int indexCount; - unsigned int vertexCount; + std::size_t indexCount; + std::size_t vertexCount; ComputeIcoSphereIndexVertexCount(primitive.sphere.ico.recursionLevel, &indexCount, &vertexCount); indexBuffer = std::make_shared(vertexCount > std::numeric_limits::max(), indexCount, params.storage, params.indexBufferFlags); @@ -222,8 +222,8 @@ namespace Nz case SphereType::UV: { - unsigned int indexCount; - unsigned int vertexCount; + std::size_t indexCount; + std::size_t vertexCount; ComputeUvSphereIndexVertexCount(primitive.sphere.uv.sliceCount, primitive.sphere.uv.stackCount, &indexCount, &vertexCount); indexBuffer = std::make_shared(vertexCount > std::numeric_limits::max(), indexCount, params.storage, params.indexBufferFlags); diff --git a/src/Nazara/Utility/RichTextDrawer.cpp b/src/Nazara/Utility/RichTextDrawer.cpp index 123c21e91..d94550e8c 100644 --- a/src/Nazara/Utility/RichTextDrawer.cpp +++ b/src/Nazara/Utility/RichTextDrawer.cpp @@ -460,10 +460,10 @@ namespace Nz glyph.atlas = nullptr; glyph.bounds.Set(m_drawPos.x, m_lines.back().bounds.y, advance, lineHeight); - glyph.corners[0].Set(glyph.bounds.GetCorner(RectCorner_LeftTop)); - glyph.corners[1].Set(glyph.bounds.GetCorner(RectCorner_RightTop)); - glyph.corners[2].Set(glyph.bounds.GetCorner(RectCorner_LeftBottom)); - glyph.corners[3].Set(glyph.bounds.GetCorner(RectCorner_RightBottom)); + glyph.corners[0].Set(glyph.bounds.GetCorner(RectCorner::LeftTop)); + glyph.corners[1].Set(glyph.bounds.GetCorner(RectCorner::RightTop)); + glyph.corners[2].Set(glyph.bounds.GetCorner(RectCorner::LeftBottom)); + glyph.corners[3].Set(glyph.bounds.GetCorner(RectCorner::RightBottom)); } m_lines.back().bounds.ExtendTo(glyph.bounds); diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index fd1b18fd3..c1fbf241d 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -247,10 +247,10 @@ namespace Nz glyph.atlas = nullptr; glyph.bounds.Set(m_drawPos.x, m_lines.back().bounds.y, advance, GetLineHeight(sizeInfo)); - glyph.corners[0].Set(glyph.bounds.GetCorner(RectCorner_LeftTop)); - glyph.corners[1].Set(glyph.bounds.GetCorner(RectCorner_RightTop)); - glyph.corners[2].Set(glyph.bounds.GetCorner(RectCorner_LeftBottom)); - glyph.corners[3].Set(glyph.bounds.GetCorner(RectCorner_RightBottom)); + glyph.corners[0].Set(glyph.bounds.GetCorner(RectCorner::LeftTop)); + glyph.corners[1].Set(glyph.bounds.GetCorner(RectCorner::RightTop)); + glyph.corners[2].Set(glyph.bounds.GetCorner(RectCorner::LeftBottom)); + glyph.corners[3].Set(glyph.bounds.GetCorner(RectCorner::RightBottom)); } m_lines.back().bounds.ExtendTo(glyph.bounds); diff --git a/src/Nazara/Utility/StaticMesh.cpp b/src/Nazara/Utility/StaticMesh.cpp index b8ac35661..eb863e6fe 100644 --- a/src/Nazara/Utility/StaticMesh.cpp +++ b/src/Nazara/Utility/StaticMesh.cpp @@ -25,8 +25,8 @@ namespace Nz VertexMapper mapper(*m_vertexBuffer); SparsePtr position = mapper.GetComponentPtr(VertexComponent::Position); - unsigned int vertexCount = m_vertexBuffer->GetVertexCount(); - for (unsigned int i = 0; i < vertexCount; ++i) + std::size_t vertexCount = m_vertexBuffer->GetVertexCount(); + for (std::size_t i = 0; i < vertexCount; ++i) *position++ -= offset; m_aabb.x -= offset.x; diff --git a/tests/Engine/Core/SerializationTest.cpp b/tests/Engine/Core/SerializationTest.cpp index d36226c09..5e86c575d 100644 --- a/tests/Engine/Core/SerializationTest.cpp +++ b/tests/Engine/Core/SerializationTest.cpp @@ -92,11 +92,11 @@ SCENARIO("Serialization", "[CORE][SERIALIZATION]") Nz::Frustumf copy(frustum); REQUIRE(Serialize(context, frustum)); frustum.Build(50, 40, 20, 100, Nz::Vector3f::UnitX(), Nz::Vector3f::UnitZ()); - for (unsigned int i = 0; i <= Nz::BoxCorner_Max; ++i) + for (unsigned int i = 0; i < Nz::BoxCornerCount; ++i) REQUIRE(frustum.GetCorner(static_cast(i)) != copy.GetCorner(static_cast(i))); context.stream->SetCursorPos(0); REQUIRE(Unserialize(context, &frustum)); - for (unsigned int i = 0; i <= Nz::BoxCorner_Max; ++i) + for (unsigned int i = 0; i < Nz::BoxCornerCount; ++i) REQUIRE(frustum.GetCorner(static_cast(i)) == copy.GetCorner(static_cast(i))); } diff --git a/tests/Engine/Math/BoundingVolumeTest.cpp b/tests/Engine/Math/BoundingVolumeTest.cpp index 8762e9047..09b1c33f9 100644 --- a/tests/Engine/Math/BoundingVolumeTest.cpp +++ b/tests/Engine/Math/BoundingVolumeTest.cpp @@ -122,8 +122,8 @@ SCENARIO("BoundingVolume", "[MATH][BOUNDINGVOLUME]") Nz::BoundingVolumef centerAndUnit(centerAndUnitOBB); - Nz::BoundingVolumef nullBoundingVolume(Nz::Extend_Null); - Nz::BoundingVolumef infiniteBoundingVolume(Nz::Extend_Infinite); + Nz::BoundingVolumef nullBoundingVolume(Nz::Extend::Null); + Nz::BoundingVolumef infiniteBoundingVolume(Nz::Extend::Infinite); THEN("Normal to null should give a smaller volume") { diff --git a/tests/Engine/Math/BoxTest.cpp b/tests/Engine/Math/BoxTest.cpp index 8052630e7..def3e4aa2 100644 --- a/tests/Engine/Math/BoxTest.cpp +++ b/tests/Engine/Math/BoxTest.cpp @@ -33,7 +33,7 @@ SCENARIO("Box", "[MATH][BOX]") { REQUIRE(firstCenterAndUnit.GetBoundingSphere() == Nz::Spheref(Nz::Vector3f::Unit() * 0.5f, std::sqrt(3.f * 0.5f * 0.5f))); REQUIRE(firstCenterAndUnit.GetCenter() == (Nz::Vector3f::Unit() * 0.5f)); - REQUIRE(firstCenterAndUnit.GetCorner(Nz::BoxCorner_FarLeftTop) == Nz::Vector3f::UnitY()); + REQUIRE(firstCenterAndUnit.GetCorner(Nz::BoxCorner::FarLeftTop) == Nz::Vector3f::UnitY()); REQUIRE(firstCenterAndUnit.GetLengths() == Nz::Vector3f::Unit()); REQUIRE(firstCenterAndUnit.GetMaximum() == Nz::Vector3f::Unit()); REQUIRE(firstCenterAndUnit.GetMinimum() == Nz::Vector3f::Zero()); diff --git a/tests/Engine/Math/FrustumTest.cpp b/tests/Engine/Math/FrustumTest.cpp index 1175b95a4..e8fffc008 100644 --- a/tests/Engine/Math/FrustumTest.cpp +++ b/tests/Engine/Math/FrustumTest.cpp @@ -14,16 +14,16 @@ SCENARIO("Frustum", "[MATH][FRUSTUM]") { Nz::BoundingVolumef bv(Nz::Vector3f::Zero(), Nz::Vector3f::Unit()); bv.Update(Nz::Matrix4f::Identity()); - REQUIRE(Nz::IntersectionSide_Outside == frustum.Intersect(bv)); - REQUIRE(Nz::IntersectionSide_Outside == frustum.Intersect(Nz::Boxf(Nz::Vector3f::Zero(), Nz::Vector3f::Unit() * 0.9f))); + REQUIRE(Nz::IntersectionSide::Outside == frustum.Intersect(bv)); + REQUIRE(Nz::IntersectionSide::Outside == frustum.Intersect(Nz::Boxf(Nz::Vector3f::Zero(), Nz::Vector3f::Unit() * 0.9f))); Nz::OrientedBoxf obb(Nz::Vector3f::Zero(), Nz::Vector3f::Unit() * 0.9f); obb.Update(Nz::Matrix4f::Identity()); - REQUIRE(Nz::IntersectionSide_Outside == frustum.Intersect(obb)); - REQUIRE(Nz::IntersectionSide_Outside == frustum.Intersect(Nz::Spheref(Nz::Vector3f::Zero(), 0.5f))); + REQUIRE(Nz::IntersectionSide::Outside == frustum.Intersect(obb)); + REQUIRE(Nz::IntersectionSide::Outside == frustum.Intersect(Nz::Spheref(Nz::Vector3f::Zero(), 0.5f))); Nz::Vector3f tmp = Nz::Vector3f::Zero(); - REQUIRE(Nz::IntersectionSide_Outside == frustum.Intersect(&tmp, 1)); + REQUIRE(Nz::IntersectionSide::Outside == frustum.Intersect(&tmp, 1)); tmp = Nz::Vector3f::UnitX() * -10.f; - REQUIRE(Nz::IntersectionSide_Outside == frustum.Intersect(&tmp, 1)); + REQUIRE(Nz::IntersectionSide::Outside == frustum.Intersect(&tmp, 1)); } } @@ -34,14 +34,14 @@ SCENARIO("Frustum", "[MATH][FRUSTUM]") Nz::BoundingVolumef bv(500.f, -0.5f, -0.5f, 1.f, 1.f, 1.f); bv.Update(Nz::Matrix4f::Identity()); - REQUIRE(Nz::IntersectionSide_Inside == frustum.Intersect(bv)); - REQUIRE(Nz::IntersectionSide_Inside == frustum.Intersect(Nz::Boxf(Nz::Vector3f::UnitX() * 500.f, Nz::Vector3f::Unit()))); + REQUIRE(Nz::IntersectionSide::Inside == frustum.Intersect(bv)); + REQUIRE(Nz::IntersectionSide::Inside == frustum.Intersect(Nz::Boxf(Nz::Vector3f::UnitX() * 500.f, Nz::Vector3f::Unit()))); Nz::OrientedBoxf obb(Nz::Vector3f::UnitX() * 100.f, Nz::Vector3f::Unit()); obb.Update(Nz::Matrix4f::Identity()); - REQUIRE(Nz::IntersectionSide_Inside == frustum.Intersect(obb)); - REQUIRE(Nz::IntersectionSide_Inside == frustum.Intersect(Nz::Spheref(Nz::Vector3f::UnitX() * 100.f, 0.5f))); + REQUIRE(Nz::IntersectionSide::Inside == frustum.Intersect(obb)); + REQUIRE(Nz::IntersectionSide::Inside == frustum.Intersect(Nz::Spheref(Nz::Vector3f::UnitX() * 100.f, 0.5f))); Nz::Vector3f tmp = Nz::Vector3f::UnitX() * 100.f; - REQUIRE(Nz::IntersectionSide_Inside == frustum.Intersect(&tmp, 1)); + REQUIRE(Nz::IntersectionSide::Inside == frustum.Intersect(&tmp, 1)); } } @@ -87,8 +87,8 @@ SCENARIO("Frustum", "[MATH][FRUSTUM]") CHECK(!frustum.Contains(nullVolume)); Nz::BoundingVolumef infiniteVolume = Nz::BoundingVolumef::Infinite(); CHECK(frustum.Contains(infiniteVolume)); - REQUIRE(frustum.Intersect(nullVolume) == Nz::IntersectionSide_Outside); - REQUIRE(frustum.Intersect(infiniteVolume) == Nz::IntersectionSide_Intersecting); + REQUIRE(frustum.Intersect(nullVolume) == Nz::IntersectionSide::Outside); + REQUIRE(frustum.Intersect(infiniteVolume) == Nz::IntersectionSide::Intersecting); } } } diff --git a/tests/Engine/Math/OrientedBoxTest.cpp b/tests/Engine/Math/OrientedBoxTest.cpp index d5bb84268..e45f1bb7b 100644 --- a/tests/Engine/Math/OrientedBoxTest.cpp +++ b/tests/Engine/Math/OrientedBoxTest.cpp @@ -37,7 +37,7 @@ SCENARIO("OrientedBox", "[MATH][ORIENTEDBOX]") secondCenterAndUnit.Update(Nz::Matrix4f::Scale(Nz::Vector3f::Unit() * 2.f)); REQUIRE(firstCenterAndUnit != secondCenterAndUnit); - for (unsigned int i = 0; i <= Nz::BoxCorner_Max; ++i) + for (unsigned int i = 0; i < Nz::BoxCornerCount; ++i) { REQUIRE(firstCenterAndUnit(i) == secondCenterAndUnit(i)); } diff --git a/tests/Engine/Math/RayTest.cpp b/tests/Engine/Math/RayTest.cpp index 6d39b936e..c602b401e 100644 --- a/tests/Engine/Math/RayTest.cpp +++ b/tests/Engine/Math/RayTest.cpp @@ -83,12 +83,12 @@ SCENARIO("Ray", "[MATH][RAY]") THEN("For the bounding volume collision's") { - Nz::BoundingVolumef nullVolume(Nz::Extend_Null); + Nz::BoundingVolumef nullVolume(Nz::Extend::Null); CHECK(!ray.Intersect(nullVolume)); float tmpClosest = -1.f; float tmpFurthest = -1.f; - Nz::BoundingVolumef infiniteVolume(Nz::Extend_Infinite); + Nz::BoundingVolumef infiniteVolume(Nz::Extend::Infinite); CHECK(ray.Intersect(infiniteVolume, &tmpClosest, &tmpFurthest)); CHECK(tmpClosest == Approx(0.f)); CHECK(tmpFurthest == std::numeric_limits::infinity()); diff --git a/tests/Engine/Math/RectTest.cpp b/tests/Engine/Math/RectTest.cpp index 3aba4f41b..f96f333a2 100644 --- a/tests/Engine/Math/RectTest.cpp +++ b/tests/Engine/Math/RectTest.cpp @@ -14,7 +14,7 @@ SCENARIO("Rect", "[MATH][RECT]") { CHECK(firstCenterAndUnit == secondCenterAndUnit); CHECK(firstCenterAndUnit.GetCenter() == secondCenterAndUnit.GetCenter()); - CHECK(firstCenterAndUnit.GetCorner(Nz::RectCorner_LeftBottom) == secondCenterAndUnit.GetCorner(Nz::RectCorner_LeftBottom)); + CHECK(firstCenterAndUnit.GetCorner(Nz::RectCorner::LeftBottom) == secondCenterAndUnit.GetCorner(Nz::RectCorner::LeftBottom)); CHECK(firstCenterAndUnit.IsValid()); } }