Fixes a lot of warnings and move math enums to enum classes
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,8 @@ namespace std
|
||||
Nz::HashCombine(seed, shader.uberShader.get());
|
||||
}
|
||||
|
||||
NazaraUnused(parameterIndex);
|
||||
|
||||
#undef NazaraPipelineMember
|
||||
#undef NazaraPipelineBoolMember
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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>;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user