< Summary

Line coverage
100%
Covered lines: 295
Uncovered lines: 0
Coverable lines: 295
Total lines: 606
Line coverage: 100%
Branch coverage
100%
Covered branches: 122
Total branches: 122
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Queries/Mixed/Sweeps/FiniteSlabProjectionSweep.cs

#LineLine coverage
 1//=======================================================================
 2// FiniteSlabProjectionSweep.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 System;
 9using System.Runtime.CompilerServices;
 10using FixedMathSharp;
 11using FixedMathSharp.Geometry;
 12using Gravitas.Colliders;
 13
 14namespace Gravitas.Queries;
 15
 16/// <summary>
 17/// Sweeps an X/Z circle against the projection of curved 3D targets clipped to
 18/// a finite Y slab.
 19/// </summary>
 20/// <content>Owns conservative advancement and projected support simplex reduction for curved targets.</content>
 21internal static partial class FiniteSlabProjectionSweep
 22{
 23    private const int MaxGjkIterations = 32;
 24    private const int MaxConservativeAdvancementIterations = 32;
 125    private static readonly Fixed64 DistanceTolerance = Fixed64.FromFraction(1, 1_048_576);
 126    private static readonly Fixed64 SweepContactTolerance = DistanceTolerance;
 27
 28    public static bool TrySweepCircleAgainstCapsule(
 29        Vector2d start,
 30        Vector2d end,
 31        Vector2d direction,
 32        Fixed64 length,
 33        Fixed64 radius,
 34        Fixed64 slabMinY,
 35        Fixed64 slabMaxY,
 36        LSCapsuleCollider capsule,
 37        out Fixed64 distance,
 38        int maxConservativeAdvancementIterations = MaxConservativeAdvancementIterations)
 39    {
 20540        var target = ProjectionTarget.CreateCapsule(capsule, slabMinY, slabMaxY);
 20541        return TrySweepCircle(
 20542            start,
 20543            end,
 20544            direction,
 20545            length,
 20546            radius,
 20547            target,
 20548            out distance,
 20549            maxConservativeAdvancementIterations);
 50    }
 51
 52    public static bool TrySweepCircleAgainstCylinder(
 53        Vector2d start,
 54        Vector2d end,
 55        Vector2d direction,
 56        Fixed64 length,
 57        Fixed64 radius,
 58        Fixed64 slabMinY,
 59        Fixed64 slabMaxY,
 60        LSCylinderCollider cylinder,
 61        out Fixed64 distance,
 62        int maxConservativeAdvancementIterations = MaxConservativeAdvancementIterations)
 63    {
 21064        var target = ProjectionTarget.CreateCylinder(cylinder, slabMinY, slabMaxY);
 21065        return TrySweepCircle(
 21066            start,
 21067            end,
 21068            direction,
 21069            length,
 21070            radius,
 21071            target,
 21072            out distance,
 21073            maxConservativeAdvancementIterations);
 74    }
 75
 76    public static bool TrySweepCircleAgainstCone(
 77        Vector2d start,
 78        Vector2d end,
 79        Vector2d direction,
 80        Fixed64 length,
 81        Fixed64 radius,
 82        Fixed64 slabMinY,
 83        Fixed64 slabMaxY,
 84        LSConeCollider cone,
 85        out Fixed64 distance,
 86        int maxConservativeAdvancementIterations = MaxConservativeAdvancementIterations)
 87    {
 18788        var target = ProjectionTarget.CreateCone(cone, slabMinY, slabMaxY);
 18789        return TrySweepCircle(
 18790            start,
 18791            end,
 18792            direction,
 18793            length,
 18794            radius,
 18795            target,
 18796            out distance,
 18797            maxConservativeAdvancementIterations);
 98    }
 99
 100    private static bool TrySweepCircle(
 101        Vector2d start,
 102        Vector2d end,
 103        Vector2d direction,
 104        Fixed64 length,
 105        Fixed64 radius,
 106        ProjectionTarget target,
 107        out Fixed64 distance,
 108        int maxConservativeAdvancementIterations)
 109    {
 602110        distance = Fixed64.Zero;
 602111        if (!Vector2d.TryGetMagnitude(direction, out Fixed64 directionMagnitude)
 602112            || (directionMagnitude != Fixed64.Zero
 602113                && FixedMath.Abs(directionMagnitude - Fixed64.One) > Fixed64.Epsilon)
 602114            || maxConservativeAdvancementIterations <= 0
 602115            || !target.TrySupport(Vector2d.Right, out Vector2d rightSupport, out bool translated))
 18116            return false;
 117
 584118        if (target.TryGetPlanarCircle(rightSupport, translated, out Vector2d targetCenter, out Fixed64 targetRadius))
 119        {
 257120            return new FixedSegment2d(start, end)
 257121                .TryGetCircleIntersectionDistanceInterval(
 257122                    new FixedBoundCircle(targetCenter, targetRadius),
 257123                    radius,
 257124                    length,
 257125                    out distance,
 257126                    out _,
 257127                    out _,
 257128                    out _);
 129        }
 130
 327131        Fixed64 travelDistance = Fixed64.Zero;
 327132        Vector2d searchDirection = Vector2d.Zero;
 327133        var segment = new FixedSegment2d(start, end);
 327134        Vector2d displacement = end - start;
 1088135        for (int i = 0; i < maxConservativeAdvancementIterations; i++)
 136        {
 543137            Vector2d point = segment.GetPointAtDistance(travelDistance, length);
 543138            PlanarGjkResult result = ComputeDistance(point, radius, target, searchDirection);
 139
 543140            if (result.Distance <= SweepContactTolerance)
 141            {
 313142                distance = travelDistance;
 313143                return true;
 144            }
 145
 230146            Vector2d normal = result.Normal;
 147            // Reuse the resolved separating direction at the next nearby pose.
 230148            searchDirection = -normal;
 149            // Keep the authored chord over its distance denominator. A rounded
 150            // unit ray can enter a shape that the original segment only grazes.
 230151            Signed320 closing = WideArithmetic.SubtractSigned320(default,
 230152                WideArithmetic.AddSigned320(
 230153                    WideArithmetic.MultiplySigned192(Signed192.Raw(displacement.X), Signed192.Raw(normal.X)),
 230154                    WideArithmetic.MultiplySigned192(Signed192.Raw(displacement.Y), Signed192.Raw(normal.Y))));
 230155            if (WideArithmetic.SubtractSigned320(closing,
 230156                    WideArithmetic.MultiplySigned192(Signed192.Raw(Fixed64.Epsilon), Signed192.Raw(length))).Sign <= 0)
 8157                return false;
 158
 222159            Fixed64 remainingDistance = length - travelDistance;
 222160            bool reachedEndpoint = !Fixed64.TryGetSignedRawRatio(
 222161                    Signed832.ExtendValue(Signed576.ExtendValue(WideArithmetic.MultiplySigned192(
 222162                        Signed192.Raw(result.Distance), Signed192.Raw(length)))),
 222163                    Signed832.ExtendValue(Signed576.ExtendValue(closing)),
 222164                    32,
 222165                    out Fixed64 stepDistance)
 222166                || stepDistance > remainingDistance;
 222167            if (reachedEndpoint)
 168            {
 5169                PlanarGjkResult endpoint = ComputeDistance(end, radius, target, searchDirection);
 170
 5171                if (endpoint.Distance <= SweepContactTolerance)
 172                {
 1173                    distance = length;
 1174                    return true;
 175                }
 176
 4177                return false;
 178            }
 179
 217180            travelDistance += stepDistance;
 181        }
 182
 1183        return false;
 184    }
 185
 186    private static PlanarGjkResult ComputeDistance(
 187        Vector2d point,
 188        Fixed64 expansionRadius,
 189        ProjectionTarget target,
 190        Vector2d initialDirection)
 191    {
 548192        Span<PlanarSupportPoint> simplex = stackalloc PlanarSupportPoint[3];
 548193        int workingShift = target.SelectWorkingShift(point, expansionRadius);
 548194        Fixed64 workingScale = GjkSimplexScale.GetCoordinateScale(workingShift);
 548195        Fixed64 workingDistanceTolerance = DistanceTolerance * workingScale;
 548196        int simplexCount = 0;
 548197        Vector2d direction = initialDirection == Vector2d.Zero
 548198            ? GjkSimplexScale.CreateWorkingDifference(target.Center, point, workingShift)
 548199            : initialDirection;
 548200        if (direction == Vector2d.Zero)
 9201            direction = Vector2d.Right;
 202
 548203        bool hasPreviousDistance = false;
 548204        Fixed64 previousDistance = Fixed64.Zero;
 548205        ClosestPlanarSimplexResult closest = default;
 548206        bool distanceIsRepresentable = false;
 548207        Fixed64 workingDistance = Fixed64.MaxValue;
 208
 3640209        for (int i = 0; i < MaxGjkIterations; i++)
 210        {
 1820211            PlanarSupportPoint support = CreateSupportPoint(
 1820212                point, expansionRadius, target, direction, workingShift);
 213
 1820214            if (ContainsSupportPoint(simplex, simplexCount, support.Point))
 215                break;
 216
 1653217            simplex[simplexCount++] = support;
 1653218            closest = SolveClosestSimplex(simplex, ref simplexCount);
 1653219            distanceIsRepresentable = Vector2d.TryGetMagnitude(closest.Point, out workingDistance);
 1653220            if (closest.Intersects
 1653221                || (distanceIsRepresentable && workingDistance <= workingDistanceTolerance))
 222            {
 314223                return PlanarGjkResult.Intersection;
 224            }
 225
 1339226            if (hasPreviousDistance
 1339227                && distanceIsRepresentable
 1339228                && previousDistance - workingDistance <= Fixed64.Epsilon)
 229            {
 230                break;
 231            }
 232
 1272233            hasPreviousDistance = distanceIsRepresentable;
 1272234            previousDistance = workingDistance;
 1272235            direction = closest.SearchDirection;
 236        }
 237
 234238        Fixed64 distance = GjkSimplexScale.RestoreDistance(workingDistance, workingShift);
 234239        Vector2d normal = -WideNormalization.GetNormalized(closest.SearchDirection);
 234240        return new PlanarGjkResult(distance, normal);
 241    }
 242
 243    private static PlanarSupportPoint CreateSupportPoint(
 244        Vector2d point,
 245        Fixed64 expansionRadius,
 246        ProjectionTarget target,
 247        Vector2d direction,
 248        int workingShift)
 249    {
 1820250        Vector2d supportDirection = WideNormalization.GetNormalized(direction);
 1820251        Vector2d targetDirection = -supportDirection;
 252        // The initial right support established a nonempty slab intersection;
 253        // admission and the chosen chart bound every later directional support.
 1820254        _ = target.TrySupport(targetDirection, out Vector2d targetSupport, out bool translated);
 255
 1820256        Vector2d expansion = targetDirection * expansionRadius;
 1820257        return new PlanarSupportPoint(
 1820258            translated
 1820259                ? GjkSimplexScale.CreateWorkingDifference(point, target.Center, targetSupport, expansion, workingShift)
 1820260                : GjkSimplexScale.CreateWorkingDifference(point, targetSupport, expansion, workingShift));
 261    }
 262
 263    private static ClosestPlanarSimplexResult SolveClosestSimplex(
 264        Span<PlanarSupportPoint> simplex,
 265        ref int count)
 266    {
 1653267        if (count == 1)
 548268            return ClosestPlanarSimplexResult.FromPoint(simplex[0].Point);
 269
 1105270        if (count == 2)
 327271            return ReduceSegment(simplex, ref count);
 272
 778273        return ReduceTriangle(simplex, ref count);
 274    }
 275
 276    private static ClosestPlanarSimplexResult ReduceSegment(
 277        Span<PlanarSupportPoint> simplex,
 278        ref int count)
 279    {
 1513280        Vector2d a = simplex[0].Point;
 1513281        Vector2d b = simplex[1].Point;
 1513282        Fixed64 t = Vector2d.GetClosestPointOnLineSegmentParameter(Vector2d.Zero, a, b);
 283
 1513284        if (t == Fixed64.Zero)
 285        {
 201286            count = 1;
 201287            return ClosestPlanarSimplexResult.FromPoint(a);
 288        }
 289
 1312290        if (t == Fixed64.One)
 291        {
 319292            simplex[0] = simplex[1];
 319293            count = 1;
 319294            return ClosestPlanarSimplexResult.FromPoint(b);
 295        }
 296
 993297        count = 2;
 993298        return ClosestPlanarSimplexResult.FromSegment(new Vector2d(
 993299            FixedMath.Lerp(a.X, b.X, t), FixedMath.Lerp(a.Y, b.Y, t)), a, b);
 300    }
 301
 302    private static ClosestPlanarSimplexResult ReduceTriangle(
 303        Span<PlanarSupportPoint> simplex,
 304        ref int count)
 305    {
 778306        Vector2d a = simplex[0].Point;
 778307        Vector2d b = simplex[1].Point;
 778308        Vector2d c = simplex[2].Point;
 778309        int winding = Vector2d.OrientationSign(a, b, c);
 778310        int ab = Vector2d.OrientationSign(a, b, Vector2d.Zero);
 778311        int bc = Vector2d.OrientationSign(b, c, Vector2d.Zero);
 778312        int ca = Vector2d.OrientationSign(c, a, Vector2d.Zero);
 778313        if (winding != 0 && ab != -winding && bc != -winding && ca != -winding)
 314        {
 5315            count = 3;
 5316            return ClosestPlanarSimplexResult.Intersection;
 317        }
 318
 773319        bool hasBest = false;
 773320        int bestFirst = 0;
 773321        int bestSecond = 1;
 773322        ClosestPlanarSimplexResult best = default;
 323        // Only origin-facing edges can own a closest feature of a proper triangle.
 324        // Collinear simplexes retain every edge because they have no interior side.
 773325        if (winding == 0 || ab != winding)
 13326            EvaluateTriangleEdge(simplex, 0, 1, ref best, ref hasBest, ref bestFirst, ref bestSecond);
 773327        if (winding == 0 || bc != winding)
 575328            EvaluateTriangleEdge(simplex, 1, 2, ref best, ref hasBest, ref bestFirst, ref bestSecond);
 773329        if (winding == 0 || ca != winding)
 598330            EvaluateTriangleEdge(simplex, 2, 0, ref best, ref hasBest, ref bestFirst, ref bestSecond);
 331
 773332        PlanarSupportPoint first = simplex[bestFirst];
 773333        PlanarSupportPoint second = simplex[bestSecond];
 773334        simplex[0] = first;
 773335        simplex[1] = second;
 773336        count = 2;
 773337        return best;
 338    }
 339
 340    private static void EvaluateTriangleEdge(
 341        Span<PlanarSupportPoint> simplex,
 342        int first,
 343        int second,
 344        ref ClosestPlanarSimplexResult best,
 345        ref bool hasBest,
 346        ref int bestFirst,
 347        ref int bestSecond)
 348    {
 1186349        Span<PlanarSupportPoint> edge = stackalloc PlanarSupportPoint[2];
 1186350        edge[0] = simplex[first];
 1186351        edge[1] = simplex[second];
 1186352        int edgeCount = 2;
 1186353        ClosestPlanarSimplexResult candidate = ReduceSegment(edge, ref edgeCount);
 1186354        if (hasBest && Vector2d.CompareMagnitudeSquared(candidate.Point, best.Point) >= 0)
 205355            return;
 356
 981357        best = candidate;
 981358        hasBest = true;
 981359        bestFirst = first;
 981360        bestSecond = second;
 981361    }
 362
 363    private static bool ContainsSupportPoint(
 364        Span<PlanarSupportPoint> simplex,
 365        int count,
 366        Vector2d point)
 367    {
 7414368        for (int i = 0; i < count; i++)
 369        {
 2054370            if (Vector2d.TryGetDistance(simplex[i].Point, point, out Fixed64 distance)
 2054371                && distance <= Fixed64.Epsilon)
 167372                return true;
 373        }
 374
 1653375        return false;
 376    }
 377
 378    private readonly struct ProjectionTarget
 379    {
 380        private readonly LSCapsuleCollider? _capsule;
 381        private readonly LSCylinderCollider? _cylinder;
 382        private readonly LSConeCollider? _cone;
 383        private readonly FixedRange _slabY;
 384        private readonly Vector2d _center;
 385        private readonly Vector3d _axis;
 386        private readonly bool _useTranslatedSupport;
 387        private readonly Fixed64 _supportExtent;
 388
 389        private ProjectionTarget(
 390            LSCapsuleCollider? capsule,
 391            LSCylinderCollider? cylinder,
 392            LSConeCollider? cone,
 393            Fixed64 slabMinY,
 394            Fixed64 slabMaxY,
 395            Vector2d center,
 396            Vector3d axis)
 397        {
 602398            _capsule = capsule;
 602399            _cylinder = cylinder;
 602400            _cone = cone;
 602401            _slabY = new FixedRange(slabMinY, slabMaxY);
 602402            _center = center;
 602403            _axis = axis;
 602404            Fixed64 length = capsule?.AxisLength ?? cylinder?.Height ?? cone!.Height;
 602405            Fixed64 radius = capsule?.ScaledRadius ?? cylinder?.ScaledRadius ?? cone!.ScaledRadius;
 602406            Fixed64 halfLength = Fixed64.FromRaw((length.m_rawValue >> 1) + (length.m_rawValue & 1));
 602407            Fixed64 axialComponent = FixedMath.Max(axis.X.Abs(), axis.Z.Abs());
 408            // Support uses a rounded axis, so exact rigid bounds alone cannot select the frame.
 409            // The admitted local dimensions bound this envelope well below the scalar limit.
 602410            _ = Fixed64.TryMultiplyAdd(halfLength, axialComponent, radius, out Fixed64 extent);
 602411            _supportExtent = extent + Fixed64.MinIncrement;
 602412            Vector2d planarExtent = new(_supportExtent, _supportExtent);
 602413            _useTranslatedSupport = !Vector2d.TryAdd(center, planarExtent, out _)
 602414                    || !Vector2d.TrySubtract(center, planarExtent, out _);
 602415        }
 416
 739417        public Vector2d Center => _center;
 418
 381419        public Vector2d BoundsMin => new(TargetBoundsMin.X, TargetBoundsMin.Z);
 420
 381421        public Vector2d BoundsMax => new(TargetBoundsMax.X, TargetBoundsMax.Z);
 422
 762423        private Vector3d TargetBoundsMin => _capsule?.BoundsMin ?? _cylinder?.BoundsMin ?? _cone!.BoundsMin;
 424
 762425        private Vector3d TargetBoundsMax => _capsule?.BoundsMax ?? _cylinder?.BoundsMax ?? _cone!.BoundsMax;
 426
 427        public static ProjectionTarget CreateCapsule(LSCapsuleCollider capsule, Fixed64 slabMinY, Fixed64 slabMaxY) =>
 205428            new(
 205429                capsule,
 205430                null,
 205431                null,
 205432                slabMinY,
 205433                slabMaxY,
 205434                new Vector2d(capsule.Center.X, capsule.Center.Z),
 205435                GetRigidUpAxis(capsule.Rotation));
 436
 437        public static ProjectionTarget CreateCylinder(LSCylinderCollider cylinder, Fixed64 slabMinY, Fixed64 slabMaxY) =
 210438            new(
 210439                null,
 210440                cylinder,
 210441                null,
 210442                slabMinY,
 210443                slabMaxY,
 210444                new Vector2d(cylinder.Center.X, cylinder.Center.Z),
 210445                GetRigidUpAxis(cylinder.Rotation));
 446
 447        public static ProjectionTarget CreateCone(LSConeCollider cone, Fixed64 slabMinY, Fixed64 slabMaxY) =>
 187448            new(
 187449                null,
 187450                null,
 187451                cone,
 187452                slabMinY,
 187453                slabMaxY,
 187454                new Vector2d(cone.Center.X, cone.Center.Z),
 187455                GetRigidUpAxis(cone.Rotation));
 456
 457        public int SelectWorkingShift(Vector2d point, Fixed64 radius)
 458        {
 548459            if (!_useTranslatedSupport)
 381460                return GjkSimplexScale.SelectThreeTermShift(point, BoundsMin, BoundsMax, radius);
 167461            Vector2d extent = new(_supportExtent, _supportExtent);
 167462            return GjkSimplexScale.SelectFourTermShift(point, _center, -extent, extent, radius);
 463        }
 464
 465        public bool TrySupport(Vector2d unitDirection, out Vector2d support, out bool translated)
 466        {
 467            // Target support and circle expansion consume the same normalized direction.
 2419468            Vector3d center = _capsule?.Center ?? _cylinder?.Center ?? _cone!.Center;
 469            // Select the frame once; retrying every unavailable support repeats the expensive solve.
 2419470            translated = _useTranslatedSupport;
 2419471            if (translated)
 572472                center = new Vector3d(Fixed64.Zero, center.Y, Fixed64.Zero);
 473
 2419474            if (_capsule != null)
 475            {
 1061476                return FixedSlabProjection.TryGetCapsuleSupport(
 1061477                    center,
 1061478                    _axis,
 1061479                    _capsule.AxisLength,
 1061480                    _capsule.ScaledRadius,
 1061481                    _slabY,
 1061482                    unitDirection,
 1061483                    out support);
 484            }
 485
 1358486            if (_cylinder != null)
 487            {
 785488                return FixedSlabProjection.TryGetCylinderSupport(
 785489                    center,
 785490                    _axis,
 785491                    _cylinder.Height,
 785492                    _cylinder.ScaledRadius,
 785493                    _slabY,
 785494                    unitDirection,
 785495                    out support);
 496            }
 497
 573498            return FixedSlabProjection.TryGetConeSupport(
 573499                center,
 573500                _axis,
 573501                _cone!.Height,
 573502                _cone.ScaledRadius,
 573503                _slabY,
 573504                unitDirection,
 573505                out support);
 506        }
 507
 508        public bool TryGetPlanarCircle(
 509            Vector2d rightSupport,
 510            bool translated,
 511            out Vector2d center,
 512            out Fixed64 radius)
 513        {
 584514            if ((_axis.X != Fixed64.Zero) | (_axis.Z != Fixed64.Zero))
 515            {
 327516                center = default;
 327517                radius = default;
 327518                return false;
 519            }
 520
 257521            center = _center;
 257522            radius = translated ? rightSupport.X : rightSupport.X - _center.X;
 257523            return true;
 524        }
 525
 526    }
 527
 528    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 529    private static Vector3d GetRigidUpAxis(FixedQuaternion rotation) =>
 602530        (rotation * Vector3d.Up).Normalized;
 531
 532}

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Queries/Mixed/Sweeps/FiniteSlabProjectionSweep.State.cs

