| | | 1 | | //======================================================================= |
| | | 2 | | // JointSolveMetrics2D.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 | | |
| | | 10 | | namespace Gravitas.Constraints; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Deterministic metrics captured from the most recent pure 2D joint solver pass. |
| | | 14 | | /// </summary> |
| | | 15 | | public readonly struct JointSolveMetrics2D |
| | | 16 | | { |
| | | 17 | | internal JointSolveMetrics2D( |
| | | 18 | | int preparedRowCount, |
| | | 19 | | Fixed64 linearAnchorErrorMagnitude, |
| | | 20 | | Fixed64 angularErrorMagnitude, |
| | | 21 | | Fixed64 limitErrorMagnitude, |
| | | 22 | | Fixed64 accumulatedImpulseMagnitude, |
| | | 23 | | Fixed64 incrementalImpulseMagnitude, |
| | | 24 | | Fixed64 motorImpulseMagnitude, |
| | | 25 | | Fixed64 motorErrorMagnitude, |
| | | 26 | | int clampedRowCount) |
| | | 27 | | { |
| | 1503 | 28 | | PreparedRowCount = preparedRowCount; |
| | 1503 | 29 | | LinearAnchorErrorMagnitude = linearAnchorErrorMagnitude; |
| | 1503 | 30 | | AngularErrorMagnitude = angularErrorMagnitude; |
| | 1503 | 31 | | LimitErrorMagnitude = limitErrorMagnitude; |
| | 1503 | 32 | | AccumulatedImpulseMagnitude = accumulatedImpulseMagnitude; |
| | 1503 | 33 | | IncrementalImpulseMagnitude = incrementalImpulseMagnitude; |
| | 1503 | 34 | | MotorImpulseMagnitude = motorImpulseMagnitude; |
| | 1503 | 35 | | MotorErrorMagnitude = motorErrorMagnitude; |
| | 1503 | 36 | | ClampedRowCount = clampedRowCount; |
| | 1503 | 37 | | } |
| | | 38 | | |
| | | 39 | | /// <summary> |
| | | 40 | | /// Gets the number of solver rows prepared for the joint. |
| | | 41 | | /// </summary> |
| | | 42 | | public int PreparedRowCount { get; } |
| | | 43 | | |
| | | 44 | | /// <summary> |
| | | 45 | | /// Gets the world-space distance between the joint anchors before the pass. |
| | | 46 | | /// </summary> |
| | | 47 | | public Fixed64 LinearAnchorErrorMagnitude { get; } |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Gets the scalar angular frame error magnitude before the pass. |
| | | 51 | | /// </summary> |
| | | 52 | | public Fixed64 AngularErrorMagnitude { get; } |
| | | 53 | | |
| | | 54 | | /// <summary> |
| | | 55 | | /// Gets the total scalar limit violation magnitude emitted by limit rows. |
| | | 56 | | /// </summary> |
| | | 57 | | public Fixed64 LimitErrorMagnitude { get; } |
| | | 58 | | |
| | | 59 | | /// <summary> |
| | | 60 | | /// Gets the total absolute cached impulse magnitude after the pass. |
| | | 61 | | /// </summary> |
| | | 62 | | public Fixed64 AccumulatedImpulseMagnitude { get; } |
| | | 63 | | |
| | | 64 | | /// <summary> |
| | | 65 | | /// Gets the total absolute incremental impulse emitted during the pass. |
| | | 66 | | /// </summary> |
| | | 67 | | public Fixed64 IncrementalImpulseMagnitude { get; } |
| | | 68 | | |
| | | 69 | | /// <summary> |
| | | 70 | | /// Gets the absolute incremental impulse emitted by motor rows. |
| | | 71 | | /// </summary> |
| | | 72 | | public Fixed64 MotorImpulseMagnitude { get; } |
| | | 73 | | |
| | | 74 | | /// <summary> |
| | | 75 | | /// Gets the scalar motor target error magnitude before the pass. |
| | | 76 | | /// </summary> |
| | | 77 | | public Fixed64 MotorErrorMagnitude { get; } |
| | | 78 | | |
| | | 79 | | /// <summary> |
| | | 80 | | /// Gets the number of rows whose accumulated impulse hit a row bound. |
| | | 81 | | /// </summary> |
| | | 82 | | public int ClampedRowCount { get; } |
| | | 83 | | } |