| | | 1 | | //======================================================================= |
| | | 2 | | // Physics2DSupportHit.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 | | |
| | | 8 | | namespace Gravitas.Queries; |
| | | 9 | | |
| | | 10 | | /// <summary>A sampled support surface and its owning collider registration lifetime.</summary> |
| | | 11 | | public readonly struct Physics2DSupportHit |
| | | 12 | | { |
| | | 13 | | private readonly long _lifetime; |
| | | 14 | | |
| | | 15 | | internal Physics2DSupportHit(Physics2DHit hit, long frame) |
| | | 16 | | { |
| | 239 | 17 | | Hit = hit; |
| | 239 | 18 | | SampledFrame = frame; |
| | 239 | 19 | | _lifetime = hit.Collider.LifetimeVersion; |
| | 239 | 20 | | } |
| | | 21 | | |
| | | 22 | | /// <summary>Gets the selected target-surface witness, not the probe center.</summary> |
| | | 23 | | public Physics2DHit Hit { get; } |
| | | 24 | | /// <summary>Gets the context frame on which the query ran.</summary> |
| | | 25 | | public long SampledFrame { get; } |
| | | 26 | | /// <summary>Whether the same active collider registration still exists; this does not certify geometric freshness.< |
| | 21 | 27 | | public bool IsCurrentLifetime => Hit.Collider != null |
| | 21 | 28 | | && Hit.Collider.IsActive && Hit.Collider.LifetimeVersion == _lifetime |
| | 21 | 29 | | && !Hit.Collider.Context.IsDisposed |
| | 21 | 30 | | && Hit.Collider.Context.Physics2D.TryGetColliderById(Hit.Collider.Id, out var registered) |
| | 21 | 31 | | && ReferenceEquals(registered, Hit.Collider); |
| | | 32 | | } |
| | | 33 | | // MIT License, Copyright (c) 2026-present David Oravsky (mrdav30) |
| | | 34 | | // See LICENSE file in the project root for full license information. |