| | | 1 | | //======================================================================= |
| | | 2 | | // GravitasDebugDrawCommandViews.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 line draw command. |
| | | 15 | | /// </summary> |
| | | 16 | | public readonly struct GravitasLineDebugDrawView |
| | | 17 | | { |
| | | 18 | | internal GravitasLineDebugDrawView(GravitasDebugDrawCommand command) => Command = command; |
| | | 19 | | |
| | | 20 | | /// <summary>Gets the underlying draw command.</summary> |
| | | 21 | | public GravitasDebugDrawCommand Command { get; } |
| | | 22 | | |
| | | 23 | | /// <summary>Gets the simulation frame in which the command was captured.</summary> |
| | | 24 | | public int Frame => Command.Frame; |
| | | 25 | | |
| | | 26 | | /// <summary>Gets the command's sequence within its capture buffer.</summary> |
| | | 27 | | public int Sequence => Command.Sequence; |
| | | 28 | | |
| | | 29 | | /// <summary>Gets the associated context-local collider identifier.</summary> |
| | | 30 | | public int ColliderId => Command.ColliderId; |
| | | 31 | | |
| | | 32 | | /// <summary>Gets the associated collider dimension.</summary> |
| | | 33 | | public GravitasColliderDimension ColliderDimension => Command.ColliderDimension; |
| | | 34 | | |
| | | 35 | | /// <summary>Gets the associated 3D collider type.</summary> |
| | | 36 | | public ColliderType ColliderType => Command.ColliderType; |
| | | 37 | | |
| | | 38 | | /// <summary>Gets the associated 2D collider type.</summary> |
| | | 39 | | public ColliderType2D Collider2DType => Command.Collider2DType; |
| | | 40 | | |
| | | 41 | | /// <summary>Gets the line start point.</summary> |
| | | 42 | | public Vector3d Start => Command.Start; |
| | | 43 | | |
| | | 44 | | /// <summary>Gets the line end point.</summary> |
| | | 45 | | public Vector3d End => Command.End; |
| | | 46 | | |
| | | 47 | | /// <summary>Gets the line color.</summary> |
| | | 48 | | public GravitasDiagnosticColor Color => Command.Color; |
| | | 49 | | } |
| | | 50 | | |
| | | 51 | | /// <summary> |
| | | 52 | | /// Typed read-only view over a ray draw command. |
| | | 53 | | /// </summary> |
| | | 54 | | public readonly struct GravitasRayDebugDrawView |
| | | 55 | | { |
| | | 56 | | internal GravitasRayDebugDrawView(GravitasDebugDrawCommand command) => Command = command; |
| | | 57 | | |
| | | 58 | | /// <summary>Gets the underlying draw command.</summary> |
| | | 59 | | public GravitasDebugDrawCommand Command { get; } |
| | | 60 | | |
| | | 61 | | /// <summary>Gets the simulation frame in which the command was captured.</summary> |
| | | 62 | | public int Frame => Command.Frame; |
| | | 63 | | |
| | | 64 | | /// <summary>Gets the command's sequence within its capture buffer.</summary> |
| | | 65 | | public int Sequence => Command.Sequence; |
| | | 66 | | |
| | | 67 | | /// <summary>Gets the associated context-local collider identifier.</summary> |
| | | 68 | | public int ColliderId => Command.ColliderId; |
| | | 69 | | |
| | | 70 | | /// <summary>Gets the associated collider dimension.</summary> |
| | | 71 | | public GravitasColliderDimension ColliderDimension => Command.ColliderDimension; |
| | | 72 | | |
| | | 73 | | /// <summary>Gets the associated 3D collider type.</summary> |
| | | 74 | | public ColliderType ColliderType => Command.ColliderType; |
| | | 75 | | |
| | | 76 | | /// <summary>Gets the associated 2D collider type.</summary> |
| | | 77 | | public ColliderType2D Collider2DType => Command.Collider2DType; |
| | | 78 | | |
| | | 79 | | /// <summary>Gets the ray origin.</summary> |
| | | 80 | | public Vector3d Start => Command.Start; |
| | | 81 | | |
| | | 82 | | /// <summary>Gets the ray endpoint.</summary> |
| | | 83 | | public Vector3d End => Command.End; |
| | | 84 | | |
| | | 85 | | /// <summary>Gets the ray color.</summary> |
| | | 86 | | public GravitasDiagnosticColor Color => Command.Color; |
| | | 87 | | } |
| | | 88 | | |
| | | 89 | | /// <summary> |
| | | 90 | | /// Typed read-only view over a point draw command. |
| | | 91 | | /// </summary> |
| | | 92 | | public readonly struct GravitasPointDebugDrawView |
| | | 93 | | { |
| | | 94 | | internal GravitasPointDebugDrawView(GravitasDebugDrawCommand command) => Command = command; |
| | | 95 | | |
| | | 96 | | /// <summary>Gets the underlying draw command.</summary> |
| | | 97 | | public GravitasDebugDrawCommand Command { get; } |
| | | 98 | | |
| | | 99 | | /// <summary>Gets the simulation frame in which the command was captured.</summary> |
| | | 100 | | public int Frame => Command.Frame; |
| | | 101 | | |
| | | 102 | | /// <summary>Gets the command's sequence within its capture buffer.</summary> |
| | | 103 | | public int Sequence => Command.Sequence; |
| | | 104 | | |
| | | 105 | | /// <summary>Gets the associated context-local collider identifier.</summary> |
| | | 106 | | public int ColliderId => Command.ColliderId; |
| | | 107 | | |
| | | 108 | | /// <summary>Gets the associated collider dimension.</summary> |
| | | 109 | | public GravitasColliderDimension ColliderDimension => Command.ColliderDimension; |
| | | 110 | | |
| | | 111 | | /// <summary>Gets the associated 3D collider type.</summary> |
| | | 112 | | public ColliderType ColliderType => Command.ColliderType; |
| | | 113 | | |
| | | 114 | | /// <summary>Gets the associated 2D collider type.</summary> |
| | | 115 | | public ColliderType2D Collider2DType => Command.Collider2DType; |
| | | 116 | | |
| | | 117 | | /// <summary>Gets the marker center.</summary> |
| | | 118 | | public Vector3d Center => Command.Center; |
| | | 119 | | |
| | | 120 | | /// <summary>Gets the marker radius.</summary> |
| | | 121 | | public Fixed64 Radius => Command.Radius; |
| | | 122 | | |
| | | 123 | | /// <summary>Gets the marker color.</summary> |
| | | 124 | | public GravitasDiagnosticColor Color => Command.Color; |
| | | 125 | | } |
| | | 126 | | |
| | | 127 | | /// <summary> |
| | | 128 | | /// Typed read-only view over a wire-sphere draw command. |
| | | 129 | | /// </summary> |
| | | 130 | | public readonly struct GravitasWireSphereDebugDrawView |
| | | 131 | | { |
| | | 132 | | internal GravitasWireSphereDebugDrawView(GravitasDebugDrawCommand command) => Command = command; |
| | | 133 | | |
| | | 134 | | /// <summary>Gets the underlying draw command.</summary> |
| | | 135 | | public GravitasDebugDrawCommand Command { get; } |
| | | 136 | | |
| | | 137 | | /// <summary>Gets the simulation frame in which the command was captured.</summary> |
| | | 138 | | public int Frame => Command.Frame; |
| | | 139 | | |
| | | 140 | | /// <summary>Gets the command's sequence within its capture buffer.</summary> |
| | | 141 | | public int Sequence => Command.Sequence; |
| | | 142 | | |
| | | 143 | | /// <summary>Gets the associated context-local collider identifier.</summary> |
| | | 144 | | public int ColliderId => Command.ColliderId; |
| | | 145 | | |
| | | 146 | | /// <summary>Gets the associated collider dimension.</summary> |
| | | 147 | | public GravitasColliderDimension ColliderDimension => Command.ColliderDimension; |
| | | 148 | | |
| | | 149 | | /// <summary>Gets the associated 3D collider type.</summary> |
| | | 150 | | public ColliderType ColliderType => Command.ColliderType; |
| | | 151 | | |
| | | 152 | | /// <summary>Gets the associated 2D collider type.</summary> |
| | | 153 | | public ColliderType2D Collider2DType => Command.Collider2DType; |
| | | 154 | | |
| | | 155 | | /// <summary>Gets the sphere center.</summary> |
| | | 156 | | public Vector3d Center => Command.Center; |
| | | 157 | | |
| | | 158 | | /// <summary>Gets the sphere radius.</summary> |
| | | 159 | | public Fixed64 Radius => Command.Radius; |
| | | 160 | | |
| | | 161 | | /// <summary>Gets the sphere color.</summary> |
| | | 162 | | public GravitasDiagnosticColor Color => Command.Color; |
| | | 163 | | } |
| | | 164 | | |
| | | 165 | | /// <summary> |
| | | 166 | | /// Typed read-only view over a wire-box draw command. |
| | | 167 | | /// </summary> |
| | | 168 | | public readonly struct GravitasWireBoxDebugDrawView |
| | | 169 | | { |
| | | 170 | | internal GravitasWireBoxDebugDrawView(GravitasDebugDrawCommand command) => Command = command; |
| | | 171 | | |
| | | 172 | | /// <summary>Gets the underlying draw command.</summary> |
| | | 173 | | public GravitasDebugDrawCommand Command { get; } |
| | | 174 | | |
| | | 175 | | /// <summary>Gets the simulation frame in which the command was captured.</summary> |
| | | 176 | | public int Frame => Command.Frame; |
| | | 177 | | |
| | | 178 | | /// <summary>Gets the command's sequence within its capture buffer.</summary> |
| | | 179 | | public int Sequence => Command.Sequence; |
| | | 180 | | |
| | | 181 | | /// <summary>Gets the associated context-local collider identifier.</summary> |
| | | 182 | | public int ColliderId => Command.ColliderId; |
| | | 183 | | |
| | | 184 | | /// <summary>Gets the associated collider dimension.</summary> |
| | | 185 | | public GravitasColliderDimension ColliderDimension => Command.ColliderDimension; |
| | | 186 | | |
| | | 187 | | /// <summary>Gets the associated 3D collider type.</summary> |
| | | 188 | | public ColliderType ColliderType => Command.ColliderType; |
| | | 189 | | |
| | | 190 | | /// <summary>Gets the associated 2D collider type.</summary> |
| | | 191 | | public ColliderType2D Collider2DType => Command.Collider2DType; |
| | | 192 | | |
| | | 193 | | /// <summary>Gets the box center.</summary> |
| | | 194 | | public Vector3d Center => Command.Center; |
| | | 195 | | |
| | | 196 | | /// <summary>Gets the box half-extents.</summary> |
| | | 197 | | public Vector3d HalfExtents => Command.HalfExtents; |
| | | 198 | | |
| | | 199 | | /// <summary>Gets the box orientation.</summary> |
| | | 200 | | public FixedQuaternion Rotation => Command.Rotation; |
| | | 201 | | |
| | | 202 | | /// <summary>Gets the box color.</summary> |
| | | 203 | | public GravitasDiagnosticColor Color => Command.Color; |
| | | 204 | | } |
| | | 205 | | |
| | | 206 | | /// <summary> |
| | | 207 | | /// Typed read-only view over a wire-capsule draw command. |
| | | 208 | | /// </summary> |
| | | 209 | | public readonly struct GravitasWireCapsuleDebugDrawView |
| | | 210 | | { |
| | 2 | 211 | | internal GravitasWireCapsuleDebugDrawView(GravitasDebugDrawCommand command) => Command = command; |
| | | 212 | | |
| | | 213 | | /// <summary>Gets the underlying draw command.</summary> |
| | | 214 | | public GravitasDebugDrawCommand Command { get; } |
| | | 215 | | |
| | | 216 | | /// <summary>Gets the simulation frame in which the command was captured.</summary> |
| | 1 | 217 | | public int Frame => Command.Frame; |
| | | 218 | | |
| | | 219 | | /// <summary>Gets the command's sequence within its capture buffer.</summary> |
| | 1 | 220 | | public int Sequence => Command.Sequence; |
| | | 221 | | |
| | | 222 | | /// <summary>Gets the associated context-local collider identifier.</summary> |
| | 1 | 223 | | public int ColliderId => Command.ColliderId; |
| | | 224 | | |
| | | 225 | | /// <summary>Gets the associated collider dimension.</summary> |
| | 1 | 226 | | public GravitasColliderDimension ColliderDimension => Command.ColliderDimension; |
| | | 227 | | |
| | | 228 | | /// <summary>Gets the associated 3D collider type.</summary> |
| | 1 | 229 | | public ColliderType ColliderType => Command.ColliderType; |
| | | 230 | | |
| | | 231 | | /// <summary>Gets the associated 2D collider type.</summary> |
| | 1 | 232 | | public ColliderType2D Collider2DType => Command.Collider2DType; |
| | | 233 | | |
| | | 234 | | /// <summary>Gets the capsule center.</summary> |
| | 1 | 235 | | public Vector3d Center => Command.Center; |
| | | 236 | | |
| | | 237 | | /// <summary>Gets the capsule orientation.</summary> |
| | 1 | 238 | | public FixedQuaternion Rotation => Command.Rotation; |
| | | 239 | | |
| | | 240 | | /// <summary>Gets the capsule radius.</summary> |
| | 1 | 241 | | public Fixed64 Radius => Command.Radius; |
| | | 242 | | |
| | | 243 | | /// <summary> |
| | | 244 | | /// Gets the full distance between the capsule's hemisphere centers. |
| | | 245 | | /// </summary> |
| | 1 | 246 | | public Fixed64 AxisLength => Command.AxisLength; |
| | | 247 | | |
| | | 248 | | /// <summary>Gets the capsule color.</summary> |
| | 1 | 249 | | public GravitasDiagnosticColor Color => Command.Color; |
| | | 250 | | } |
| | | 251 | | |
| | | 252 | | /// <summary> |
| | | 253 | | /// Typed read-only view over a wire-cylinder draw command. |
| | | 254 | | /// </summary> |
| | | 255 | | public readonly struct GravitasWireCylinderDebugDrawView |
| | | 256 | | { |
| | | 257 | | internal GravitasWireCylinderDebugDrawView(GravitasDebugDrawCommand command) => Command = command; |
| | | 258 | | |
| | | 259 | | /// <summary>Gets the underlying draw command.</summary> |
| | | 260 | | public GravitasDebugDrawCommand Command { get; } |
| | | 261 | | |
| | | 262 | | /// <summary>Gets the simulation frame in which the command was captured.</summary> |
| | | 263 | | public int Frame => Command.Frame; |
| | | 264 | | |
| | | 265 | | /// <summary>Gets the command's sequence within its capture buffer.</summary> |
| | | 266 | | public int Sequence => Command.Sequence; |
| | | 267 | | |
| | | 268 | | /// <summary>Gets the associated context-local collider identifier.</summary> |
| | | 269 | | public int ColliderId => Command.ColliderId; |
| | | 270 | | |
| | | 271 | | /// <summary>Gets the associated collider dimension.</summary> |
| | | 272 | | public GravitasColliderDimension ColliderDimension => Command.ColliderDimension; |
| | | 273 | | |
| | | 274 | | /// <summary>Gets the associated 3D collider type.</summary> |
| | | 275 | | public ColliderType ColliderType => Command.ColliderType; |
| | | 276 | | |
| | | 277 | | /// <summary>Gets the associated 2D collider type.</summary> |
| | | 278 | | public ColliderType2D Collider2DType => Command.Collider2DType; |
| | | 279 | | |
| | | 280 | | /// <summary>Gets the cylinder center.</summary> |
| | | 281 | | public Vector3d Center => Command.Center; |
| | | 282 | | |
| | | 283 | | /// <summary>Gets the cylinder orientation.</summary> |
| | | 284 | | public FixedQuaternion Rotation => Command.Rotation; |
| | | 285 | | |
| | | 286 | | /// <summary>Gets the cylinder radius.</summary> |
| | | 287 | | public Fixed64 Radius => Command.Radius; |
| | | 288 | | |
| | | 289 | | /// <summary>Gets the cylinder height.</summary> |
| | | 290 | | public Fixed64 Height => Command.Height; |
| | | 291 | | |
| | | 292 | | /// <summary>Gets the cylinder color.</summary> |
| | | 293 | | public GravitasDiagnosticColor Color => Command.Color; |
| | | 294 | | } |
| | | 295 | | |
| | | 296 | | /// <summary> |
| | | 297 | | /// Typed read-only view over a wire-triangle draw command. |
| | | 298 | | /// </summary> |
| | | 299 | | public readonly struct GravitasWireTriangleDebugDrawView |
| | | 300 | | { |
| | | 301 | | internal GravitasWireTriangleDebugDrawView(GravitasDebugDrawCommand command) => Command = command; |
| | | 302 | | |
| | | 303 | | /// <summary>Gets the underlying draw command.</summary> |
| | | 304 | | public GravitasDebugDrawCommand Command { get; } |
| | | 305 | | |
| | | 306 | | /// <summary>Gets the simulation frame in which the command was captured.</summary> |
| | | 307 | | public int Frame => Command.Frame; |
| | | 308 | | |
| | | 309 | | /// <summary>Gets the command's sequence within its capture buffer.</summary> |
| | | 310 | | public int Sequence => Command.Sequence; |
| | | 311 | | |
| | | 312 | | /// <summary>Gets the associated context-local collider identifier.</summary> |
| | | 313 | | public int ColliderId => Command.ColliderId; |
| | | 314 | | |
| | | 315 | | /// <summary>Gets the associated collider dimension.</summary> |
| | | 316 | | public GravitasColliderDimension ColliderDimension => Command.ColliderDimension; |
| | | 317 | | |
| | | 318 | | /// <summary>Gets the associated 3D collider type.</summary> |
| | | 319 | | public ColliderType ColliderType => Command.ColliderType; |
| | | 320 | | |
| | | 321 | | /// <summary>Gets the associated 2D collider type.</summary> |
| | | 322 | | public ColliderType2D Collider2DType => Command.Collider2DType; |
| | | 323 | | |
| | | 324 | | /// <summary>Gets the first triangle vertex.</summary> |
| | | 325 | | public Vector3d PointA => Command.PointA; |
| | | 326 | | |
| | | 327 | | /// <summary>Gets the second triangle vertex.</summary> |
| | | 328 | | public Vector3d PointB => Command.PointB; |
| | | 329 | | |
| | | 330 | | /// <summary>Gets the third triangle vertex.</summary> |
| | | 331 | | public Vector3d PointC => Command.PointC; |
| | | 332 | | |
| | | 333 | | /// <summary>Gets the triangle color.</summary> |
| | | 334 | | public GravitasDiagnosticColor Color => Command.Color; |
| | | 335 | | } |
| | | 336 | | |
| | | 337 | | /// <summary> |
| | | 338 | | /// Typed read-only view over a wire-cone draw command. |
| | | 339 | | /// </summary> |
| | | 340 | | public readonly struct GravitasWireConeDebugDrawView |
| | | 341 | | { |
| | | 342 | | internal GravitasWireConeDebugDrawView(GravitasDebugDrawCommand command) => Command = command; |
| | | 343 | | |
| | | 344 | | /// <summary>Gets the underlying draw command.</summary> |
| | | 345 | | public GravitasDebugDrawCommand Command { get; } |
| | | 346 | | |
| | | 347 | | /// <summary>Gets the simulation frame in which the command was captured.</summary> |
| | | 348 | | public int Frame => Command.Frame; |
| | | 349 | | |
| | | 350 | | /// <summary>Gets the command's sequence within its capture buffer.</summary> |
| | | 351 | | public int Sequence => Command.Sequence; |
| | | 352 | | |
| | | 353 | | /// <summary>Gets the associated context-local collider identifier.</summary> |
| | | 354 | | public int ColliderId => Command.ColliderId; |
| | | 355 | | |
| | | 356 | | /// <summary>Gets the associated collider dimension.</summary> |
| | | 357 | | public GravitasColliderDimension ColliderDimension => Command.ColliderDimension; |
| | | 358 | | |
| | | 359 | | /// <summary>Gets the associated 3D collider type.</summary> |
| | | 360 | | public ColliderType ColliderType => Command.ColliderType; |
| | | 361 | | |
| | | 362 | | /// <summary>Gets the associated 2D collider type.</summary> |
| | | 363 | | public ColliderType2D Collider2DType => Command.Collider2DType; |
| | | 364 | | |
| | | 365 | | /// <summary>Gets the cone center.</summary> |
| | | 366 | | public Vector3d Center => Command.Center; |
| | | 367 | | |
| | | 368 | | /// <summary>Gets the cone orientation.</summary> |
| | | 369 | | public FixedQuaternion Rotation => Command.Rotation; |
| | | 370 | | |
| | | 371 | | /// <summary>Gets the cone base radius.</summary> |
| | | 372 | | public Fixed64 Radius => Command.Radius; |
| | | 373 | | |
| | | 374 | | /// <summary>Gets the cone height.</summary> |
| | | 375 | | public Fixed64 Height => Command.Height; |
| | | 376 | | |
| | | 377 | | /// <summary>Gets the cone color.</summary> |
| | | 378 | | public GravitasDiagnosticColor Color => Command.Color; |
| | | 379 | | } |