< Summary

Information
Class: Gravitas.Diagnostics.GravitasDiagnosticEvent
Assembly: Gravitas
File(s): /home/runner/work/Gravitas/Gravitas/src/Gravitas/Diagnostics/Events/GravitasDiagnosticEvent.cs
Line coverage
100%
Covered lines: 146
Uncovered lines: 0
Coverable lines: 146
Total lines: 461
Line coverage: 100%
Branch coverage
100%
Covered branches: 60
Total branches: 60
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
DispatchTo(...)100%2222100%
TryAsForceDelta(...)100%22100%
TryAsTorqueDelta(...)100%22100%
TryAsLinearVelocityDelta(...)100%22100%
TryAsAngularVelocityDelta(...)100%22100%
TryAsGroundProbe(...)100%22100%
TryAsRayQuery(...)100%22100%
TryAsCircleQuery(...)100%22100%
TryAsQuerySummary(...)100%22100%
TryAsContact(...)100%22100%
TryAsResponseImpulse(...)100%22100%
TryAsMixedQuery(...)100%22100%
TryAsMixedContact(...)100%22100%
TryAsMixedResponseImpulse(...)100%22100%
TryAsMixedResponseIsland(...)100%22100%
TryAsJoint(...)100%88100%
TryAsRagdoll(...)100%22100%

File(s)

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Diagnostics/Events/GravitasDiagnosticEvent.cs

