Optimize BoundingFrustum::Intersects(BoundingSphere)
This commit is contained in:
@@ -178,3 +178,14 @@ ContainmentType BoundingFrustum::Contains(const BoundingSphere& sphere) const
|
||||
return ContainmentType::Contains;
|
||||
}
|
||||
}
|
||||
|
||||
bool BoundingFrustum::Intersects(const BoundingSphere& sphere) const
|
||||
{
|
||||
for (int32 i = 0; i < 6; i++)
|
||||
{
|
||||
const Real distance = Vector3::Dot(_planes[i].Normal, sphere.Center) + _planes[i].D;
|
||||
if (distance < -sphere.Radius)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -235,10 +235,7 @@ public:
|
||||
/// </summary>
|
||||
/// <param name="sphere">The sphere.</param>
|
||||
/// <returns>True if the current BoundingFrustum intersects a BoundingSphere, otherwise false.</returns>
|
||||
FORCE_INLINE bool Intersects(const BoundingSphere& sphere) const
|
||||
{
|
||||
return Contains(sphere) != ContainmentType::Disjoint;
|
||||
}
|
||||
bool Intersects(const BoundingSphere& sphere) const;
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the current BoundingFrustum intersects a BoundingBox.
|
||||
|
||||
@@ -907,6 +907,7 @@ namespace FlaxEngine
|
||||
/// <param name="left">First source vector.</param>
|
||||
/// <param name="right">Second source vector.</param>
|
||||
/// <param name="result">When the method completes, contains the dot product of the two vectors.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Dot(ref Vector3 left, ref Vector3 right, out Real result)
|
||||
{
|
||||
result = left.X * right.X + left.Y * right.Y + left.Z * right.Z;
|
||||
@@ -918,6 +919,7 @@ namespace FlaxEngine
|
||||
/// <param name="left">First source vector.</param>
|
||||
/// <param name="right">Second source vector.</param>
|
||||
/// <returns>The dot product of the two vectors.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Real Dot(ref Vector3 left, ref Vector3 right)
|
||||
{
|
||||
return left.X * right.X + left.Y * right.Y + left.Z * right.Z;
|
||||
@@ -929,6 +931,7 @@ namespace FlaxEngine
|
||||
/// <param name="left">First source vector.</param>
|
||||
/// <param name="right">Second source vector.</param>
|
||||
/// <returns>The dot product of the two vectors.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Real Dot(Vector3 left, Vector3 right)
|
||||
{
|
||||
return left.X * right.X + left.Y * right.Y + left.Z * right.Z;
|
||||
|
||||
@@ -622,7 +622,7 @@ public:
|
||||
}
|
||||
|
||||
// dot product with another vector
|
||||
static T Dot(const Vector3Base& a, const Vector3Base& b)
|
||||
FORCE_INLINE static T Dot(const Vector3Base& a, const Vector3Base& b)
|
||||
{
|
||||
return a.X * b.X + a.Y * b.Y + a.Z * b.Z;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user