| | | 1 | | //======================================================================= |
| | | 2 | | // ContactResponseSnapshot.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>Pre-warm-start motion and lever frames for one discrete solver pass.</summary> |
| | | 13 | | internal readonly struct ContactResponseSnapshot |
| | | 14 | | { |
| | | 15 | | internal ContactResponseSnapshot(SolidBody? first, SolidBody? second, |
| | | 16 | | Vector3d linearA, Vector3d angularA, Vector3d linearB, Vector3d angularB) |
| | 47629 | 17 | | : this(first?.Position3d ?? Vector3d.Zero, second?.Position3d ?? Vector3d.Zero, |
| | 47629 | 18 | | first?.GetCenterOfMassAnchor() ?? default, second?.GetCenterOfMassAnchor() ?? default, |
| | 47629 | 19 | | linearA, angularA, linearB, angularB) |
| | | 20 | | { |
| | 47629 | 21 | | } |
| | | 22 | | |
| | | 23 | | internal ContactResponseSnapshot(Vector3d positionA, Vector3d positionB, |
| | | 24 | | ContactAnchor centerA, ContactAnchor centerB, Vector3d linearA, |
| | | 25 | | Vector3d angularA, Vector3d linearB, Vector3d angularB, Fixed64 planarAngularB = default, |
| | | 26 | | Fixed64 planarAngularA = default) |
| | | 27 | | { |
| | 409884 | 28 | | IsValid = true; |
| | 409884 | 29 | | PositionA = positionA; |
| | 409884 | 30 | | PositionB = positionB; |
| | 409884 | 31 | | CenterA = centerA; |
| | 409884 | 32 | | CenterB = centerB; |
| | 409884 | 33 | | LinearA = linearA; |
| | 409884 | 34 | | AngularA = angularA; |
| | 409884 | 35 | | LinearB = linearB; |
| | 409884 | 36 | | AngularB = angularB; |
| | 409884 | 37 | | PlanarAngularB = planarAngularB; |
| | 409884 | 38 | | PlanarAngularA = planarAngularA; |
| | 409884 | 39 | | } |
| | | 40 | | |
| | | 41 | | internal readonly bool IsValid; |
| | | 42 | | internal readonly Vector3d PositionA, PositionB, LinearA, AngularA, LinearB, AngularB; |
| | | 43 | | internal readonly ContactAnchor CenterA, CenterB; |
| | | 44 | | // Planar yaw retains its own signed domain: negating MinValue cannot fit a spatial Fixed64 Y. |
| | | 45 | | internal readonly Fixed64 PlanarAngularA, PlanarAngularB; |
| | | 46 | | } |