| | | 1 | | //======================================================================= |
| | | 2 | | // GravitasContactDiagnosticView.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 3D contact diagnostic event. |
| | | 15 | | /// </summary> |
| | | 16 | | public readonly struct GravitasContactDiagnosticView |
| | | 17 | | { |
| | 4 | 18 | | internal GravitasContactDiagnosticView(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 contact 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 first context-local collider identifier.</summary> |
| | 1 | 30 | | public int ColliderAId => Event.ColliderAId; |
| | | 31 | | |
| | | 32 | | /// <summary>Gets the second context-local collider identifier.</summary> |
| | 1 | 33 | | public int ColliderBId => Event.ColliderBId; |
| | | 34 | | |
| | | 35 | | /// <summary>Gets the first collider type.</summary> |
| | 1 | 36 | | public ColliderType ColliderAType => Event.ColliderAType; |
| | | 37 | | |
| | | 38 | | /// <summary>Gets the second collider type.</summary> |
| | 1 | 39 | | public ColliderType ColliderBType => Event.ColliderBType; |
| | | 40 | | |
| | | 41 | | /// <summary>Gets the materialized contact point on the first collider.</summary> |
| | 1 | 42 | | public Vector3d PointA => Event.PointA; |
| | | 43 | | |
| | | 44 | | /// <summary>Gets the materialized contact point on the second collider.</summary> |
| | 1 | 45 | | public Vector3d PointB => Event.PointB; |
| | | 46 | | |
| | | 47 | | /// <summary>Gets whether <see cref="PointA"/> contains a materialized point.</summary> |
| | 2 | 48 | | public bool HasPointA => Event.HasPointA; |
| | | 49 | | |
| | | 50 | | /// <summary>Gets whether <see cref="PointB"/> contains a materialized point.</summary> |
| | 2 | 51 | | public bool HasPointB => Event.HasPointB; |
| | | 52 | | |
| | | 53 | | /// <summary>Gets the contact normal.</summary> |
| | 1 | 54 | | public Vector3d Normal => Event.Vector; |
| | | 55 | | |
| | | 56 | | /// <summary>Gets the contact penetration depth.</summary> |
| | 1 | 57 | | public Fixed64 Depth => Event.ScalarA; |
| | | 58 | | |
| | | 59 | | /// <summary>Gets the number of contacts in the manifold.</summary> |
| | 1 | 60 | | public int ContactCount => Event.DataA; |
| | | 61 | | |
| | | 62 | | /// <summary>Gets whether the reported penetration depth was clamped.</summary> |
| | 2 | 63 | | public bool DepthIsClamped => Event.DataB != 0; |
| | | 64 | | |
| | | 65 | | /// <summary>Gets whether the collision produced a contact.</summary> |
| | 2 | 66 | | public bool HasContact => Event.Hit; |
| | | 67 | | } |