Optimize BoundingSphere.Intersects to be inlined by the compiler

This commit is contained in:
Wojtek Figat
2024-04-11 15:58:34 +02:00
parent 890b2da108
commit 4e65b76b8c
2 changed files with 8 additions and 4 deletions

View File

@@ -51,7 +51,11 @@ bool BoundingSphere::Intersects(const BoundingBox& box) const
bool BoundingSphere::Intersects(const BoundingSphere& sphere) const
{
return CollisionsHelper::SphereIntersectsSphere(*this, sphere);
const Real radiisum = Radius + sphere.Radius;
const Real x = Center.X - sphere.Center.X;
const Real y = Center.Y - sphere.Center.Y;
const Real z = Center.Z - sphere.Center.Z;
return x * x + y * y + z * z <= radiisum * radiisum;
}
ContainmentType BoundingSphere::Contains(const Vector3& point) const