Fix code style

This commit is contained in:
Wojtek Figat
2021-01-24 14:01:42 +01:00
parent 2563409e6f
commit f1819ee35c
2 changed files with 10 additions and 21 deletions

View File

@@ -15,7 +15,7 @@ void CollisionsHelper::ClosestPointPointLine(const Vector2& point, const Vector2
Vector2 n = p1 - p0;
const float length = n.Length();
if (length < 1e-10)
if (length < 1e-10f)
{
// Both points are the same, just give any
result = p0;
@@ -24,7 +24,7 @@ void CollisionsHelper::ClosestPointPointLine(const Vector2& point, const Vector2
n /= length;
const float dot = Vector2::Dot(n, p);
if (dot <= 0.0)
if (dot <= 0.0f)
{
// Before first point
result = p0;
@@ -48,25 +48,24 @@ Vector2 CollisionsHelper::ClosestPointPointLine(const Vector2& point, const Vect
return result;
}
void CollisionsHelper::ClosestPointPointLine(const Vector3& point, const Vector3& p0, const Vector3& p1, Vector3& result)
{
const Vector3 p = point - p0;
Vector3 n = p1 - p0;
const float length = n.Length();
if (length < 1e-10)
if (length < 1e-10f)
{
result = p0;
return;
}
n /= length;
const float dot = Vector3::Dot(n, p);
if (dot <= 0.0)
if (dot <= 0.0f)
{
result = p0;
return;
}
else if (dot >= length)
if (dot >= length)
{
result = p1;
return;
@@ -903,7 +902,6 @@ bool CollisionsHelper::RayIntersectsBox(const Ray& ray, const BoundingBox& box,
d = Math::Abs(size.Z - Math::Abs(localPoint.Z));
if (d < dMin)
{
dMin = d;
normal = Vector3(0, 0, Math::Sign(localPoint.Z));
}
@@ -1072,15 +1070,11 @@ PlaneIntersectionType CollisionsHelper::PlaneIntersectsBox(const Plane& plane, c
min.Z = plane.Normal.Z >= 0.0f ? box.Maximum.Z : box.Minimum.Z;
float distance = Vector3::Dot(plane.Normal, max);
if (distance + plane.D > Plane::DistanceEpsilon)
return PlaneIntersectionType::Front;
distance = Vector3::Dot(plane.Normal, min);
if (distance + plane.D < Plane::DistanceEpsilon)
return PlaneIntersectionType::Back;
return PlaneIntersectionType::Intersecting;
}
@@ -1094,10 +1088,8 @@ PlaneIntersectionType CollisionsHelper::PlaneIntersectsSphere(const Plane& plane
if (distance > sphere.Radius)
return PlaneIntersectionType::Front;
if (distance < -sphere.Radius)
return PlaneIntersectionType::Back;
return PlaneIntersectionType::Intersecting;
}
@@ -1105,13 +1097,10 @@ bool CollisionsHelper::BoxIntersectsBox(const BoundingBox& box1, const BoundingB
{
if (box1.Minimum.X > box2.Maximum.X || box2.Minimum.X > box1.Maximum.X)
return false;
if (box1.Minimum.Y > box2.Maximum.Y || box2.Minimum.Y > box1.Maximum.Y)
return false;
if (box1.Minimum.Z > box2.Maximum.Z || box2.Minimum.Z > box1.Maximum.Z)
return false;
return true;
}

View File

@@ -126,7 +126,7 @@ public:
/// <param name="point">The point to test.</param>
/// <param name="result">When the method completes, contains the closest point between the two objects.</param>
static void ClosestPointPlanePoint(const Plane& plane, const Vector3& point, Vector3& result);
/// <summary>
/// Determines the closest point between a <see cref="Plane" /> and a point.
/// </summary>
@@ -142,7 +142,7 @@ public:
/// <param name="point">The point to test.</param>
/// <param name="result">When the method completes, contains the closest point between the two objects.</param>
static void ClosestPointBoxPoint(const BoundingBox& box, const Vector3& point, Vector3& result);
/// <summary>
/// Determines the closest point between a <see cref="BoundingBox" /> and a point.
/// </summary>
@@ -158,7 +158,7 @@ public:
/// <param name="point">The point to test.</param>
/// <param name="result">When the method completes, contains the closest point between the two objects.</param>
static void ClosestPointRectanglePoint(const Rectangle& rect, const Vector2& point, Vector2& result);
/// <summary>
/// Determines the closest point between a <see cref="Rectangle" /> and a point.
/// </summary>
@@ -174,7 +174,7 @@ public:
/// <param name="point">The point to test.</param>
/// <param name="result">When the method completes, contains the closest point between the two objects; or, if the point is directly in the center of the sphere, contains <see cref="Vector3.Zero" />.</param>
static void ClosestPointSpherePoint(const BoundingSphere& sphere, const Vector3& point, Vector3& result);
/// <summary>
/// Determines the closest point between a <see cref="BoundingSphere" /> and a point.
/// </summary>
@@ -195,7 +195,7 @@ public:
/// intersection.
/// </remarks>
static void ClosestPointSphereSphere(const BoundingSphere& sphere1, const BoundingSphere& sphere2, Vector3& result);
/// <summary>
/// Determines the closest point between a <see cref="BoundingSphere" /> and a <see cref="BoundingSphere" />.
/// </summary>