Fix code quality issues detected by PVS-Studio

This commit is contained in:
Wojtek Figat
2021-09-04 16:57:28 +02:00
parent 9c76d0c3cb
commit 53022ff013
30 changed files with 102 additions and 135 deletions

View File

@@ -123,7 +123,7 @@ public:
/// Sets the size of the box.
/// </summary>
/// <param name="value">The box size to set.</param>
void SetSize(const Vector3 value)
void SetSize(const Vector3& value)
{
Vector3 center;
GetCenter(center);

View File

@@ -1221,61 +1221,54 @@ ContainmentType CollisionsHelper::SphereContainsBox(const BoundingSphere& sphere
if (!BoxIntersectsSphere(box, sphere))
return ContainmentType::Disjoint;
const float radiussquared = sphere.Radius * sphere.Radius;
const float radiusSquared = sphere.Radius * sphere.Radius;
vector.X = sphere.Center.X - box.Minimum.X;
vector.Y = sphere.Center.Y - box.Maximum.Y;
vector.Z = sphere.Center.Z - box.Maximum.Z;
if (vector.LengthSquared() > radiussquared)
if (vector.LengthSquared() > radiusSquared)
return ContainmentType::Intersects;
vector.X = sphere.Center.X - box.Maximum.X;
vector.Y = sphere.Center.Y - box.Maximum.Y;
vector.Z = sphere.Center.Z - box.Maximum.Z;
if (vector.LengthSquared() > radiussquared)
if (vector.LengthSquared() > radiusSquared)
return ContainmentType::Intersects;
vector.X = sphere.Center.X - box.Maximum.X;
vector.Y = sphere.Center.Y - box.Minimum.Y;
vector.Z = sphere.Center.Z - box.Maximum.Z;
if (vector.LengthSquared() > radiussquared)
if (vector.LengthSquared() > radiusSquared)
return ContainmentType::Intersects;
vector.X = sphere.Center.X - box.Minimum.X;
vector.Y = sphere.Center.Y - box.Minimum.Y;
vector.Z = sphere.Center.Z - box.Maximum.Z;
if (vector.LengthSquared() > radiussquared)
if (vector.LengthSquared() > radiusSquared)
return ContainmentType::Intersects;
vector.X = sphere.Center.X - box.Minimum.X;
vector.Y = sphere.Center.Y - box.Maximum.Y;
vector.Z = sphere.Center.Z - box.Minimum.Z;
if (vector.LengthSquared() > radiussquared)
if (vector.LengthSquared() > radiusSquared)
return ContainmentType::Intersects;
vector.X = sphere.Center.X - box.Maximum.X;
vector.Y = sphere.Center.Y - box.Maximum.Y;
vector.Z = sphere.Center.Z - box.Minimum.Z;
if (vector.LengthSquared() > radiussquared)
if (vector.LengthSquared() > radiusSquared)
return ContainmentType::Intersects;
vector.X = sphere.Center.X - box.Maximum.X;
vector.Y = sphere.Center.Y - box.Minimum.Y;
vector.Z = sphere.Center.Z - box.Minimum.Z;
if (vector.LengthSquared() > radiussquared)
if (vector.LengthSquared() > radiusSquared)
return ContainmentType::Intersects;
vector.X = sphere.Center.X - box.Minimum.X;
vector.Y = sphere.Center.Y - box.Minimum.Y;
vector.Z = sphere.Center.Z - box.Minimum.Z;
if (vector.LengthSquared() > radiussquared)
if (vector.LengthSquared() > radiusSquared)
return ContainmentType::Intersects;
return ContainmentType::Contains;

View File

@@ -1425,61 +1425,54 @@ namespace FlaxEngine
if (!BoxIntersectsSphere(ref box, ref sphere))
return ContainmentType.Disjoint;
float radiussquared = sphere.Radius * sphere.Radius;
float radiusSquared = sphere.Radius * sphere.Radius;
vector.X = sphere.Center.X - box.Minimum.X;
vector.Y = sphere.Center.Y - box.Maximum.Y;
vector.Z = sphere.Center.Z - box.Maximum.Z;
if (vector.LengthSquared > radiussquared)
if (vector.LengthSquared > radiusSquared)
return ContainmentType.Intersects;
vector.X = sphere.Center.X - box.Maximum.X;
vector.Y = sphere.Center.Y - box.Maximum.Y;
vector.Z = sphere.Center.Z - box.Maximum.Z;
if (vector.LengthSquared > radiussquared)
if (vector.LengthSquared > radiusSquared)
return ContainmentType.Intersects;
vector.X = sphere.Center.X - box.Maximum.X;
vector.Y = sphere.Center.Y - box.Minimum.Y;
vector.Z = sphere.Center.Z - box.Maximum.Z;
if (vector.LengthSquared > radiussquared)
if (vector.LengthSquared > radiusSquared)
return ContainmentType.Intersects;
vector.X = sphere.Center.X - box.Minimum.X;
vector.Y = sphere.Center.Y - box.Minimum.Y;
vector.Z = sphere.Center.Z - box.Maximum.Z;
if (vector.LengthSquared > radiussquared)
if (vector.LengthSquared > radiusSquared)
return ContainmentType.Intersects;
vector.X = sphere.Center.X - box.Minimum.X;
vector.Y = sphere.Center.Y - box.Maximum.Y;
vector.Z = sphere.Center.Z - box.Minimum.Z;
if (vector.LengthSquared > radiussquared)
if (vector.LengthSquared > radiusSquared)
return ContainmentType.Intersects;
vector.X = sphere.Center.X - box.Maximum.X;
vector.Y = sphere.Center.Y - box.Maximum.Y;
vector.Z = sphere.Center.Z - box.Minimum.Z;
if (vector.LengthSquared > radiussquared)
if (vector.LengthSquared > radiusSquared)
return ContainmentType.Intersects;
vector.X = sphere.Center.X - box.Maximum.X;
vector.Y = sphere.Center.Y - box.Minimum.Y;
vector.Z = sphere.Center.Z - box.Minimum.Z;
if (vector.LengthSquared > radiussquared)
if (vector.LengthSquared > radiusSquared)
return ContainmentType.Intersects;
vector.X = sphere.Center.X - box.Minimum.X;
vector.Y = sphere.Center.Y - box.Minimum.Y;
vector.Z = sphere.Center.Z - box.Minimum.Z;
if (vector.LengthSquared > radiussquared)
if (vector.LengthSquared > radiusSquared)
return ContainmentType.Intersects;
return ContainmentType.Contains;