Bugfix
This commit is contained in:
@@ -86,6 +86,16 @@ namespace OpenVulkano::Math
|
|||||||
return Range<T>::min + (GetDiagonal() * 0.5f);
|
return Range<T>::min + (GetDiagonal() * 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool Covers(const AABB_T& other) const
|
||||||
|
{
|
||||||
|
return other.IsCovered(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool IsCovered(const AABB_T& other) const
|
||||||
|
{
|
||||||
|
return Math::Utils::all(Math::Utils::greaterThanEqual(other.GetMax(), Range<T>::max)) && Math::Utils::all(Math::Utils::greaterThanEqual(Range<T>::min, other.GetMin()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Checks if the AABB overlaps with another AABB
|
* \brief Checks if the AABB overlaps with another AABB
|
||||||
* \param other The other AABB that should be checked
|
* \param other The other AABB that should be checked
|
||||||
@@ -93,9 +103,7 @@ namespace OpenVulkano::Math
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] bool IsOverlapping(const AABB_T& other) const
|
[[nodiscard]] bool IsOverlapping(const AABB_T& other) const
|
||||||
{
|
{
|
||||||
//return !(other.min.x > max.x || other.max.x < min.x || other.min.y > max.y ||
|
return Math::Utils::all(Math::Utils::lessThanEqual(Range<T>::min, other.GetMax())) && Math::Utils::all(Math::Utils::greaterThanEqual(Range<T>::max, other.GetMin()));
|
||||||
// other.max.y < min.y || other.min.z > max.z || other.max.z < min.z);
|
|
||||||
return Math::Utils::any(Math::Utils::greaterThan(Range<T>::min, other.GetMin())) || Math::Utils::any(Math::Utils::lessThan(other.GetMax(), Range<T>::max));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool InBounds(const T& position) const
|
[[nodiscard]] bool InBounds(const T& position) const
|
||||||
|
|||||||
@@ -170,31 +170,34 @@ namespace OpenVulkano::Scene
|
|||||||
|
|
||||||
if (roots == 0) return 0;
|
if (roots == 0) return 0;
|
||||||
SortPair(x1, x2);
|
SortPair(x1, x2);
|
||||||
|
bool calcP2 = false;
|
||||||
if (roots == 1)
|
if (roots == 1)
|
||||||
{
|
{
|
||||||
if (x1 < 0) return 0; // ray intersects sphere behind the origin
|
if (x1 < 0) return 0; // ray intersects sphere behind the origin
|
||||||
p2 = p1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (x1 < 0 && x2 < 0) return 0; // ray intersects sphere behind the origin
|
if (x1 < 0 && x2 < 0) return 0; // ray intersects sphere behind the origin
|
||||||
if (x1 >= 0 && x2 >= 0)
|
if (x1 >= 0 && x2 >= 0)
|
||||||
{
|
{
|
||||||
p2.point = m_origin + x2 * m_dir;
|
calcP2 = true;
|
||||||
p2.distance2 = distance2(m_origin, p2.point);
|
|
||||||
p2.normal = normalize(p2.point - center);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
--roots;
|
--roots;
|
||||||
if (x1 < 0) x1 = x2;
|
if (x1 < 0) x1 = x2;
|
||||||
p2 = p1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p1.point = m_origin + x1 * m_dir;
|
p1.point = m_origin + x1 * m_dir;
|
||||||
p1.distance2 = distance2(m_origin, p1.point);
|
p1.distance2 = distance2(m_origin, p1.point);
|
||||||
p1.normal = normalize(p1.point - center);
|
p1.normal = normalize(p1.point - center);
|
||||||
|
if (calcP2)
|
||||||
|
{
|
||||||
|
p2.point = m_origin + x2 * m_dir;
|
||||||
|
p2.distance2 = distance2(m_origin, p2.point);
|
||||||
|
p2.normal = normalize(p2.point - center);
|
||||||
|
}
|
||||||
|
else p2 = p1;
|
||||||
return roots;
|
return roots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user