diff --git a/Source/Engine/Core/Math/BoundingSphere.cpp b/Source/Engine/Core/Math/BoundingSphere.cpp index 0b3ed6ba7..78879ffb9 100644 --- a/Source/Engine/Core/Math/BoundingSphere.cpp +++ b/Source/Engine/Core/Math/BoundingSphere.cpp @@ -122,15 +122,13 @@ void BoundingSphere::FromPoints(const Vector3* points, int32 pointsCount, Boundi void BoundingSphere::FromBox(const BoundingBox& box, BoundingSphere& result) { ASSERT(!box.Minimum.IsNanOrInfinity() && !box.Maximum.IsNanOrInfinity()); - - Vector3::Lerp(box.Minimum, box.Maximum, 0.5f, result.Center); - - const float x = box.Minimum.X - box.Maximum.X; - const float y = box.Minimum.Y - box.Maximum.Y; - const float z = box.Minimum.Z - box.Maximum.Z; - - const float distance = Math::Sqrt(x * x + y * y + z * z); - result.Radius = distance * 0.5f; + const float x = box.Maximum.X - box.Minimum.X; + const float y = box.Maximum.Y - box.Minimum.Y; + const float z = box.Maximum.Z - box.Minimum.Z; + result.Center.X = box.Minimum.X + x * 0.5f; + result.Center.Y = box.Minimum.Y + y * 0.5f; + result.Center.Z = box.Minimum.Z + z * 0.5f; + result.Radius = Math::Sqrt(x * x + y * y + z * z) * 0.5f; } void BoundingSphere::Merge(const BoundingSphere& value1, const BoundingSphere& value2, BoundingSphere& result) diff --git a/Source/Engine/Core/Math/BoundingSphere.cs b/Source/Engine/Core/Math/BoundingSphere.cs index 6f1271285..ef4f74c94 100644 --- a/Source/Engine/Core/Math/BoundingSphere.cs +++ b/Source/Engine/Core/Math/BoundingSphere.cs @@ -286,14 +286,13 @@ namespace FlaxEngine /// When the method completes, the newly constructed bounding sphere. public static void FromBox(ref BoundingBox box, out BoundingSphere result) { - Vector3.Lerp(ref box.Minimum, ref box.Maximum, 0.5f, out result.Center); - - float x = box.Minimum.X - box.Maximum.X; - float y = box.Minimum.Y - box.Maximum.Y; - float z = box.Minimum.Z - box.Maximum.Z; - - var distance = (float)Math.Sqrt(x * x + y * y + z * z); - result.Radius = distance * 0.5f; + float x = box.Maximum.X - box.Minimum.X; + float y = box.Maximum.Y - box.Minimum.Y; + float z = box.Maximum.Z - box.Minimum.Z; + result.Center.X = box.Minimum.X + x * 0.5f; + result.Center.Y = box.Minimum.Y + y * 0.5f; + result.Center.Z = box.Minimum.Z + z * 0.5f; + result.Radius = (float)Math.Sqrt(x * x + y * y + z * z) * 0.5f; } ///