< Summary

Information
Class: Gravitas.Queries.ConvexSweepHitPolicy
Assembly: Gravitas
File(s): /home/runner/work/Gravitas/Gravitas/src/Gravitas/Queries/3D/Sweeps/ConvexSweepHitPolicy.cs
Line coverage
100%
Covered lines: 25
Uncovered lines: 0
Coverable lines: 25
Total lines: 55
Line coverage: 100%
Branch coverage
100%
Covered branches: 18
Total branches: 18
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ResolveHitNormal(...)100%1818100%

File(s)

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Queries/3D/Sweeps/ConvexSweepHitPolicy.cs

#LineLine coverage
 1//=======================================================================
 2// ConvexSweepHitPolicy.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2026-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using FixedMathSharp;
 9using Gravitas.Colliders;
 10
 11namespace Gravitas.Queries;
 12
 13internal static class ConvexSweepHitPolicy
 14{
 15    internal static Vector3d ResolveHitNormal(
 16        LSCollider targetCollider,
 17        Vector3d point,
 18        Vector3d resultNormal,
 19        Vector3d fallbackNormal,
 20        Vector3d sweepDirection,
 21        Vector3d planarNormal,
 22        bool hasRefinedSurfaceNormal = false,
 23        bool hasMaterializedPoint = true)
 24    {
 16125        Vector3d surfaceNormal = hasRefinedSurfaceNormal
 16126            ? targetCollider.GetNormalAtPoint(point)
 16127            : Vector3d.Zero;
 16128        Vector3d normal = surfaceNormal.MagnitudeSquared > Fixed64.Epsilon
 16129            ? surfaceNormal
 16130            : planarNormal.MagnitudeSquared > Fixed64.Epsilon
 16131                ? planarNormal
 16132            : resultNormal.MagnitudeSquared > Fixed64.Epsilon
 16133                ? resultNormal
 16134                : fallbackNormal.MagnitudeSquared > Fixed64.Epsilon
 16135                    ? fallbackNormal
 16136                    : hasMaterializedPoint
 16137                        ? targetCollider.GetNormalAtPoint(point)
 16138                        : Vector3d.Zero;
 39
 16140        if (normal.MagnitudeSquared <= Fixed64.Epsilon)
 41        {
 342            return sweepDirection.MagnitudeSquared > Fixed64.Epsilon
 343                ? -sweepDirection.Normalized
 344                : Vector3d.Zero;
 45        }
 46
 15847        normal = normal.Normalized;
 15848        return Vector3d.CompareProjection(
 15849                normal,
 15850                Vector3d.Zero,
 15851                sweepDirection) > 0
 15852            ? -normal
 15853            : normal;
 54    }
 55}