Fixes unit tests

This commit is contained in:
SirLynix
2022-12-18 17:08:03 +01:00
parent 5ca7b398c2
commit 46fe1c550c
8 changed files with 15 additions and 69 deletions

View File

@@ -41,7 +41,6 @@ namespace Nz
bool Intersect(const BoundingVolume<T>& volume, T* closestHit = nullptr, T* furthestHit = nullptr) const;
bool Intersect(const Box<T>& box, T* closestHit = nullptr, T* furthestHit = nullptr) const;
bool Intersect(const Box<T>& box, const Matrix4<T>& transform, T* closestHit = nullptr, T* furthestHit = nullptr) const;
bool Intersect(const OrientedBox<T>& orientedBox, T* closestHit = nullptr, T* furthestHit = nullptr) const;
bool Intersect(const Plane<T>& plane, T* hit = nullptr) const;
bool Intersect(const Sphere<T>& sphere, T* closestHit = nullptr, T* furthestHit = nullptr) const;
bool Intersect(const Vector3<T>& firstPoint, const Vector3<T>& secondPoint, const Vector3<T>& thirdPoint, T* hit = nullptr) const;

View File

@@ -308,44 +308,6 @@ namespace Nz
return true;
}
/*!
* \brief Checks whether or not this ray intersects with the OrientedBox
* \return true if it intersects
*
* \param orientedBox OrientedBox to check
* \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
*
* \see Intersect
*/
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> 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,
width.y, height.y, depth.y, corner.y,
width.z, height.z, depth.z, corner.z,
T(0.0), T(0.0), T(0.0), T(1.0));
matrix.InverseTransform();
corner = matrix.Transform(corner);
oppositeCorner = matrix.Transform(oppositeCorner);
Box<T> tmpBox(corner, oppositeCorner);
Ray<T> tmpRay(matrix.Transform(origin), matrix.Transform(direction));
return tmpRay.Intersect(tmpBox, closestHit, furthestHit);
}
/*!
* \brief Checks whether or not this ray intersects with the plane
* \return true if it intersects