Fixes a lot of warnings and move math enums to enum classes

This commit is contained in:
Jérôme Leclercq 2021-08-19 20:27:20 +02:00
parent a2a0e6bd54
commit 8db8533300
27 changed files with 323 additions and 315 deletions

View File

@ -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;
}

View File

@ -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<const T*>()(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<const T*>()(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<const T*>()(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<const T*>()(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<const T*>()(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<const T*>()(entry.renderable));
@ -111,7 +111,7 @@ namespace Nz
entry.forceInvalidation = false;
break;
case IntersectionSide_Outside:
case IntersectionSide::Outside:
break;
}
}

View File

@ -77,6 +77,8 @@ namespace std
Nz::HashCombine(seed, shader.uberShader.get());
}
NazaraUnused(parameterIndex);
#undef NazaraPipelineMember
#undef NazaraPipelineBoolMember

View File

@ -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<typename T>
BoundingVolume<T>::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<typename T>
bool BoundingVolume<T>::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<typename T>
bool BoundingVolume<T>::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<typename T>
bool BoundingVolume<T>::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<typename T>
BoundingVolume<T>& BoundingVolume<T>::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<typename T>
BoundingVolume<T>& BoundingVolume<T>::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<typename T>
@ -264,7 +264,7 @@ namespace Nz
BoundingVolume<T>& BoundingVolume<T>::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<T>& BoundingVolume<T>::Set(const Box<T>& box)
{
obb.Set(box);
extend = Extend_Finite;
extend = Extend::Finite;
return *this;
}
@ -312,7 +312,7 @@ namespace Nz
BoundingVolume<T>& BoundingVolume<T>::Set(const OrientedBox<T>& orientedBox)
{
obb.Set(orientedBox);
extend = Extend_Finite;
extend = Extend::Finite;
return *this;
}
@ -329,7 +329,7 @@ namespace Nz
BoundingVolume<T>& BoundingVolume<T>::Set(const Vector3<T>& vec1, const Vector3<T>& vec2)
{
obb.Set(vec1, vec2);
extend = Extend_Finite;
extend = Extend::Finite;
return *this;
}
@ -441,7 +441,7 @@ namespace Nz
bool BoundingVolume<T>::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<T>::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>(extend);
@ -648,15 +648,15 @@ std::ostream& operator<<(std::ostream& out, const Nz::BoundingVolume<T>& 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;
}

View File

@ -276,32 +276,32 @@ namespace Nz
{
switch (corner)
{
case BoxCorner_FarLeftBottom:
case BoxCorner::FarLeftBottom:
return Vector3<T>(x, y, z);
case BoxCorner_FarLeftTop:
case BoxCorner::FarLeftTop:
return Vector3<T>(x, y + height, z);
case BoxCorner_FarRightBottom:
case BoxCorner::FarRightBottom:
return Vector3<T>(x + width, y, z);
case BoxCorner_FarRightTop:
case BoxCorner::FarRightTop:
return Vector3<T>(x + width, y + height, z);
case BoxCorner_NearLeftBottom:
case BoxCorner::NearLeftBottom:
return Vector3<T>(x, y, z + depth);
case BoxCorner_NearLeftTop:
case BoxCorner::NearLeftTop:
return Vector3<T>(x, y + height, z + depth);
case BoxCorner_NearRightBottom:
case BoxCorner::NearRightBottom:
return Vector3<T>(x + width, y, z + depth);
case BoxCorner_NearRightTop:
case BoxCorner::NearRightTop:
return Vector3<T>(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<T>();
}
@ -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
*/

View File

@ -7,6 +7,8 @@
#ifndef NAZARA_ENUMS_MATH_HPP
#define NAZARA_ENUMS_MATH_HPP
#include <Nazara/Core/Algorithm.hpp>
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
};
}

View File

@ -49,7 +49,7 @@ namespace Nz
IntersectionSide Intersect(const Box<T>& box) const;
IntersectionSide Intersect(const OrientedBox<T>& orientedBox) const;
IntersectionSide Intersect(const Sphere<T>& sphere) const;
IntersectionSide Intersect(const Vector3<T>* points, unsigned int pointCount) const;
IntersectionSide Intersect(const Vector3<T>* points, std::size_t pointCount) const;
Frustum& operator=(const Frustum& other) = default;
@ -64,8 +64,8 @@ namespace Nz
friend bool Unserialize(SerializationContext& context, Frustum<U>* frustum, TypeTag<Frustum<U>>);
private:
Vector3<T> m_corners[BoxCorner_Max+1];
Plane<T> m_planes[FrustumPlane_Max+1];
Vector3<T> m_corners[BoxCornerCount];
Plane<T> m_planes[FrustumPlaneCount];
};
using Frustumd = Frustum<double>;

