< 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: 58
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
 13/// <summary>
 14/// Selects the reported sweep normal from available contact evidence and orients it against travel.
 15/// </summary>
 16internal static class ConvexSweepHitPolicy
 17{
 18    internal static Vector3d ResolveHitNormal(
 19        LSCollider targetCollider,
 20        Vector3d point,
 21        Vector3d resultNormal,
 22        Vector3d fallbackNormal,
 23        Vector3d sweepDirection,
 24        Vector3d planarNormal,
 25        bool hasRefinedSurfaceNormal = false,
 26        bool hasMaterializedPoint = true)
 27    {
 378328        Vector3d surfaceNormal = hasRefinedSurfaceNormal
 378329            ? targetCollider.GetNormalAtPoint(point)
 378330            : Vector3d.Zero;
 378331        Vector3d normal = surfaceNormal.MagnitudeSquared > Fixed64.Epsilon
 378332            ? surfaceNormal
 378333            : planarNormal.MagnitudeSquared > Fixed64.Epsilon
 378334                ? planarNormal
 378335            : resultNormal.MagnitudeSquared > Fixed64.Epsilon
 378336                ? resultNormal
 378337                : fallbackNormal.MagnitudeSquared > Fixed64.Epsilon
 378338                    ? fallbackNormal
 378339                    : hasMaterializedPoint
 378340                        ? targetCollider.GetNormalAtPoint(point)
 378341                        : Vector3d.Zero;
 42
 378343        if (normal.MagnitudeSquared <= Fixed64.Epsilon)
 44        {
 745            return sweepDirection.MagnitudeSquared > Fixed64.Epsilon
 746                ? -sweepDirection.Normalized
 747                : Vector3d.Zero;
 48        }
 49
 377650        normal = normal.Normalized;
 377651        return Vector3d.CompareProjection(
 377652                normal,
 377653                Vector3d.Zero,
 377654                sweepDirection) > 0
 377655            ? -normal
 377656            : normal;
 57    }
 58}