#LineLine coverage
 1//=======================================================================
 2// FiniteSlabProjectionSweep.State.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;
 9
 10namespace Gravitas.Queries;
 11
 12/// <content>Defines the support and closest-simplex results used by finite slab projection sweeps.</content>
 13internal static partial class FiniteSlabProjectionSweep
 14{
 15    private readonly struct PlanarSupportPoint
 16    {
 17        public PlanarSupportPoint(Vector2d point)
 18        {
 182019            Point = point;
 182020        }
 21
 22        public Vector2d Point { get; }
 23    }
 24
 25    private readonly struct PlanarGjkResult
 26    {
 27        public PlanarGjkResult(Fixed64 distance, Vector2d normal)
 28        {
 54829            Distance = distance;
 54830            Normal = normal;
 54831        }
 32
 33        public Fixed64 Distance { get; }
 34
 35        public Vector2d Normal { get; }
 36
 31437        public static PlanarGjkResult Intersection => new(Fixed64.Zero, Vector2d.Zero);
 38    }
 39
 40    private readonly struct ClosestPlanarSimplexResult
 41    {
 42        private ClosestPlanarSimplexResult(bool intersects, Vector2d point, Vector2d searchDirection)
 43        {
 206644            Intersects = intersects;
 206645            Point = point;
 206646            SearchDirection = searchDirection;
 206647        }
 48
 49        public bool Intersects { get; }
 50
 51        public Vector2d Point { get; }
 52
 53        public Vector2d SearchDirection { get; }
 54
 14255        public static ClosestPlanarSimplexResult Intersection => new(true, Vector2d.Zero, Vector2d.Zero);
 56
 106857        public static ClosestPlanarSimplexResult FromPoint(Vector2d point) => new(false, point, -point);
 58
 59        public static ClosestPlanarSimplexResult FromSegment(Vector2d point, Vector2d a, Vector2d b)
 60        {
 99361            int side = Vector2d.OrientationSign(a, b, Vector2d.Zero);
 99362            if (side == 0)
 13763                return Intersection;
 64            // A rounded near-zero closest point can erase a normal component;
 65            // the edge's perpendicular retains its direction independently.
 85666            Vector2d edgeDirection = Vector2d.TrySubtract(b, a, out Vector2d edge)
 85667                ? edge : Vector2d.GetDirection(a, b);
 85668            Vector2d searchDirection = side > 0
 85669                ? new Vector2d(-edgeDirection.Y, edgeDirection.X)
 85670                : new Vector2d(edgeDirection.Y, -edgeDirection.X);
 85671            return new ClosestPlanarSimplexResult(false, point, searchDirection);
 72        }
 73    }
 74}