#LineLine coverage
 1//=======================================================================
 2// GravitasDiagnosticEvent.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;
 11
 12namespace Gravitas.Diagnostics;
 13
 14/// <summary>
 15/// Deterministic physics diagnostic event data captured from one world context.
 16/// </summary>
 17public readonly struct GravitasDiagnosticEvent
 18{
 19    internal GravitasDiagnosticEvent(
 20        int frame,
 21        int sequence,
 22        GravitasDiagnosticEventKind kind,
 23        int bodyId,
 24        int jointId,
 25        int colliderAId,
 26        int colliderBId,
 27        GravitasColliderDimension colliderADimension,
 28        GravitasColliderDimension colliderBDimension,
 29        ColliderType colliderAType,
 30        ColliderType colliderBType,
 31        ColliderType2D colliderA2DType,
 32        ColliderType2D colliderB2DType,
 33        Vector3d start,
 34        Vector3d end,
 35        Vector3d pointA,
 36        Vector3d pointB,
 37        bool hasPointA,
 38        bool hasPointB,
 39        Vector3d vector,
 40        Fixed64 scalarA,
 41        Fixed64 scalarB,
 42        int dataA,
 43        int dataB,
 44        bool hit)
 45    {
 160046        Frame = frame;
 160047        Sequence = sequence;
 160048        Kind = kind;
 160049        BodyId = bodyId;
 160050        JointId = jointId;
 160051        ColliderAId = colliderAId;
 160052        ColliderBId = colliderBId;
 160053        ColliderADimension = colliderADimension;
 160054        ColliderBDimension = colliderBDimension;
 160055        ColliderAType = colliderAType;
 160056        ColliderBType = colliderBType;
 160057        ColliderA2DType = colliderA2DType;
 160058        ColliderB2DType = colliderB2DType;
 160059        Start = start;
 160060        End = end;
 160061        PointA = pointA;
 160062        PointB = pointB;
 160063        HasPointA = hasPointA;
 160064        HasPointB = hasPointB;
 160065        Vector = vector;
 160066        ScalarA = scalarA;
 160067        ScalarB = scalarB;
 160068        DataA = dataA;
 160069        DataB = dataB;
 160070        Hit = hit;
 160071    }
 72
 73    /// <summary>Gets the simulation frame in which the event was captured.</summary>
 74    public int Frame { get; }
 75
 76    /// <summary>Gets the event's sequence within its capture buffer.</summary>
 77    public int Sequence { get; }
 78
 79    /// <summary>Gets the event kind that determines how its payload is interpreted.</summary>
 80    public GravitasDiagnosticEventKind Kind { get; }
 81
 82    /// <summary>Gets the context-local body, ragdoll, or diagnostic root identifier.</summary>
 83    public int BodyId { get; }
 84
 85    /// <summary>Gets the context-local joint identifier.</summary>
 86    public int JointId { get; }
 87
 88    /// <summary>Gets the first context-local collider identifier.</summary>
 89    public int ColliderAId { get; }
 90
 91    /// <summary>Gets the second context-local collider identifier.</summary>
 92    public int ColliderBId { get; }
 93
 94    /// <summary>Gets the dimensional runtime surface of the first collider.</summary>
 95    public GravitasColliderDimension ColliderADimension { get; }
 96
 97    /// <summary>Gets the dimensional runtime surface of the second collider.</summary>
 98    public GravitasColliderDimension ColliderBDimension { get; }
 99
 100    /// <summary>Gets the 3D type of the first collider.</summary>
 101    public ColliderType ColliderAType { get; }
 102
 103    /// <summary>Gets the 3D type of the second collider.</summary>
 104    public ColliderType ColliderBType { get; }
 105
 106    /// <summary>Gets the 2D type of the first collider.</summary>
 107    public ColliderType2D ColliderA2DType { get; }
 108
 109    /// <summary>Gets the 2D type of the second collider.</summary>
 110    public ColliderType2D ColliderB2DType { get; }
 111
 112    /// <summary>Gets the event-specific start vector.</summary>
 113    public Vector3d Start { get; }
 114
 115    /// <summary>Gets the event-specific end vector.</summary>
 116    public Vector3d End { get; }
 117
 118    /// <summary>Gets the first event-specific point.</summary>
 119    public Vector3d PointA { get; }
 120
 121    /// <summary>Gets the second event-specific point.</summary>
 122    public Vector3d PointB { get; }
 123
 124    /// <summary>
 125    /// Gets whether <see cref="PointA"/> contains a materialized point.
 126    /// </summary>
 127    public bool HasPointA { get; }
 128
 129    /// <summary>
 130    /// Gets whether <see cref="PointB"/> contains a materialized point.
 131    /// </summary>
 132    public bool HasPointB { get; }
 133
 134    /// <summary>Gets the event-specific vector payload.</summary>
 135    public Vector3d Vector { get; }
 136
 137    /// <summary>Gets the first event-specific fixed-point scalar.</summary>
 138    public Fixed64 ScalarA { get; }
 139
 140    /// <summary>Gets the second event-specific fixed-point scalar.</summary>
 141    public Fixed64 ScalarB { get; }
 142
 143    /// <summary>Gets the first event-specific integer value.</summary>
 144    public int DataA { get; }
 145
 146    /// <summary>Gets the second event-specific integer value.</summary>
 147    public int DataB { get; }
 148
 149    /// <summary>Gets the event-specific result flag.</summary>
 150    public bool Hit { get; }
 151
 152    /// <summary>
 153    /// Dispatches this event to a typed diagnostic visitor based on <see cref="Kind"/>.
 154    /// </summary>
 155    public void DispatchTo(GravitasDiagnosticEventVisitor visitor)
 156    {
 43157        if (visitor == null)
 1158            throw new ArgumentNullException(nameof(visitor));
 159
 42160        switch (Kind)
 161        {
 162            case GravitasDiagnosticEventKind.ForceDelta:
 3163                visitor.VisitForceDelta(new GravitasForceDeltaDiagnosticView(this));
 3164                break;
 165            case GravitasDiagnosticEventKind.TorqueDelta:
 3166                visitor.VisitTorqueDelta(new GravitasTorqueDeltaDiagnosticView(this));
 3167                break;
 168            case GravitasDiagnosticEventKind.LinearVelocityDelta:
 2169                visitor.VisitLinearVelocityDelta(new GravitasVelocityDeltaDiagnosticView(this));
 2170                break;
 171            case GravitasDiagnosticEventKind.AngularVelocityDelta:
 2172                visitor.VisitAngularVelocityDelta(new GravitasVelocityDeltaDiagnosticView(this));
 2173                break;
 174            case GravitasDiagnosticEventKind.GroundProbe:
 2175                visitor.VisitGroundProbe(new GravitasGroundProbeDiagnosticView(this));
 2176                break;
 177            case GravitasDiagnosticEventKind.RayQuery:
 2178                visitor.VisitRayQuery(new GravitasRayQueryDiagnosticView(this));
 2179                break;
 180            case GravitasDiagnosticEventKind.CircleQuery:
 2181                visitor.VisitCircleQuery(new GravitasCircleQueryDiagnosticView(this));
 2182                break;
 183            case GravitasDiagnosticEventKind.QuerySummary:
 2184                visitor.VisitQuerySummary(new GravitasQuerySummaryDiagnosticView(this));
 2185                break;
 186            case GravitasDiagnosticEventKind.Contact:
 2187                visitor.VisitContact(new GravitasContactDiagnosticView(this));
 2188                break;
 189            case GravitasDiagnosticEventKind.ResponseImpulse:
 2190                visitor.VisitResponseImpulse(new GravitasResponseImpulseDiagnosticView(this));
 2191                break;
 192            case GravitasDiagnosticEventKind.MixedQuery:
 2193                visitor.VisitMixedQuery(new GravitasMixedQueryDiagnosticView(this));
 2194                break;
 195            case GravitasDiagnosticEventKind.MixedContact:
 2196                visitor.VisitMixedContact(new GravitasMixedContactDiagnosticView(this));
 2197                break;
 198            case GravitasDiagnosticEventKind.MixedResponseImpulse:
 2199                visitor.VisitMixedResponseImpulse(new GravitasMixedResponseImpulseDiagnosticView(this));
 2200                break;
 201            case GravitasDiagnosticEventKind.MixedResponseIsland:
 2202                visitor.VisitMixedResponseIsland(new GravitasMixedResponseIslandDiagnosticView(this));
 2203                break;
 204            case GravitasDiagnosticEventKind.JointRegistered:
 205            case GravitasDiagnosticEventKind.JointRemoved:
 206            case GravitasDiagnosticEventKind.JointImpulse:
 207            case GravitasDiagnosticEventKind.JointLimitReached:
 8208                visitor.VisitJoint(new GravitasJointDiagnosticView(this));
 8209                break;
 210            case GravitasDiagnosticEventKind.RagdollActivated:
 2211                visitor.VisitRagdoll(new GravitasRagdollDiagnosticView(this));
 2212                break;
 213            default:
 2214                visitor.VisitUnknown(this);
 215                break;
 216        }
 2217    }
 218
 219    /// <summary>
 220    /// Tries to decode this event as a force-delta diagnostic view.
 221    /// </summary>
 222    public bool TryAsForceDelta(out GravitasForceDeltaDiagnosticView view)
 223    {
 2224        if (Kind == GravitasDiagnosticEventKind.ForceDelta)
 225        {
 1226            view = new GravitasForceDeltaDiagnosticView(this);
 1227            return true;
 228        }
 229
 1230        view = default;
 1231        return false;
 232    }
 233
 234    /// <summary>
 235    /// Tries to decode this event as a torque-delta diagnostic view.
 236    /// </summary>
 237    public bool TryAsTorqueDelta(out GravitasTorqueDeltaDiagnosticView view)
 238    {
 3239        if (Kind == GravitasDiagnosticEventKind.TorqueDelta)
 240        {
 1241            view = new GravitasTorqueDeltaDiagnosticView(this);
 1242            return true;
 243        }
 244
 2245        view = default;
 2246        return false;
 247    }
 248
 249    /// <summary>
 250    /// Tries to decode this event as a linear-velocity-delta diagnostic view.
 251    /// </summary>
 252    public bool TryAsLinearVelocityDelta(out GravitasVelocityDeltaDiagnosticView view)
 253    {
 2254        if (Kind == GravitasDiagnosticEventKind.LinearVelocityDelta)
 255        {
 1256            view = new GravitasVelocityDeltaDiagnosticView(this);
 1257            return true;
 258        }
 259
 1260        view = default;
 1261        return false;
 262    }
 263
 264    /// <summary>
 265    /// Tries to decode this event as an angular-velocity-delta diagnostic view.
 266    /// </summary>
 267    public bool TryAsAngularVelocityDelta(out GravitasVelocityDeltaDiagnosticView view)
 268    {
 2269        if (Kind == GravitasDiagnosticEventKind.AngularVelocityDelta)
 270        {
 1271            view = new GravitasVelocityDeltaDiagnosticView(this);
 1272            return true;
 273        }
 274
 1275        view = default;
 1276        return false;
 277    }
 278
 279    /// <summary>
 280    /// Tries to decode this event as a ground-probe diagnostic view.
 281    /// </summary>
 282    public bool TryAsGroundProbe(out GravitasGroundProbeDiagnosticView view)
 283    {
 3284        if (Kind == GravitasDiagnosticEventKind.GroundProbe)
 285        {
 2286            view = new GravitasGroundProbeDiagnosticView(this);
 2287            return true;
 288        }
 289
 1290        view = default;
 1291        return false;
 292    }
 293
 294    /// <summary>
 295    /// Tries to decode this event as a ray or swept-sphere query diagnostic view.
 296    /// </summary>
 297    public bool TryAsRayQuery(out GravitasRayQueryDiagnosticView view)
 298    {
 2299        if (Kind == GravitasDiagnosticEventKind.RayQuery)
 300        {
 1301            view = new GravitasRayQueryDiagnosticView(this);
 1302            return true;
 303        }
 304
 1305        view = default;
 1306        return false;
 307    }
 308
 309    /// <summary>
 310    /// Tries to decode this event as an X/Z circle-query diagnostic view.
 311    /// </summary>
 312    public bool TryAsCircleQuery(out GravitasCircleQueryDiagnosticView view)
 313    {
 2314        if (Kind == GravitasDiagnosticEventKind.CircleQuery)
 315        {
 1316            view = new GravitasCircleQueryDiagnosticView(this);
 1317            return true;
 318        }
 319
 1320        view = default;
 1321        return false;
 322    }
 323
 324    /// <summary>
 325    /// Tries to decode this event as a query quality summary diagnostic view.
 326    /// </summary>
 327    public bool TryAsQuerySummary(out GravitasQuerySummaryDiagnosticView view)
 328    {
 7329        if (Kind == GravitasDiagnosticEventKind.QuerySummary)
 330        {
 6331            view = new GravitasQuerySummaryDiagnosticView(this);
 6332            return true;
 333        }
 334
 1335        view = default;
 1336        return false;
 337    }
 338
 339    /// <summary>
 340    /// Tries to decode this event as a 3D contact diagnostic view.
 341    /// </summary>
 342    public bool TryAsContact(out GravitasContactDiagnosticView view)
 343    {
 3344        if (Kind == GravitasDiagnosticEventKind.Contact)
 345        {
 2346            view = new GravitasContactDiagnosticView(this);
 2347            return true;
 348        }
 349
 1350        view = default;
 1351        return false;
 352    }
 353
 354    /// <summary>
 355    /// Tries to decode this event as a 3D response-impulse diagnostic view.
 356    /// </summary>
 357    public bool TryAsResponseImpulse(out GravitasResponseImpulseDiagnosticView view)
 358    {
 2359        if (Kind == GravitasDiagnosticEventKind.ResponseImpulse)
 360        {
 1361            view = new GravitasResponseImpulseDiagnosticView(this);
 1362            return true;
 363        }
 364
 1365        view = default;
 1366        return false;
 367    }
 368
 369    /// <summary>
 370    /// Tries to decode this event as a mixed 3D/2D query diagnostic view.
 371    /// </summary>
 372    public bool TryAsMixedQuery(out GravitasMixedQueryDiagnosticView view)
 373    {
 5374        if (Kind == GravitasDiagnosticEventKind.MixedQuery)
 375        {
 4376            view = new GravitasMixedQueryDiagnosticView(this);
 4377            return true;
 378        }
 379
 1380        view = default;
 1381        return false;
 382    }
 383
 384    /// <summary>
 385    /// Tries to decode this event as a mixed 3D/2D contact diagnostic view.
 386    /// </summary>
 387    public bool TryAsMixedContact(out GravitasMixedContactDiagnosticView view)
 388    {
 2389        if (Kind == GravitasDiagnosticEventKind.MixedContact)
 390        {
 1391            view = new GravitasMixedContactDiagnosticView(this);
 1392            return true;
 393        }
 394
 1395        view = default;
 1396        return false;
 397    }
 398
 399    /// <summary>
 400    /// Tries to decode this event as a mixed 3D/2D response-impulse diagnostic view.
 401    /// </summary>
 402    public bool TryAsMixedResponseImpulse(out GravitasMixedResponseImpulseDiagnosticView view)
 403    {
 45404        if (Kind == GravitasDiagnosticEventKind.MixedResponseImpulse)
 405        {
 10406            view = new GravitasMixedResponseImpulseDiagnosticView(this);
 10407            return true;
 408        }
 409
 35410        view = default;
 35411        return false;
 412    }
 413
 414    /// <summary>
 415    /// Tries to decode this event as a mixed 3D/2D response-island diagnostic view.
 416    /// </summary>
 417    public bool TryAsMixedResponseIsland(out GravitasMixedResponseIslandDiagnosticView view)
 418    {
 58419        if (Kind == GravitasDiagnosticEventKind.MixedResponseIsland)
 420        {
 5421            view = new GravitasMixedResponseIslandDiagnosticView(this);
 5422            return true;
 423        }
 424
 53425        view = default;
 53426        return false;
 427    }
 428
 429    /// <summary>
 430    /// Tries to decode this event as a joint diagnostic view.
 431    /// </summary>
 432    public bool TryAsJoint(out GravitasJointDiagnosticView view)
 433    {
 1140434        if (Kind == GravitasDiagnosticEventKind.JointRegistered
 1140435            || Kind == GravitasDiagnosticEventKind.JointRemoved
 1140436            || Kind == GravitasDiagnosticEventKind.JointImpulse
 1140437            || Kind == GravitasDiagnosticEventKind.JointLimitReached)
 438        {
 354439            view = new GravitasJointDiagnosticView(this);
 354440            return true;
 441        }
 442
 786443        view = default;
 786444        return false;
 445    }
 446
 447    /// <summary>
 448    /// Tries to decode this event as a ragdoll active-state diagnostic view.
 449    /// </summary>
 450    public bool TryAsRagdoll(out GravitasRagdollDiagnosticView view)
 451    {
 3452        if (Kind == GravitasDiagnosticEventKind.RagdollActivated)
 453        {
 1454            view = new GravitasRagdollDiagnosticView(this);
 1455            return true;
 456        }
 457
 2458        view = default;
 2459        return false;
 460    }
 461}

