Renamed Corner enum to BoxCorner
Added RectCorner and Rect::GetCorner method Former-commit-id: dc99823ceb17f6e91cdf12779c982ab7e024ec24
This commit is contained in:
parent
4e9bec804a
commit
7c47a93a72
|
|
@ -38,7 +38,7 @@ class NzBox
|
|||
NzBox& ExtendTo(const NzVector3<T>& point);
|
||||
|
||||
NzSphere<T> GetBoundingSphere() const;
|
||||
NzVector3<T> GetCorner(nzCorner corner) const;
|
||||
NzVector3<T> GetCorner(nzBoxCorner corner) const;
|
||||
NzVector3<T> GetCenter() const;
|
||||
NzVector3<T> GetLengths() const;
|
||||
NzVector3<T> GetMaximum() const;
|
||||
|
|
|
|||
|
|
@ -117,32 +117,32 @@ NzBox<T>& NzBox<T>::ExtendTo(const NzVector3<T>& point)
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzBox<T>::GetCorner(nzCorner corner) const
|
||||
NzVector3<T> NzBox<T>::GetCorner(nzBoxCorner corner) const
|
||||
{
|
||||
switch (corner)
|
||||
{
|
||||
case nzCorner_FarLeftBottom:
|
||||
case nzBoxCorner_FarLeftBottom:
|
||||
return NzVector3<T>(x, y, z);
|
||||
|
||||
case nzCorner_FarLeftTop:
|
||||
case nzBoxCorner_FarLeftTop:
|
||||
return NzVector3<T>(x, y + height, z);
|
||||
|
||||
case nzCorner_FarRightBottom:
|
||||
case nzBoxCorner_FarRightBottom:
|
||||
return NzVector3<T>(x + width, y, z);
|
||||
|
||||
case nzCorner_FarRightTop:
|
||||
case nzBoxCorner_FarRightTop:
|
||||
return NzVector3<T>(x + width, y + height, z);
|
||||
|
||||
case nzCorner_NearLeftBottom:
|
||||
case nzBoxCorner_NearLeftBottom:
|
||||
return NzVector3<T>(x, y, z + depth);
|
||||
|
||||
case nzCorner_NearLeftTop:
|
||||
case nzBoxCorner_NearLeftTop:
|
||||
return NzVector3<T>(x, y + height, z + depth);
|
||||
|
||||
case nzCorner_NearRightBottom:
|
||||
case nzBoxCorner_NearRightBottom:
|
||||
return NzVector3<T>(x + width, y, z + depth);
|
||||
|
||||
case nzCorner_NearRightTop:
|
||||
case nzBoxCorner_NearRightTop:
|
||||
return NzVector3<T>(x + width, y + height, z + depth);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,18 +7,18 @@
|
|||
#ifndef NAZARA_ENUMS_MATH_HPP
|
||||
#define NAZARA_ENUMS_MATH_HPP
|
||||
|
||||
enum nzCorner
|
||||
enum nzBoxCorner
|
||||
{
|
||||
nzCorner_FarLeftBottom,
|
||||
nzCorner_FarLeftTop,
|
||||
nzCorner_FarRightBottom,
|
||||
nzCorner_FarRightTop,
|
||||
nzCorner_NearLeftBottom,
|
||||
nzCorner_NearLeftTop,
|
||||
nzCorner_NearRightBottom,
|
||||
nzCorner_NearRightTop,
|
||||
nzBoxCorner_FarLeftBottom,
|
||||
nzBoxCorner_FarLeftTop,
|
||||
nzBoxCorner_FarRightBottom,
|
||||
nzBoxCorner_FarRightTop,
|
||||
nzBoxCorner_NearLeftBottom,
|
||||
nzBoxCorner_NearLeftTop,
|
||||
nzBoxCorner_NearRightBottom,
|
||||
nzBoxCorner_NearRightTop,
|
||||
|
||||
nzCorner_Max = nzCorner_NearRightTop
|
||||
nzBoxCorner_Max = nzBoxCorner_NearRightTop
|
||||
};
|
||||
|
||||
enum nzExtend
|
||||
|
|
@ -51,4 +51,14 @@ enum nzIntersectionSide
|
|||
nzIntersectionSide_Max = nzIntersectionSide_Outside
|
||||
};
|
||||
|
||||
enum nzRectCorner
|
||||
{
|
||||
nzRectCorner_LeftBottom,
|
||||
nzRectCorner_LeftTop,
|
||||
nzRectCorner_RightBottom,
|
||||
nzRectCorner_RightTop,
|
||||
|
||||
nzRectCorner_Max = nzRectCorner_RightTop
|
||||
};
|
||||
|
||||
#endif // NAZARA_ENUMS_MATH_HPP
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class NzFrustum
|
|||
NzFrustum& Extract(const NzMatrix4<T>& clipMatrix);
|
||||
NzFrustum& Extract(const NzMatrix4<T>& view, const NzMatrix4<T>& projection);
|
||||
|
||||
const NzVector3<T>& GetCorner(nzCorner corner) const;
|
||||
const NzVector3<T>& GetCorner(nzBoxCorner corner) const;
|
||||
const NzPlane<T>& GetPlane(nzFrustumPlane plane) const;
|
||||
|
||||
nzIntersectionSide Intersect(const NzBoundingVolume<T>& volume) const;
|
||||
|
|
@ -52,7 +52,7 @@ class NzFrustum
|
|||
NzString ToString() const;
|
||||
|
||||
private:
|
||||
NzVector3<T> m_corners[nzCorner_Max+1];
|
||||
NzVector3<T> m_corners[nzBoxCorner_Max+1];
|
||||
NzPlane<T> m_planes[nzFrustumPlane_Max+1];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -44,23 +44,23 @@ NzFrustum<T>& NzFrustum<T>::Build(T angle, T ratio, T zNear, T zFar, const NzVec
|
|||
NzVector3<T> fc = eye + f * zFar;
|
||||
|
||||
// Calcul du frustum
|
||||
m_corners[nzCorner_FarLeftBottom] = fc - u*farH - s*farW;
|
||||
m_corners[nzCorner_FarLeftTop] = fc + u*farH - s*farW;
|
||||
m_corners[nzCorner_FarRightTop] = fc + u*farH + s*farW;
|
||||
m_corners[nzCorner_FarRightBottom] = fc - u*farH + s*farW;
|
||||
m_corners[nzBoxCorner_FarLeftBottom] = fc - u*farH - s*farW;
|
||||
m_corners[nzBoxCorner_FarLeftTop] = fc + u*farH - s*farW;
|
||||
m_corners[nzBoxCorner_FarRightTop] = fc + u*farH + s*farW;
|
||||
m_corners[nzBoxCorner_FarRightBottom] = fc - u*farH + s*farW;
|
||||
|
||||
m_corners[nzCorner_NearLeftBottom] = nc - u*nearH - s*nearW;
|
||||
m_corners[nzCorner_NearLeftTop] = nc + u*nearH - s*nearW;
|
||||
m_corners[nzCorner_NearRightTop] = nc + u*nearH + s*nearW;
|
||||
m_corners[nzCorner_NearRightBottom] = nc - u*nearH + s*nearW;
|
||||
m_corners[nzBoxCorner_NearLeftBottom] = nc - u*nearH - s*nearW;
|
||||
m_corners[nzBoxCorner_NearLeftTop] = nc + u*nearH - s*nearW;
|
||||
m_corners[nzBoxCorner_NearRightTop] = nc + u*nearH + s*nearW;
|
||||
m_corners[nzBoxCorner_NearRightBottom] = nc - u*nearH + s*nearW;
|
||||
|
||||
// Construction des plans du frustum
|
||||
m_planes[nzFrustumPlane_Bottom].Set(m_corners[nzCorner_NearLeftBottom], m_corners[nzCorner_NearRightBottom], m_corners[nzCorner_FarRightBottom]);
|
||||
m_planes[nzFrustumPlane_Far].Set(m_corners[nzCorner_FarRightTop], m_corners[nzCorner_FarLeftTop], m_corners[nzCorner_FarLeftBottom]);
|
||||
m_planes[nzFrustumPlane_Left].Set(m_corners[nzCorner_NearLeftTop], m_corners[nzCorner_NearLeftBottom], m_corners[nzCorner_FarLeftBottom]);
|
||||
m_planes[nzFrustumPlane_Near].Set(m_corners[nzCorner_NearLeftTop], m_corners[nzCorner_NearRightTop], m_corners[nzCorner_NearRightBottom]);
|
||||
m_planes[nzFrustumPlane_Right].Set(m_corners[nzCorner_NearRightBottom], m_corners[nzCorner_NearRightTop], m_corners[nzCorner_FarRightBottom]);
|
||||
m_planes[nzFrustumPlane_Top].Set(m_corners[nzCorner_NearRightTop], m_corners[nzCorner_NearLeftTop], m_corners[nzCorner_FarLeftTop]);
|
||||
m_planes[nzFrustumPlane_Bottom].Set(m_corners[nzBoxCorner_NearLeftBottom], m_corners[nzBoxCorner_NearRightBottom], m_corners[nzBoxCorner_FarRightBottom]);
|
||||
m_planes[nzFrustumPlane_Far].Set(m_corners[nzBoxCorner_FarRightTop], m_corners[nzBoxCorner_FarLeftTop], m_corners[nzBoxCorner_FarLeftBottom]);
|
||||
m_planes[nzFrustumPlane_Left].Set(m_corners[nzBoxCorner_NearLeftTop], m_corners[nzBoxCorner_NearLeftBottom], m_corners[nzBoxCorner_FarLeftBottom]);
|
||||
m_planes[nzFrustumPlane_Near].Set(m_corners[nzBoxCorner_NearLeftTop], m_corners[nzBoxCorner_NearRightTop], m_corners[nzBoxCorner_NearRightBottom]);
|
||||
m_planes[nzFrustumPlane_Right].Set(m_corners[nzBoxCorner_NearRightBottom], m_corners[nzBoxCorner_NearRightTop], m_corners[nzBoxCorner_FarRightBottom]);
|
||||
m_planes[nzFrustumPlane_Top].Set(m_corners[nzBoxCorner_NearRightTop], m_corners[nzBoxCorner_NearLeftTop], m_corners[nzBoxCorner_FarLeftTop]);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -272,56 +272,56 @@ NzFrustum<T>& NzFrustum<T>::Extract(const NzMatrix4<T>& clipMatrix)
|
|||
corner = invClipMatrix.Transform(corner);
|
||||
corner.Normalize();
|
||||
|
||||
m_corners[nzCorner_FarLeftBottom] = NzVector3<T>(corner.x, corner.y, corner.z);
|
||||
m_corners[nzBoxCorner_FarLeftBottom] = NzVector3<T>(corner.x, corner.y, corner.z);
|
||||
|
||||
// FarLeftTop
|
||||
corner.Set(F(-1.0), F(1.0), F(1.0));
|
||||
corner = invClipMatrix.Transform(corner);
|
||||
corner.Normalize();
|
||||
|
||||
m_corners[nzCorner_FarLeftTop] = NzVector3<T>(corner.x, corner.y, corner.z);
|
||||
m_corners[nzBoxCorner_FarLeftTop] = NzVector3<T>(corner.x, corner.y, corner.z);
|
||||
|
||||
// FarRightBottom
|
||||
corner.Set(F(1.0), F(-1.0), F(1.0));
|
||||
corner = invClipMatrix.Transform(corner);
|
||||
corner.Normalize();
|
||||
|
||||
m_corners[nzCorner_FarRightBottom] = NzVector3<T>(corner.x, corner.y, corner.z);
|
||||
m_corners[nzBoxCorner_FarRightBottom] = NzVector3<T>(corner.x, corner.y, corner.z);
|
||||
|
||||
// FarRightTop
|
||||
corner.Set(F(1.0), F(1.0), F(1.0));
|
||||
corner = invClipMatrix.Transform(corner);
|
||||
corner.Normalize();
|
||||
|
||||
m_corners[nzCorner_FarRightTop] = NzVector3<T>(corner.x, corner.y, corner.z);
|
||||
m_corners[nzBoxCorner_FarRightTop] = NzVector3<T>(corner.x, corner.y, corner.z);
|
||||
|
||||
// NearLeftBottom
|
||||
corner.Set(F(-1.0), F(-1.0), F(0.0));
|
||||
corner = invClipMatrix.Transform(corner);
|
||||
corner.Normalize();
|
||||
|
||||
m_corners[nzCorner_NearLeftBottom] = NzVector3<T>(corner.x, corner.y, corner.z);
|
||||
m_corners[nzBoxCorner_NearLeftBottom] = NzVector3<T>(corner.x, corner.y, corner.z);
|
||||
|
||||
// NearLeftTop
|
||||
corner.Set(F(-1.0), F(1.0), F(0.0));
|
||||
corner = invClipMatrix.Transform(corner);
|
||||
corner.Normalize();
|
||||
|
||||
m_corners[nzCorner_NearLeftTop] = NzVector3<T>(corner.x, corner.y, corner.z);
|
||||
m_corners[nzBoxCorner_NearLeftTop] = NzVector3<T>(corner.x, corner.y, corner.z);
|
||||
|
||||
// NearRightBottom
|
||||
corner.Set(F(1.0), F(-1.0), F(0.0));
|
||||
corner = invClipMatrix.Transform(corner);
|
||||
corner.Normalize();
|
||||
|
||||
m_corners[nzCorner_NearRightBottom] = NzVector3<T>(corner.x, corner.y, corner.z);
|
||||
m_corners[nzBoxCorner_NearRightBottom] = NzVector3<T>(corner.x, corner.y, corner.z);
|
||||
|
||||
// NearRightTop
|
||||
corner.Set(F(1.0), F(1.0), F(0.0));
|
||||
corner = invClipMatrix.Transform(corner);
|
||||
corner.Normalize();
|
||||
|
||||
m_corners[nzCorner_NearRightTop] = NzVector3<T>(corner.x, corner.y, corner.z);
|
||||
m_corners[nzBoxCorner_NearRightTop] = NzVector3<T>(corner.x, corner.y, corner.z);
|
||||
}
|
||||
else
|
||||
NazaraWarning("Clip matrix is not invertible, failed to compute frustum corners");
|
||||
|
|
@ -339,10 +339,10 @@ NzFrustum<T>& NzFrustum<T>::Extract(const NzMatrix4<T>& view, const NzMatrix4<T>
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
const NzVector3<T>& NzFrustum<T>::GetCorner(nzCorner corner) const
|
||||
const NzVector3<T>& NzFrustum<T>::GetCorner(nzBoxCorner corner) const
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (corner > nzCorner_Max)
|
||||
if (corner > nzBoxCorner_Max)
|
||||
{
|
||||
NazaraError("Corner not handled (0x" + NzString::Number(corner, 16) + ')');
|
||||
|
||||
|
|
@ -481,7 +481,7 @@ template<typename T>
|
|||
template<typename U>
|
||||
NzFrustum<T>& NzFrustum<T>::Set(const NzFrustum<U>& frustum)
|
||||
{
|
||||
for (unsigned int i = 0; i <= nzCorner_Max; ++i)
|
||||
for (unsigned int i = 0; i <= nzBoxCorner_Max; ++i)
|
||||
m_corners[i].Set(frustum.m_corners[i]);
|
||||
|
||||
for (unsigned int i = 0; i <= nzFrustumPlane_Max; ++i)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class NzOrientedBox
|
|||
NzOrientedBox(const NzOrientedBox& orientedBox) = default;
|
||||
~NzOrientedBox() = default;
|
||||
|
||||
const NzVector3<T>& GetCorner(nzCorner corner) const;
|
||||
const NzVector3<T>& GetCorner(nzBoxCorner corner) const;
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ class NzOrientedBox
|
|||
NzBox<T> localBox;
|
||||
|
||||
private:
|
||||
NzVector3<T> m_corners[nzCorner_Max+1]; // Ne peuvent pas être modifiés directement
|
||||
NzVector3<T> m_corners[nzBoxCorner_Max+1]; // Ne peuvent pas être modifiés directement
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@ NzOrientedBox<T>::NzOrientedBox(const NzOrientedBox<U>& orientedBox)
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
const NzVector3<T>& NzOrientedBox<T>::GetCorner(nzCorner corner) const
|
||||
const NzVector3<T>& NzOrientedBox<T>::GetCorner(nzBoxCorner corner) const
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (corner > nzCorner_Max)
|
||||
if (corner > nzBoxCorner_Max)
|
||||
{
|
||||
NazaraError("Corner not handled (0x" + NzString::Number(corner, 16) + ')');
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ template<typename T>
|
|||
template<typename U>
|
||||
NzOrientedBox<T>& NzOrientedBox<T>::Set(const NzOrientedBox<U>& orientedBox)
|
||||
{
|
||||
for (unsigned int i = 0; i <= nzCorner_Max; ++i)
|
||||
for (unsigned int i = 0; i <= nzBoxCorner_Max; ++i)
|
||||
m_corners[i].Set(orientedBox.m_corners[i]);
|
||||
|
||||
localBox = orientedBox.localBox;
|
||||
|
|
@ -115,21 +115,21 @@ NzString NzOrientedBox<T>::ToString() const
|
|||
{
|
||||
NzStringStream ss;
|
||||
|
||||
return ss << "OrientedBox(FLB: " << m_corners[nzCorner_FarLeftBottom].ToString() << "\n"
|
||||
<< " FLT: " << m_corners[nzCorner_FarLeftTop].ToString() << "\n"
|
||||
<< " FRB: " << m_corners[nzCorner_FarRightBottom].ToString() << "\n"
|
||||
<< " FRT: " << m_corners[nzCorner_FarRightTop].ToString() << "\n"
|
||||
<< " NLB: " << m_corners[nzCorner_NearLeftBottom].ToString() << "\n"
|
||||
<< " NLT: " << m_corners[nzCorner_NearLeftTop].ToString() << "\n"
|
||||
<< " NRB: " << m_corners[nzCorner_NearRightBottom].ToString() << "\n"
|
||||
<< " NRT: " << m_corners[nzCorner_NearRightTop].ToString() << ")\n";
|
||||
return ss << "OrientedBox(FLB: " << m_corners[nzBoxCorner_FarLeftBottom].ToString() << "\n"
|
||||
<< " FLT: " << m_corners[nzBoxCorner_FarLeftTop].ToString() << "\n"
|
||||
<< " FRB: " << m_corners[nzBoxCorner_FarRightBottom].ToString() << "\n"
|
||||
<< " FRT: " << m_corners[nzBoxCorner_FarRightTop].ToString() << "\n"
|
||||
<< " NLB: " << m_corners[nzBoxCorner_NearLeftBottom].ToString() << "\n"
|
||||
<< " NLT: " << m_corners[nzBoxCorner_NearLeftTop].ToString() << "\n"
|
||||
<< " NRB: " << m_corners[nzBoxCorner_NearRightBottom].ToString() << "\n"
|
||||
<< " NRT: " << m_corners[nzBoxCorner_NearRightTop].ToString() << ")\n";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void NzOrientedBox<T>::Update(const NzMatrix4<T>& transformMatrix)
|
||||
{
|
||||
for (unsigned int i = 0; i <= nzCorner_Max; ++i)
|
||||
m_corners[i] = transformMatrix.Transform(localBox.GetCorner(static_cast<nzCorner>(i)));
|
||||
for (unsigned int i = 0; i <= nzBoxCorner_Max; ++i)
|
||||
m_corners[i] = transformMatrix.Transform(localBox.GetCorner(static_cast<nzBoxCorner>(i)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -148,7 +148,7 @@ template<typename T>
|
|||
NzVector3<T>& NzOrientedBox<T>::operator()(unsigned int i)
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (i > nzCorner_Max)
|
||||
if (i > nzBoxCorner_Max)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << "Index out of range: (" << i << " >= 3)";
|
||||
|
|
@ -165,7 +165,7 @@ template<typename T>
|
|||
NzVector3<T> NzOrientedBox<T>::operator()(unsigned int i) const
|
||||
{
|
||||
#if NAZARA_MATH_SAFE
|
||||
if (i > nzCorner_Max)
|
||||
if (i > nzBoxCorner_Max)
|
||||
{
|
||||
NzStringStream ss;
|
||||
ss << "Index out of range: (" << i << " >= 3)";
|
||||
|
|
|
|||
|
|
@ -204,9 +204,9 @@ bool NzRay<T>::Intersect(const NzBox<T>& box, const NzMatrix4<T>& transform, T*
|
|||
template<typename T>
|
||||
bool NzRay<T>::Intersect(const NzOrientedBox<T>& orientedBox, T* closestHit, T* farthestHit) const
|
||||
{
|
||||
NzVector3<T> width = (orientedBox.GetCorner(nzCorner_NearLeftBottom) - orientedBox.GetCorner(nzCorner_FarLeftBottom)).Normalize();
|
||||
NzVector3<T> height = (orientedBox.GetCorner(nzCorner_FarLeftTop) - orientedBox.GetCorner(nzCorner_FarLeftBottom)).Normalize();
|
||||
NzVector3<T> depth = (orientedBox.GetCorner(nzCorner_FarRightBottom) - orientedBox.GetCorner(nzCorner_FarLeftBottom)).Normalize();
|
||||
NzVector3<T> width = (orientedBox.GetCorner(nzBoxCorner_NearLeftBottom) - orientedBox.GetCorner(nzBoxCorner_FarLeftBottom)).Normalize();
|
||||
NzVector3<T> height = (orientedBox.GetCorner(nzBoxCorner_FarLeftTop) - orientedBox.GetCorner(nzBoxCorner_FarLeftBottom)).Normalize();
|
||||
NzVector3<T> depth = (orientedBox.GetCorner(nzBoxCorner_FarRightBottom) - orientedBox.GetCorner(nzBoxCorner_FarLeftBottom)).Normalize();
|
||||
|
||||
// Construction de la matrice de transformation de l'OBB
|
||||
NzMatrix4<T> matrix(width.x, height.x, depth.x, F(0.0),
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#define NAZARA_RECT_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Enums.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -33,6 +34,7 @@ class NzRect
|
|||
NzRect& ExtendTo(const NzRect& rect);
|
||||
|
||||
NzVector2<T> GetCenter() const;
|
||||
NzVector2<T> GetCorner(nzRectCorner corner) const;
|
||||
NzVector2<T> GetLengths() const;
|
||||
NzVector2<T> GetMaximum() const;
|
||||
NzVector2<T> GetMinimum() const;
|
||||
|
|
|
|||
|
|
@ -109,6 +109,28 @@ NzVector2<T> NzRect<T>::GetCenter() const
|
|||
return GetPosition() + GetLengths() / F(2.0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzRect<T>::GetCorner(nzRectCorner corner) const
|
||||
{
|
||||
switch (corner)
|
||||
{
|
||||
case nzRectCorner_LeftBottom:
|
||||
return NzVector2<T>(x, y + height);
|
||||
|
||||
case nzRectCorner_LeftTop:
|
||||
return NzVector2<T>(x, y);
|
||||
|
||||
case nzRectCorner_RightBottom:
|
||||
return NzVector2<T>(x + width, y + height);
|
||||
|
||||
case nzRectCorner_RightTop:
|
||||
return NzVector2<T>(x + width, y);
|
||||
}
|
||||
|
||||
NazaraError("Corner not handled (0x" + NzString::Number(corner, 16) + ')');
|
||||
return NzVector2<T>();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector2<T> NzRect<T>::GetLengths() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -159,64 +159,64 @@ void NzDebugDrawer::Draw(const NzFrustumf& frustum)
|
|||
NzBufferMapper<NzVertexBuffer> mapper(s_vertexBuffer, nzBufferAccess_DiscardAndWrite, 0, 24);
|
||||
NzVertexStruct_XYZ* vertex = reinterpret_cast<NzVertexStruct_XYZ*>(mapper.GetPointer());
|
||||
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_NearLeftBottom));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_NearLeftBottom));
|
||||
vertex++;
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_NearRightBottom));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_NearRightBottom));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_NearLeftBottom));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_NearLeftBottom));
|
||||
vertex++;
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_NearLeftTop));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_NearLeftTop));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_NearLeftBottom));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_NearLeftBottom));
|
||||
vertex++;
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_FarLeftBottom));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_FarLeftBottom));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_FarRightTop));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_FarRightTop));
|
||||
vertex++;
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_FarLeftTop));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_FarLeftTop));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_FarRightTop));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_FarRightTop));
|
||||
vertex++;
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_FarRightBottom));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_FarRightBottom));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_FarRightTop));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_FarRightTop));
|
||||
vertex++;
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_NearRightTop));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_NearRightTop));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_FarLeftBottom));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_FarLeftBottom));
|
||||
vertex++;
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_FarRightBottom));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_FarRightBottom));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_FarLeftBottom));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_FarLeftBottom));
|
||||
vertex++;
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_FarLeftTop));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_FarLeftTop));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_NearLeftTop));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_NearLeftTop));
|
||||
vertex++;
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_NearRightTop));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_NearRightTop));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_NearLeftTop));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_NearLeftTop));
|
||||
vertex++;
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_FarLeftTop));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_FarLeftTop));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_NearRightBottom));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_NearRightBottom));
|
||||
vertex++;
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_NearRightTop));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_NearRightTop));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_NearRightBottom));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_NearRightBottom));
|
||||
vertex++;
|
||||
vertex->position.Set(frustum.GetCorner(nzCorner_FarRightBottom));
|
||||
vertex->position.Set(frustum.GetCorner(nzBoxCorner_FarRightBottom));
|
||||
vertex++;
|
||||
|
||||
mapper.Unmap();
|
||||
|
|
@ -241,64 +241,64 @@ void NzDebugDrawer::Draw(const NzOrientedBoxf& orientedBox)
|
|||
NzBufferMapper<NzVertexBuffer> mapper(s_vertexBuffer, nzBufferAccess_DiscardAndWrite, 0, 24);
|
||||
NzVertexStruct_XYZ* vertex = reinterpret_cast<NzVertexStruct_XYZ*>(mapper.GetPointer());
|
||||
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearLeftBottom));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_NearLeftBottom));
|
||||
vertex++;
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearRightBottom));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_NearRightBottom));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearLeftBottom));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_NearLeftBottom));
|
||||
vertex++;
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearLeftTop));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_NearLeftTop));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearLeftBottom));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_NearLeftBottom));
|
||||
vertex++;
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarLeftBottom));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_FarLeftBottom));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarRightTop));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_FarRightTop));
|
||||
vertex++;
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarLeftTop));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_FarLeftTop));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarRightTop));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_FarRightTop));
|
||||
vertex++;
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarRightBottom));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_FarRightBottom));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarRightTop));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_FarRightTop));
|
||||
vertex++;
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearRightTop));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_NearRightTop));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarLeftBottom));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_FarLeftBottom));
|
||||
vertex++;
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarRightBottom));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_FarRightBottom));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarLeftBottom));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_FarLeftBottom));
|
||||
vertex++;
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarLeftTop));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_FarLeftTop));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearLeftTop));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_NearLeftTop));
|
||||
vertex++;
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearRightTop));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_NearRightTop));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearLeftTop));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_NearLeftTop));
|
||||
vertex++;
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarLeftTop));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_FarLeftTop));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearRightBottom));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_NearRightBottom));
|
||||
vertex++;
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearRightTop));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_NearRightTop));
|
||||
vertex++;
|
||||
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearRightBottom));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_NearRightBottom));
|
||||
vertex++;
|
||||
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarRightBottom));
|
||||
vertex->position.Set(orientedBox.GetCorner(nzBoxCorner_FarRightBottom));
|
||||
vertex++;
|
||||
|
||||
mapper.Unmap();
|
||||
|
|
|
|||
Loading…
Reference in New Issue