| | | 1 | | //======================================================================= |
| | | 2 | | // GravitasGroundProbeDiagnosticView.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 | | using FixedMathSharp; |
| | | 9 | | using Gravitas.Colliders; |
| | | 10 | | |
| | | 11 | | namespace Gravitas.Diagnostics; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Typed read-only view over a ground-probe diagnostic event. |
| | | 15 | | /// </summary> |
| | | 16 | | public readonly struct GravitasGroundProbeDiagnosticView |
| | | 17 | | { |
| | 4 | 18 | | internal GravitasGroundProbeDiagnosticView(GravitasDiagnosticEvent diagnosticEvent) => Event = diagnosticEvent; |
| | | 19 | | |
| | | 20 | | /// <summary>Gets the underlying diagnostic event.</summary> |
| | | 21 | | public GravitasDiagnosticEvent Event { get; } |
| | | 22 | | |
| | | 23 | | /// <summary>Gets the simulation frame in which the probe was captured.</summary> |
| | 1 | 24 | | public long Frame => Event.Frame; |
| | | 25 | | |
| | | 26 | | /// <summary>Gets the event's sequence within its capture buffer.</summary> |
| | 1 | 27 | | public int Sequence => Event.Sequence; |
| | | 28 | | |
| | | 29 | | /// <summary>Gets the context-local body identifier.</summary> |
| | 1 | 30 | | public int BodyId => Event.BodyId; |
| | | 31 | | |
| | | 32 | | /// <summary>Gets the probing body's context-local collider identifier.</summary> |
| | 1 | 33 | | public int ColliderId => Event.ColliderAId; |
| | | 34 | | |
| | | 35 | | /// <summary>Gets the hit collider identifier, or <c>-1</c> when no collider was hit.</summary> |
| | 1 | 36 | | public int HitColliderId => Event.ColliderBId; |
| | | 37 | | |
| | | 38 | | /// <summary>Gets the probing collider's dimension.</summary> |
| | 1 | 39 | | public GravitasColliderDimension ColliderDimension => Event.ColliderADimension; |
| | | 40 | | |
| | | 41 | | /// <summary>Gets the hit collider's dimension.</summary> |
| | 1 | 42 | | public GravitasColliderDimension HitColliderDimension => Event.ColliderBDimension; |
| | | 43 | | |
| | | 44 | | /// <summary>Gets the probing collider's 3D type.</summary> |
| | 1 | 45 | | public ColliderType ColliderType => Event.ColliderAType; |
| | | 46 | | |
| | | 47 | | /// <summary>Gets the hit collider's 3D type.</summary> |
| | 1 | 48 | | public ColliderType HitColliderType => Event.ColliderBType; |
| | | 49 | | |
| | | 50 | | /// <summary>Gets the probing collider's 2D type.</summary> |
| | 1 | 51 | | public ColliderType2D Collider2DType => Event.ColliderA2DType; |
| | | 52 | | |
| | | 53 | | /// <summary>Gets the hit collider's 2D type.</summary> |
| | 1 | 54 | | public ColliderType2D HitCollider2DType => Event.ColliderB2DType; |
| | | 55 | | |
| | | 56 | | /// <summary>Gets the probe start point.</summary> |
| | 1 | 57 | | public Vector3d Start => Event.Start; |
| | | 58 | | |
| | | 59 | | /// <summary>Gets the probe endpoint.</summary> |
| | 1 | 60 | | public Vector3d End => Event.End; |
| | | 61 | | |
| | | 62 | | /// <summary>Gets the materialized hit point, or zero when unavailable.</summary> |
| | 1 | 63 | | public Vector3d HitPoint => Event.PointA; |
| | | 64 | | |
| | | 65 | | /// <summary>Gets the hit normal.</summary> |
| | 1 | 66 | | public Vector3d Normal => Event.Vector; |
| | | 67 | | |
| | | 68 | | /// <summary>Gets the probe radius.</summary> |
| | 1 | 69 | | public Fixed64 Radius => Event.ScalarA; |
| | | 70 | | |
| | | 71 | | /// <summary>Gets the distance to the hit.</summary> |
| | 1 | 72 | | public Fixed64 Distance => Event.ScalarB; |
| | | 73 | | |
| | | 74 | | /// <summary>Gets the probe mode for a 3D event.</summary> |
| | 1 | 75 | | public GroundProbeMode Mode => (GroundProbeMode)Event.DataA; |
| | | 76 | | |
| | | 77 | | /// <summary>Gets the probe mode for a 2D event.</summary> |
| | 1 | 78 | | public GroundProbeMode2D Mode2D => (GroundProbeMode2D)Event.DataA; |
| | | 79 | | |
| | | 80 | | /// <summary>Gets whether the probe hit a collider.</summary> |
| | 1 | 81 | | public bool Hit => Event.Hit; |
| | | 82 | | } |