Methods/Properties

.cctor()
TrySweepCircleAgainstCapsule(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,Gravitas.Colliders.LSCapsuleCollider,FixedMathSharp.Fixed64&,System.Int32)
TrySweepCircleAgainstCylinder(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,Gravitas.Colliders.LSCylinderCollider,FixedMathSharp.Fixed64&,System.Int32)
TrySweepCircleAgainstCone(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,Gravitas.Colliders.LSConeCollider,FixedMathSharp.Fixed64&,System.Int32)
TrySweepCircle(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,Gravitas.Queries.FiniteSlabProjectionSweep/ProjectionTarget,FixedMathSharp.Fixed64&,System.Int32)
ComputeDistance(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,Gravitas.Queries.FiniteSlabProjectionSweep/ProjectionTarget,FixedMathSharp.Vector2d)
CreateSupportPoint(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,Gravitas.Queries.FiniteSlabProjectionSweep/ProjectionTarget,FixedMathSharp.Vector2d,System.Int32)
SolveClosestSimplex(System.Span`1<Gravitas.Queries.FiniteSlabProjectionSweep/PlanarSupportPoint>,System.Int32&)
ReduceSegment(System.Span`1<Gravitas.Queries.FiniteSlabProjectionSweep/PlanarSupportPoint>,System.Int32&)
ReduceTriangle(System.Span`1<Gravitas.Queries.FiniteSlabProjectionSweep/PlanarSupportPoint>,System.Int32&)
EvaluateTriangleEdge(System.Span`1<Gravitas.Queries.FiniteSlabProjectionSweep/PlanarSupportPoint>,System.Int32,System.Int32,Gravitas.Queries.FiniteSlabProjectionSweep/ClosestPlanarSimplexResult&,System.Boolean&,System.Int32&,System.Int32&)
ContainsSupportPoint(System.Span`1<Gravitas.Queries.FiniteSlabProjectionSweep/PlanarSupportPoint>,System.Int32,FixedMathSharp.Vector2d)
.ctor(Gravitas.Colliders.LSCapsuleCollider,Gravitas.Colliders.LSCylinderCollider,Gravitas.Colliders.LSConeCollider,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,FixedMathSharp.Vector2d,FixedMathSharp.Vector3d)
get_Center()
get_BoundsMin()
get_BoundsMax()
get_TargetBoundsMin()
get_TargetBoundsMax()
CreateCapsule(Gravitas.Colliders.LSCapsuleCollider,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64)
CreateCylinder(Gravitas.Colliders.LSCylinderCollider,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64)
CreateCone(Gravitas.Colliders.LSConeCollider,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64)
SelectWorkingShift(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64)
TrySupport(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d&,System.Boolean&)
TryGetPlanarCircle(FixedMathSharp.Vector2d,System.Boolean,FixedMathSharp.Vector2d&,FixedMathSharp.Fixed64&)
GetRigidUpAxis(FixedMathSharp.FixedQuaternion)
.ctor(FixedMathSharp.Vector2d)
.ctor(FixedMathSharp.Fixed64,FixedMathSharp.Vector2d)
get_Intersection()
.ctor(System.Boolean,FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
get_Intersection()
FromPoint(FixedMathSharp.Vector2d)
FromSegment(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)