| | | 1 | | //======================================================================= |
| | | 2 | | // ContactNormalImpulseResult2D.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.CollisionHandling; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Side-effect-free 2D contact-normal impulse result for two participants. |
| | | 14 | | /// </summary> |
| | | 15 | | internal readonly struct ContactNormalImpulseResult2D |
| | | 16 | | { |
| | | 17 | | public ContactNormalImpulseResult2D( |
| | | 18 | | Fixed64 normalVelocity, |
| | | 19 | | Fixed64 impulseScalar, |
| | | 20 | | Vector2d linearVelocityDeltaA, |
| | | 21 | | Fixed64 angularVelocityDeltaA, |
| | | 22 | | Vector2d linearVelocityDeltaB, |
| | | 23 | | Fixed64 angularVelocityDeltaB) |
| | 16040 | 24 | | : this( |
| | 16040 | 25 | | normalVelocity, |
| | 16040 | 26 | | impulseScalar, |
| | 16040 | 27 | | impulseScalar, |
| | 16040 | 28 | | linearVelocityDeltaA, |
| | 16040 | 29 | | angularVelocityDeltaA, |
| | 16040 | 30 | | linearVelocityDeltaB, |
| | 16040 | 31 | | angularVelocityDeltaB) |
| | | 32 | | { |
| | 16040 | 33 | | } |
| | | 34 | | |
| | | 35 | | public ContactNormalImpulseResult2D( |
| | | 36 | | Fixed64 normalVelocity, |
| | | 37 | | Fixed64 impulseScalar, |
| | | 38 | | Fixed64 appliedImpulseScalar, |
| | | 39 | | Vector2d linearVelocityDeltaA, |
| | | 40 | | Fixed64 angularVelocityDeltaA, |
| | | 41 | | Vector2d linearVelocityDeltaB, |
| | | 42 | | Fixed64 angularVelocityDeltaB, |
| | | 43 | | bool hasRepresentableNormalVelocity = true, |
| | | 44 | | bool hasRepresentableAppliedImpulse = true, |
| | | 45 | | bool hasRepresentableAccumulatedImpulse = true) |
| | | 46 | | { |
| | 16407 | 47 | | NormalVelocity = normalVelocity; |
| | 16407 | 48 | | ImpulseScalar = impulseScalar; |
| | 16407 | 49 | | AppliedImpulseScalar = appliedImpulseScalar; |
| | 16407 | 50 | | LinearVelocityDeltaA = linearVelocityDeltaA; |
| | 16407 | 51 | | AngularVelocityDeltaA = angularVelocityDeltaA; |
| | 16407 | 52 | | LinearVelocityDeltaB = linearVelocityDeltaB; |
| | 16407 | 53 | | AngularVelocityDeltaB = angularVelocityDeltaB; |
| | 16407 | 54 | | HasRepresentableNormalVelocity = hasRepresentableNormalVelocity; |
| | 16407 | 55 | | HasRepresentableAppliedImpulse = hasRepresentableAppliedImpulse; |
| | 16407 | 56 | | HasRepresentableAccumulatedImpulse = |
| | 16407 | 57 | | hasRepresentableAccumulatedImpulse; |
| | 16407 | 58 | | } |
| | | 59 | | |
| | | 60 | | public Fixed64 NormalVelocity { get; } |
| | | 61 | | |
| | | 62 | | public Fixed64 ImpulseScalar { get; } |
| | | 63 | | |
| | | 64 | | public Fixed64 AppliedImpulseScalar { get; } |
| | | 65 | | |
| | | 66 | | public bool HasRepresentableNormalVelocity { get; } |
| | | 67 | | |
| | | 68 | | public bool HasRepresentableAppliedImpulse { get; } |
| | | 69 | | |
| | | 70 | | public bool HasRepresentableAccumulatedImpulse { get; } |
| | | 71 | | |
| | | 72 | | public Vector2d LinearVelocityDeltaA { get; } |
| | | 73 | | |
| | | 74 | | public Fixed64 AngularVelocityDeltaA { get; } |
| | | 75 | | |
| | | 76 | | public Vector2d LinearVelocityDeltaB { get; } |
| | | 77 | | |
| | | 78 | | public Fixed64 AngularVelocityDeltaB { get; } |
| | | 79 | | } |