< Summary

Information
Class: Gravitas.Diagnostics.GravitasDebugDrawCommand
Assembly: Gravitas
File(s): /home/runner/work/Gravitas/Gravitas/src/Gravitas/Diagnostics/DebugDraw/GravitasDebugDrawCommand.cs
Line coverage
100%
Covered lines: 43
Uncovered lines: 0
Coverable lines: 43
Total lines: 166
Line coverage: 100%
Branch coverage
100%
Covered branches: 12
Total branches: 12
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%1212100%

File(s)

/home/runner/work/Gravitas/Gravitas/src/Gravitas/Diagnostics/DebugDraw/GravitasDebugDrawCommand.cs

#LineLine coverage
 1//=======================================================================
 2// GravitasDebugDrawCommand.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/// Engine-agnostic debug draw command that host adapters can translate into renderer calls.
 16/// </summary>
 17public readonly struct GravitasDebugDrawCommand
 18{
 19    internal GravitasDebugDrawCommand(
 20        int frame,
 21        int sequence,
 22        GravitasDebugDrawKind kind,
 23        int colliderId,
 24        GravitasColliderDimension colliderDimension,
 25        ColliderType colliderType,
 26        ColliderType2D collider2DType,
 27        Vector3d start,
 28        Vector3d end,
 29        Vector3d center,
 30        Vector3d halfExtents,
 31        Vector3d pointA,
 32        Vector3d pointB,
 33        Vector3d pointC,
 34        FixedQuaternion rotation,
 35        Fixed64 radius,
 36        Fixed64 axisLength,
 37        Fixed64 height,
 38        GravitasDiagnosticColor color)
 39    {
 40440        Frame = frame;
 40441        Sequence = sequence;
 40442        Kind = kind;
 40443        ColliderId = colliderId;
 40444        ColliderDimension = colliderDimension;
 40445        ColliderType = colliderType;
 40446        Collider2DType = collider2DType;
 40447        Start = start;
 40448        End = end;
 40449        Center = center;
 40450        HalfExtents = halfExtents;
 40451        PointA = pointA;
 40452        PointB = pointB;
 40453        PointC = pointC;
 40454        Rotation = rotation;
 40455        Radius = radius;
 40456        AxisLength = axisLength;
 40457        Height = height;
 40458        Color = color;
 40459    }
 60
 61    /// <summary>Gets the simulation frame in which the command was captured.</summary>
 62    public int Frame { get; }
 63
 64    /// <summary>Gets the command's sequence within its capture buffer.</summary>
 65    public int Sequence { get; }
 66
 67    /// <summary>Gets the command kind that determines how its payload is interpreted.</summary>
 68    public GravitasDebugDrawKind Kind { get; }
 69
 70    /// <summary>Gets the context-local collider identifier, or <c>-1</c> when unassociated.</summary>
 71    public int ColliderId { get; }
 72
 73    /// <summary>Gets the dimensional runtime surface of the associated collider.</summary>
 74    public GravitasColliderDimension ColliderDimension { get; }
 75
 76    /// <summary>Gets the associated 3D collider type.</summary>
 77    public ColliderType ColliderType { get; }
 78
 79    /// <summary>Gets the associated 2D collider type.</summary>
 80    public ColliderType2D Collider2DType { get; }
 81
 82    /// <summary>Gets the start point for line and ray commands.</summary>
 83    public Vector3d Start { get; }
 84
 85    /// <summary>Gets the end point for line and ray commands.</summary>
 86    public Vector3d End { get; }
 87
 88    /// <summary>Gets the center of a point or wireframe volume.</summary>
 89    public Vector3d Center { get; }
 90
 91    /// <summary>
 92    /// Gets the center-relative half-extents for
 93    /// <see cref="GravitasDebugDrawKind.WireBox"/> commands.
 94    /// </summary>
 95    public Vector3d HalfExtents { get; }
 96
 97    /// <summary>Gets the first vertex of a wireframe triangle.</summary>
 98    public Vector3d PointA { get; }
 99
 100    /// <summary>Gets the second vertex of a wireframe triangle.</summary>
 101    public Vector3d PointB { get; }
 102
 103    /// <summary>Gets the third vertex of a wireframe triangle.</summary>
 104    public Vector3d PointC { get; }
 105
 106    /// <summary>Gets the orientation of a wireframe volume.</summary>
 107    public FixedQuaternion Rotation { get; }
 108
 109    /// <summary>Gets the point or wireframe volume radius.</summary>
 110    public Fixed64 Radius { get; }
 111
 112    /// <summary>
 113    /// Gets the full distance between hemisphere centers for
 114    /// <see cref="GravitasDebugDrawKind.WireCapsule"/> commands.
 115    /// </summary>
 116    public Fixed64 AxisLength { get; }
 117
 118    /// <summary>Gets the full height of a cylinder or cone.</summary>
 119    public Fixed64 Height { get; }
 120
 121    /// <summary>Gets the command color.</summary>
 122    public GravitasDiagnosticColor Color { get; }
 123
 124    /// <summary>
 125    /// Dispatches this draw command to a typed debug draw visitor based on <see cref="Kind"/>.
 126    /// </summary>
 127    public void DispatchTo(GravitasDebugDrawCommandVisitor visitor)
 128    {
 23129        if (visitor == null)
 1130            throw new ArgumentNullException(nameof(visitor));
 131
 22132        switch (Kind)
 133        {
 134            case GravitasDebugDrawKind.Line:
 3135                visitor.VisitLine(new GravitasLineDebugDrawView(this));
 3136                break;
 137            case GravitasDebugDrawKind.Ray:
 2138                visitor.VisitRay(new GravitasRayDebugDrawView(this));
 2139                break;
 140            case GravitasDebugDrawKind.Point:
 3141                visitor.VisitPoint(new GravitasPointDebugDrawView(this));
 3142                break;
 143            case GravitasDebugDrawKind.WireSphere:
 2144                visitor.VisitWireSphere(new GravitasWireSphereDebugDrawView(this));
 2145                break;
 146            case GravitasDebugDrawKind.WireBox:
 2147                visitor.VisitWireBox(new GravitasWireBoxDebugDrawView(this));
 2148                break;
 149            case GravitasDebugDrawKind.WireCapsule:
 2150                visitor.VisitWireCapsule(new GravitasWireCapsuleDebugDrawView(this));
 2151                break;
 152            case GravitasDebugDrawKind.WireCylinder:
 2153                visitor.VisitWireCylinder(new GravitasWireCylinderDebugDrawView(this));
 2154                break;
 155            case GravitasDebugDrawKind.WireTriangle:
 2156                visitor.VisitWireTriangle(new GravitasWireTriangleDebugDrawView(this));
 2157                break;
 158            case GravitasDebugDrawKind.WireCone:
 2159                visitor.VisitWireCone(new GravitasWireConeDebugDrawView(this));
 2160                break;
 161            default:
 2162                visitor.VisitUnknown(this);
 163                break;
 164        }
 2165    }
 166}