Methods/Properties

.ctor(System.Int32,System.Int32,Gravitas.Diagnostics.GravitasDiagnosticEventKind,System.Int32,System.Int32,System.Int32,System.Int32,Gravitas.Diagnostics.GravitasColliderDimension,Gravitas.Diagnostics.GravitasColliderDimension,Gravitas.Colliders.ColliderType,Gravitas.Colliders.ColliderType,Gravitas.Colliders.ColliderType2D,Gravitas.Colliders.ColliderType2D,FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,FixedMathSharp.Vector3d,System.Boolean,System.Boolean,FixedMathSharp.Vector3d,FixedMathSharp.Fixed64,FixedMathSharp.Fixed64,System.Int32,System.Int32,System.Boolean)
DispatchTo(Gravitas.Diagnostics.GravitasDiagnosticEventVisitor)
TryAsForceDelta(Gravitas.Diagnostics.GravitasForceDeltaDiagnosticView&)
TryAsTorqueDelta(Gravitas.Diagnostics.GravitasTorqueDeltaDiagnosticView&)
TryAsLinearVelocityDelta(Gravitas.Diagnostics.GravitasVelocityDeltaDiagnosticView&)
TryAsAngularVelocityDelta(Gravitas.Diagnostics.GravitasVelocityDeltaDiagnosticView&)
TryAsGroundProbe(Gravitas.Diagnostics.GravitasGroundProbeDiagnosticView&)
TryAsRayQuery(Gravitas.Diagnostics.GravitasRayQueryDiagnosticView&)
TryAsCircleQuery(Gravitas.Diagnostics.GravitasCircleQueryDiagnosticView&)
TryAsQuerySummary(Gravitas.Diagnostics.GravitasQuerySummaryDiagnosticView&)
TryAsContact(Gravitas.Diagnostics.GravitasContactDiagnosticView&)
TryAsResponseImpulse(Gravitas.Diagnostics.GravitasResponseImpulseDiagnosticView&)
TryAsMixedQuery(Gravitas.Diagnostics.GravitasMixedQueryDiagnosticView&)
TryAsMixedContact(Gravitas.Diagnostics.GravitasMixedContactDiagnosticView&)
TryAsMixedResponseImpulse(Gravitas.Diagnostics.GravitasMixedResponseImpulseDiagnosticView&)
TryAsMixedResponseIsland(Gravitas.Diagnostics.GravitasMixedResponseIslandDiagnosticView&)
TryAsJoint(Gravitas.Diagnostics.GravitasJointDiagnosticView&)
TryAsRagdoll(Gravitas.Diagnostics.GravitasRagdollDiagnosticView&)