< Summary

Line coverage
100%
Covered lines: 479
Uncovered lines: 0
Coverable lines: 479
Total lines: 1160
Line coverage: 100%
Branch coverage
100%
Covered branches: 130
Total branches: 130
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
File 1: .ctor(...)100%11100%
File 1: RaycastBatch(...)100%22100%
File 1: RaycastAllBatch(...)100%22100%
File 1: OverlapCircleBatch(...)100%22100%
File 1: OverlapCircleAllBatch(...)100%22100%
File 1: OverlapAabbBatch(...)100%22100%
File 1: OverlapAabbAllBatch(...)100%22100%
File 1: OverlapPolygonBatch(...)100%22100%
File 1: OverlapPolygonAllBatch(...)100%22100%
File 1: SweepCircleBatch(...)100%22100%
File 1: SweepCircleAllBatch(...)100%22100%
File 1: WriteClosestHit(...)100%22100%
File 1: AppendRange(...)100%22100%
File 1: ResetBatchCounters(...)100%11100%
File 1: AccumulateBatchCounters(...)100%11100%
File 1: ValidateClosestBatchOutput(...)100%11100%
File 1: ValidateRangeBatchOutput(...)100%11100%
File 1: ValidatePolygonRequestRanges(...)100%88100%
File 1: ValidateOverlapCircleRequests(...)100%22100%
File 1: ValidateOverlapAabbRequests(...)100%22100%
File 1: ValidateSweepCircleRequests(...)100%22100%
File 2: .ctor(...)100%11100%
File 2: get_Context()100%11100%
File 2: Reset()100%11100%
File 3: OverlapCircleAll(...)100%11100%
File 3: OverlapCircleAll(...)100%11100%
File 3: OverlapCircleAgainstStaticAll(...)100%11100%
File 3: OverlapCircle(...)100%11100%
File 3: OverlapCircle(...)100%66100%
File 3: OverlapAabb(...)100%11100%
File 3: OverlapAabb(...)100%11100%
File 3: OverlapAabbAll(...)100%11100%
File 3: OverlapAabbAll(...)100%11100%
File 3: OverlapPolygon(...)100%11100%
File 3: OverlapPolygon(...)100%11100%
File 3: OverlapPolygonAll(...)100%11100%
File 3: OverlapPolygonAll(...)100%11100%
File 3: OverlapCircleAllCore(...)100%66100%
File 3: OverlapAreaCore(...)100%66100%
File 3: OverlapAreaAllCore(...)100%44100%
File 4: Raycast(...)100%11100%
File 4: Raycast(...)100%1212100%
File 4: RaycastAll(...)100%11100%
File 4: RaycastAll(...)100%1010100%
File 5: EnsureCandidateCapacity()100%22100%
File 5: NextOverlapQueryVersion()100%22100%
File 5: NextRaycastVersion()100%22100%
File 5: ResetColliderOverlapQueryVersions()100%22100%
File 5: ResetColliderRaycastVersions()100%22100%
File 5: CreateMin(...)100%11100%
File 5: CreateMax(...)100%11100%
File 5: CreateSweepMin(...)100%11100%
File 5: CreateSweepMax(...)100%11100%
File 5: CreateAabbVertices(...)100%11100%
File 5: CalculateAreaBounds(...)100%22100%
File 5: IsEligibleSweepCandidate(...)100%1010100%
File 6: SweepCircle(...)100%11100%
File 6: SweepCircle(...)100%1414100%
File 6: SweepCircleAll(...)100%11100%
File 6: SweepCircleAll(...)100%11100%
File 6: SweepCircleAgainstStaticAll(...)100%11100%
File 6: SweepCircleAllCore(...)100%1212100%

File(s)

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Queries/2D/GravitasQuery2DService.Batch.cs

