| | | 1 | | //======================================================================= |
| | | 2 | | // ContactNormalVelocityDeltaResult2D.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 velocity deltas for a normal response whose impulse |
| | | 14 | | /// scalar does not need to be representable. |
| | | 15 | | /// </summary> |
| | | 16 | | internal readonly struct ContactNormalVelocityDeltaResult2D |
| | | 17 | | { |
| | | 18 | | public ContactNormalVelocityDeltaResult2D( |
| | | 19 | | Fixed64 normalVelocity, |
| | | 20 | | Vector2d linearVelocityDeltaA, |
| | | 21 | | Fixed64 angularVelocityDeltaA, |
| | | 22 | | Vector2d linearVelocityDeltaB, |
| | | 23 | | Fixed64 angularVelocityDeltaB) |
| | 33 | 24 | | : this( |
| | 33 | 25 | | normalVelocity, |
| | 33 | 26 | | linearVelocityDeltaA, |
| | 33 | 27 | | angularVelocityDeltaA, |
| | 33 | 28 | | linearVelocityDeltaB, |
| | 33 | 29 | | angularVelocityDeltaB, |
| | 33 | 30 | | normalVelocity < Fixed64.Zero, |
| | 33 | 31 | | hasRepresentableNormalVelocity: true) |
| | | 32 | | { |
| | 33 | 33 | | } |
| | | 34 | | |
| | | 35 | | public ContactNormalVelocityDeltaResult2D( |
| | | 36 | | Fixed64 normalVelocity, |
| | | 37 | | Vector2d linearVelocityDeltaA, |
| | | 38 | | Fixed64 angularVelocityDeltaA, |
| | | 39 | | Vector2d linearVelocityDeltaB, |
| | | 40 | | Fixed64 angularVelocityDeltaB, |
| | | 41 | | bool isClosing, |
| | | 42 | | bool hasRepresentableNormalVelocity) |
| | | 43 | | { |
| | 57 | 44 | | NormalVelocity = normalVelocity; |
| | 57 | 45 | | LinearVelocityDeltaA = linearVelocityDeltaA; |
| | 57 | 46 | | AngularVelocityDeltaA = angularVelocityDeltaA; |
| | 57 | 47 | | LinearVelocityDeltaB = linearVelocityDeltaB; |
| | 57 | 48 | | AngularVelocityDeltaB = angularVelocityDeltaB; |
| | 57 | 49 | | IsClosing = isClosing; |
| | 57 | 50 | | HasRepresentableNormalVelocity = hasRepresentableNormalVelocity; |
| | 57 | 51 | | } |
| | | 52 | | |
| | | 53 | | public Fixed64 NormalVelocity { get; } |
| | | 54 | | |
| | | 55 | | public bool IsClosing { get; } |
| | | 56 | | |
| | | 57 | | public bool HasRepresentableNormalVelocity { get; } |
| | | 58 | | |
| | | 59 | | public Vector2d LinearVelocityDeltaA { get; } |
| | | 60 | | |
| | | 61 | | public Fixed64 AngularVelocityDeltaA { get; } |
| | | 62 | | |
| | | 63 | | public Vector2d LinearVelocityDeltaB { get; } |
| | | 64 | | |
| | | 65 | | public Fixed64 AngularVelocityDeltaB { get; } |
| | | 66 | | } |