View File

@ -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<T> 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<T>::Contains(const Box<T>& 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<typename T>
bool Frustum<T>::Contains(const Sphere<T>& 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<typename T>
bool Frustum<T>::Contains(const Vector3<T>& 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<typename T>
bool Frustum<T>::Contains(const Vector3<T>* 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<T>(corner.x, corner.y, corner.z);
m_corners[BoxCorner::FarLeftBottom] = Vector3<T>(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<T>(corner.x, corner.y, corner.z);
m_corners[BoxCorner::FarLeftTop] = Vector3<T>(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<T>(corner.x, corner.y, corner.z);
m_corners[BoxCorner::FarRightBottom] = Vector3<T>(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<T>(corner.x, corner.y, corner.z);
m_corners[BoxCorner::FarRightTop] = Vector3<T>(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<T>(corner.x, corner.y, corner.z);
m_corners[BoxCorner::NearLeftBottom] = Vector3<T>(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<T>(corner.x, corner.y, corner.z);
m_corners[BoxCorner::NearLeftTop] = Vector3<T>(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<T>(corner.x, corner.y, corner.z);
m_corners[BoxCorner::NearRightBottom] = Vector3<T>(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<T>(corner.x, corner.y, corner.z);
m_corners[BoxCorner::NearRightTop] = Vector3<T>(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<T>& Frustum<T>::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<T>& Frustum<T>::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<typename T>
@ -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<T>::Intersect(const Box<T>& 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<T>::Intersect(const Sphere<T>& 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<typename T>
IntersectionSide Frustum<T>::Intersect(const Vector3<T>* points, unsigned int pointCount) const
IntersectionSide Frustum<T>::Intersect(const Vector3<T>* 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<typename U>
Frustum<T>& Frustum<T>::Set(const Frustum<U>& 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<typename T>
bool Serialize(SerializationContext& context, const Frustum<T>& frustum, TypeTag<Frustum<T>>)
{
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<typename T>
bool Unserialize(SerializationContext& context, Frustum<T>* frustum, TypeTag<Frustum<T>>)
{
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<typename T>
std::ostream& operator<<(std::ostream& out, const Nz::Frustum<T>& 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 <Nazara/Core/DebugOff.hpp>

View File

@ -63,7 +63,7 @@ namespace Nz
Box<T> localBox;
private:
Vector3<T> m_corners[BoxCorner_Max+1]; // Ne peuvent pas être modifiés directement
Vector3<T> m_corners[BoxCornerCount];
};
using OrientedBoxd = OrientedBox<double>;

View File

@ -89,7 +89,7 @@ namespace Nz
const Vector3<T>& OrientedBox<T>::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<typename T>
@ -195,7 +195,7 @@ namespace Nz
template<typename U>
OrientedBox<T>& OrientedBox<T>::Set(const OrientedBox<U>& 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<typename T>
void OrientedBox<T>::Update(const Matrix4<T>& 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<BoxCorner>(i)));
}
@ -239,7 +239,7 @@ namespace Nz
template<typename T>
void OrientedBox<T>::Update(const Vector3<T>& 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<BoxCorner>(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<typename T>
Vector3<T>& OrientedBox<T>::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<typename T>
Vector3<T> OrientedBox<T>::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<typename T>
std::ostream& operator<<(std::ostream& out, const Nz::OrientedBox<T>& 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 <Nazara/Core/DebugOff.hpp>

View File

@ -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<typename T>
bool Ray<T>::Intersect(const OrientedBox<T>& orientedBox, T* closestHit, T* furthestHit) const
{
Vector3<T> corner = orientedBox.GetCorner(BoxCorner_FarLeftBottom);
Vector3<T> oppositeCorner = orientedBox.GetCorner(BoxCorner_NearRightTop);
Vector3<T> corner = orientedBox.GetCorner(BoxCorner::FarLeftBottom);
Vector3<T> oppositeCorner = orientedBox.GetCorner(BoxCorner::NearRightTop);
Vector3<T> width = (orientedBox.GetCorner(BoxCorner_NearLeftBottom) - corner);
Vector3<T> height = (orientedBox.GetCorner(BoxCorner_FarLeftTop) - corner);
Vector3<T> depth = (orientedBox.GetCorner(BoxCorner_FarRightBottom) - corner);
Vector3<T> width = (orientedBox.GetCorner(BoxCorner::NearLeftBottom) - corner);
Vector3<T> height = (orientedBox.GetCorner(BoxCorner::FarLeftTop) - corner);
Vector3<T> depth = (orientedBox.GetCorner(BoxCorner::FarRightBottom) - corner);
// Construction de la matrice de transformation de l'OBB
Matrix4<T> matrix(width.x, height.x, depth.x, corner.x,

View File

@ -239,20 +239,20 @@ namespace Nz
{
switch (corner)
{
case RectCorner_LeftBottom:
case RectCorner::LeftBottom:
return Vector2<T>(x, y + height);
case RectCorner_LeftTop:
case RectCorner::LeftTop:
return Vector2<T>(x, y);
case RectCorner_RightBottom:
case RectCorner::RightBottom:
return Vector2<T>(x + width, y + height);
case RectCorner_RightTop:
case RectCorner::RightTop:
return Vector2<T>(x + width, y);
}
NazaraError("Corner not handled (0x" + NumberToString(corner, 16) + ')');
NazaraError("Corner not handled (0x" + NumberToString(UnderlyingCast(corner), 16) + ')');
return Vector2<T>();
}
@ -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
*/

View File

@ -42,14 +42,14 @@ namespace Nz
SparsePtr<Vector2f> uvPtr;
};
NAZARA_UTILITY_API Boxf ComputeAABB(SparsePtr<const Vector3f> 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<const Vector3f> 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<typename T> constexpr ComponentType ComponentTypeId();
template<typename T> constexpr ComponentType GetComponentTypeOf();

View File

@ -46,12 +46,12 @@ namespace Nz
currentFunction->calledFunctions.UnboundedSet(std::get<std::size_t>(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?");
}

View File

@ -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;

View File

@ -634,7 +634,7 @@ namespace Nz
/**********************************Compute**********************************/
Boxf ComputeAABB(SparsePtr<const Vector3f> positionPtr, unsigned int vertexCount)
Boxf ComputeAABB(SparsePtr<const Vector3f> 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];

View File

@ -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<IndexBuffer>(vertexCount > std::numeric_limits<UInt16>::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<IndexBuffer>(vertexCount > std::numeric_limits<UInt16>::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<IndexBuffer>(vertexCount > std::numeric_limits<UInt16>::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<IndexBuffer>(vertexCount > std::numeric_limits<UInt16>::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<IndexBuffer>(vertexCount > std::numeric_limits<UInt16>::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<IndexBuffer>(vertexCount > std::numeric_limits<UInt16>::max(), indexCount, params.storage, params.indexBufferFlags);

View File

@ -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);

View File

@ -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);

View File

@ -25,8 +25,8 @@ namespace Nz
VertexMapper mapper(*m_vertexBuffer);
SparsePtr<Vector3f> position = mapper.GetComponentPtr<Vector3f>(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;

View File

@ -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<Nz::BoxCorner>(i)) != copy.GetCorner(static_cast<Nz::BoxCorner>(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<Nz::BoxCorner>(i)) == copy.GetCorner(static_cast<Nz::BoxCorner>(i)));
}

View File

@ -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")
{

View File

@ -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());

View File

@ -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);
}
}
}

View File

@ -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));
}

View File

@ -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<float>::infinity());

View File

@ -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());
}
}