#LineLine coverage
 1//=======================================================================
 2// GravitasQuery2DService.Batch.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 SwiftCollections;
 10using System;
 11
 12namespace Gravitas.Queries;
 13
 14/// <summary>
 15/// Owns batched pure 2D query behavior for one <see cref="GravitasWorldContext"/>.
 16/// </summary>
 17public sealed partial class GravitasQuery2DService
 18{
 508319    private readonly SwiftList<Physics2DHit> _batch2DHits = new();
 20
 21    /// <summary>
 22    /// Gets the number of requests processed by the last pure 2D batch query call.
 23    /// </summary>
 24    public int LastBatchRequestCount { get; private set; }
 25
 26    /// <summary>
 27    /// Gets the number of hits accepted by the last pure 2D batch query call.
 28    /// </summary>
 29    public int LastBatchHitCount { get; private set; }
 30
 31    /// <summary>
 32    /// Gets the summed candidate count reported by the last pure 2D batch query call.
 33    /// </summary>
 34    public int LastBatchCandidateCount { get; private set; }
 35
 36    /// <summary>
 37    /// Executes multiple pure 2D segment raycasts and writes one closest-hit slot per request.
 38    /// </summary>
 39    public int RaycastBatch(ReadOnlySpan<PhysicsRaycast2DRequest> requests, Span<Physics2DHit> closestHits)
 40    {
 20941        ValidateClosestBatchOutput(requests.Length, closestHits);
 20942        ResetBatchCounters(requests.Length);
 43
 20944        int hitCount = 0;
 125645        for (int i = 0; i < requests.Length; i++)
 46        {
 41947            PhysicsRaycast2DRequest request = requests[i];
 41948            bool found = Raycast(request.Start, request.End, request.LayerMask, out Physics2DHit hit);
 41949            WriteClosestHit(closestHits, i, hit, found, ref hitCount);
 50        }
 51
 20952        LastBatchHitCount = hitCount;
 20953        return hitCount;
 54    }
 55
 56    /// <summary>
 57    /// Executes multiple pure 2D segment raycasts and appends all hits into one caller-owned hit buffer.
 58    /// </summary>
 59    public int RaycastAllBatch(
 60        ReadOnlySpan<PhysicsRaycast2DRequest> requests,
 61        SwiftList<Physics2DHit> hits,
 62        Span<PhysicsQueryHitRange> ranges)
 63    {
 20964        SwiftThrowHelper.ThrowIfNull(hits, nameof(hits));
 20965        ValidateRangeBatchOutput(requests.Length, ranges);
 20966        ResetBatchCounters(requests.Length);
 20967        hits.FastClear();
 68
 125669        for (int i = 0; i < requests.Length; i++)
 70        {
 41971            PhysicsRaycast2DRequest request = requests[i];
 41972            int count = RaycastAll(request.Start, request.End, request.LayerMask, _batch2DHits);
 41973            AppendRange(hits, ranges, i, count);
 74        }
 75
 20976        LastBatchHitCount = hits.Count;
 20977        return hits.Count;
 78    }
 79
 80    /// <summary>
 81    /// Executes multiple pure 2D circle overlaps and writes one closest-hit slot per request.
 82    /// </summary>
 83    public int OverlapCircleBatch(ReadOnlySpan<PhysicsOverlapCircle2DRequest> requests, Span<Physics2DHit> closestHits)
 84    {
 20985        ValidateClosestBatchOutput(requests.Length, closestHits);
 20986        ValidateOverlapCircleRequests(requests);
 20987        ResetBatchCounters(requests.Length);
 88
 20989        int hitCount = 0;
 125490        for (int i = 0; i < requests.Length; i++)
 91        {
 41892            PhysicsOverlapCircle2DRequest request = requests[i];
 41893            bool found = OverlapCircle(request.Center, request.Radius, request.LayerMask, out Physics2DHit hit);
 41894            WriteClosestHit(closestHits, i, hit, found, ref hitCount);
 95        }
 96
 20997        LastBatchHitCount = hitCount;
 20998        return hitCount;
 99    }
 100
 101    /// <summary>
 102    /// Executes multiple pure 2D circle overlaps and appends all hits into one caller-owned hit buffer.
 103    /// </summary>
 104    public int OverlapCircleAllBatch(
 105        ReadOnlySpan<PhysicsOverlapCircle2DRequest> requests,
 106        SwiftList<Physics2DHit> hits,
 107        Span<PhysicsQueryHitRange> ranges)
 108    {
 208109        SwiftThrowHelper.ThrowIfNull(hits, nameof(hits));
 208110        ValidateRangeBatchOutput(requests.Length, ranges);
 208111        ValidateOverlapCircleRequests(requests);
 208112        ResetBatchCounters(requests.Length);
 208113        hits.FastClear();
 114
 1248115        for (int i = 0; i < requests.Length; i++)
 116        {
 416117            PhysicsOverlapCircle2DRequest request = requests[i];
 416118            int count = OverlapCircleAll(request.Center, request.Radius, request.LayerMask, _batch2DHits);
 416119            AppendRange(hits, ranges, i, count);
 120        }
 121
 208122        LastBatchHitCount = hits.Count;
 208123        return hits.Count;
 124    }
 125
 126    /// <summary>
 127    /// Executes multiple pure 2D AABB overlaps and writes one closest-hit slot per request.
 128    /// </summary>
 129    public int OverlapAabbBatch(ReadOnlySpan<PhysicsOverlapAabb2DRequest> requests, Span<Physics2DHit> closestHits)
 130    {
 209131        ValidateClosestBatchOutput(requests.Length, closestHits);
 209132        ValidateOverlapAabbRequests(requests);
 209133        ResetBatchCounters(requests.Length);
 134
 209135        int hitCount = 0;
 1256136        for (int i = 0; i < requests.Length; i++)
 137        {
 419138            PhysicsOverlapAabb2DRequest request = requests[i];
 419139            bool found = OverlapAabb(request.Center, request.Size, request.LayerMask, out Physics2DHit hit);
 419140            WriteClosestHit(closestHits, i, hit, found, ref hitCount);
 141        }
 142
 209143        LastBatchHitCount = hitCount;
 209144        return hitCount;
 145    }
 146
 147    /// <summary>
 148    /// Executes multiple pure 2D AABB overlaps and appends all hits into one caller-owned hit buffer.
 149    /// </summary>
 150    public int OverlapAabbAllBatch(
 151        ReadOnlySpan<PhysicsOverlapAabb2DRequest> requests,
 152        SwiftList<Physics2DHit> hits,
 153        Span<PhysicsQueryHitRange> ranges)
 154    {
 209155        SwiftThrowHelper.ThrowIfNull(hits, nameof(hits));
 209156        ValidateRangeBatchOutput(requests.Length, ranges);
 209157        ValidateOverlapAabbRequests(requests);
 209158        ResetBatchCounters(requests.Length);
 209159        hits.FastClear();
 160
 1256161        for (int i = 0; i < requests.Length; i++)
 162        {
 419163            PhysicsOverlapAabb2DRequest request = requests[i];
 419164            int count = OverlapAabbAll(request.Center, request.Size, request.LayerMask, _batch2DHits);
 419165            AppendRange(hits, ranges, i, count);
 166        }
 167
 209168        LastBatchHitCount = hits.Count;
 209169        return hits.Count;
 170    }
 171
 172    /// <summary>
 173    /// Executes multiple pure 2D convex polygon overlaps and writes one closest-hit slot per request.
 174    /// </summary>
 175    public int OverlapPolygonBatch(
 176        ReadOnlySpan<PhysicsOverlapPolygon2DRequest> requests,
 177        ReadOnlySpan<Vector2d> vertices,
 178        Span<Physics2DHit> closestHits)
 179    {
 5180        ValidateClosestBatchOutput(requests.Length, closestHits);
 5181        ValidatePolygonRequestRanges(requests, vertices);
 1182        ResetBatchCounters(requests.Length);
 183
 1184        int hitCount = 0;
 6185        for (int i = 0; i < requests.Length; i++)
 186        {
 2187            PhysicsOverlapPolygon2DRequest request = requests[i];
 2188            ReadOnlySpan<Vector2d> polygon = vertices.Slice(request.VertexStart, request.VertexCount);
 2189            bool found = OverlapPolygon(polygon, request.LayerMask, out Physics2DHit hit);
 2190            WriteClosestHit(closestHits, i, hit, found, ref hitCount);
 191        }
 192
 1193        LastBatchHitCount = hitCount;
 1194        return hitCount;
 195    }
 196
 197    /// <summary>
 198    /// Executes multiple pure 2D convex polygon overlaps and appends all hits into one caller-owned hit buffer.
 199    /// </summary>
 200    public int OverlapPolygonAllBatch(
 201        ReadOnlySpan<PhysicsOverlapPolygon2DRequest> requests,
 202        ReadOnlySpan<Vector2d> vertices,
 203        SwiftList<Physics2DHit> hits,
 204        Span<PhysicsQueryHitRange> ranges)
 205    {
 1206        SwiftThrowHelper.ThrowIfNull(hits, nameof(hits));
 1207        ValidateRangeBatchOutput(requests.Length, ranges);
 1208        ValidatePolygonRequestRanges(requests, vertices);
 1209        ResetBatchCounters(requests.Length);
 1210        hits.FastClear();
 211
 6212        for (int i = 0; i < requests.Length; i++)
 213        {
 2214            PhysicsOverlapPolygon2DRequest request = requests[i];
 2215            ReadOnlySpan<Vector2d> polygon = vertices.Slice(request.VertexStart, request.VertexCount);
 2216            int count = OverlapPolygonAll(polygon, request.LayerMask, _batch2DHits);
 2217            AppendRange(hits, ranges, i, count);
 218        }
 219
 1220        LastBatchHitCount = hits.Count;
 1221        return hits.Count;
 222    }
 223
 224    /// <summary>
 225    /// Executes multiple pure 2D swept-circle queries and writes one closest-hit slot per request.
 226    /// </summary>
 227    public int SweepCircleBatch(ReadOnlySpan<PhysicsSweepCircle2DRequest> requests, Span<Physics2DHit> closestHits)
 228    {
 2229        ValidateClosestBatchOutput(requests.Length, closestHits);
 2230        ValidateSweepCircleRequests(requests);
 2231        ResetBatchCounters(requests.Length);
 232
 2233        int hitCount = 0;
 10234        for (int i = 0; i < requests.Length; i++)
 235        {
 3236            PhysicsSweepCircle2DRequest request = requests[i];
 3237            bool found = SweepCircle(
 3238                request.Start,
 3239                request.End,
 3240                request.Radius,
 3241                request.LayerMask,
 3242                out Physics2DHit hit,
 3243                request.ExcludedCollider,
 3244                request.IncludeTriggers);
 3245            WriteClosestHit(closestHits, i, hit, found, ref hitCount);
 246        }
 247
 2248        LastBatchHitCount = hitCount;
 2249        return hitCount;
 250    }
 251
 252    /// <summary>
 253    /// Executes multiple pure 2D swept-circle queries and appends all hits into one caller-owned hit buffer.
 254    /// </summary>
 255    public int SweepCircleAllBatch(
 256        ReadOnlySpan<PhysicsSweepCircle2DRequest> requests,
 257        SwiftList<Physics2DHit> hits,
 258        Span<PhysicsQueryHitRange> ranges)
 259    {
 210260        SwiftThrowHelper.ThrowIfNull(hits, nameof(hits));
 210261        ValidateRangeBatchOutput(requests.Length, ranges);
 210262        ValidateSweepCircleRequests(requests);
 210263        ResetBatchCounters(requests.Length);
 210264        hits.FastClear();
 265
 842266        for (int i = 0; i < requests.Length; i++)
 267        {
 211268            PhysicsSweepCircle2DRequest request = requests[i];
 211269            int count = SweepCircleAll(
 211270                request.Start,
 211271                request.End,
 211272                request.Radius,
 211273                request.LayerMask,
 211274                _batch2DHits,
 211275                request.ExcludedCollider,
 211276                request.IncludeTriggers);
 211277            AppendRange(hits, ranges, i, count);
 278        }
 279
 210280        LastBatchHitCount = hits.Count;
 210281        return hits.Count;
 282    }
 283
 284    private void WriteClosestHit(Span<Physics2DHit> closestHits, int index, Physics2DHit hit, bool found, ref int hitCou
 285    {
 1261286        if (found)
 287        {
 1050288            closestHits[index] = hit;
 1050289            hitCount++;
 1050290            AccumulateBatchCounters(1);
 291        }
 292        else
 293        {
 211294            closestHits[index] = default;
 211295            AccumulateBatchCounters(0);
 296        }
 211297    }
 298
 299    private void AppendRange(
 300        SwiftList<Physics2DHit> hits,
 301        Span<PhysicsQueryHitRange> ranges,
 302        int index,
 303        int count)
 304    {
 1467305        int start = hits.Count;
 1467306        if (count > 0)
 1256307            hits.AddRange(_batch2DHits.AsReadOnlySpan());
 308
 1467309        ranges[index] = new PhysicsQueryHitRange(start, count);
 1467310        AccumulateBatchCounters(count);
 1467311    }
 312
 313    private void ResetBatchCounters(int requestCount)
 314    {
 1499315        LastBatchRequestCount = requestCount;
 1499316        LastBatchHitCount = 0;
 1499317        LastBatchCandidateCount = 0;
 1499318    }
 319
 320    private void AccumulateBatchCounters(int hitCount)
 321    {
 2728322        LastBatchHitCount += hitCount;
 2728323        LastBatchCandidateCount += LastQueryCandidateCount;
 2728324    }
 325
 326    private static void ValidateClosestBatchOutput(int requestCount, Span<Physics2DHit> closestHits)
 327    {
 634328        SwiftThrowHelper.ThrowIfArgument(
 634329            closestHits.Length < requestCount,
 634330            nameof(closestHits),
 634331            "Closest-hit output span must contain at least one slot per request.");
 634332    }
 333
 334    private static void ValidateRangeBatchOutput(int requestCount, Span<PhysicsQueryHitRange> ranges)
 335    {
 837336        SwiftThrowHelper.ThrowIfArgument(
 837337            ranges.Length < requestCount,
 837338            nameof(ranges),
 837339            "Range output span must contain at least one slot per request.");
 837340    }
 341
 342    private static void ValidatePolygonRequestRanges(
 343        ReadOnlySpan<PhysicsOverlapPolygon2DRequest> requests,
 344        ReadOnlySpan<Vector2d> vertices)
 345    {
 20346        for (int i = 0; i < requests.Length; i++)
 347        {
 8348            PhysicsOverlapPolygon2DRequest request = requests[i];
 8349            SwiftThrowHelper.ThrowIfArgument(
 8350                request.VertexStart < 0
 8351                || request.VertexCount < 0
 8352                || request.VertexStart > vertices.Length
 8353                || request.VertexCount > vertices.Length - request.VertexStart,
 8354                nameof(requests),
 8355                "Polygon batch request vertex range must be contained by the supplied vertex span.");
 356
 4357            QueryDetection2D.ValidateConvexQueryPolygon(vertices.Slice(request.VertexStart, request.VertexCount));
 358        }
 2359    }
 360
 361    private static void ValidateOverlapCircleRequests(ReadOnlySpan<PhysicsOverlapCircle2DRequest> requests)
 362    {
 2502363        for (int i = 0; i < requests.Length; i++)
 364        {
 834365            SwiftThrowHelper.ThrowIfArgument(
 834366                requests[i].Radius < Fixed64.Zero,
 834367                nameof(requests),
 834368                "2D query radius cannot be negative.");
 369        }
 417370    }
 371
 372    private static void ValidateOverlapAabbRequests(ReadOnlySpan<PhysicsOverlapAabb2DRequest> requests)
 373    {
 2512374        for (int i = 0; i < requests.Length; i++)
 838375            QueryDetection2D.ValidateAabbSize(requests[i].Size);
 418376    }
 377
 378    private static void ValidateSweepCircleRequests(ReadOnlySpan<PhysicsSweepCircle2DRequest> requests)
 379    {
 852380        for (int i = 0; i < requests.Length; i++)
 381        {
 214382            SwiftThrowHelper.ThrowIfArgument(
 214383                requests[i].Radius <= Fixed64.Zero,
 214384                nameof(requests),
 214385                "2D sweep radius must be greater than zero.");
 386        }
 212387    }
 388}

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Queries/2D/GravitasQuery2DService.cs

#LineLine coverage
 1//=======================================================================
 2// GravitasQuery2DService.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 Gravitas.Colliders;
 9using SwiftCollections;
 10
 11namespace Gravitas.Queries;
 12
 13/// <summary>
 14/// Owns pure 2D query buffers and query dispatch for one <see cref="GravitasWorldContext"/>.
 15/// </summary>
 16public sealed partial class GravitasQuery2DService
 17{
 18    private readonly GravitasWorldContext _context;
 508319    private readonly SwiftList<LSCollider2D> _queryCandidates = new();
 20    internal uint OverlapQueryVersion { get; set; }
 21    internal uint RaycastVersion { get; set; }
 22
 23    /// <summary>
 24    /// Initializes a pure 2D query service for the supplied context.
 25    /// </summary>
 26    /// <param name="context">The owning world context.</param>
 508327    public GravitasQuery2DService(GravitasWorldContext context)
 28    {
 508329        SwiftThrowHelper.ThrowIfNull(context, nameof(context));
 508330        _context = context;
 508331    }
 32
 33    /// <summary>
 34    /// Gets the owning world context.
 35    /// </summary>
 136    public GravitasWorldContext Context => _context;
 37
 38    internal int LastQueryCandidateCount { get; private set; }
 39
 40    /// <summary>
 41    /// Resets context-local pure 2D query buffers.
 42    /// </summary>
 43    public void Reset()
 44    {
 3245        ResetColliderOverlapQueryVersions();
 3246        ResetColliderRaycastVersions();
 3247        _queryCandidates.FastClear();
 3248        _batch2DHits.FastClear();
 3249        LastQueryCandidateCount = 0;
 3250        ResetBatchCounters(0);
 3251        OverlapQueryVersion = 0;
 3252        RaycastVersion = 0;
 3253    }
 54
 55}

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Queries/2D/GravitasQuery2DService.Overlap.cs

#LineLine coverage
 1//=======================================================================
 2// GravitasQuery2DService.Overlap.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;
 10using Gravitas.Support;
 11using SwiftCollections;
 12using System;
 13
 14namespace Gravitas.Queries;
 15
 16/// <summary>
 17/// Owns pure 2D overlap query behavior for one <see cref="GravitasWorldContext"/>.
 18/// </summary>
 19public sealed partial class GravitasQuery2DService
 20{
 21    /// <summary>
 22    /// Writes all active pure 2D colliders overlapping the query circle into <paramref name="results"/>.
 23    /// </summary>
 24    /// <returns>The number of hits written to <paramref name="results"/>.</returns>
 25    public int OverlapCircleAll(Vector2d center, Fixed64 radius, SwiftList<Physics2DHit> results)
 26    {
 2027        return OverlapCircleAll(center, radius, PhysicsLayerMask.All, results);
 28    }
 29
 30    /// <summary>
 31    /// Writes all active pure 2D colliders on included layers that overlap the query circle.
 32    /// </summary>
 33    /// <returns>The number of hits written to <paramref name="results"/>.</returns>
 34    public int OverlapCircleAll(
 35        Vector2d center,
 36        Fixed64 radius,
 37        PhysicsLayerMask layerMask,
 38        SwiftList<Physics2DHit> results)
 39    {
 43940        return OverlapCircleAllCore(center, radius, layerMask, results, staticTargetsOnly: false);
 41    }
 42
 43    internal int OverlapCircleAgainstStaticAll(
 44        Vector2d center,
 45        Fixed64 radius,
 46        PhysicsLayerMask layerMask,
 47        SwiftList<Physics2DHit> results,
 48        LSCollider2D? excludedCollider = null,
 49        bool includeTriggers = true)
 50    {
 21351        return OverlapCircleAllCore(
 21352            center,
 21353            radius,
 21354            layerMask,
 21355            results,
 21356            staticTargetsOnly: true,
 21357            excludedCollider: excludedCollider,
 21358            includeTriggers: includeTriggers);
 59    }
 60
 61    /// <summary>
 62    /// Finds the closest active pure 2D collider overlapping the supplied query circle.
 63    /// </summary>
 64    public bool OverlapCircle(Vector2d center, Fixed64 radius, out Physics2DHit hit)
 65    {
 566        return OverlapCircle(center, radius, PhysicsLayerMask.All, out hit);
 67    }
 68
 69    /// <summary>
 70    /// Finds the closest active pure 2D collider on an included layer overlapping the supplied query circle.
 71    /// </summary>
 72    public bool OverlapCircle(Vector2d center, Fixed64 radius, PhysicsLayerMask layerMask, out Physics2DHit hit)
 73    {
 42474        SwiftThrowHelper.ThrowIfArgument(radius < Fixed64.Zero, nameof(radius), "2D query radius cannot be negative.");
 75
 42476        EnsureCandidateCapacity();
 42477        uint queryVersion = NextOverlapQueryVersion();
 42478        _context.Collisions2D.CollectBoundsCandidates(
 42479            new Vector2d(center.X - radius, center.Y - radius),
 42480            new Vector2d(center.X + radius, center.Y + radius),
 42481            layerMask,
 42482            queryVersion,
 42483            raycastQuery: false,
 42484            _queryCandidates);
 85
 42486        LastQueryCandidateCount = _queryCandidates.Count;
 42487        bool found = false;
 42488        Physics2DHit closest = default;
 1501089        for (int i = 0; i < _queryCandidates.Count; i++)
 90        {
 708191            if (!QueryDetection2D.TryOverlapCircle(center, radius, _queryCandidates[i], out Physics2DHit candidate)
 708192                || !PhysicsHitSelectionPolicy.ShouldReplace(candidate, found, closest))
 93            {
 94                continue;
 95            }
 96
 375197            closest = candidate;
 375198            found = true;
 99        }
 100
 424101        hit = closest;
 424102        return found;
 103    }
 104
 105    /// <summary>
 106    /// Finds the closest active pure 2D collider overlapping the supplied axis-aligned box.
 107    /// </summary>
 108    public bool OverlapAabb(Vector2d center, Vector2d size, out Physics2DHit hit)
 109    {
 2110        return OverlapAabb(center, size, PhysicsLayerMask.All, out hit);
 111    }
 112
 113    /// <summary>
 114    /// Finds the closest active pure 2D collider on an included layer overlapping the supplied axis-aligned box.
 115    /// </summary>
 116    public bool OverlapAabb(Vector2d center, Vector2d size, PhysicsLayerMask layerMask, out Physics2DHit hit)
 117    {
 422118        QueryDetection2D.ValidateAabbSize(size);
 422119        Vector2d halfExtents = size * Fixed64.Half;
 422120        Span<Vector2d> vertices = stackalloc Vector2d[4];
 422121        CreateAabbVertices(center, halfExtents, vertices);
 422122        return OverlapAreaCore(
 422123            vertices,
 422124            center,
 422125            center - halfExtents,
 422126            center + halfExtents,
 422127            layerMask,
 422128            out hit);
 129    }
 130
 131    /// <summary>
 132    /// Writes all active pure 2D colliders overlapping the supplied axis-aligned box into <paramref name="results"/>.
 133    /// </summary>
 134    /// <returns>The number of hits written to <paramref name="results"/>.</returns>
 135    public int OverlapAabbAll(Vector2d center, Vector2d size, SwiftList<Physics2DHit> results)
 136    {
 8137        return OverlapAabbAll(center, size, PhysicsLayerMask.All, results);
 138    }
 139
 140    /// <summary>
 141    /// Writes all active pure 2D colliders on included layers that overlap the supplied axis-aligned box.
 142    /// </summary>
 143    /// <returns>The number of hits written to <paramref name="results"/>.</returns>
 144    public int OverlapAabbAll(
 145        Vector2d center,
 146        Vector2d size,
 147        PhysicsLayerMask layerMask,
 148        SwiftList<Physics2DHit> results)
 149    {
 427150        SwiftThrowHelper.ThrowIfNull(results, nameof(results));
 427151        QueryDetection2D.ValidateAabbSize(size);
 425152        Vector2d halfExtents = size * Fixed64.Half;
 425153        Span<Vector2d> vertices = stackalloc Vector2d[4];
 425154        CreateAabbVertices(center, halfExtents, vertices);
 425155        return OverlapAreaAllCore(
 425156            vertices,
 425157            center,
 425158            center - halfExtents,
 425159            center + halfExtents,
 425160            layerMask,
 425161            results);
 162    }
 163
 164    /// <summary>
 165    /// Finds the closest active pure 2D collider overlapping the supplied convex polygon.
 166    /// </summary>
 167    public bool OverlapPolygon(ReadOnlySpan<Vector2d> vertices, out Physics2DHit hit)
 168    {
 3169        return OverlapPolygon(vertices, PhysicsLayerMask.All, out hit);
 170    }
 171
 172    /// <summary>
 173    /// Finds the closest active pure 2D collider on an included layer overlapping the supplied convex polygon.
 174    /// </summary>
 175    public bool OverlapPolygon(ReadOnlySpan<Vector2d> vertices, PhysicsLayerMask layerMask, out Physics2DHit hit)
 176    {
 5177        QueryDetection2D.ValidateConvexQueryPolygon(vertices);
 5178        Vector2d center = QueryDetection2D.CalculateAverageCenter(vertices);
 5179        CalculateAreaBounds(vertices, out Vector2d min, out Vector2d max);
 5180        return OverlapAreaCore(vertices, center, min, max, layerMask, out hit);
 181    }
 182
 183    /// <summary>
 184    /// Writes all active pure 2D colliders overlapping the supplied convex polygon into <paramref name="results"/>.
 185    /// </summary>
 186    /// <returns>The number of hits written to <paramref name="results"/>.</returns>
 187    public int OverlapPolygonAll(ReadOnlySpan<Vector2d> vertices, SwiftList<Physics2DHit> results)
 188    {
 5189        return OverlapPolygonAll(vertices, PhysicsLayerMask.All, results);
 190    }
 191
 192    /// <summary>
 193    /// Writes all active pure 2D colliders on included layers that overlap the supplied convex polygon.
 194    /// </summary>
 195    /// <returns>The number of hits written to <paramref name="results"/>.</returns>
 196    public int OverlapPolygonAll(
 197        ReadOnlySpan<Vector2d> vertices,
 198        PhysicsLayerMask layerMask,
 199        SwiftList<Physics2DHit> results)
 200    {
 7201        SwiftThrowHelper.ThrowIfNull(results, nameof(results));
 7202        QueryDetection2D.ValidateConvexQueryPolygon(vertices);
 7203        Vector2d center = QueryDetection2D.CalculateAverageCenter(vertices);
 7204        CalculateAreaBounds(vertices, out Vector2d min, out Vector2d max);
 7205        return OverlapAreaAllCore(vertices, center, min, max, layerMask, results);
 206    }
 207
 208    private int OverlapCircleAllCore(
 209        Vector2d center,
 210        Fixed64 radius,
 211        PhysicsLayerMask layerMask,
 212        SwiftList<Physics2DHit> results,
 213        bool staticTargetsOnly,
 214        LSCollider2D? excludedCollider = null,
 215        bool includeTriggers = true)
 216    {
 652217        SwiftThrowHelper.ThrowIfNull(results, nameof(results));
 652218        SwiftThrowHelper.ThrowIfArgument(radius < Fixed64.Zero, nameof(radius), "2D query radius cannot be negative.");
 219
 652220        results.FastClear();
 652221        EnsureCandidateCapacity();
 652222        uint queryVersion = NextOverlapQueryVersion();
 652223        _context.Collisions2D.CollectBoundsCandidates(
 652224            new Vector2d(center.X - radius, center.Y - radius),
 652225            new Vector2d(center.X + radius, center.Y + radius),
 652226            layerMask,
 652227            queryVersion,
 652228            raycastQuery: false,
 652229            _queryCandidates,
 652230            staticStyleOnly: staticTargetsOnly);
 231
 652232        LastQueryCandidateCount = _queryCandidates.Count;
 16128233        for (int i = 0; i < _queryCandidates.Count; i++)
 234        {
 7412235            LSCollider2D collider = _queryCandidates[i];
 7412236            if (IsEligibleSweepCandidate(collider, excludedCollider, includeTriggers)
 7412237                && QueryDetection2D.TryOverlapCircle(center, radius, collider, out Physics2DHit hit))
 238            {
 7228239                results.Add(hit);
 240            }
 241        }
 242
 652243        Physics2DHitSorter.SortByDistance(results);
 652244        return results.Count;
 245    }
 246
 247    private bool OverlapAreaCore(
 248        ReadOnlySpan<Vector2d> vertices,
 249        Vector2d center,
 250        Vector2d min,
 251        Vector2d max,
 252        PhysicsLayerMask layerMask,
 253        out Physics2DHit hit)
 254    {
 427255        EnsureCandidateCapacity();
 427256        uint queryVersion = NextOverlapQueryVersion();
 427257        _context.Collisions2D.CollectBoundsCandidates(
 427258            min,
 427259            max,
 427260            layerMask,
 427261            queryVersion,
 427262            raycastQuery: false,
 427263            _queryCandidates);
 264
 427265        LastQueryCandidateCount = _queryCandidates.Count;
 427266        bool found = false;
 427267        Physics2DHit closest = default;
 8362268        for (int i = 0; i < _queryCandidates.Count; i++)
 269        {
 3754270            if (!QueryDetection2D.TryOverlapPolygon(vertices, center, _queryCandidates[i], out Physics2DHit candidate)
 3754271                || !PhysicsHitSelectionPolicy.ShouldReplace(candidate, found, closest))
 272            {
 273                continue;
 274            }
 275
 2089276            closest = candidate;
 2089277            found = true;
 278        }
 279
 427280        hit = closest;
 427281        return found;
 282    }
 283
 284    private int OverlapAreaAllCore(
 285        ReadOnlySpan<Vector2d> vertices,
 286        Vector2d center,
 287        Vector2d min,
 288        Vector2d max,
 289        PhysicsLayerMask layerMask,
 290        SwiftList<Physics2DHit> results)
 291    {
 432292        results.FastClear();
 432293        EnsureCandidateCapacity();
 432294        uint queryVersion = NextOverlapQueryVersion();
 432295        _context.Collisions2D.CollectBoundsCandidates(
 432296            min,
 432297            max,
 432298            layerMask,
 432299            queryVersion,
 432300            raycastQuery: false,
 432301            _queryCandidates);
 302
 432303        LastQueryCandidateCount = _queryCandidates.Count;
 8902304        for (int i = 0; i < _queryCandidates.Count; i++)
 4019305            if (QueryDetection2D.TryOverlapPolygon(vertices, center, _queryCandidates[i], out Physics2DHit hit))
 4018306                results.Add(hit);
 307
 432308        Physics2DHitSorter.SortByDistance(results);
 432309        return results.Count;
 310    }
 311
 312}

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Queries/2D/GravitasQuery2DService.Raycast.cs

#LineLine coverage
 1//=======================================================================
 2// GravitasQuery2DService.Raycast.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.Support;
 10using SwiftCollections;
 11
 12namespace Gravitas.Queries;
 13
 14/// <summary>
 15/// Owns pure 2D segment raycast query behavior for one <see cref="GravitasWorldContext"/>.
 16/// </summary>
 17public sealed partial class GravitasQuery2DService
 18{
 19    /// <summary>
 20    /// Finds the closest pure 2D collider hit by the segment from <paramref name="start"/> to <paramref name="end"/>.
 21    /// </summary>
 22    public bool Raycast(Vector2d start, Vector2d end, out Physics2DHit hit)
 23    {
 724        return Raycast(start, end, PhysicsLayerMask.All, out hit);
 25    }
 26
 27    /// <summary>
 28    /// Finds the closest pure 2D collider on an included layer hit by the segment.
 29    /// </summary>
 30    public bool Raycast(Vector2d start, Vector2d end, PhysicsLayerMask layerMask, out Physics2DHit hit)
 31    {
 42632        if (!Vector2d.TrySubtract(end, start, out Vector2d segment)
 42633            || !Vector2d.TryGetMagnitude(segment, out Fixed64 segmentLength)
 42634            || segmentLength == Fixed64.Zero)
 35        {
 336            LastQueryCandidateCount = 0;
 337            hit = default;
 338            return false;
 39        }
 40
 42341        EnsureCandidateCapacity();
 42342        uint queryVersion = NextRaycastVersion();
 42343        _context.Collisions2D.CollectBoundsCandidates(
 42344            CreateMin(start, end),
 42345            CreateMax(start, end),
 42346            layerMask,
 42347            queryVersion,
 42348            raycastQuery: true,
 42349            _queryCandidates);
 50
 42351        LastQueryCandidateCount = _queryCandidates.Count;
 42352        bool found = false;
 42353        Physics2DHit closest = default;
 1417254        for (int i = 0; i < _queryCandidates.Count; i++)
 55        {
 666356            if (!QueryDetection2D.TryRaycast(start, end, _queryCandidates[i], out Physics2DHit candidate)
 666357                || !PhysicsHitSelectionPolicy.ShouldReplace(candidate, found, closest))
 58            {
 59                continue;
 60            }
 61
 21462            closest = candidate;
 21463            found = true;
 64        }
 65
 42366        hit = closest;
 42367        return found;
 68    }
 69
 70    /// <summary>
 71    /// Writes all pure 2D colliders hit by the segment into <paramref name="results"/>.
 72    /// </summary>
 73    public int RaycastAll(Vector2d start, Vector2d end, SwiftList<Physics2DHit> results)
 74    {
 1675        return RaycastAll(start, end, PhysicsLayerMask.All, results);
 76    }
 77
 78    /// <summary>
 79    /// Writes all pure 2D colliders on included layers hit by the segment into <paramref name="results"/>.
 80    /// </summary>
 81    public int RaycastAll(Vector2d start, Vector2d end, PhysicsLayerMask layerMask, SwiftList<Physics2DHit> results)
 82    {
 45683        SwiftThrowHelper.ThrowIfNull(results, nameof(results));
 84
 45685        results.FastClear();
 45686        if (!Vector2d.TrySubtract(end, start, out Vector2d segment)
 45687            || !Vector2d.TryGetMagnitude(segment, out Fixed64 segmentLength)
 45688            || segmentLength == Fixed64.Zero)
 89        {
 490            LastQueryCandidateCount = 0;
 491            return 0;
 92        }
 93
 45294        EnsureCandidateCapacity();
 45295        uint queryVersion = NextRaycastVersion();
 45296        _context.Collisions2D.CollectBoundsCandidates(
 45297            CreateMin(start, end),
 45298            CreateMax(start, end),
 45299            layerMask,
 452100            queryVersion,
 452101            raycastQuery: true,
 452102            _queryCandidates);
 103
 452104        LastQueryCandidateCount = _queryCandidates.Count;
 15312105        for (int i = 0; i < _queryCandidates.Count; i++)
 7204106            if (QueryDetection2D.TryRaycast(start, end, _queryCandidates[i], out Physics2DHit hit))
 7200107                results.Add(hit);
 108
 452109        Physics2DHitSorter.SortByDistance(results);
 452110        return results.Count;
 111    }
 112
 113}

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Queries/2D/GravitasQuery2DService.Support.cs

#LineLine coverage
 1//=======================================================================
 2// GravitasQuery2DService.Support.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;
 10using System;
 11using System.Runtime.CompilerServices;
 12
 13namespace Gravitas.Queries;
 14
 15/// <summary>
 16/// Owns pure 2D query scratch, version, and bounds helpers.
 17/// </summary>
 18public sealed partial class GravitasQuery2DService
 19{
 20    private void EnsureCandidateCapacity()
 21    {
 879422        int colliderCount = _context.Physics2D.ColliderCount;
 879423        if (colliderCount > 0)
 879324            _queryCandidates.EnsureCapacity(colliderCount);
 879425    }
 26
 27    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 28    private uint NextOverlapQueryVersion()
 29    {
 193530        OverlapQueryVersion++;
 193531        if (OverlapQueryVersion == 0)
 32        {
 133            ResetColliderOverlapQueryVersions();
 134            OverlapQueryVersion = 1;
 35        }
 193536        return OverlapQueryVersion;
 37    }
 38
 39    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 40    private uint NextRaycastVersion()
 41    {
 685942        RaycastVersion++;
 685943        if (RaycastVersion == 0)
 44        {
 145            ResetColliderRaycastVersions();
 146            RaycastVersion = 1;
 47        }
 685948        return RaycastVersion;
 49    }
 50
 51    private void ResetColliderOverlapQueryVersions()
 52    {
 7053        for (int i = 0; i < _context.Physics2D.ColliderCount; i++)
 254            _context.Physics2D.GetColliderByServiceIndex(i).CircleQueryVersion = 0;
 3355    }
 56
 57    private void ResetColliderRaycastVersions()
 58    {
 7059        for (int i = 0; i < _context.Physics2D.ColliderCount; i++)
 260            _context.Physics2D.GetColliderByServiceIndex(i).RaycastVersion = 0;
 3361    }
 62
 63    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 64    private static Vector2d CreateMin(Vector2d first, Vector2d second) =>
 87565        new(FixedMath.Min(first.X, second.X), FixedMath.Min(first.Y, second.Y));
 66
 67    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 68    private static Vector2d CreateMax(Vector2d first, Vector2d second) =>
 87569        new(FixedMath.Max(first.X, second.X), FixedMath.Max(first.Y, second.Y));
 70
 71    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 72    private static Vector2d CreateSweepMin(Vector2d first, Vector2d second, Fixed64 radius) =>
 598473        new(FixedMath.Min(first.X, second.X) - radius, FixedMath.Min(first.Y, second.Y) - radius);
 74
 75    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 76    private static Vector2d CreateSweepMax(Vector2d first, Vector2d second, Fixed64 radius) =>
 598477        new(FixedMath.Max(first.X, second.X) + radius, FixedMath.Max(first.Y, second.Y) + radius);
 78
 79    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 80    private static void CreateAabbVertices(Vector2d center, Vector2d halfExtents, Span<Vector2d> vertices)
 81    {
 84782        vertices[0] = center - halfExtents;
 84783        vertices[1] = new Vector2d(center.X + halfExtents.X, center.Y - halfExtents.Y);
 84784        vertices[2] = center + halfExtents;
 84785        vertices[3] = new Vector2d(center.X - halfExtents.X, center.Y + halfExtents.Y);
 84786    }
 87
 88    private static void CalculateAreaBounds(ReadOnlySpan<Vector2d> vertices, out Vector2d min, out Vector2d max)
 89    {
 1290        min = vertices[0];
 1291        max = min;
 9492        for (int i = 1; i < vertices.Length; i++)
 93        {
 3594            Vector2d vertex = vertices[i];
 3595            min = new Vector2d(FixedMath.Min(min.X, vertex.X), FixedMath.Min(min.Y, vertex.Y));
 3596            max = new Vector2d(FixedMath.Max(max.X, vertex.X), FixedMath.Max(max.Y, vertex.Y));
 97        }
 1298    }
 99
 100    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 101    private static bool IsEligibleSweepCandidate(LSCollider2D collider, LSCollider2D? excludedCollider, bool includeTrig
 102    {
 15473103        if (!includeTriggers && collider.IsTrigger)
 27104            return false;
 105
 15446106        return excludedCollider == null
 15446107            || (!ReferenceEquals(collider, excludedCollider)
 15446108                && !ReferenceEquals(collider.AgentOrNull, excludedCollider.AgentOrNull)
 15446109                && !collider.IsSibling(excludedCollider));
 110    }
 111}

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Queries/2D/GravitasQuery2DService.Sweep.cs

#LineLine coverage
 1//=======================================================================
 2// GravitasQuery2DService.Sweep.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;
 10using Gravitas.Support;
 11using SwiftCollections;
 12
 13namespace Gravitas.Queries;
 14
 15/// <summary>
 16/// Owns pure 2D swept-circle query behavior for one <see cref="GravitasWorldContext"/>.
 17/// </summary>
 18public sealed partial class GravitasQuery2DService
 19{
 20    /// <summary>
 21    /// Finds the closest pure 2D collider hit by sweeping a circle from <paramref name="start"/> to <paramref name="end
 22    /// </summary>
 23    public bool SweepCircle(Vector2d start, Vector2d end, Fixed64 radius, out Physics2DHit hit)
 24    {
 525        return SweepCircle(start, end, radius, PhysicsLayerMask.All, out hit);
 26    }
 27
 28    /// <summary>
 29    /// Finds the closest pure 2D collider on an included layer hit by sweeping a circle.
 30    /// </summary>
 31    public bool SweepCircle(
 32        Vector2d start,
 33        Vector2d end,
 34        Fixed64 radius,
 35        PhysicsLayerMask layerMask,
 36        out Physics2DHit hit,
 37        LSCollider2D? excludedCollider = null,
 38        bool includeTriggers = true)
 39    {
 940        SwiftThrowHelper.ThrowIfArgument(radius <= Fixed64.Zero, nameof(radius), "2D sweep radius must be greater than z
 41
 942        if (!Vector2d.TrySubtract(end, start, out Vector2d segment)
 943            || !Vector2d.TryGetMagnitude(segment, out Fixed64 segmentLength)
 944            || segmentLength <= Fixed64.Epsilon)
 45        {
 546            LastQueryCandidateCount = 0;
 547            hit = default;
 548            return false;
 49        }
 50
 451        EnsureCandidateCapacity();
 452        uint queryVersion = NextRaycastVersion();
 453        _context.Collisions2D.CollectBoundsCandidates(
 454            CreateSweepMin(start, end, radius),
 455            CreateSweepMax(start, end, radius),
 456            layerMask,
 457            queryVersion,
 458            raycastQuery: true,
 459            _queryCandidates);
 60
 461        LastQueryCandidateCount = _queryCandidates.Count;
 462        bool found = false;
 463        Physics2DHit closest = default;
 2264        for (int i = 0; i < _queryCandidates.Count; i++)
 65        {
 766            LSCollider2D collider = _queryCandidates[i];
 767            if (!IsEligibleSweepCandidate(collider, excludedCollider, includeTriggers)
 768                || !QueryDetection2D.TrySweepCircle(start, end, radius, collider, out Physics2DHit candidate)
 769                || !PhysicsHitSelectionPolicy.ShouldReplace(candidate, found, closest))
 70            {
 71                continue;
 72            }
 73
 374            closest = candidate;
 375            found = true;
 76        }
 77
 478        hit = closest;
 479        return found;
 80    }
 81
 82    /// <summary>
 83    /// Writes all pure 2D colliders hit by sweeping a circle into <paramref name="results"/>.
 84    /// </summary>
 85    public int SweepCircleAll(Vector2d start, Vector2d end, Fixed64 radius, SwiftList<Physics2DHit> results)
 86    {
 1587        return SweepCircleAll(start, end, radius, PhysicsLayerMask.All, results);
 88    }
 89
 90    /// <summary>
 91    /// Writes all pure 2D colliders on included layers hit by sweeping a circle into <paramref name="results"/>.
 92    /// </summary>
 93    public int SweepCircleAll(
 94        Vector2d start,
 95        Vector2d end,
 96        Fixed64 radius,
 97        PhysicsLayerMask layerMask,
 98        SwiftList<Physics2DHit> results,
 99        LSCollider2D? excludedCollider = null,
 100        bool includeTriggers = true)
 101    {
 230102        return SweepCircleAllCore(
 230103            start,
 230104            end,
 230105            radius,
 230106            layerMask,
 230107            results,
 230108            excludedCollider,
 230109            includeTriggers,
 230110            staticTargetsOnly: false);
 111    }
 112
 113    internal int SweepCircleAgainstStaticAll(
 114        Vector2d start,
 115        Vector2d end,
 116        Fixed64 radius,
 117        PhysicsLayerMask layerMask,
 118        SwiftList<Physics2DHit> results,
 119        LSCollider2D? excludedCollider = null,
 120        bool includeTriggers = true)
 121    {
 5756122        return SweepCircleAllCore(
 5756123            start,
 5756124            end,
 5756125            radius,
 5756126            layerMask,
 5756127            results,
 5756128            excludedCollider,
 5756129            includeTriggers,
 5756130            staticTargetsOnly: true);
 131    }
 132
 133    private int SweepCircleAllCore(
 134        Vector2d start,
 135        Vector2d end,
 136        Fixed64 radius,
 137        PhysicsLayerMask layerMask,
 138        SwiftList<Physics2DHit> results,
 139        LSCollider2D? excludedCollider,
 140        bool includeTriggers,
 141        bool staticTargetsOnly)
 142    {
 5986143        SwiftThrowHelper.ThrowIfNull(results, nameof(results));
 5986144        SwiftThrowHelper.ThrowIfArgument(radius <= Fixed64.Zero, nameof(radius), "2D sweep radius must be greater than z
 145
 5986146        results.FastClear();
 5986147        if (!Vector2d.TrySubtract(end, start, out Vector2d segment)
 5986148            || !Vector2d.TryGetMagnitude(segment, out Fixed64 segmentLength)
 5986149            || segmentLength <= Fixed64.Epsilon)
 150        {
 6151            LastQueryCandidateCount = 0;
 6152            return 0;
 153        }
 154
 5980155        EnsureCandidateCapacity();
 5980156        uint queryVersion = NextRaycastVersion();
 5980157        _context.Collisions2D.CollectBoundsCandidates(
 5980158            CreateSweepMin(start, end, radius),
 5980159            CreateSweepMax(start, end, radius),
 5980160            layerMask,
 5980161            queryVersion,
 5980162            raycastQuery: true,
 5980163            _queryCandidates,
 5980164            staticStyleOnly: staticTargetsOnly);
 165
 5980166        LastQueryCandidateCount = _queryCandidates.Count;
 28068167        for (int i = 0; i < _queryCandidates.Count; i++)
 168        {
 8054169            LSCollider2D collider = _queryCandidates[i];
 8054170            if (IsEligibleSweepCandidate(collider, excludedCollider, includeTriggers)
 8054171                && QueryDetection2D.TrySweepCircle(start, end, radius, collider, out Physics2DHit hit))
 172            {
 7953173                results.Add(hit);
 174            }
 175        }
 176
 5980177        Physics2DHitSorter.SortByDistance(results);
 5980178        return results.Count;
 179    }
 180
 181}

Methods/Properties

.ctor(Gravitas.GravitasWorldContext)
RaycastBatch(System.ReadOnlySpan`1<Gravitas.Queries.PhysicsRaycast2DRequest>,System.Span`1<Gravitas.Queries.Physics2DHit>)
RaycastAllBatch(System.ReadOnlySpan`1<Gravitas.Queries.PhysicsRaycast2DRequest>,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>,System.Span`1<Gravitas.Queries.PhysicsQueryHitRange>)
OverlapCircleBatch(System.ReadOnlySpan`1<Gravitas.Queries.PhysicsOverlapCircle2DRequest>,System.Span`1<Gravitas.Queries.Physics2DHit>)
OverlapCircleAllBatch(System.ReadOnlySpan`1<Gravitas.Queries.PhysicsOverlapCircle2DRequest>,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>,System.Span`1<Gravitas.Queries.PhysicsQueryHitRange>)
OverlapAabbBatch(System.ReadOnlySpan`1<Gravitas.Queries.PhysicsOverlapAabb2DRequest>,System.Span`1<Gravitas.Queries.Physics2DHit>)
OverlapAabbAllBatch(System.ReadOnlySpan`1<Gravitas.Queries.PhysicsOverlapAabb2DRequest>,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>,System.Span`1<Gravitas.Queries.PhysicsQueryHitRange>)
OverlapPolygonBatch(System.ReadOnlySpan`1<Gravitas.Queries.PhysicsOverlapPolygon2DRequest>,System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,System.Span`1<Gravitas.Queries.Physics2DHit>)
OverlapPolygonAllBatch(System.ReadOnlySpan`1<Gravitas.Queries.PhysicsOverlapPolygon2DRequest>,System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>,System.Span`1<Gravitas.Queries.PhysicsQueryHitRange>)
SweepCircleBatch(System.ReadOnlySpan`1<Gravitas.Queries.PhysicsSweepCircle2DRequest>,System.Span`1<Gravitas.Queries.Physics2DHit>)
SweepCircleAllBatch(System.ReadOnlySpan`1<Gravitas.Queries.PhysicsSweepCircle2DRequest>,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>,System.Span`1<Gravitas.Queries.PhysicsQueryHitRange>)
WriteClosestHit(System.Span`1<Gravitas.Queries.Physics2DHit>,System.Int32,Gravitas.Queries.Physics2DHit,System.Boolean,System.Int32&)
AppendRange(SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>,System.Span`1<Gravitas.Queries.PhysicsQueryHitRange>,System.Int32,System.Int32)
ResetBatchCounters(System.Int32)
AccumulateBatchCounters(System.Int32)
ValidateClosestBatchOutput(System.Int32,System.Span`1<Gravitas.Queries.Physics2DHit>)
ValidateRangeBatchOutput(System.Int32,System.Span`1<Gravitas.Queries.PhysicsQueryHitRange>)
ValidatePolygonRequestRanges(System.ReadOnlySpan`1<Gravitas.Queries.PhysicsOverlapPolygon2DRequest>,System.ReadOnlySpan`1<FixedMathSharp.Vector2d>)
ValidateOverlapCircleRequests(System.ReadOnlySpan`1<Gravitas.Queries.PhysicsOverlapCircle2DRequest>)
ValidateOverlapAabbRequests(System.ReadOnlySpan`1<Gravitas.Queries.PhysicsOverlapAabb2DRequest>)
ValidateSweepCircleRequests(System.ReadOnlySpan`1<Gravitas.Queries.PhysicsSweepCircle2DRequest>)
.ctor(Gravitas.GravitasWorldContext)
get_Context()
Reset()
OverlapCircleAll(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>)
OverlapCircleAll(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,Gravitas.Support.PhysicsLayerMask,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>)
OverlapCircleAgainstStaticAll(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,Gravitas.Support.PhysicsLayerMask,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>,Gravitas.Colliders.LSCollider2D,System.Boolean)
OverlapCircle(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,Gravitas.Queries.Physics2DHit&)
OverlapCircle(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,Gravitas.Support.PhysicsLayerMask,Gravitas.Queries.Physics2DHit&)
OverlapAabb(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,Gravitas.Queries.Physics2DHit&)
OverlapAabb(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,Gravitas.Support.PhysicsLayerMask,Gravitas.Queries.Physics2DHit&)
OverlapAabbAll(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>)
OverlapAabbAll(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,Gravitas.Support.PhysicsLayerMask,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>)
OverlapPolygon(System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,Gravitas.Queries.Physics2DHit&)
OverlapPolygon(System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,Gravitas.Support.PhysicsLayerMask,Gravitas.Queries.Physics2DHit&)
OverlapPolygonAll(System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>)
OverlapPolygonAll(System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,Gravitas.Support.PhysicsLayerMask,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>)
OverlapCircleAllCore(FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,Gravitas.Support.PhysicsLayerMask,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>,System.Boolean,Gravitas.Colliders.LSCollider2D,System.Boolean)
OverlapAreaCore(System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,Gravitas.Support.PhysicsLayerMask,Gravitas.Queries.Physics2DHit&)
OverlapAreaAllCore(System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,Gravitas.Support.PhysicsLayerMask,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>)
Raycast(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,Gravitas.Queries.Physics2DHit&)
Raycast(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,Gravitas.Support.PhysicsLayerMask,Gravitas.Queries.Physics2DHit&)
RaycastAll(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>)
RaycastAll(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,Gravitas.Support.PhysicsLayerMask,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>)
EnsureCandidateCapacity()
NextOverlapQueryVersion()
NextRaycastVersion()
ResetColliderOverlapQueryVersions()
ResetColliderRaycastVersions()
CreateMin(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
CreateMax(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d)
CreateSweepMin(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64)
CreateSweepMax(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64)
CreateAabbVertices(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,System.Span`1<FixedMathSharp.Vector2d>)
CalculateAreaBounds(System.ReadOnlySpan`1<FixedMathSharp.Vector2d>,FixedMathSharp.Vector2d&,FixedMathSharp.Vector2d&)
IsEligibleSweepCandidate(Gravitas.Colliders.LSCollider2D,Gravitas.Colliders.LSCollider2D,System.Boolean)
SweepCircle(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,Gravitas.Queries.Physics2DHit&)
SweepCircle(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,Gravitas.Support.PhysicsLayerMask,Gravitas.Queries.Physics2DHit&,Gravitas.Colliders.LSCollider2D,System.Boolean)
SweepCircleAll(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>)
SweepCircleAll(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,Gravitas.Support.PhysicsLayerMask,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>,Gravitas.Colliders.LSCollider2D,System.Boolean)
SweepCircleAgainstStaticAll(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,Gravitas.Support.PhysicsLayerMask,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>,Gravitas.Colliders.LSCollider2D,System.Boolean)
SweepCircleAllCore(FixedMathSharp.Vector2d,FixedMathSharp.Vector2d,FixedMathSharp.Fixed64,Gravitas.Support.PhysicsLayerMask,SwiftCollections.SwiftList`1<Gravitas.Queries.Physics2DHit>,Gravitas.Colliders.LSCollider2D,System.Boolean,System.Boolean)