| | | 1 | | //======================================================================= |
| | | 2 | | // GravitasDiagnosticEventViews.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 force-delta diagnostic event. |
| | | 15 | | /// </summary> |
| | | 16 | | public readonly struct GravitasForceDeltaDiagnosticView |
| | | 17 | | { |
| | | 18 | | internal GravitasForceDeltaDiagnosticView(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 force was captured.</summary> |
| | | 24 | | public int Frame => Event.Frame; |
| | | 25 | | |
| | | 26 | | /// <summary>Gets the event's sequence within its capture buffer.</summary> |
| | | 27 | | public int Sequence => Event.Sequence; |
| | | 28 | | |
| | | 29 | | /// <summary>Gets the context-local body identifier.</summary> |
| | | 30 | | public int BodyId => Event.BodyId; |
| | | 31 | | |
| | | 32 | | /// <summary>Gets the body's context-local collider identifier.</summary> |
| | | 33 | | public int ColliderId => Event.ColliderAId; |
| | | 34 | | |
| | | 35 | | /// <summary>Gets the body's collider type.</summary> |
| | | 36 | | public ColliderType ColliderType => Event.ColliderAType; |
| | | 37 | | |
| | | 38 | | /// <summary>Gets the applied force.</summary> |
| | | 39 | | public Vector3d Force => Event.Vector; |
| | | 40 | | |
| | | 41 | | /// <summary>Gets the resulting acceleration delta.</summary> |
| | | 42 | | public Vector3d AccelerationDelta => Event.PointA; |
| | | 43 | | |
| | | 44 | | /// <summary>Gets the magnitude of the applied force.</summary> |
| | | 45 | | public Fixed64 ForceMagnitude => Event.ScalarA; |
| | | 46 | | } |
| | | 47 | | |
| | | 48 | | /// <summary> |
| | | 49 | | /// Typed read-only view over a torque-delta diagnostic event. |
| | | 50 | | /// </summary> |
| | | 51 | | public readonly struct GravitasTorqueDeltaDiagnosticView |
| | | 52 | | { |
| | | 53 | | internal GravitasTorqueDeltaDiagnosticView(GravitasDiagnosticEvent diagnosticEvent) => Event = diagnosticEvent; |
| | | 54 | | |
| | | 55 | | /// <summary>Gets the underlying diagnostic event.</summary> |
| | | 56 | | public GravitasDiagnosticEvent Event { get; } |
| | | 57 | | |
| | | 58 | | /// <summary>Gets the simulation frame in which the torque was captured.</summary> |
| | | 59 | | public int Frame => Event.Frame; |
| | | 60 | | |
| | | 61 | | /// <summary>Gets the event's sequence within its capture buffer.</summary> |
| | | 62 | | public int Sequence => Event.Sequence; |
| | | 63 | | |
| | | 64 | | /// <summary>Gets the context-local body identifier.</summary> |
| | | 65 | | public int BodyId => Event.BodyId; |
| | | 66 | | |
| | | 67 | | /// <summary>Gets the body's context-local collider identifier.</summary> |
| | | 68 | | public int ColliderId => Event.ColliderAId; |
| | | 69 | | |
| | | 70 | | /// <summary>Gets the body's collider type.</summary> |
| | | 71 | | public ColliderType ColliderType => Event.ColliderAType; |
| | | 72 | | |
| | | 73 | | /// <summary>Gets the applied torque.</summary> |
| | | 74 | | public Vector3d Torque => Event.Vector; |
| | | 75 | | |
| | | 76 | | /// <summary>Gets the magnitude of the applied torque.</summary> |
| | | 77 | | public Fixed64 TorqueMagnitude => Event.ScalarA; |
| | | 78 | | } |
| | | 79 | | |
| | | 80 | | /// <summary> |
| | | 81 | | /// Typed read-only view over linear or angular velocity diagnostic events. |
| | | 82 | | /// </summary> |
| | | 83 | | public readonly struct GravitasVelocityDeltaDiagnosticView |
| | | 84 | | { |
| | | 85 | | internal GravitasVelocityDeltaDiagnosticView(GravitasDiagnosticEvent diagnosticEvent) => Event = diagnosticEvent; |
| | | 86 | | |
| | | 87 | | /// <summary>Gets the underlying diagnostic event.</summary> |
| | | 88 | | public GravitasDiagnosticEvent Event { get; } |
| | | 89 | | |
| | | 90 | | /// <summary>Gets the simulation frame in which the velocity change was captured.</summary> |
| | | 91 | | public int Frame => Event.Frame; |
| | | 92 | | |
| | | 93 | | /// <summary>Gets the event's sequence within its capture buffer.</summary> |
| | | 94 | | public int Sequence => Event.Sequence; |
| | | 95 | | |
| | | 96 | | /// <summary>Gets whether the event describes linear or angular velocity.</summary> |
| | | 97 | | public GravitasDiagnosticEventKind Kind => Event.Kind; |
| | | 98 | | |
| | | 99 | | /// <summary>Gets the context-local body identifier.</summary> |
| | | 100 | | public int BodyId => Event.BodyId; |
| | | 101 | | |
| | | 102 | | /// <summary>Gets the body's context-local collider identifier.</summary> |
| | | 103 | | public int ColliderId => Event.ColliderAId; |
| | | 104 | | |
| | | 105 | | /// <summary>Gets the body's collider type.</summary> |
| | | 106 | | public ColliderType ColliderType => Event.ColliderAType; |
| | | 107 | | |
| | | 108 | | /// <summary>Gets the velocity before the change.</summary> |
| | | 109 | | public Vector3d Before => Event.Start; |
| | | 110 | | |
| | | 111 | | /// <summary>Gets the velocity after the change.</summary> |
| | | 112 | | public Vector3d After => Event.End; |
| | | 113 | | |
| | | 114 | | /// <summary>Gets the velocity delta.</summary> |
| | | 115 | | public Vector3d Delta => Event.Vector; |
| | | 116 | | |
| | | 117 | | /// <summary>Gets the magnitude of the resulting velocity.</summary> |
| | | 118 | | public Fixed64 ResultSpeed => Event.ScalarA; |
| | | 119 | | } |
| | | 120 | | |
| | | 121 | | /// <summary> |
| | | 122 | | /// Typed read-only view over a ground-probe diagnostic event. |
| | | 123 | | /// </summary> |
| | | 124 | | public readonly struct GravitasGroundProbeDiagnosticView |
| | | 125 | | { |
| | | 126 | | internal GravitasGroundProbeDiagnosticView(GravitasDiagnosticEvent diagnosticEvent) => Event = diagnosticEvent; |
| | | 127 | | |
| | | 128 | | /// <summary>Gets the underlying diagnostic event.</summary> |
| | | 129 | | public GravitasDiagnosticEvent Event { get; } |
| | | 130 | | |
| | | 131 | | /// <summary>Gets the simulation frame in which the probe was captured.</summary> |
| | | 132 | | public int Frame => Event.Frame; |
| | | 133 | | |
| | | 134 | | /// <summary>Gets the event's sequence within its capture buffer.</summary> |
| | | 135 | | public int Sequence => Event.Sequence; |
| | | 136 | | |
| | | 137 | | /// <summary>Gets the context-local body identifier.</summary> |
| | | 138 | | public int BodyId => Event.BodyId; |
| | | 139 | | |
| | | 140 | | /// <summary>Gets the probing body's context-local collider identifier.</summary> |
| | | 141 | | public int ColliderId => Event.ColliderAId; |
| | | 142 | | |
| | | 143 | | /// <summary>Gets the hit collider identifier, or <c>-1</c> when no collider was hit.</summary> |
| | | 144 | | public int HitColliderId => Event.ColliderBId; |
| | | 145 | | |
| | | 146 | | /// <summary>Gets the probing collider's dimension.</summary> |
| | | 147 | | public GravitasColliderDimension ColliderDimension => Event.ColliderADimension; |
| | | 148 | | |
| | | 149 | | /// <summary>Gets the hit collider's dimension.</summary> |
| | | 150 | | public GravitasColliderDimension HitColliderDimension => Event.ColliderBDimension; |
| | | 151 | | |
| | | 152 | | /// <summary>Gets the probing collider's 3D type.</summary> |
| | | 153 | | public ColliderType ColliderType => Event.ColliderAType; |
| | | 154 | | |
| | | 155 | | /// <summary>Gets the hit collider's 3D type.</summary> |
| | | 156 | | public ColliderType HitColliderType => Event.ColliderBType; |
| | | 157 | | |
| | | 158 | | /// <summary>Gets the probing collider's 2D type.</summary> |
| | | 159 | | public ColliderType2D Collider2DType => Event.ColliderA2DType; |
| | | 160 | | |
| | | 161 | | /// <summary>Gets the hit collider's 2D type.</summary> |
| | | 162 | | public ColliderType2D HitCollider2DType => Event.ColliderB2DType; |
| | | 163 | | |
| | | 164 | | /// <summary>Gets the probe start point.</summary> |
| | | 165 | | public Vector3d Start => Event.Start; |
| | | 166 | | |
| | | 167 | | /// <summary>Gets the probe endpoint.</summary> |
| | | 168 | | public Vector3d End => Event.End; |
| | | 169 | | |
| | | 170 | | /// <summary>Gets the materialized hit point, or zero when unavailable.</summary> |
| | | 171 | | public Vector3d HitPoint => Event.PointA; |
| | | 172 | | |
| | | 173 | | /// <summary>Gets the hit normal.</summary> |
| | | 174 | | public Vector3d Normal => Event.Vector; |
| | | 175 | | |
| | | 176 | | /// <summary>Gets the probe radius.</summary> |
| | | 177 | | public Fixed64 Radius => Event.ScalarA; |
| | | 178 | | |
| | | 179 | | /// <summary>Gets the distance to the hit.</summary> |
| | | 180 | | public Fixed64 Distance => Event.ScalarB; |
| | | 181 | | |
| | | 182 | | /// <summary>Gets the probe mode for a 3D event.</summary> |
| | | 183 | | public GroundProbeMode Mode => (GroundProbeMode)Event.DataA; |
| | | 184 | | |
| | | 185 | | /// <summary>Gets the probe mode for a 2D event.</summary> |
| | | 186 | | public GroundProbeMode2D Mode2D => (GroundProbeMode2D)Event.DataA; |
| | | 187 | | |
| | | 188 | | /// <summary>Gets whether the probe hit a collider.</summary> |
| | | 189 | | public bool Hit => Event.Hit; |
| | | 190 | | } |
| | | 191 | | |
| | | 192 | | /// <summary> |
| | | 193 | | /// Typed read-only view over a 3D ray or swept-sphere query diagnostic event. |
| | | 194 | | /// </summary> |
| | | 195 | | public readonly struct GravitasRayQueryDiagnosticView |
| | | 196 | | { |
| | | 197 | | internal GravitasRayQueryDiagnosticView(GravitasDiagnosticEvent diagnosticEvent) => Event = diagnosticEvent; |
| | | 198 | | |
| | | 199 | | /// <summary>Gets the underlying diagnostic event.</summary> |
| | | 200 | | public GravitasDiagnosticEvent Event { get; } |
| | | 201 | | |
| | | 202 | | /// <summary>Gets the simulation frame in which the query was captured.</summary> |
| | | 203 | | public int Frame => Event.Frame; |
| | | 204 | | |
| | | 205 | | /// <summary>Gets the event's sequence within its capture buffer.</summary> |
| | | 206 | | public int Sequence => Event.Sequence; |
| | | 207 | | |
| | | 208 | | /// <summary>Gets the hit collider identifier, or <c>-1</c> when no collider was hit.</summary> |
| | | 209 | | public int HitColliderId => Event.ColliderAId; |
| | | 210 | | |
| | | 211 | | /// <summary>Gets the hit collider type.</summary> |
| | | 212 | | public ColliderType HitColliderType => Event.ColliderAType; |
| | | 213 | | |
| | | 214 | | /// <summary>Gets the query start point.</summary> |
| | | 215 | | public Vector3d Start => Event.Start; |
| | | 216 | | |
| | | 217 | | /// <summary>Gets the query endpoint.</summary> |
| | | 218 | | public Vector3d End => Event.End; |
| | | 219 | | |
| | | 220 | | /// <summary>Gets the materialized hit point, or zero when unavailable.</summary> |
| | | 221 | | public Vector3d HitPoint => Event.PointA; |
| | | 222 | | |
| | | 223 | | /// <summary>Gets the hit normal.</summary> |
| | | 224 | | public Vector3d Normal => Event.Vector; |
| | | 225 | | |
| | | 226 | | /// <summary>Gets the sweep radius, or zero for a raycast.</summary> |
| | | 227 | | public Fixed64 SweepRadius => Event.ScalarA; |
| | | 228 | | |
| | | 229 | | /// <summary>Gets the distance to the nearest hit.</summary> |
| | | 230 | | public Fixed64 Distance => Event.ScalarB; |
| | | 231 | | |
| | | 232 | | /// <summary>Gets the query layer-mask bits.</summary> |
| | | 233 | | public int LayerMaskBits => Event.DataA; |
| | | 234 | | |
| | | 235 | | /// <summary>Gets the number of hits reported by the query.</summary> |
| | | 236 | | public int HitCount => Event.DataB; |
| | | 237 | | |
| | | 238 | | /// <summary>Gets whether the query hit a collider.</summary> |
| | | 239 | | public bool Hit => Event.Hit; |
| | | 240 | | } |
| | | 241 | | |
| | | 242 | | /// <summary> |
| | | 243 | | /// Typed read-only view over a 3D X/Z circle-query diagnostic event. |
| | | 244 | | /// </summary> |
| | | 245 | | public readonly struct GravitasCircleQueryDiagnosticView |
| | | 246 | | { |
| | | 247 | | internal GravitasCircleQueryDiagnosticView(GravitasDiagnosticEvent diagnosticEvent) => Event = diagnosticEvent; |
| | | 248 | | |
| | | 249 | | /// <summary>Gets the underlying diagnostic event.</summary> |
| | | 250 | | public GravitasDiagnosticEvent Event { get; } |
| | | 251 | | |
| | | 252 | | /// <summary>Gets the simulation frame in which the query was captured.</summary> |
| | | 253 | | public int Frame => Event.Frame; |
| | | 254 | | |
| | | 255 | | /// <summary>Gets the event's sequence within its capture buffer.</summary> |
| | | 256 | | public int Sequence => Event.Sequence; |
| | | 257 | | |
| | | 258 | | /// <summary>Gets the nearest hit collider identifier, or <c>-1</c> when none was hit.</summary> |
| | | 259 | | public int HitColliderId => Event.ColliderAId; |
| | | 260 | | |
| | | 261 | | /// <summary>Gets the nearest hit collider type.</summary> |
| | | 262 | | public ColliderType HitColliderType => Event.ColliderAType; |
| | | 263 | | |
| | | 264 | | /// <summary>Gets the X/Z query-circle center.</summary> |
| | | 265 | | public Vector3d Center => Event.Start; |
| | | 266 | | |
| | | 267 | | /// <summary>Gets the endpoint of the directional-filter visualization.</summary> |
| | | 268 | | public Vector3d End => Event.End; |
| | | 269 | | |
| | | 270 | | /// <summary>Gets the materialized nearest hit point, or zero when unavailable.</summary> |
| | | 271 | | public Vector3d HitPoint => Event.PointA; |
| | | 272 | | |
| | | 273 | | /// <summary>Gets the normalized directional filter, or zero for an undirected query.</summary> |
| | | 274 | | public Vector3d Direction => Event.Vector; |
| | | 275 | | |
| | | 276 | | /// <summary>Gets the query-circle radius.</summary> |
| | | 277 | | public Fixed64 Radius => Event.ScalarA; |
| | | 278 | | |
| | | 279 | | /// <summary>Gets the nearest hit separation distance.</summary> |
| | | 280 | | public Fixed64 Distance => Event.ScalarB; |
| | | 281 | | |
| | | 282 | | /// <summary>Gets the query layer-mask bits.</summary> |
| | | 283 | | public int LayerMaskBits => Event.DataA; |
| | | 284 | | |
| | | 285 | | /// <summary>Gets the number of hits reported by the query.</summary> |
| | | 286 | | public int HitCount => Event.DataB; |
| | | 287 | | |
| | | 288 | | /// <summary>Gets whether the query found an overlap.</summary> |
| | | 289 | | public bool Hit => Event.Hit; |
| | | 290 | | } |
| | | 291 | | |
| | | 292 | | /// <summary> |
| | | 293 | | /// Typed read-only view over query reducer quality counters. |
| | | 294 | | /// </summary> |
| | | 295 | | public readonly struct GravitasQuerySummaryDiagnosticView |
| | | 296 | | { |
| | | 297 | | internal GravitasQuerySummaryDiagnosticView(GravitasDiagnosticEvent diagnosticEvent) => Event = diagnosticEvent; |
| | | 298 | | |
| | | 299 | | /// <summary>Gets the underlying diagnostic event.</summary> |
| | | 300 | | public GravitasDiagnosticEvent Event { get; } |
| | | 301 | | |
| | | 302 | | /// <summary>Gets the simulation frame in which the summary was captured.</summary> |
| | | 303 | | public int Frame => Event.Frame; |
| | | 304 | | |
| | | 305 | | /// <summary>Gets the event's sequence within its capture buffer.</summary> |
| | | 306 | | public int Sequence => Event.Sequence; |
| | | 307 | | |
| | | 308 | | /// <summary>Gets the query source dimension.</summary> |
| | | 309 | | public GravitasColliderDimension SourceDimension => Event.ColliderADimension; |
| | | 310 | | |
| | | 311 | | /// <summary>Gets the query target dimension.</summary> |
| | | 312 | | public GravitasColliderDimension TargetDimension => Event.ColliderBDimension; |
| | | 313 | | |
| | | 314 | | /// <summary>Gets the query start point.</summary> |
| | | 315 | | public Vector3d Start => Event.Start; |
| | | 316 | | |
| | | 317 | | /// <summary>Gets the query endpoint.</summary> |
| | | 318 | | public Vector3d End => Event.End; |
| | | 319 | | |
| | | 320 | | /// <summary>Gets the number of exact reducer attempts.</summary> |
| | | 321 | | public int ExactReducerAttempts => Event.DataA; |
| | | 322 | | |
| | | 323 | | /// <summary>Gets the number of accepted hits.</summary> |
| | | 324 | | public int AcceptedHits => Event.DataB; |
| | | 325 | | |
| | | 326 | | /// <summary>Gets the number of conservative fallback hits.</summary> |
| | | 327 | | public int FallbackHits => (int)Event.ScalarA; |
| | | 328 | | |
| | | 329 | | /// <summary>Gets the number of rejected conservative candidates.</summary> |
| | | 330 | | public int RejectedConservativeCandidates => (int)Event.ScalarB; |
| | | 331 | | |
| | | 332 | | /// <summary>Gets whether conservative fallback affected the query.</summary> |
| | | 333 | | public bool HasConservativeFallback => FallbackHits > 0 || RejectedConservativeCandidates > 0; |
| | | 334 | | } |
| | | 335 | | |
| | | 336 | | /// <summary> |
| | | 337 | | /// Typed read-only view over a 3D contact diagnostic event. |
| | | 338 | | /// </summary> |
| | | 339 | | public readonly struct GravitasContactDiagnosticView |
| | | 340 | | { |
| | | 341 | | internal GravitasContactDiagnosticView(GravitasDiagnosticEvent diagnosticEvent) => Event = diagnosticEvent; |
| | | 342 | | |
| | | 343 | | /// <summary>Gets the underlying diagnostic event.</summary> |
| | | 344 | | public GravitasDiagnosticEvent Event { get; } |
| | | 345 | | |
| | | 346 | | /// <summary>Gets the simulation frame in which the contact was captured.</summary> |
| | | 347 | | public int Frame => Event.Frame; |
| | | 348 | | |
| | | 349 | | /// <summary>Gets the event's sequence within its capture buffer.</summary> |
| | | 350 | | public int Sequence => Event.Sequence; |
| | | 351 | | |
| | | 352 | | /// <summary>Gets the first context-local collider identifier.</summary> |
| | | 353 | | public int ColliderAId => Event.ColliderAId; |
| | | 354 | | |
| | | 355 | | /// <summary>Gets the second context-local collider identifier.</summary> |
| | | 356 | | public int ColliderBId => Event.ColliderBId; |
| | | 357 | | |
| | | 358 | | /// <summary>Gets the first collider type.</summary> |
| | | 359 | | public ColliderType ColliderAType => Event.ColliderAType; |
| | | 360 | | |
| | | 361 | | /// <summary>Gets the second collider type.</summary> |
| | | 362 | | public ColliderType ColliderBType => Event.ColliderBType; |
| | | 363 | | |
| | | 364 | | /// <summary>Gets the materialized contact point on the first collider.</summary> |
| | | 365 | | public Vector3d PointA => Event.PointA; |
| | | 366 | | |
| | | 367 | | /// <summary>Gets the materialized contact point on the second collider.</summary> |
| | | 368 | | public Vector3d PointB => Event.PointB; |
| | | 369 | | |
| | | 370 | | /// <summary>Gets whether <see cref="PointA"/> contains a materialized point.</summary> |
| | | 371 | | public bool HasPointA => Event.HasPointA; |
| | | 372 | | |
| | | 373 | | /// <summary>Gets whether <see cref="PointB"/> contains a materialized point.</summary> |
| | | 374 | | public bool HasPointB => Event.HasPointB; |
| | | 375 | | |
| | | 376 | | /// <summary>Gets the contact normal.</summary> |
| | | 377 | | public Vector3d Normal => Event.Vector; |
| | | 378 | | |
| | | 379 | | /// <summary>Gets the contact penetration depth.</summary> |
| | | 380 | | public Fixed64 Depth => Event.ScalarA; |
| | | 381 | | |
| | | 382 | | /// <summary>Gets the number of contacts in the manifold.</summary> |
| | | 383 | | public int ContactCount => Event.DataA; |
| | | 384 | | |
| | | 385 | | /// <summary>Gets whether the reported penetration depth was clamped.</summary> |
| | | 386 | | public bool DepthIsClamped => Event.DataB != 0; |
| | | 387 | | |
| | | 388 | | /// <summary>Gets whether the collision produced a contact.</summary> |
| | | 389 | | public bool HasContact => Event.Hit; |
| | | 390 | | } |
| | | 391 | | |
| | | 392 | | /// <summary> |
| | | 393 | | /// Typed read-only view over a 3D response-impulse diagnostic event. |
| | | 394 | | /// </summary> |
| | | 395 | | public readonly struct GravitasResponseImpulseDiagnosticView |
| | | 396 | | { |
| | | 397 | | internal GravitasResponseImpulseDiagnosticView(GravitasDiagnosticEvent diagnosticEvent) => Event = diagnosticEvent; |
| | | 398 | | |
| | | 399 | | /// <summary>Gets the underlying diagnostic event.</summary> |
| | | 400 | | public GravitasDiagnosticEvent Event { get; } |
| | | 401 | | |
| | | 402 | | /// <summary>Gets the simulation frame in which the impulse was captured.</summary> |
| | | 403 | | public int Frame => Event.Frame; |
| | | 404 | | |
| | | 405 | | /// <summary>Gets the event's sequence within its capture buffer.</summary> |
| | | 406 | | public int Sequence => Event.Sequence; |
| | | 407 | | |
| | | 408 | | /// <summary>Gets the first context-local collider identifier.</summary> |
| | | 409 | | public int ColliderAId => Event.ColliderAId; |
| | | 410 | | |
| | | 411 | | /// <summary>Gets the second context-local collider identifier.</summary> |
| | | 412 | | public int ColliderBId => Event.ColliderBId; |
| | | 413 | | |
| | | 414 | | /// <summary>Gets the first collider type.</summary> |
| | | 415 | | public ColliderType ColliderAType => Event.ColliderAType; |
| | | 416 | | |
| | | 417 | | /// <summary>Gets the second collider type.</summary> |
| | | 418 | | public ColliderType ColliderBType => Event.ColliderBType; |
| | | 419 | | |
| | | 420 | | /// <summary>Gets the materialized impulse point on the first collider.</summary> |
| | | 421 | | public Vector3d PointA => Event.PointA; |
| | | 422 | | |
| | | 423 | | /// <summary>Gets the materialized impulse point on the second collider.</summary> |
| | | 424 | | public Vector3d PointB => Event.PointB; |
| | | 425 | | |
| | | 426 | | /// <summary>Gets whether <see cref="PointA"/> contains a materialized point.</summary> |
| | | 427 | | public bool HasPointA => Event.HasPointA; |
| | | 428 | | |
| | | 429 | | /// <summary>Gets whether <see cref="PointB"/> contains a materialized point.</summary> |
| | | 430 | | public bool HasPointB => Event.HasPointB; |
| | | 431 | | |
| | | 432 | | /// <summary>Gets the applied impulse.</summary> |
| | | 433 | | public Vector3d Impulse => Event.Vector; |
| | | 434 | | |
| | | 435 | | /// <summary>Gets the magnitude of the applied impulse.</summary> |
| | | 436 | | public Fixed64 ImpulseMagnitude => Event.ScalarA; |
| | | 437 | | |
| | | 438 | | /// <summary>Gets the relative normal velocity used by the response.</summary> |
| | | 439 | | public Fixed64 NormalVelocity => Event.ScalarB; |
| | | 440 | | } |
| | | 441 | | |
| | | 442 | | /// <summary> |
| | | 443 | | /// Typed read-only view over a mixed 3D/2D query diagnostic event. |
| | | 444 | | /// </summary> |
| | | 445 | | public readonly struct GravitasMixedQueryDiagnosticView |
| | | 446 | | { |
| | | 447 | | internal GravitasMixedQueryDiagnosticView(GravitasDiagnosticEvent diagnosticEvent) => Event = diagnosticEvent; |
| | | 448 | | |
| | | 449 | | /// <summary>Gets the underlying diagnostic event.</summary> |
| | | 450 | | public GravitasDiagnosticEvent Event { get; } |
| | | 451 | | |
| | | 452 | | /// <summary>Gets the simulation frame in which the query was captured.</summary> |
| | | 453 | | public int Frame => Event.Frame; |
| | | 454 | | |
| | | 455 | | /// <summary>Gets the event's sequence within its capture buffer.</summary> |
| | | 456 | | public int Sequence => Event.Sequence; |
| | | 457 | | |
| | | 458 | | /// <summary>Gets the participating 3D collider identifier, or <c>-1</c> when absent.</summary> |
| | | 459 | | public int Collider3DId => Event.ColliderAId; |
| | | 460 | | |
| | | 461 | | /// <summary>Gets the participating 2D collider identifier, or <c>-1</c> when absent.</summary> |
| | | 462 | | public int Collider2DId => Event.ColliderBId; |
| | | 463 | | |
| | | 464 | | /// <summary>Gets the 3D collider's dimension tag.</summary> |
| | | 465 | | public GravitasColliderDimension Collider3DDimension => Event.ColliderADimension; |
| | | 466 | | |
| | | 467 | | /// <summary>Gets the 2D collider's dimension tag.</summary> |
| | | 468 | | public GravitasColliderDimension Collider2DDimension => Event.ColliderBDimension; |
| | | 469 | | |
| | | 470 | | /// <summary>Gets the participating 3D collider type.</summary> |
| | | 471 | | public ColliderType Collider3DType => Event.ColliderAType; |
| | | 472 | | |
| | | 473 | | /// <summary>Gets the participating 2D collider type.</summary> |
| | | 474 | | public ColliderType2D Collider2DType => Event.ColliderB2DType; |
| | | 475 | | |
| | | 476 | | /// <summary>Gets the query start point.</summary> |
| | | 477 | | public Vector3d Start => Event.Start; |
| | | 478 | | |
| | | 479 | | /// <summary>Gets the query endpoint.</summary> |
| | | 480 | | public Vector3d End => Event.End; |
| | | 481 | | |
| | | 482 | | /// <summary>Gets the materialized hit point on the 3D collider, or zero when unavailable.</summary> |
| | | 483 | | public Vector3d Point3D => Event.PointA; |
| | | 484 | | |
| | | 485 | | /// <summary>Gets the materialized hit point on the 2D collider, or zero when unavailable.</summary> |
| | | 486 | | public Vector3d Point2D => Event.PointB; |
| | | 487 | | |
| | | 488 | | /// <summary>Gets the hit normal directed from the 3D collider toward the 2D collider.</summary> |
| | | 489 | | public Vector3d Normal3DTo2D => Event.Vector; |
| | | 490 | | |
| | | 491 | | /// <summary>Gets the query radius.</summary> |
| | | 492 | | public Fixed64 Radius => Event.ScalarA; |
| | | 493 | | |
| | | 494 | | /// <summary>Gets the distance to the nearest hit.</summary> |
| | | 495 | | public Fixed64 Distance => Event.ScalarB; |
| | | 496 | | |
| | | 497 | | /// <summary>Gets the query layer-mask bits.</summary> |
| | | 498 | | public int LayerMaskBits => Event.DataA; |
| | | 499 | | |
| | | 500 | | /// <summary>Gets the number of hits reported by the query.</summary> |
| | | 501 | | public int HitCount => Event.DataB; |
| | | 502 | | |
| | | 503 | | /// <summary>Gets whether the query found a target.</summary> |
| | | 504 | | public bool Hit => Event.Hit; |
| | | 505 | | } |
| | | 506 | | |
| | | 507 | | /// <summary> |
| | | 508 | | /// Typed read-only view over a mixed 3D/2D contact diagnostic event. |
| | | 509 | | /// </summary> |
| | | 510 | | public readonly struct GravitasMixedContactDiagnosticView |
| | | 511 | | { |
| | | 512 | | internal GravitasMixedContactDiagnosticView(GravitasDiagnosticEvent diagnosticEvent) => Event = diagnosticEvent; |
| | | 513 | | |
| | | 514 | | /// <summary>Gets the underlying diagnostic event.</summary> |
| | | 515 | | public GravitasDiagnosticEvent Event { get; } |
| | | 516 | | |
| | | 517 | | /// <summary>Gets the simulation frame in which the contact was captured.</summary> |
| | | 518 | | public int Frame => Event.Frame; |
| | | 519 | | |
| | | 520 | | /// <summary>Gets the event's sequence within its capture buffer.</summary> |
| | | 521 | | public int Sequence => Event.Sequence; |
| | | 522 | | |
| | | 523 | | /// <summary>Gets the context-local 3D collider identifier.</summary> |
| | | 524 | | public int Collider3DId => Event.ColliderAId; |
| | | 525 | | |
| | | 526 | | /// <summary>Gets the context-local 2D collider identifier.</summary> |
| | | 527 | | public int Collider2DId => Event.ColliderBId; |
| | | 528 | | |
| | | 529 | | /// <summary>Gets the 3D collider's dimension tag.</summary> |
| | | 530 | | public GravitasColliderDimension Collider3DDimension => Event.ColliderADimension; |
| | | 531 | | |
| | | 532 | | /// <summary>Gets the 2D collider's dimension tag.</summary> |
| | | 533 | | public GravitasColliderDimension Collider2DDimension => Event.ColliderBDimension; |
| | | 534 | | |
| | | 535 | | /// <summary>Gets the 3D collider type.</summary> |
| | | 536 | | public ColliderType Collider3DType => Event.ColliderAType; |
| | | 537 | | |
| | | 538 | | /// <summary>Gets the 2D collider type.</summary> |
| | | 539 | | public ColliderType2D Collider2DType => Event.ColliderB2DType; |
| | | 540 | | |
| | | 541 | | /// <summary>Gets the materialized contact point on the 3D collider.</summary> |
| | | 542 | | public Vector3d Point3D => Event.PointA; |
| | | 543 | | |
| | | 544 | | /// <summary>Gets the materialized contact point on the 2D collider.</summary> |
| | | 545 | | public Vector3d Point2D => Event.PointB; |
| | | 546 | | |
| | | 547 | | /// <summary>Gets whether <see cref="Point3D"/> contains a materialized point.</summary> |
| | | 548 | | public bool HasPoint3D => Event.HasPointA; |
| | | 549 | | |
| | | 550 | | /// <summary>Gets whether <see cref="Point2D"/> contains a materialized point.</summary> |
| | | 551 | | public bool HasPoint2D => Event.HasPointB; |
| | | 552 | | |
| | | 553 | | /// <summary>Gets the contact normal directed from the 3D collider toward the 2D collider.</summary> |
| | | 554 | | public Vector3d Normal3DTo2D => Event.Vector; |
| | | 555 | | |
| | | 556 | | /// <summary>Gets the contact penetration depth.</summary> |
| | | 557 | | public Fixed64 Depth => Event.ScalarA; |
| | | 558 | | |
| | | 559 | | /// <summary>Gets whether the reported penetration depth was clamped.</summary> |
| | | 560 | | public bool DepthIsClamped => Event.DataA != 0; |
| | | 561 | | |
| | | 562 | | /// <summary>Gets whether the mixed collision produced a contact.</summary> |
| | | 563 | | public bool HasContact => Event.Hit; |
| | | 564 | | } |
| | | 565 | | |
| | | 566 | | /// <summary> |
| | | 567 | | /// Typed read-only view over a mixed 3D/2D response-impulse diagnostic event. |
| | | 568 | | /// </summary> |
| | | 569 | | public readonly struct GravitasMixedResponseImpulseDiagnosticView |
| | | 570 | | { |
| | 12 | 571 | | internal GravitasMixedResponseImpulseDiagnosticView(GravitasDiagnosticEvent diagnosticEvent) => Event = diagnosticEv |
| | | 572 | | |
| | | 573 | | /// <summary>Gets the underlying diagnostic event.</summary> |
| | | 574 | | public GravitasDiagnosticEvent Event { get; } |
| | | 575 | | |
| | | 576 | | /// <summary>Gets the simulation frame in which the impulse was captured.</summary> |
| | 1 | 577 | | public int Frame => Event.Frame; |
| | | 578 | | |
| | | 579 | | /// <summary>Gets the event's sequence within its capture buffer.</summary> |
| | 1 | 580 | | public int Sequence => Event.Sequence; |
| | | 581 | | |
| | | 582 | | /// <summary>Gets the context-local 3D collider identifier.</summary> |
| | 1 | 583 | | public int Collider3DId => Event.ColliderAId; |
| | | 584 | | |
| | | 585 | | /// <summary>Gets the context-local 2D collider identifier.</summary> |
| | 1 | 586 | | public int Collider2DId => Event.ColliderBId; |
| | | 587 | | |
| | | 588 | | /// <summary>Gets the 3D collider's dimension tag.</summary> |
| | 1 | 589 | | public GravitasColliderDimension Collider3DDimension => Event.ColliderADimension; |
| | | 590 | | |
| | | 591 | | /// <summary>Gets the 2D collider's dimension tag.</summary> |
| | 1 | 592 | | public GravitasColliderDimension Collider2DDimension => Event.ColliderBDimension; |
| | | 593 | | |
| | | 594 | | /// <summary>Gets the 3D collider type.</summary> |
| | 1 | 595 | | public ColliderType Collider3DType => Event.ColliderAType; |
| | | 596 | | |
| | | 597 | | /// <summary>Gets the 2D collider type.</summary> |
| | 1 | 598 | | public ColliderType2D Collider2DType => Event.ColliderB2DType; |
| | | 599 | | |
| | | 600 | | /// <summary>Gets the materialized impulse point on the 3D collider.</summary> |
| | 1 | 601 | | public Vector3d Point3D => Event.PointA; |
| | | 602 | | |
| | | 603 | | /// <summary>Gets the materialized impulse point on the 2D collider.</summary> |
| | 3 | 604 | | public Vector3d Point2D => Event.PointB; |
| | | 605 | | |
| | | 606 | | /// <summary>Gets whether <see cref="Point3D"/> contains a materialized point.</summary> |
| | 1 | 607 | | public bool HasPoint3D => Event.HasPointA; |
| | | 608 | | |
| | | 609 | | /// <summary>Gets whether <see cref="Point2D"/> contains a materialized point.</summary> |
| | 1 | 610 | | public bool HasPoint2D => Event.HasPointB; |
| | | 611 | | |
| | | 612 | | /// <summary>Gets the applied impulse.</summary> |
| | 3 | 613 | | public Vector3d Impulse => Event.Vector; |
| | | 614 | | |
| | | 615 | | /// <summary>Gets the magnitude of the applied impulse.</summary> |
| | 1 | 616 | | public Fixed64 ImpulseMagnitude => Event.ScalarA; |
| | | 617 | | |
| | | 618 | | /// <summary>Gets the relative normal velocity used by the response.</summary> |
| | 1 | 619 | | public Fixed64 NormalVelocity => Event.ScalarB; |
| | | 620 | | |
| | | 621 | | /// <summary>Gets the response iteration that applied the impulse.</summary> |
| | 2 | 622 | | public int Iteration => Event.DataA; |
| | | 623 | | |
| | | 624 | | /// <summary>Gets the configured response iteration limit.</summary> |
| | 9 | 625 | | public int IterationLimit => Event.DataB; |
| | | 626 | | } |
| | | 627 | | |
| | | 628 | | /// <summary> |
| | | 629 | | /// Typed read-only view over a mixed 3D/2D response-island diagnostic event. |
| | | 630 | | /// </summary> |
| | | 631 | | public readonly struct GravitasMixedResponseIslandDiagnosticView |
| | | 632 | | { |
| | | 633 | | internal GravitasMixedResponseIslandDiagnosticView(GravitasDiagnosticEvent diagnosticEvent) => Event = diagnosticEve |
| | | 634 | | |
| | | 635 | | /// <summary>Gets the underlying diagnostic event.</summary> |
| | | 636 | | public GravitasDiagnosticEvent Event { get; } |
| | | 637 | | |
| | | 638 | | /// <summary>Gets the simulation frame in which the island result was captured.</summary> |
| | | 639 | | public int Frame => Event.Frame; |
| | | 640 | | |
| | | 641 | | /// <summary>Gets the event's sequence within its capture buffer.</summary> |
| | | 642 | | public int Sequence => Event.Sequence; |
| | | 643 | | |
| | | 644 | | /// <summary>Gets the deterministic root key of the response island.</summary> |
| | | 645 | | public int RootKey => Event.BodyId; |
| | | 646 | | |
| | | 647 | | /// <summary>Gets the number of constraints in the island.</summary> |
| | | 648 | | public int ConstraintCount => Event.DataA; |
| | | 649 | | |
| | | 650 | | /// <summary>Gets the number of response iterations performed.</summary> |
| | | 651 | | public int IterationCount => Event.DataB; |
| | | 652 | | |
| | | 653 | | /// <summary>Gets whether the response reached its iteration limit.</summary> |
| | | 654 | | public bool ReachedIterationLimit => Event.Hit; |
| | | 655 | | } |
| | | 656 | | |
| | | 657 | | /// <summary> |
| | | 658 | | /// Typed read-only view over a joint diagnostic event. |
| | | 659 | | /// </summary> |
| | | 660 | | public readonly struct GravitasJointDiagnosticView |
| | | 661 | | { |
| | | 662 | | internal GravitasJointDiagnosticView(GravitasDiagnosticEvent diagnosticEvent) => Event = diagnosticEvent; |
| | | 663 | | |
| | | 664 | | /// <summary>Gets the underlying diagnostic event.</summary> |
| | | 665 | | public GravitasDiagnosticEvent Event { get; } |
| | | 666 | | |
| | | 667 | | /// <summary>Gets the simulation frame in which the joint event was captured.</summary> |
| | | 668 | | public int Frame => Event.Frame; |
| | | 669 | | |
| | | 670 | | /// <summary>Gets the event's sequence within its capture buffer.</summary> |
| | | 671 | | public int Sequence => Event.Sequence; |
| | | 672 | | |
| | | 673 | | /// <summary>Gets the joint event kind.</summary> |
| | | 674 | | public GravitasDiagnosticEventKind Kind => Event.Kind; |
| | | 675 | | |
| | | 676 | | /// <summary>Gets the context-local joint identifier.</summary> |
| | | 677 | | public int JointId => Event.JointId; |
| | | 678 | | |
| | | 679 | | /// <summary>Gets the first endpoint's context-local collider identifier.</summary> |
| | | 680 | | public int ColliderAId => Event.ColliderAId; |
| | | 681 | | |
| | | 682 | | /// <summary>Gets the second endpoint's context-local collider identifier.</summary> |
| | | 683 | | public int ColliderBId => Event.ColliderBId; |
| | | 684 | | |
| | | 685 | | /// <summary>Gets the first endpoint collider's dimension.</summary> |
| | | 686 | | public GravitasColliderDimension ColliderADimension => Event.ColliderADimension; |
| | | 687 | | |
| | | 688 | | /// <summary>Gets the second endpoint collider's dimension.</summary> |
| | | 689 | | public GravitasColliderDimension ColliderBDimension => Event.ColliderBDimension; |
| | | 690 | | |
| | | 691 | | /// <summary>Gets the first endpoint's 3D collider type.</summary> |
| | | 692 | | public ColliderType ColliderAType => Event.ColliderAType; |
| | | 693 | | |
| | | 694 | | /// <summary>Gets the second endpoint's 3D collider type.</summary> |
| | | 695 | | public ColliderType ColliderBType => Event.ColliderBType; |
| | | 696 | | |
| | | 697 | | /// <summary>Gets the first endpoint's 2D collider type.</summary> |
| | | 698 | | public ColliderType2D ColliderA2DType => Event.ColliderA2DType; |
| | | 699 | | |
| | | 700 | | /// <summary>Gets the second endpoint's 2D collider type.</summary> |
| | | 701 | | public ColliderType2D ColliderB2DType => Event.ColliderB2DType; |
| | | 702 | | |
| | | 703 | | /// <summary>Gets the accumulated impulse magnitude for an impulse event.</summary> |
| | | 704 | | public Fixed64 ImpulseMagnitude => Event.ScalarA; |
| | | 705 | | |
| | | 706 | | /// <summary>Gets the limit error reported by an impulse or limit event.</summary> |
| | | 707 | | public Fixed64 LimitError => Kind == GravitasDiagnosticEventKind.JointLimitReached |
| | | 708 | | ? Event.ScalarB |
| | | 709 | | : LimitErrorMagnitude; |
| | | 710 | | |
| | | 711 | | /// <summary>Gets the linear anchor-error magnitude for an impulse event.</summary> |
| | | 712 | | public Fixed64 LinearAnchorErrorMagnitude => Event.ScalarB; |
| | | 713 | | |
| | | 714 | | /// <summary>Gets the motor impulse magnitude for an impulse event.</summary> |
| | | 715 | | public Fixed64 MotorImpulseMagnitude => Event.Vector.X; |
| | | 716 | | |
| | | 717 | | /// <summary>Gets the motor error magnitude for an impulse event.</summary> |
| | | 718 | | public Fixed64 MotorErrorMagnitude => Event.Vector.Y; |
| | | 719 | | |
| | | 720 | | /// <summary>Gets the limit-error magnitude stored by an impulse event.</summary> |
| | | 721 | | public Fixed64 LimitErrorMagnitude => Event.Vector.Z; |
| | | 722 | | |
| | | 723 | | /// <summary>Gets the prepared solver-row count for an impulse event.</summary> |
| | | 724 | | public int RowCount => Event.DataA; |
| | | 725 | | |
| | | 726 | | /// <summary>Gets the clamped solver-row count for an impulse event.</summary> |
| | | 727 | | public int ClampedRowCount => Event.DataB; |
| | | 728 | | } |
| | | 729 | | |
| | | 730 | | /// <summary> |
| | | 731 | | /// Typed read-only view over a ragdoll active-state diagnostic event. |
| | | 732 | | /// </summary> |
| | | 733 | | public readonly struct GravitasRagdollDiagnosticView |
| | | 734 | | { |
| | | 735 | | internal GravitasRagdollDiagnosticView(GravitasDiagnosticEvent diagnosticEvent) => Event = diagnosticEvent; |
| | | 736 | | |
| | | 737 | | /// <summary>Gets the underlying diagnostic event.</summary> |
| | | 738 | | public GravitasDiagnosticEvent Event { get; } |
| | | 739 | | |
| | | 740 | | /// <summary>Gets the simulation frame in which the state change was captured.</summary> |
| | | 741 | | public int Frame => Event.Frame; |
| | | 742 | | |
| | | 743 | | /// <summary>Gets the event's sequence within its capture buffer.</summary> |
| | | 744 | | public int Sequence => Event.Sequence; |
| | | 745 | | |
| | | 746 | | /// <summary>Gets the context-local ragdoll identifier.</summary> |
| | | 747 | | public int RagdollId => Event.BodyId; |
| | | 748 | | |
| | | 749 | | /// <summary>Gets the number of ragdoll links.</summary> |
| | | 750 | | public int LinkCount => Event.DataA; |
| | | 751 | | |
| | | 752 | | /// <summary>Gets the number of ragdoll joints.</summary> |
| | | 753 | | public int JointCount => Event.DataB; |
| | | 754 | | |
| | | 755 | | /// <summary>Gets whether the ragdoll is active.</summary> |
| | | 756 | | public bool IsActive => Event.Hit; |
| | | 757 | | } |